Class TilePlaceholder

java.lang.Object
org.apache.sis.internal.coverage.j2d.TilePlaceholder
Direct Known Subclasses:
TilePlaceholder.Filled, TilePlaceholder.WithCross

public class TilePlaceholder extends Object
Source of read-only empty tiles to use as placeholder for tiles that were not computed. This class reduces memory usage by sharing the same data buffer for all tiles. Subclasses can optionally draw some symbols in the tile, for example to signal an error.
Since:
1.2
Version:
1.2
  • Field Details

    • PENDING_JDK_FIX

      @Workaround(library="JDK", version="17") public static final boolean PENDING_JDK_FIX
      Identifies workaround for two JDK bugs.

      JDK-8166038: If BufferedImage cannot be used, fallback on ReshapedImage at the cost of an image larger than necessary. In such case, the tests need to specify the sub-region of pixels to verify.

      JDK-8275345: call to Graphics2D.drawRenderedImage(…) fails if the image contains more than one tile (or a single tile not located at 0,0) and the tiles are not instances of WritableRaster (i.e. are instances of the read-only Raster parent class). The exception thrown is:

      See Also:
    • CACHE

      private static final WeakHashSet<TilePlaceholder> CACHE
      Cache of empty tiles for different sample models.
    • model

      protected final SampleModel model
      The sample model of the empty tiles to create.
    • reference

      private TilePlaceholder.BufferRef reference
      The data buffers for empty tiles. The same data buffer is shared by all Raster instances using the same sample model. Data may contain some drawing such as a cross (X).
  • Constructor Details

    • TilePlaceholder

      protected TilePlaceholder(SampleModel model)
      Creates a initially empty set of empty tiles.
      Parameters:
      model - sample model of the empty tiles.
  • Method Details

    • empty

      public static TilePlaceholder empty(SampleModel model)
      Returns a provider of empty tiles for the given sample model. All pixel values will be zero in all bands.
      Parameters:
      model - sample model of the empty tiles.
      Returns:
      provider of fully empty tiles.
    • filled

      public static TilePlaceholder filled(SampleModel model, Number fillValue)
      Returns a provider of empty tiles filled with the given value in all bands. A value of null is interpreted as 0 for integer types or NaN for floating point types.
      Parameters:
      model - sample model of the empty tiles.
      fillValue - the value to use for filling empty spaces in rasters, or null for zero.
      Returns:
      provider of filled tiles.
    • filled

      public static TilePlaceholder filled(SampleModel model, FillValues fill)
      Returns a provider of empty tiles filled with the given values.
      Parameters:
      model - sample model of the empty tiles.
      fill - the fill values.
      Returns:
      provider of filled tiles.
    • withCross

      public static TilePlaceholder withCross(RenderedImage image)
      Returns a source of "empty" tiles with a white border and a white cross.
      Parameters:
      image - sample model and color model of the tiles to create.
      Returns:
      a source of "empty" tiles with white borders and crosses.
    • create

      public final Raster create(Point location)
      Creates a tile to use as a placeholder when a tile cannot be computed.
      Parameters:
      location - minimum x and y coordinates of the tile raster.
      Returns:
      placeholder for a tile at the given location.
    • isCreatorOf

      public final boolean isCreatorOf(Raster tile)
      Returns true if this factory is the creator of given raster.
      Parameters:
      tile - the tile to test, or null.
      Returns:
      whether this tile is the creator of given raster.
    • draw

      protected void draw(WritableRaster tile)
      Invoked when a new empty tile is created. Subclasses can override this method for drawing some visual indication that the tile is missing. The default implementation does nothing.
      Parameters:
      tile - the tile where to draw.
    • equals

      public boolean equals(Object obj)
      Compares this object with given object for equality.
      Overrides:
      equals in class Object
      Parameters:
      obj - the other object to compare with this object.
      Returns:
      true if the two objects will create equivalent empty tiles.
    • hashCode

      public int hashCode()
      Returns a hash code value for this provider of tile placeholders.
      Overrides:
      hashCode in class Object