Class BatchComputedImage
java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.image.ComputedImage
org.apache.sis.internal.coverage.j2d.BatchComputedImage
- All Implemented Interfaces:
RenderedImage
,Disposable
- Direct Known Subclasses:
TiledDeferredImage
A computed image for which it is more efficient to compute tiles in batch instead of one-by-one.
This class is useful only when users may prefetch in advance groups of tiles by calls to the
ImageProcessor.prefetch(RenderedImage, Rectangle)
method.
Caching
Implementations should manage their own cache for avoiding to compute the same tiles many times. The caching mechanism inherited fromComputedImage
is less useful here.- Since:
- 1.2
- Version:
- 1.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
The set of tiles fetched by a single call toprefetch(Rectangle)
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BatchComputedImage.Rasters
Tiles fetched by a calls toprefetch(Rectangle)
, ornull
if none.Image properties, or an empty map if none.Fields inherited from class org.apache.sis.image.ComputedImage
sampleModel, SOURCE_PADDING_KEY
Fields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BatchComputedImage
(SampleModel sampleModel, Map<String, Object> properties, RenderedImage... sources) Creates an initially empty image with the given sample model. -
Method Summary
Modifier and TypeMethodDescriptionprotected final Raster
computeTile
(int tileX, int tileY, WritableRaster previous) Invoked when a single tile need to be computed.protected abstract Raster[]
computeTiles
(Rectangle tiles) Computes immediately and returns all tiles in the given ranges of tile indices.getProperty
(String key) Gets a property from this image.String[]
Returns the names of all recognized properties, ornull
if this image has no properties.protected Disposable
Notifies this image that tiles will be computed soon in the given region.private void
remove
(BatchComputedImage.Rasters tiles) Discards the given set of tiles.Methods inherited from class org.apache.sis.image.ComputedImage
clearErrorFlags, createTile, dispose, getSampleModel, getSource, getSources, getTile, getTileHeight, getTileWidth, getWritableTileIndices, hasTileWriters, isTileWritable, markDirtyTiles, markTileWritable, sourceTileChanged
Methods inherited from class org.apache.sis.image.PlanarImage
copyData, getBounds, getData, getData, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getTileGridXOffset, getTileGridYOffset, toString, verify
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.awt.image.RenderedImage
getColorModel, getHeight, getWidth
-
Field Details
-
properties
Image properties, or an empty map if none. May contain instances ofDeferredProperty
. -
prefetched
Tiles fetched by a calls toprefetch(Rectangle)
, ornull
if none. This is a linked list, but the list will rarely have more than 1 element.
-
-
Constructor Details
-
BatchComputedImage
protected BatchComputedImage(SampleModel sampleModel, Map<String, Object> properties, RenderedImage... sources) Creates an initially empty image with the given sample model.- Parameters:
sampleModel
- the sample model shared by all tiles in this image.properties
- image properties (DeferredProperty
supported), ornull
if none.sources
- sources of this image (may be an empty array), or a null array if unknown.
-
-
Method Details
-
getProperty
Gets a property from this image.- Specified by:
getProperty
in interfaceRenderedImage
- Overrides:
getProperty
in classPlanarImage
- Parameters:
key
- the name of the property to get.- Returns:
- the property value, or
Image.UndefinedProperty
if none.
-
getPropertyNames
Returns the names of all recognized properties, ornull
if this image has no properties.- Specified by:
getPropertyNames
in interfaceRenderedImage
- Overrides:
getPropertyNames
in classPlanarImage
- Returns:
- names of all recognized properties, or
null
if none.
-
computeTiles
Computes immediately and returns all tiles in the given ranges of tile indices. Tiles shall be returned in row-major order. It is implementer responsibility to ensure that all rasters have consistentRaster.getMinX()
/getMinY()
values.- Parameters:
tiles
- range of tile indices for which to precompute tiles.- Returns:
- precomputed tiles for the given indices, in row-major fashion.
- Throws:
Exception
- if an error occurred when computing tiles.
-
computeTile
Invoked when a single tile need to be computed. This method first searches for the tile in the regions prepared by calls toprefetch(Rectangle)
. If the requested tile is not already fetched, then this method delegates tocomputeTiles(Rectangle)
.- Specified by:
computeTile
in classComputedImage
- Parameters:
tileX
- the column index of the tile to compute.tileY
- the row index of the tile to compute.previous
- ignored (this method creates a new raster on each invocation).- Returns:
- computed tile for the given indices.
- Throws:
Exception
- if an error occurred while computing the tile.
-
prefetch
Notifies this image that tiles will be computed soon in the given region.- Overrides:
prefetch
in classComputedImage
- Parameters:
region
- indices of the tiles which will be prefetched.- Returns:
- handler on which to invoke
dispose()
after the prefetch operation.
-
remove
Discards the given set of tiles. This method is invoked when the fetched tiles are no longer needed.- Parameters:
tiles
- fetched tiles to removed from theprefetched
linked list.
-