Class AbstractPlanePyramidSource

java.lang.Object
net.algart.matrices.maps.pyramids.io.api.AbstractPlanePyramidSource
All Implemented Interfaces:
PlanePyramidSource
Direct Known Subclasses:
DefaultPlanePyramidSource, ExtendingPlanePyramidSource

public abstract class AbstractPlanePyramidSource extends Object implements PlanePyramidSource
  • Constructor Details

    • AbstractPlanePyramidSource

      protected AbstractPlanePyramidSource()
  • Method Details

    • getMemoryModel

      public final net.algart.arrays.MemoryModel getMemoryModel()
    • setMemoryModel

      public final void setMemoryModel(net.algart.arrays.MemoryModel memoryModel)
    • isSkipCoarseData

      public final boolean isSkipCoarseData()
      Enforces some plane pyramid sources to skip (usually to stay zero) coarse data, which should not be processed by image processing algorithms, like PlanePyramidSource.SpecialImageKind.WHOLE_SLIDE.
      Returns:
      the flag; false by default.
    • setSkipCoarseData

      public final void setSkipCoarseData(boolean skipCoarseData)
    • getSkippingFiller

      public final double getSkippingFiller()
    • setSkippingFiller

      public final void setSkippingFiller(double skippingFiller)
    • numberOfResolutions

      public abstract int numberOfResolutions()
      Specified by:
      numberOfResolutions in interface PlanePyramidSource
    • compression

      public int compression()
      Specified by:
      compression in interface PlanePyramidSource
    • bandCount

      public abstract int bandCount()
      Specified by:
      bandCount in interface PlanePyramidSource
    • isResolutionLevelAvailable

      public boolean isResolutionLevelAvailable(int resolutionLevel)
      Specified by:
      isResolutionLevelAvailable in interface PlanePyramidSource
    • getResolutionLevelsAvailability

      public boolean[] getResolutionLevelsAvailability()
      Specified by:
      getResolutionLevelsAvailability in interface PlanePyramidSource
    • dimensions

      public abstract long[] dimensions(int resolutionLevel) throws NoSuchElementException
      Description copied from interface: PlanePyramidSource

      Returns dimensions of any pyramid level. Number of elements in the result arrays is always 3:

      This method always returns a new Java array and never returns a reference to an internal field.

      Specified by:
      dimensions in interface PlanePyramidSource
      Parameters:
      resolutionLevel - the level of pyramid; zero level (resolutionLevel=0) corresponds to the best resolution.
      Returns:
      dimensions of the specified pyramid level.
      Throws:
      NoSuchElementException - if !isResolutionLevelAvailable(resolutionLevel)
    • dim

      public abstract long dim(int resolutionLevel, int index)
      Description copied from interface: PlanePyramidSource
      Returns the dimension #index of the given pyramid level. Equivalent to dimensions(resolutionLevel)[index], but works faster.
      Specified by:
      dim in interface PlanePyramidSource
      index - the index of dimension.
      Returns:
      the dimension #index of this level.
    • isElementTypeSupported

      public boolean isElementTypeSupported()
      Description copied from interface: PlanePyramidSource
      Returns true if PlanePyramidSource.elementType() method works properly. In other case, that method throws UnsupportedOperationException. In particular, returns true in DefaultPlanePyramidSource.
      Specified by:
      isElementTypeSupported in interface PlanePyramidSource
      Returns:
      whether PlanePyramidSource.elementType() is supported.
    • elementType

      public Class<?> elementType() throws UnsupportedOperationException
      Specified by:
      elementType in interface PlanePyramidSource
      Throws:
      UnsupportedOperationException
    • zeroLevelActualAreaBoundaries

      public List<List<List<net.algart.math.IPoint>>> zeroLevelActualAreaBoundaries()
      Description copied from interface: PlanePyramidSource

      Returns a set of all areas, filled by actual data, at the zero level, in a form of a list of polygons, represented by their consecutive vertices. All other areas should be considered to be a background and may be not passed to image analysis algorithms.

      More precisely, each element P of the returned list, i.e. List<List<IPoint>>, corresponds to one connected 2D polygon. The structure of this element P is the following:

      • P.get(0) is the list of sequential vertices of the polygon; each vertex appears in this list only once;
      • P.get(1), P.get(2), ..., P.get(m), where m=P.size() describe sequential vertices of all polygonal holes, that may appear in the polygon. If the polygon has no holes (very probable case) or if their detection is not supported, the list P contains only 1 element (m=1).

      The default implementation in AbstractPlanePyramidSource calls PlanePyramidSource.zeroLevelActualRectangles() and converts each rectangle to the list P, containing only 1 element, and this element is the list of 4 vertices of the rectangle. If PlanePyramidSource.zeroLevelActualRectangles() returns null, the default implementation also returns null.

      Specified by:
      zeroLevelActualAreaBoundaries in interface PlanePyramidSource
      Returns:
      the list of all polygonal areas, filled by actual data, at the level #0, and their holes (if they exist), or null if this ability is not supported.
    • readSubMatrix

      public net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> readSubMatrix(int resolutionLevel, long fromX, long fromY, long toX, long toY) throws NoSuchElementException, NotYetConnectedException
      Specified by:
      readSubMatrix in interface PlanePyramidSource
      Throws:
      NoSuchElementException
      NotYetConnectedException
    • readFullMatrix

      public net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> readFullMatrix(int resolutionLevel) throws NoSuchElementException, NotYetConnectedException, UnsupportedOperationException
      Specified by:
      readFullMatrix in interface PlanePyramidSource
      Throws:
      NoSuchElementException
      NotYetConnectedException
      UnsupportedOperationException
    • isSpecialMatrixSupported

      public boolean isSpecialMatrixSupported(PlanePyramidSource.SpecialImageKind kind)
      Description copied from interface: PlanePyramidSource
      Returns true if this special image kind is provided by current format.

      Default implementation in AbstractPlanePyramidSource return false.

      Specified by:
      isSpecialMatrixSupported in interface PlanePyramidSource
      Parameters:
      kind - the kind of special image.
      Returns:
      whether this kind is supported; false by default.
    • readSpecialMatrix

      public Optional<net.algart.arrays.Matrix<? extends net.algart.arrays.PArray>> readSpecialMatrix(PlanePyramidSource.SpecialImageKind kind) throws NotYetConnectedException
      Description copied from interface: PlanePyramidSource
      Reads special image according specified kind.

      If the argument is PlanePyramidSource.SpecialImageKind.NONE, return null. In all other cases returns some non-null result.

      If there is no appropriate image, returns Optional.empty()..

      Specified by:
      readSpecialMatrix in interface PlanePyramidSource
      Parameters:
      kind - what special image is requested.
      Returns:
      special image or Optional.empty() if this kind is not supported.
      Throws:
      NotYetConnectedException
    • isDataReady

      public boolean isDataReady()
      Description copied from interface: PlanePyramidSource
      Returns true if the data at all available levels of this source are available. In other case, PlanePyramidSource.readSubMatrix(int, long, long, long, long) and PlanePyramidSource.readFullMatrix(int) method can throw NotYetConnectedException (but also, maybe, work properly),

      Note: all other methods, including PlanePyramidSource.dimensions(int), must work without NotYetConnectedException even if this method returns false.

      Specified by:
      isDataReady in interface PlanePyramidSource
      Returns:
      whether the data at all available levels of this source are available.
    • loadResources

      public void loadResources()
      This implementation does nothing.

      If your implementation overrides this method, it must call super.loadResources at the end — because it is possible that future version will do something useful.

      Specified by:
      loadResources in interface PlanePyramidSource
    • freeResources

      public void freeResources(PlanePyramidSource.FlushMode flushMode)
      This implementation frees the tile cache.
      Specified by:
      freeResources in interface PlanePyramidSource
      Parameters:
      flushMode - possible strategy of freeing resources (ignored by this implementation).
    • fillBySkippingFiller

      public void fillBySkippingFiller(net.algart.arrays.Matrix<? extends net.algart.arrays.UpdatablePArray> matrix, boolean fillWhenZero)
    • constantMatrixSkippingFiller

      public net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> constantMatrixSkippingFiller(Class<?> elementType, long dimX, long dimY)
    • isTileCachingEnabled

      public final boolean isTileCachingEnabled()
    • getTileCacheDirection

      public final AbstractPlanePyramidSource.TileDirection getTileCacheDirection()
    • enableTileCaching

      public final void enableTileCaching(AbstractPlanePyramidSource.TileDirection tileDirection)
    • disableTileCaching

      public final void disableTileCaching()
    • getTileCachingMemory

      public final long getTileCachingMemory()
      Returns the size in bytes of the cache, used when isTileCachingEnabled(). The real amount memory, used by this instance of this class, can me little greater (approximately by the size of 1 tile).

      The initial value is retrieved from the system property "net.algart.matrices.maps.pyramids.io.maxNonTiledReadingDim", if it exists and contains a valid integer number. If there is no such property, or if it contains not a number, or if some exception occurred while calling Long.getLong, the default value 67108864 (64 MB) is used.

      Returns:
      the amount of memory in bytes, which is allowed to use for caching by this instance.
    • setTileCachingMemory

      public final void setTileCachingMemory(long tileCachingMemory)
    • getLabelRotation

      public final RotatingPlanePyramidSource.RotationMode getLabelRotation()
    • setLabelRotation

      public final void setLabelRotation(RotatingPlanePyramidSource.RotationMode labelRotation)
    • getLabelRotationBackground

      public final Color getLabelRotationBackground()
    • setLabelRotationBackground

      public final void setLabelRotationBackground(Color labelRotationBackground)
    • checkSubMatrixRanges

      public final void checkSubMatrixRanges(int resolutionLevel, long fromX, long fromY, long toX, long toY, boolean require31BitSize)
    • readingTileDim

      protected int readingTileDim()
      Returns the size (width and height) of a tile, used for cache (when isTileCachingEnabled() and for splitting large submatrix for reading into smaller tiles, read by readLittleSubMatrix(int, long, long, long, long).

      The default implementation retrieves the value from the system property "net.algart.matrices.maps.pyramids.io.tileCachingMemory", if it exists and contains a valid integer number. If there is no such property, or if it contains not a number, or if some exception occurred while calling Long.getLong, this method returns the default value 4096.

      The result must be positive.

      The result must be stable (constant) for the given instance.

      This method must work quickly.

      Returns:
      the width/height of tiles for caching and splitting large read submatrix.
    • readLittleSubMatrix

      protected abstract net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> readLittleSubMatrix(int resolutionLevel, long fromX, long fromY, long toX, long toY) throws NoSuchElementException, NotYetConnectedException
      Throws:
      NoSuchElementException
      NotYetConnectedException
    • makeWholeSlideFromLabelAndMap

      protected final net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> makeWholeSlideFromLabelAndMap(AbstractPlanePyramidSource.LabelPosition labelPosition)
    • newResultMatrix

      protected final net.algart.arrays.Matrix<net.algart.arrays.UpdatablePArray> newResultMatrix(long dimX, long dimY)
    • newFilledResultMatrix

      protected final net.algart.arrays.Matrix<net.algart.arrays.UpdatablePArray> newFilledResultMatrix(long dimX, long dimY, Color backgroundColor)
    • defaultZeroLevelActualRectangles

      public static List<net.algart.math.IRectangularArea> defaultZeroLevelActualRectangles(PlanePyramidSource source)
    • checkSubMatrixRanges

      public static void checkSubMatrixRanges(long[] dimensions, long fromX, long fromY, long toX, long toY, boolean require31BitSize)
    • wholeSlideDimX

      public static long wholeSlideDimX(long mapDimX, long mapDimY, long labelDimX, long labelDimY)