Class ImageAdapter
- All Implemented Interfaces:
RenderedImage
- Direct Known Subclasses:
AnnotatedImage,RecoloredImage
RenderedImage methods related to coordinate systems (pixel coordinates or tile
indices), and all methods fetching tiles, delegate to the wrapped image.
Design note
most non-abstract methods are final becausePixelIterator (among others) relies
on the fact that it can unwrap this image and still get the same pixel values.
Relationship with other classes
This class is similar toSourceAlignedImage except that it does not extend ComputedImage
and forward getTile(int, int), getData() and other data methods to the source image.
Requirements for subclasses
All subclasses shall overrideequals(Object) and hashCode().- Since:
- 1.1
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final RenderedImageThe source image wrapped by this adapter.Fields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedImageAdapter(RenderedImage source) Creates a new wrapper for the given image. -
Method Summary
Modifier and TypeMethodDescription(package private) abstract Class<? extends ImageAdapter>appendStringContent(StringBuilder buffer) Appends a content to show in thetoString()representation, after the class name and before the string representation of the wrapped image.final WritableRasterCopies an arbitrary rectangular region of this image to the supplied writable raster.booleanCompares the given object with this image for equality.Returns the color model of this image.final RastergetData()Returns a copy of this image as one large tile.final RasterReturns a copy of an arbitrary region of this image.final intfinal intReturns the minimum tile index in the x direction.final intReturns the minimum tile index in the y direction.final intgetMinX()Returns the minimum x coordinate (inclusive) of this image.final intgetMinY()Returns the minimum y coordinate (inclusive) of this image.final intReturns the number of tiles in the x direction.final intReturns the number of tiles in the y direction.getProperty(String name) Gets a property from this image or from its source.String[]Returns the names of properties of wrapped image.final SampleModelDelegates to the wrapped image.final Vector<RenderedImage>Returns the source of this image in an vector of length 1.final RastergetTile(int tx, int ty) final intReturns the x coordinate of the upper-left pixel of tile (0, 0).final intReturns the y coordinate of the upper-left pixel of tile (0, 0).final intfinal intfinal intgetWidth()inthashCode()Returns a hash code value for this image.protected DisposableNotifies the source image that tiles will be computed soon in the given region.toString()Returns a string representation of this image for debugging purpose.Methods inherited from class org.apache.sis.image.PlanarImage
getBounds, verify
-
Field Details
-
source
The source image wrapped by this adapter.
-
-
Constructor Details
-
ImageAdapter
Creates a new wrapper for the given image.- Parameters:
source- the image to wrap.
-
-
Method Details
-
getSources
Returns the source of this image in an vector of length 1.- Specified by:
getSourcesin interfaceRenderedImage- Overrides:
getSourcesin classPlanarImage- Returns:
- the unique source of this image.
-
getPropertyNames
Returns the names of properties of wrapped image.- Specified by:
getPropertyNamesin interfaceRenderedImage- Overrides:
getPropertyNamesin classPlanarImage- Returns:
- all recognized property names.
-
getProperty
Gets a property from this image or from its source.- Specified by:
getPropertyin interfaceRenderedImage- Overrides:
getPropertyin classPlanarImage- Parameters:
name- name of the property to get.- Returns:
- the property for the given name (
nullis a valid result), orImage.UndefinedPropertyif the given name is not a recognized property name.
-
getColorModel
Returns the color model of this image. -
getSampleModel
Delegates to the wrapped image. -
getWidth
public final int getWidth() -
getHeight
public final int getHeight() -
getMinX
public final int getMinX()Description copied from class:PlanarImageReturns the minimum x coordinate (inclusive) of this image.Default implementation returns zero. Subclasses shall override this method if the image starts at another coordinate.
- Specified by:
getMinXin interfaceRenderedImage- Overrides:
getMinXin classPlanarImage- Returns:
- the minimum x coordinate (column) of this image.
-
getMinY
public final int getMinY()Description copied from class:PlanarImageReturns the minimum y coordinate (inclusive) of this image.The default implementation returns zero. Subclasses shall override this method if the image starts at another coordinate.
- Specified by:
getMinYin interfaceRenderedImage- Overrides:
getMinYin classPlanarImage- Returns:
- the minimum y coordinate (row) of this image.
-
getNumXTiles
public final int getNumXTiles()Description copied from class:PlanarImageReturns the number of tiles in the x direction.The default implementation computes this value from
RenderedImage.getWidth()andRenderedImage.getTileWidth()on the assumption thatPlanarImage.getMinX()is the coordinate of the leftmost pixels of tiles located atPlanarImage.getMinTileX()index. This assumption can be verified byPlanarImage.verify().- Specified by:
getNumXTilesin interfaceRenderedImage- Overrides:
getNumXTilesin classPlanarImage- Returns:
- returns the number of tiles in the x direction.
-
getNumYTiles
public final int getNumYTiles()Description copied from class:PlanarImageReturns the number of tiles in the y direction.The default implementation computes this value from
RenderedImage.getHeight()andRenderedImage.getTileHeight()on the assumption thatPlanarImage.getMinY()is the coordinate of the uppermost pixels of tiles located atPlanarImage.getMinTileY()index. This assumption can be verified byPlanarImage.verify().- Specified by:
getNumYTilesin interfaceRenderedImage- Overrides:
getNumYTilesin classPlanarImage- Returns:
- returns the number of tiles in the y direction.
-
getMinTileX
public final int getMinTileX()Description copied from class:PlanarImageReturns the minimum tile index in the x direction.The default implementation returns zero. Subclasses shall override this method if the tile grid starts at another index.
- Specified by:
getMinTileXin interfaceRenderedImage- Overrides:
getMinTileXin classPlanarImage- Returns:
- the minimum tile index in the x direction.
-
getMinTileY
public final int getMinTileY()Description copied from class:PlanarImageReturns the minimum tile index in the y direction.The default implementation returns zero. Subclasses shall override this method if the tile grid starts at another index.
- Specified by:
getMinTileYin interfaceRenderedImage- Overrides:
getMinTileYin classPlanarImage- Returns:
- the minimum tile index in the y direction.
-
getTileWidth
public final int getTileWidth() -
getTileHeight
public final int getTileHeight() -
getTileGridXOffset
public final int getTileGridXOffset()Description copied from class:PlanarImageReturns the x coordinate of the upper-left pixel of tile (0, 0). That tile (0, 0) may not actually exist.The default implementation computes this value from
PlanarImage.getMinX(),PlanarImage.getMinTileX()andRenderedImage.getTileWidth().- Specified by:
getTileGridXOffsetin interfaceRenderedImage- Overrides:
getTileGridXOffsetin classPlanarImage- Returns:
- the x offset of the tile grid relative to the origin.
-
getTileGridYOffset
public final int getTileGridYOffset()Description copied from class:PlanarImageReturns the y coordinate of the upper-left pixel of tile (0, 0). That tile (0, 0) may not actually exist.The default implementation computes this value from
PlanarImage.getMinY(),PlanarImage.getMinTileY()andRenderedImage.getTileHeight().- Specified by:
getTileGridYOffsetin interfaceRenderedImage- Overrides:
getTileGridYOffsetin classPlanarImage- Returns:
- the y offset of the tile grid relative to the origin.
-
getTile
-
getData
Description copied from class:PlanarImageReturns a copy of this image as one large tile. The returned raster will not be updated if this image is changed.- Specified by:
getDatain interfaceRenderedImage- Overrides:
getDatain classPlanarImage- Returns:
- a copy of this image as one large tile.
-
getData
Description copied from class:PlanarImageReturns a copy of an arbitrary region of this image. The returned raster will not be updated if this image is changed.- Specified by:
getDatain interfaceRenderedImage- Overrides:
getDatain classPlanarImage- Parameters:
region- the region of this image to copy.- Returns:
- a copy of this image in the given area of interest.
-
copyData
Description copied from class:PlanarImageCopies an arbitrary rectangular region of this image to the supplied writable raster. The region to be copied is determined from the bounds of the supplied raster. The supplied raster must have aSampleModelthat is compatible with this image. If the raster isnull, an raster is created by this method.- Specified by:
copyDatain interfaceRenderedImage- Overrides:
copyDatain classPlanarImage- Parameters:
r- the raster to hold a copy of this image, ornull.- Returns:
- the given raster if it was not-null, or a new raster otherwise.
-
prefetch
Notifies the source image that tiles will be computed soon in the given region. If the source image is an instance ofPlanarImage, then this method forwards the notification to it. Otherwise default implementation does nothing.- Overrides:
prefetchin classPlanarImage- Parameters:
tiles- indices of the tiles which will be prefetched.- Returns:
- handler on which to invoke
dispose()after the prefetch operation completed (successfully or not), ornullif none.
-
equals
Compares the given object with this image for equality. This method should be quick and compare how images compute their values from their sources; it should not compare the actual pixel values.The default implementation returns
trueif the given object is non-null, is an instance of the exact same class than this image and the source of both images are equal. Subclasses should override this method if more properties need to be compared. -
hashCode
public int hashCode()Returns a hash code value for this image. This method should be quick, for example using only a description of the operation to be done (e.g. implementation class, parameters). This method should not compute the hash code from sample values.The default implementation computes a hash code based on the
sourcehash code and this image class. Subclasses should override this method if more properties need to be hashed. -
toString
Returns a string representation of this image for debugging purpose.- Overrides:
toStringin classPlanarImage- Returns:
- a string representation of this image for debugging purpose only.
-
appendStringContent
Appends a content to show in thetoString()representation, after the class name and before the string representation of the wrapped image.- Parameters:
buffer- where to start writing content oftoString()representation.- Returns:
- name of the class to show in the
toString()representation.
-