Class RecoloredImage

All Implemented Interfaces:
RenderedImage

final class RecoloredImage extends ImageAdapter
An image with the same sample values than the wrapped image but a different color model. The only interesting member method is getColorModel(), which returns the model specified at construction time. All other non-trivial methods are static helper methods for ImageProcessor, defined here for reducing ImageProcessor size.
Since:
1.1
Version:
1.2
  • Field Details

    • colors

      private final ColorModel colors
      The color model to associate with this recolored image.
      See Also:
    • minimum

      final double minimum
      The minimum and maximum values used for computing the color model. This is used for preserving color ramp stretching when a new color ramp is applied.

      Current implementation can only describes a uniform stretching between a minimum and maximum value. Future version may allow more sophisticated ways to redistribute the colors. The possibilities are determined by stretchColorRamp(ImageProcessor, RenderedImage, Map) implementation.

    • maximum

      final double maximum
      The minimum and maximum values used for computing the color model. This is used for preserving color ramp stretching when a new color ramp is applied.

      Current implementation can only describes a uniform stretching between a minimum and maximum value. Future version may allow more sophisticated ways to redistribute the colors. The possibilities are determined by stretchColorRamp(ImageProcessor, RenderedImage, Map) implementation.

  • Constructor Details

    • RecoloredImage

      private RecoloredImage(RenderedImage source, ColorModel colors, double minimum, double maximum)
      Creates a new recolored image with the given colors.
      Parameters:
      source - the image to wrap.
      colors - the new color model.
      minimum - the minimal sample value used for computing the color model.
      maximum - the maximal sample value used for computing the color model.
  • Method Details

    • applySameColors

      static RenderedImage applySameColors(RenderedImage source, RenderedImage colored)
      Returns a recolored image with the same colors than the given image. This method may return an existing ancestor if one is found with the desired color model.
      Parameters:
      source - the image to wrap.
      colored - the image from which to preserve the color model.
    • stretchColorRamp

      static RenderedImage stretchColorRamp(ImageProcessor processor, RenderedImage source, Map<String,?> modifiers)
      Returns an image with the same sample values than the given image, but with its color ramp stretched between specified or inferred bounds. The mapping applied by this method is conceptually a linear transform applied on sample values before they are mapped to their colors.

      Current implementation can stretch gray scale and index color models). If this method cannot stretch the color ramp, for example because the given image is an RGB image, then the image is returned unchanged.

      Parameters:
      processor - the processor to use for computing statistics if needed.
      source - the image to recolor (can be null).
      modifiers - modifiers for narrowing the range of values, or null if none.
      Returns:
      the image with color ramp stretched between the automatic bounds, or image unchanged if the operation cannot be applied on the given image.
      See Also:
    • illegalPropertyType

      private static IllegalArgumentException illegalPropertyType(Map<String,?> properties, String key, Object value)
      Returns the exception to be thrown when a property is of illegal type.
    • getColorModel

      public ColorModel getColorModel()
      Returns the color model of this image.
      Specified by:
      getColorModel in interface RenderedImage
      Overrides:
      getColorModel in class ImageAdapter
    • equals

      public boolean equals(Object object)
      Compares the given object with this image for equality.
      Overrides:
      equals in class ImageAdapter
      Parameters:
      object - the object to compare with this image.
      Returns:
      true if the given object is an image performing the same calculation than this image.
    • hashCode

      public int hashCode()
      Returns a hash code value for this image.
      Overrides:
      hashCode in class ImageAdapter
      Returns:
      a hash code value based on a description of the operation performed by this image.
    • appendStringContent

      final Class<RecoloredImage> appendStringContent(StringBuilder buffer)
      Appends a content to show in the ImageAdapter.toString() representation, after the class name and before the string representation of the wrapped image.
      Specified by:
      appendStringContent in class ImageAdapter
      Parameters:
      buffer - where to start writing content of ImageAdapter.toString() representation.
      Returns:
      name of the class to show in the ImageAdapter.toString() representation.