Class ArrayColormap

java.lang.Object
com.jhlabs.image.ArrayColormap
All Implemented Interfaces:
Colormap, Serializable, Cloneable
Direct Known Subclasses:
Gradient, SplineColormap

public class ArrayColormap extends Object implements Colormap, Cloneable, Serializable
A colormap implemented with an array of colors. This corresponds to the IndexColorModel class.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
    The array of colors.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an all-black colormap
    ArrayColormap(int[] map)
    Construct a colormap with the given map
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
    getColor(float v)
    Convert a value in the range 0..1 to an RGB color.
    int[]
     
    void
    setColor(int index, int color)
     
    void
    setColorInterpolated(int index, int firstIndex, int lastIndex, int color)
    Set the color at "index" to "color".
    void
    setColorRange(int firstIndex, int lastIndex, int color)
     
    void
    setColorRange(int firstIndex, int lastIndex, int color1, int color2)
     
    void
    setMap(int[] map)
     

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • map

      protected int[] map
      The array of colors.
  • Constructor Details

    • ArrayColormap

      public ArrayColormap()
      Construct an all-black colormap
    • ArrayColormap

      public ArrayColormap(int[] map)
      Construct a colormap with the given map
      Parameters:
      map - the array of ARGB colors
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • setMap

      public void setMap(int[] map)
    • getMap

      public int[] getMap()
    • getColor

      public int getColor(float v)
      Convert a value in the range 0..1 to an RGB color.
      Specified by:
      getColor in interface Colormap
      Parameters:
      v - a value in the range 0..1
      Returns:
      an RGB color
    • setColorInterpolated

      public void setColorInterpolated(int index, int firstIndex, int lastIndex, int color)
      Set the color at "index" to "color". Entries are interpolated linearly from the existing entries at "firstIndex" and "lastIndex" to the new entry. firstIndex < index < lastIndex must hold.
    • setColorRange

      public void setColorRange(int firstIndex, int lastIndex, int color1, int color2)
    • setColorRange

      public void setColorRange(int firstIndex, int lastIndex, int color)
    • setColor

      public void setColor(int index, int color)