Class ColorMap.Index<T>

Object
ColorMap<T>
Index<T>
Type Parameters:
T - type of color object: String or MeshLambertMaterial for GWT and Color for JRE
Direct Known Subclasses:
ColorMap3D.Index, ColorMapCSS.Index
Enclosing class:
ColorMap<T>

public abstract static class ColorMap.Index<T> extends ColorMap<T>
Associates integer indices with colors.
See Also:
  • Field Details

    • colors

      protected T[] colors
      Array of generic colors T.
    • srccolors

      protected Color[] srccolors
      This is currently only needed to pass something to toGradient1D(int).
    • nColors

      protected final int nColors
      Number of colors
  • Constructor Details

    • Index

      protected Index(int size)
      Constructs a new index color map.
      Parameters:
      size - the number of colors
    • Index

      protected Index(Color[] srccolors, int alpha, T[] colors)
      Constructs a new index color map with transparency alpha.
      Parameters:
      srccolors - the indexed colors
      alpha - the transparency of the colors
      colors - the array to store the colors
  • Method Details

    • getColors

      public T[] getColors()
      Get the array of colors tha backs this color map.
      Returns:
      the array of colors
    • setColor

      public void setColor(int index, Color color)
      Assign a new color to index.
      Parameters:
      index - the index of the color
      color - the new color for index
    • setColor

      public void setColor(int index, Color color, int alpha)
      Assign a new color to index with transparency alpha.

      Note: the transparency of the supplied color is always honoured.

      Parameters:
      index - the index of the color
      color - the new color for index
      alpha - the transparency of the new color
    • translate

      public boolean translate(int[] data, T[] color)
      Description copied from class: ColorMap
      Translate the data array of int values to colors and store the results in the color array. The type of the color array depends on the implementation.

      Note: for performance reasons no validity checks are performed on the data. If any data entry is negative or >nColors an ArrayIndexOutOfBoundsException is thrown.

      Overrides:
      translate in class ColorMap<T>
      Parameters:
      data - the int[] array to convert to colors
      color - the array for the resulting colors
      Returns:
      true if translation successful
    • toGradient1D

      public abstract ColorMap.Gradient1D<T> toGradient1D(int nIncr)
      Convert the index colors into a 1D gradient with a total of nIncr shades.
      Parameters:
      nIncr - the total number of color increments
      Returns:
      the 1D color gradient