Class ReshapedImage

java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.coverage.grid.ReshapedImage
All Implemented Interfaces:
RenderedImage

final class ReshapedImage extends PlanarImage
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 Details

    • source

      final RenderedImage source
      The image to translate.
    • offsetX

      private final int offsetX
      Value 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 offsetY
      Value 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 width
      The image size in pixels. May be smaller than source size by an integer amount of tiles.
    • height

      private final int height
      The image size in pixels. May be smaller than source size by an integer amount of tiles.
    • minX

      private final int minX
      Coordinate of the upper-left pixel. Computed at construction time in order to detect integer overflows early.
    • minY

      private final int minY
      Coordinate of the upper-left pixel. Computed at construction time in order to detect integer overflows early.
    • minTileX

      private final int minTileX
      Index in tile matrix of the upper-left tile. Computed at construction time in order to detect integer overflows early.
    • minTileY

      private final int minTileY
      Index 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()
      Returns true if this image does not move and does not subset the wrapped image.
    • getSources

      public Vector<RenderedImage> getSources()
      Returns the immediate source of this image.
      Specified by:
      getSources in interface RenderedImage
      Overrides:
      getSources in class PlanarImage
      Returns:
      the immediate sources, or null if unknown.
    • getProperty

      public Object getProperty(String name)
      Delegates to the wrapped image with no change.
      Specified by:
      getProperty in interface RenderedImage
      Overrides:
      getProperty in class PlanarImage
      Parameters:
      name - the name of the property to get.
      Returns:
      the property value, or Image.UndefinedProperty if none.
    • getPropertyNames

      public String[] getPropertyNames()
      Description copied from class: PlanarImage
      Returns the names of all recognized properties, or null if this image has no properties.

      The default implementation returns null.

      Specified by:
      getPropertyNames in interface RenderedImage
      Overrides:
      getPropertyNames in class PlanarImage
      Returns:
      names of all recognized properties, or null if none.
    • getColorModel

      public ColorModel getColorModel()
    • getSampleModel

      public SampleModel getSampleModel()
    • getTileWidth

      public int getTileWidth()
    • getTileHeight

      public int getTileHeight()
    • getMinX

      public int getMinX()
      Returns properties determined at construction time.
      Specified by:
      getMinX in interface RenderedImage
      Overrides:
      getMinX in class PlanarImage
      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 interface RenderedImage
      Overrides:
      getMinY in class PlanarImage
      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 interface RenderedImage
      Overrides:
      getMinTileX in class PlanarImage
      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 interface RenderedImage
      Overrides:
      getMinTileY in class PlanarImage
      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 interface RenderedImage
      Overrides:
      getTileGridXOffset in class PlanarImage
      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 interface RenderedImage
      Overrides:
      getTileGridYOffset in class PlanarImage
      Returns:
      the y offset of the tile grid relative to the origin.
    • offset

      private Raster offset(Raster data)
      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

      public Raster getTile(int tileX, int tileY)
      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

      public Raster 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 interface RenderedImage
      Overrides:
      getData in class PlanarImage
      Returns:
      a copy of this image as one large tile.
    • getData

      public Raster getData(Rectangle aoi)
      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 interface RenderedImage
      Overrides:
      getData in class PlanarImage
      Parameters:
      aoi - the region of this image to copy.
      Returns:
      a copy of this image in the given area of interest.
    • copyData

      private Raster copyData(Rectangle aoi)
      Implementation of getData(Rectangle). This implementation will modify the given aoi argument. If that argument was supplied by user, then it should first be copied by the caller.
    • copyData

      public WritableRaster copyData(WritableRaster raster)
      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 interface RenderedImage
      Overrides:
      copyData in class PlanarImage
      Parameters:
      raster - the raster to hold a copy of this image, or null.
      Returns:
      the given raster if it was not-null, or a new raster otherwise.
    • verify

      public String 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
      invalid reference
      documented in parent class
      .
      Overrides:
      verify in class PlanarImage
      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.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Compares the given object with this image for equality.
      Overrides:
      equals in class Object