Class TiledImage

java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.internal.coverage.j2d.TiledImage
All Implemented Interfaces:
RenderedImage
Direct Known Subclasses:
WritableTiledImage

public class TiledImage extends PlanarImage
A rendered image which can contain an arbitrary number of tiles. Tiles are stored in memory. This class may become public in a future version, but not yet because managing large tiled images would require a more sophisticated class than current implementation.

This class should not perform any computation; all tiles are given at construction time. This requirement makes this class thread-safe and concurrent without the need for synchronization.

Since:
1.1
Version:
1.2
  • Field Details

    • colorModel

      private final ColorModel colorModel
      The color model, or null if none.
    • width

      private final int width
      Number of pixels along X or Y axis in the whole rendered image.
    • height

      private final int height
      Number of pixels along X or Y axis in the whole rendered image.
    • minTileX

      private final int minTileX
      Index of the first tile in the image.
    • minTileY

      private final int minTileY
      Index of the first tile in the image.
    • tiles

      private final Raster[] tiles
      The tiles. They must all use the same sample model.
    • properties

      private final Map<String,Object> properties
      Image properties, or an empty map if none.
  • Constructor Details

    • TiledImage

      public TiledImage(Map<String,Object> properties, ColorModel colorModel, int width, int height, int minTileX, int minTileY, Raster... tiles)
      Creates a new tiled image. The first tile in the given array must be the one located at the minimal tile indices. All tiles must have the same size and the same sample model and must be sorted in row-major fashion (this is not verified in current version, but may be in the future).
      Parameters:
      properties - image properties, or null if none.
      colorModel - the color model, or null if none.
      width - number of pixels along X axis in the whole rendered image.
      height - number of pixels along Y axis in the whole rendered image.
      minTileX - minimum tile index in the X direction.
      minTileY - minimum tile index in the Y direction.
      tiles - the tiles. Must contains at least one element. This array is not cloned.
  • Method Details

    • verify

      public String verify()
      Verifies whether image layout information and tile coordinates are consistent. This method verifies the size and minimum pixel coordinates of all tiles. 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.
    • property

      private static String property(int tx, int ty, String name)
      Label returned by verify() for identifying an error in a specified tile.
    • getColorModel

      public ColorModel getColorModel()
      Returns the color model, or null if none.
    • getSampleModel

      public SampleModel getSampleModel()
      Returns the sample model.
    • getProperty

      public Object getProperty(String key)
      Gets a property from this image.
      Specified by:
      getProperty in interface RenderedImage
      Overrides:
      getProperty in class PlanarImage
      Parameters:
      key - the name of the property to get.
      Returns:
      the property value, or Image.UndefinedProperty if none.
    • getPropertyNames

      public String[] getPropertyNames()
      Returns the names of all recognized properties, or null if this image has no properties.
      Specified by:
      getPropertyNames in interface RenderedImage
      Overrides:
      getPropertyNames in class PlanarImage
      Returns:
      names of all recognized properties, or null if none.
    • getMinX

      public int getMinX()
      Returns the minimum x coordinate (inclusive) of this image.
      Specified by:
      getMinX in interface RenderedImage
      Overrides:
      getMinX in class PlanarImage
      Returns:
      the minimum x coordinate (column) of this image.
    • getMinY

      public int getMinY()
      Returns the minimum y coordinate (inclusive) of this image.
      Specified by:
      getMinY in interface RenderedImage
      Overrides:
      getMinY in class PlanarImage
      Returns:
      the minimum y coordinate (row) of this image.
    • getWidth

      public int getWidth()
      Returns the number of pixels along X axis in the whole rendered image.
    • getHeight

      public int getHeight()
      Returns the number of pixels along Y axis in the whole rendered image.
    • getTileWidth

      public int getTileWidth()
      Returns the tile width in pixels. All tiles must have the same width.
    • getTileHeight

      public int getTileHeight()
      Returns the tile height in pixels. All tiles must have the same height.
    • getMinTileX

      public int getMinTileX()
      Returns the minimum tile index in the X direction.
      Specified by:
      getMinTileX in interface RenderedImage
      Overrides:
      getMinTileX in class PlanarImage
      Returns:
      the minimum tile index in the x direction.
    • getMinTileY

      public int getMinTileY()
      Returns the minimum tile index in the Y direction.
      Specified by:
      getMinTileY in interface RenderedImage
      Overrides:
      getMinTileY in class PlanarImage
      Returns:
      the minimum tile index in the y direction.
    • getTile

      public Raster getTile(int tileX, int tileY)
      Returns the tile at the given location in tile coordinates.
    • verifyTileIndex

      private static int verifyTileIndex(String name, int value, int min, int count)
      Verifies that the given tile index is inside expected bounds, then returns is zero-based value.