Package org.apache.sis.coverage.grid
Class ReshapedImage
java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.coverage.grid.ReshapedImage
- All Implemented Interfaces:
RenderedImage
A view over another image with the origin relocated to a new position.
Only the pixel coordinates are changed; the tile indices stay the same.
However, the image view may expose less tiles than the wrapped image.
This wrapper does not change image size otherwise than by an integer amount of tiles.
- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
The image size in pixels.private final int
Index in tile matrix of the upper-left tile.private final int
Index in tile matrix of the upper-left tile.private final int
Coordinate of the upper-left pixel.private final int
Coordinate of the upper-left pixel.private final int
Value to add for converting a column index from the coordinate system of the wrapped image to the coordinate system of this image.private final int
Value to add for converting a row index from the coordinate system of the wrapped image to the coordinate system of this image.(package private) final RenderedImage
The image to translate.private final int
The image size in pixels.Fields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY
-
Constructor Summary
ConstructorsConstructorDescriptionReshapedImage
(RenderedImage source, long xmin, long ymin, long xmax, long ymax) Creates a new image with the same data than the given image but located at different coordinates. -
Method Summary
Modifier and TypeMethodDescriptioncopyData
(WritableRaster raster) Copies an arbitrary rectangular region of this image to the supplied writable raster.private Raster
Implementation ofgetData(Rectangle)
.boolean
Compares the given object with this image for equality.getData()
Returns a copy of this image as one large tile.Returns a copy of an arbitrary region of this image.int
int
Returns the minimum tile index in the x direction.int
Returns the minimum tile index in the y direction.int
getMinX()
Returns properties determined at construction time.int
getMinY()
Returns the minimum y coordinate (inclusive) of this image.getProperty
(String name) Delegates to the wrapped image with no change.String[]
Returns the names of all recognized properties, ornull
if this image has no properties.Returns the immediate source of this image.getTile
(int tileX, int tileY) Returns the tile at the given tile indices (not to be confused with pixel indices).int
Returns the x coordinate of the upper-left pixel of tile (0, 0).int
Returns the y coordinate of the upper-left pixel of tile (0, 0).int
int
int
getWidth()
int
hashCode()
Returns a hash code value for this image.(package private) final boolean
Returnstrue
if this image does not move and does not subset the wrapped image.private Raster
Returns a raster with the same data than the given raster but with coordinates translated from the coordinate system of the wrapped image to the coordinate system of this image.verify()
Verifies whether image layout information are consistent.Methods inherited from class org.apache.sis.image.PlanarImage
getBounds, getNumXTiles, getNumYTiles, toString
-
Field Details
-
source
The image to translate. -
offsetX
private final int offsetXValue to add for converting a column index from the coordinate system of the wrapped image to the coordinate system of this image. For a conversion in opposite direction, that value shall be subtracted. -
offsetY
private final int offsetYValue to add for converting a row index from the coordinate system of the wrapped image to the coordinate system of this image. For a conversion in opposite direction, that value shall be subtracted. -
width
private final int widthThe image size in pixels. May be smaller thansource
size by an integer amount of tiles. -
height
private final int heightThe image size in pixels. May be smaller thansource
size by an integer amount of tiles. -
minX
private final int minXCoordinate of the upper-left pixel. Computed at construction time in order to detect integer overflows early. -
minY
private final int minYCoordinate of the upper-left pixel. Computed at construction time in order to detect integer overflows early. -
minTileX
private final int minTileXIndex in tile matrix of the upper-left tile. Computed at construction time in order to detect integer overflows early. -
minTileY
private final int minTileYIndex in tile matrix of the upper-left tile. Computed at construction time in order to detect integer overflows early.
-
-
Constructor Details
-
ReshapedImage
ReshapedImage(RenderedImage source, long xmin, long ymin, long xmax, long ymax) Creates a new image with the same data than the given image but located at different coordinates. In addition, this constructor can reduce the number of tiles.- Parameters:
source
- the image to move.xmin
- minimal x coordinate of the requested region, inclusive.ymin
- minimal y coordinate of the requested region, inclusive.xmax
- maximal x coordinate of the requested region, inclusive.ymax
- maximal y coordinate of the requested region, inclusive.- Throws:
ArithmeticException
- if image indices would overflow 32 bits integer capacity.
-
-
Method Details
-
isIdentity
final boolean isIdentity()Returnstrue
if this image does not move and does not subset the wrapped image. -
getSources
Returns the immediate source of this image.- Specified by:
getSources
in interfaceRenderedImage
- Overrides:
getSources
in classPlanarImage
- Returns:
- the immediate sources, or
null
if unknown.
-
getProperty
Delegates to the wrapped image with no change.- Specified by:
getProperty
in interfaceRenderedImage
- Overrides:
getProperty
in classPlanarImage
- Parameters:
name
- the name of the property to get.- Returns:
- the property value, or
Image.UndefinedProperty
if none.
-
getPropertyNames
Description copied from class:PlanarImage
Returns the names of all recognized properties, ornull
if this image has no properties.The default implementation returns
null
.- Specified by:
getPropertyNames
in interfaceRenderedImage
- Overrides:
getPropertyNames
in classPlanarImage
- Returns:
- names of all recognized properties, or
null
if none.
-
getColorModel
-
getSampleModel
-
getTileWidth
public int getTileWidth() -
getTileHeight
public int getTileHeight() -
getMinX
public int getMinX()Returns properties determined at construction time.- Specified by:
getMinX
in interfaceRenderedImage
- Overrides:
getMinX
in classPlanarImage
- Returns:
- the minimum x coordinate (column) of this image.
-
getMinY
public 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.
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getMinTileX
public 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 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.
-
getTileGridXOffset
public int getTileGridXOffset()Returns the x coordinate of the upper-left pixel of tile (0, 0). That tile (0, 0) may not actually exist.- Specified by:
getTileGridXOffset
in interfaceRenderedImage
- Overrides:
getTileGridXOffset
in classPlanarImage
- Returns:
- the x offset of the tile grid relative to the origin.
-
getTileGridYOffset
public int getTileGridYOffset()Returns the y coordinate of the upper-left pixel of tile (0, 0). That tile (0, 0) may not actually exist.- Specified by:
getTileGridYOffset
in interfaceRenderedImage
- Overrides:
getTileGridYOffset
in classPlanarImage
- Returns:
- the y offset of the tile grid relative to the origin.
-
offset
Returns a raster with the same data than the given raster but with coordinates translated from the coordinate system of the wrapped image to the coordinate system of this image. The returned raster will have the given raster as its parent. -
getTile
Returns the tile at the given tile indices (not to be confused with pixel indices).- Parameters:
tileX
- the x index of the requested tile in the tile array.tileY
- the y index of the requested tile in the tile array.- Returns:
- the tile specified by the specified indices.
-
getData
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
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:
aoi
- the region of this image to copy.- Returns:
- a copy of this image in the given area of interest.
-
copyData
Implementation ofgetData(Rectangle)
. This implementation will modify the givenaoi
argument. If that argument was supplied by user, then it should first be copied by the caller. -
copyData
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.- Specified by:
copyData
in interfaceRenderedImage
- Overrides:
copyData
in classPlanarImage
- Parameters:
raster
- the raster to hold a copy of this image, ornull
.- Returns:
- the given raster if it was not-null, or a new raster otherwise.
-
verify
Verifies whether image layout information are consistent. This method first checks the properties modified by this class. If okay, then this method completes the check with all verifications documented in parent class.- Overrides:
verify
in classPlanarImage
- Returns:
null
if image layout information are consistent, or the name of inconsistent attribute if a problem is found.
-
hashCode
public int hashCode()Returns a hash code value for this image. -
equals
Compares the given object with this image for equality.
-