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 intThe image size in pixels.private final intIndex in tile matrix of the upper-left tile.private final intIndex in tile matrix of the upper-left tile.private final intCoordinate of the upper-left pixel.private final intCoordinate of the upper-left pixel.private final intValue to add for converting a column index from the coordinate system of the wrapped image to the coordinate system of this image.private final intValue 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 RenderedImageThe image to translate.private final intThe 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 RasterImplementation ofgetData(Rectangle).booleanCompares 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.intintReturns the minimum tile index in the x direction.intReturns the minimum tile index in the y direction.intgetMinX()Returns properties determined at construction time.intgetMinY()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, ornullif 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).intReturns the x coordinate of the upper-left pixel of tile (0, 0).intReturns the y coordinate of the upper-left pixel of tile (0, 0).intintintgetWidth()inthashCode()Returns a hash code value for this image.(package private) final booleanReturnstrueif this image does not move and does not subset the wrapped image.private RasterReturns 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 thansourcesize by an integer amount of tiles. -
height
private final int heightThe image size in pixels. May be smaller thansourcesize 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()Returnstrueif this image does not move and does not subset the wrapped image. -
getSources
Returns the immediate source of this image.- Specified by:
getSourcesin interfaceRenderedImage- Overrides:
getSourcesin classPlanarImage- Returns:
- the immediate sources, or
nullif unknown.
-
getProperty
Delegates to the wrapped image with no change.- Specified by:
getPropertyin interfaceRenderedImage- Overrides:
getPropertyin classPlanarImage- Parameters:
name- the name of the property to get.- Returns:
- the property value, or
Image.UndefinedPropertyif none.
-
getPropertyNames
Description copied from class:PlanarImageReturns the names of all recognized properties, ornullif this image has no properties.The default implementation returns
null.- Specified by:
getPropertyNamesin interfaceRenderedImage- Overrides:
getPropertyNamesin classPlanarImage- Returns:
- names of all recognized properties, or
nullif none.
-
getColorModel
-
getSampleModel
-
getTileWidth
public int getTileWidth() -
getTileHeight
public int getTileHeight() -
getMinX
public int getMinX()Returns properties determined at construction time.- Specified by:
getMinXin interfaceRenderedImage- Overrides:
getMinXin classPlanarImage- Returns:
- the minimum x coordinate (column) of this image.
-
getMinY
public 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.
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getMinTileX
public 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 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.
-
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:
getTileGridXOffsetin interfaceRenderedImage- Overrides:
getTileGridXOffsetin 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:
getTileGridYOffsetin interfaceRenderedImage- Overrides:
getTileGridYOffsetin 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:
getDatain interfaceRenderedImage- Overrides:
getDatain 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:
getDatain interfaceRenderedImage- Overrides:
getDatain 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 givenaoiargument. 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:
copyDatain interfaceRenderedImage- Overrides:
copyDatain 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:
verifyin classPlanarImage- Returns:
nullif 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.
-