Class ScaledColorSpace

java.lang.Object
java.awt.color.ColorSpace
org.apache.sis.internal.coverage.j2d.ScaledColorSpace
All Implemented Interfaces:
Serializable

final class ScaledColorSpace extends ColorSpace
Color space for images storing pixels as real numbers. This color space can have an arbitrary number of bands, but only one band is shown. Current implementation produces grayscale image only, but it may change in future.

The use of this color space is very slow. It should be used only when no standard color space can be used.

Since:
1.0
Version:
1.1
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • scale

      final double scale
      The scaling factor from sample values to RGB values. The target RGB values will be in range 0 to 255 inclusive. Note that the target range is different than the range of ColorSpace normalized values; methods in this class has to divide values by 256.
    • offset

      final double offset
      The offset to subtract from sample values before to apply the scale factor.
    • maximum

      final double maximum
      The maximum value specified at construction time.
    • visibleBand

      final int visibleBand
      Index of the band to display, from 0 inclusive to ColorSpace.getNumComponents() exclusive.
  • Constructor Details

    • ScaledColorSpace

      ScaledColorSpace(int numComponents, int visibleBand, double minimum, double maximum)
      Creates a color space for the given range of values. The given range does not need to be exact; values outside that range will be clamped.
      Parameters:
      numComponents - the number of components.
      visibleBand - the band to use for computing colors.
      minimum - the minimal sample value expected, inclusive.
      maximum - the maximal sample value expected, exclusive.
    • ScaledColorSpace

      ScaledColorSpace(ScaledColorSpace parent, int[] bands)
      Creates a color space for the same range of values than the given space, but a subset of the bands.
  • Method Details

    • toRGB

      public float[] toRGB(float[] samples)
      Returns a RGB color for a sample value.
      Specified by:
      toRGB in class ColorSpace
      Parameters:
      samples - sample values in the raster.
      Returns:
      color as normalized RGB values between 0 and 1.
    • fromRGB

      public float[] fromRGB(float[] color)
      Returns a sample value for the specified RGB color.
      Specified by:
      fromRGB in class ColorSpace
      Parameters:
      color - normalized RGB values between 0 and 1.
      Returns:
      sample values in the raster.
    • toCIEXYZ

      public float[] toCIEXYZ(float[] values)
      Returns a CIEXYZ color for a sample value.
      Specified by:
      toCIEXYZ in class ColorSpace
      Parameters:
      values - sample values in the raster.
      Returns:
      color as normalized CIEXYZ values between 0 and 1.
    • fromCIEXYZ

      public float[] fromCIEXYZ(float[] color)
      Returns a sample value for the specified CIEXYZ color.
      Specified by:
      fromCIEXYZ in class ColorSpace
      Parameters:
      color - normalized CIEXYZ values between 0 and 1.
      Returns:
      sample values in the raster.
    • getMinValue

      public float getMinValue(int component)
      Returns the minimum value for the specified RGB component.
      Overrides:
      getMinValue in class ColorSpace
      Parameters:
      component - the component index.
      Returns:
      minimum normalized component value.
    • getMaxValue

      public float getMaxValue(int component)
      Returns the maximum value for the specified RGB component.
      Overrides:
      getMaxValue in class ColorSpace
      Parameters:
      component - the component index.
      Returns:
      maximum normalized component value.
    • toString

      public String toString()
      Returns a string representation of this color space.
      Overrides:
      toString in class Object
      Returns:
      a string representation for debugging purpose.
    • formatRange

      @Debug final void formatRange(StringBuilder buffer)
      Formats the range of values in the given buffer. This method is used for toString() implementation and may change in any future version.
      Parameters:
      buffer - where to append the range of values.
    • hashCode

      public int hashCode()
      Returns a hash code value for this color space.
      Overrides:
      hashCode in class Object
    • equals

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