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 RenderedImage
The 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
ConstructorsModifierConstructorDescriptionprotected
ImageAdapter
(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 WritableRaster
Copies an arbitrary rectangular region of this image to the supplied writable raster.boolean
Compares the given object with this image for equality.Returns the color model of this image.final Raster
getData()
Returns a copy of this image as one large tile.final Raster
Returns a copy of an arbitrary region of this image.final int
final int
Returns the minimum tile index in the x direction.final int
Returns the minimum tile index in the y direction.final int
getMinX()
Returns the minimum x coordinate (inclusive) of this image.final int
getMinY()
Returns the minimum y coordinate (inclusive) of this image.final int
Returns the number of tiles in the x direction.final int
Returns 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 SampleModel
Delegates to the wrapped image.final Vector
<RenderedImage> Returns the source of this image in an vector of length 1.final Raster
getTile
(int tx, int ty) final int
Returns the x coordinate of the upper-left pixel of tile (0, 0).final int
Returns the y coordinate of the upper-left pixel of tile (0, 0).final int
final int
final int
getWidth()
int
hashCode()
Returns a hash code value for this image.protected Disposable
Notifies 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:
getSources
in interfaceRenderedImage
- Overrides:
getSources
in classPlanarImage
- Returns:
- the unique source of this image.
-
getPropertyNames
Returns the names of properties of wrapped image.- Specified by:
getPropertyNames
in interfaceRenderedImage
- Overrides:
getPropertyNames
in classPlanarImage
- Returns:
- all recognized property names.
-
getProperty
Gets a property from this image or from its source.- Specified by:
getProperty
in interfaceRenderedImage
- Overrides:
getProperty
in classPlanarImage
- Parameters:
name
- name of the property to get.- Returns:
- the property for the given name (
null
is a valid result), orImage.UndefinedProperty
if 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:PlanarImage
Returns 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:
getMinX
in interfaceRenderedImage
- Overrides:
getMinX
in classPlanarImage
- Returns:
- the minimum x coordinate (column) of this image.
-
getMinY
public final int getMinY()Description copied from class:PlanarImage
Returns 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:
getMinY
in interfaceRenderedImage
- Overrides:
getMinY
in classPlanarImage
- Returns:
- the minimum y coordinate (row) of this image.
-
getNumXTiles
public final int getNumXTiles()Description copied from class:PlanarImage
Returns 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:
getNumXTiles
in interfaceRenderedImage
- Overrides:
getNumXTiles
in classPlanarImage
- Returns:
- returns the number of tiles in the x direction.
-
getNumYTiles
public final int getNumYTiles()Description copied from class:PlanarImage
Returns 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:
getNumYTiles
in interfaceRenderedImage
- Overrides:
getNumYTiles
in classPlanarImage
- Returns:
- returns the number of tiles in the y direction.
-
getMinTileX
public final int getMinTileX()Description copied from class:PlanarImage
Returns 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:
getMinTileX
in interfaceRenderedImage
- Overrides:
getMinTileX
in classPlanarImage
- Returns:
- the minimum tile index in the x direction.
-
getMinTileY
public final int getMinTileY()Description copied from class:PlanarImage
Returns 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:
getMinTileY
in interfaceRenderedImage
- Overrides:
getMinTileY
in 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:PlanarImage
Returns 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:
getTileGridXOffset
in interfaceRenderedImage
- Overrides:
getTileGridXOffset
in classPlanarImage
- Returns:
- the x offset of the tile grid relative to the origin.
-
getTileGridYOffset
public final int getTileGridYOffset()Description copied from class:PlanarImage
Returns 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:
getTileGridYOffset
in interfaceRenderedImage
- Overrides:
getTileGridYOffset
in classPlanarImage
- Returns:
- the y offset of the tile grid relative to the origin.
-
getTile
-
getData
Description copied from class:PlanarImage
Returns a copy of this image as one large tile. The returned raster will not be updated if this image is changed.- Specified by:
getData
in interfaceRenderedImage
- Overrides:
getData
in classPlanarImage
- Returns:
- a copy of this image as one large tile.
-
getData
Description copied from class:PlanarImage
Returns a copy of an arbitrary region of this image. The returned raster will not be updated if this image is changed.- Specified by:
getData
in interfaceRenderedImage
- Overrides:
getData
in 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:PlanarImage
Copies 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 aSampleModel
that is compatible with this image. If the raster isnull
, an raster is created by this method.- Specified by:
copyData
in interfaceRenderedImage
- Overrides:
copyData
in 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:
prefetch
in 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), ornull
if 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
true
if 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
source
hash 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:
toString
in 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.
-