Package loci.formats.cache
Class CacheStrategy
java.lang.Object
loci.formats.cache.CacheStrategy
- All Implemented Interfaces:
Comparator,CacheReporter,ICacheStrategy
- Direct Known Subclasses:
CrosshairStrategy,RectangleStrategy
public abstract class CacheStrategy
extends Object
implements CacheReporter, Comparator, ICacheStrategy
Superclass of cache strategies.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault cache range.private booleanWhether load order array needs to be recomputed before building the next load list.protected int[]Length of each dimensional axis.protected VectorList of cache event listeners.protected int[]The order in which planes should be loaded along each axis.private int[][]The list of dimensional positions to consider caching, in order of preference based on strategy, axis priority and planar ordering.protected int[]Priority for caching each axis.protected int[]Number of planes to cache along each axis.Fields inherited from interface loci.formats.cache.ICacheStrategy
BACKWARD_ORDER, CENTERED_ORDER, FORWARD_ORDER, HIGH_PRIORITY, LOW_PRIORITY, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener for status update events.intDefault comparator orders dimensional positions based on distance from the current position, taking into account axis priorities and planar ordering.intdistance(int axis, int value) Computes the distance from the given axis value to the axis center, taking into account the axis ordering scheme.Gets a list of all registered status update listeners.int[]Gets the lengths of all the axes.int[][]getLoadList(int[] pos) Gets the indices of the objects to cache, surrounding the object at the given position.int[]getOrder()Retrieves the order in which objects should be loaded along each axis.protected abstract int[][]Gets positions to consider for possible inclusion in the cache, assuming a current position at the origin (0).int[]Retrieves the priority for caching each axis.int[]getRange()Retrieves the number of objects to cache along each axis.protected intlength()Shortcut for computing total number of positions.protected voidInforms listeners of a cache update.protected int[]pos(int raster) Shortcut for converting rasterized position to N-D position.protected int[]pos(int raster, int[] pos) Shortcut for converting rasterized position to N-D position, using the given array instead of allocating a new one.protected intraster(int[] pos) Shortcut for converting N-D position to rasterized position.voidRemoves a listener for status update events.voidsetOrder(int order, int axis) Sets the order in which objects should be loaded along each axis.voidsetPriority(int priority, int axis) Sets the priority for caching the given axis.voidsetRange(int num, int axis) Sets the number of objects to cache along the given axis.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
DEFAULT_RANGE
public static final int DEFAULT_RANGEDefault cache range.- See Also:
-
lengths
protected int[] lengthsLength of each dimensional axis. -
order
protected int[] orderThe order in which planes should be loaded along each axis. -
range
protected int[] rangeNumber of planes to cache along each axis. -
priorities
protected int[] prioritiesPriority for caching each axis. Controls axis caching order. -
positions
private int[][] positionsThe list of dimensional positions to consider caching, in order of preference based on strategy, axis priority and planar ordering. -
dirty
private boolean dirtyWhether load order array needs to be recomputed before building the next load list. -
listeners
List of cache event listeners.
-
-
Constructor Details
-
CacheStrategy
public CacheStrategy(int[] lengths) Constructs a cache strategy.
-
-
Method Details
-
getPossiblePositions
protected abstract int[][] getPossiblePositions()Gets positions to consider for possible inclusion in the cache, assuming a current position at the origin (0). -
distance
public int distance(int axis, int value) Computes the distance from the given axis value to the axis center, taking into account the axis ordering scheme. -
raster
protected int raster(int[] pos) Shortcut for converting N-D position to rasterized position. -
pos
protected int[] pos(int raster) Shortcut for converting rasterized position to N-D position. -
pos
protected int[] pos(int raster, int[] pos) Shortcut for converting rasterized position to N-D position, using the given array instead of allocating a new one. -
length
protected int length()Shortcut for computing total number of positions. -
addCacheListener
Description copied from interface:CacheReporterAdds a listener for status update events.- Specified by:
addCacheListenerin interfaceCacheReporter
-
removeCacheListener
Description copied from interface:CacheReporterRemoves a listener for status update events.- Specified by:
removeCacheListenerin interfaceCacheReporter
-
getCacheListeners
Description copied from interface:CacheReporterGets a list of all registered status update listeners.- Specified by:
getCacheListenersin interfaceCacheReporter
-
compare
Default comparator orders dimensional positions based on distance from the current position, taking into account axis priorities and planar ordering.- Specified by:
comparein interfaceComparator
-
getLoadList
Description copied from interface:ICacheStrategyGets the indices of the objects to cache, surrounding the object at the given position.- Specified by:
getLoadListin interfaceICacheStrategy- Throws:
CacheException
-
getPriorities
public int[] getPriorities()Description copied from interface:ICacheStrategyRetrieves the priority for caching each axis.- Specified by:
getPrioritiesin interfaceICacheStrategy
-
setPriority
public void setPriority(int priority, int axis) Description copied from interface:ICacheStrategySets the priority for caching the given axis.- Specified by:
setPriorityin interfaceICacheStrategy
-
getOrder
public int[] getOrder()Description copied from interface:ICacheStrategyRetrieves the order in which objects should be loaded along each axis.- Specified by:
getOrderin interfaceICacheStrategy- Returns:
- An array whose constituents are each one of:
- CENTERED_ORDER
- FORWARD_ORDER
- BACKWARD_ORDER
-
setOrder
public void setOrder(int order, int axis) Description copied from interface:ICacheStrategySets the order in which objects should be loaded along each axis.- Specified by:
setOrderin interfaceICacheStrategy- Parameters:
order- One of:- CENTERED_ORDER
- FORWARD_ORDER
- BACKWARD_ORDER
axis- The axis for which to set the order.
-
getRange
public int[] getRange()Description copied from interface:ICacheStrategyRetrieves the number of objects to cache along each axis.- Specified by:
getRangein interfaceICacheStrategy
-
setRange
public void setRange(int num, int axis) Description copied from interface:ICacheStrategySets the number of objects to cache along the given axis.- Specified by:
setRangein interfaceICacheStrategy
-
getLengths
public int[] getLengths()Description copied from interface:ICacheStrategyGets the lengths of all the axes.- Specified by:
getLengthsin interfaceICacheStrategy
-
notifyListeners
Informs listeners of a cache update.
-