Class FillValues

java.lang.Object
org.apache.sis.internal.coverage.j2d.FillValues

public final class FillValues extends Object
Helper class for handling the fill values of a raster. A value can be specified for each band.
Since:
1.2
Version:
1.2
  • Field Details

    • asPrimitiveArray

      public final Object asPrimitiveArray
      The fill values as an array of primitive type: int[], float[] or double[]. No other type is allowed. This field is never null and the array length is the number of bands.
    • isFullyZero

      public final boolean isFullyZero
      true if all values in asPrimitiveArray are positive 0. This is the value of newly constructed Java arrays or
      invalid reference
      Raster
      instances. Consequently, calls to fill(WritableRaster) can be skipped if the raster is new and this flag is true.
  • Constructor Details

    • FillValues

      public FillValues(SampleModel model, Number[] values, boolean allowFloat)
      Stores the given fill values as an array of primitive type. If the given array is null, or if any element in the given array is null, then the default fill value is NaN for floating point data types or zero for integer data types. If the array is shorter than the number of bands, then above-cited default values are used for missing values. If longer than the number of bands, extraneous values are ignored.
      Parameters:
      model - the sample model of the image for which to prepare fill values.
      values - the fill values, or null for the default values.
      allowFloat - whether to allow asPrimitiveArray to be float[]. If false, then asPrimitiveArray can only be double[] or int[].
  • Method Details

    • fill

      public void fill(WritableRaster tile)
      Fills the given raster with the fill value. The raster sample model should be the same than the sample model specified at construction time of this FillValues object.

      Implementation note

      This method fills the raster using its API, without direct access to the backing array. We do not use direct array access because it would disable Java2D hardware acceleration in subsequent operations.
      Parameters:
      tile - the raster to fill.
      See Also:
    • fill

      public void fill(WritableRenderedImage image)
      Fills the given image with the fill value. The image sample model should be the same than the sample model specified at construction time of this FillValues object.
      Parameters:
      image - the image to fill.
    • 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 have the same fill values.
    • hashCode

      public int hashCode()
      Returns a hash code for the fill values.
      Overrides:
      hashCode in class Object