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 Details

    • DEFAULT_RANGE

      public static final int DEFAULT_RANGE
      Default cache range.
      See Also:
    • lengths

      protected int[] lengths
      Length of each dimensional axis.
    • order

      protected int[] order
      The order in which planes should be loaded along each axis.
    • range

      protected int[] range
      Number of planes to cache along each axis.
    • priorities

      protected int[] priorities
      Priority for caching each axis. Controls axis caching order.
    • listeners

      protected Vector 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

      public void addCacheListener(CacheListener l)
      Description copied from interface: CacheReporter
      Adds a listener for status update events.
      Specified by:
      addCacheListener in interface CacheReporter
    • removeCacheListener

      public void removeCacheListener(CacheListener l)
      Description copied from interface: CacheReporter
      Removes a listener for status update events.
      Specified by:
      removeCacheListener in interface CacheReporter
    • getCacheListeners

      public CacheListener[] getCacheListeners()
      Description copied from interface: CacheReporter
      Gets a list of all registered status update listeners.
      Specified by:
      getCacheListeners in interface CacheReporter
    • compare

      public int compare(Object o1, Object o2)
      Default comparator orders dimensional positions based on distance from the current position, taking into account axis priorities and planar ordering.
      Specified by:
      compare in interface Comparator
    • getLoadList

      public int[][] getLoadList(int[] pos) throws CacheException
      Description copied from interface: ICacheStrategy
      Gets the indices of the objects to cache, surrounding the object at the given position.
      Specified by:
      getLoadList in interface ICacheStrategy
      Throws:
      CacheException
    • getPriorities

      public int[] getPriorities()
      Description copied from interface: ICacheStrategy
      Retrieves the priority for caching each axis.
      Specified by:
      getPriorities in interface ICacheStrategy
    • setPriority

      public void setPriority(int priority, int axis)
      Description copied from interface: ICacheStrategy
      Sets the priority for caching the given axis.
      Specified by:
      setPriority in interface ICacheStrategy
    • getOrder

      public int[] getOrder()
      Description copied from interface: ICacheStrategy
      Retrieves the order in which objects should be loaded along each axis.
      Specified by:
      getOrder in interface ICacheStrategy
      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: ICacheStrategy
      Sets the order in which objects should be loaded along each axis.
      Specified by:
      setOrder in interface ICacheStrategy
      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: ICacheStrategy
      Retrieves the number of objects to cache along each axis.
      Specified by:
      getRange in interface ICacheStrategy
    • setRange

      public void setRange(int num, int axis)
      Description copied from interface: ICacheStrategy
      Sets the number of objects to cache along the given axis.
      Specified by:
      setRange in interface ICacheStrategy
    • getLengths

      public int[] getLengths()
      Description copied from interface: ICacheStrategy
      Gets the lengths of all the axes.
      Specified by:
      getLengths in interface ICacheStrategy
    • notifyListeners

      protected void notifyListeners(CacheEvent e)
      Informs listeners of a cache update.