Class ColorTable

java.lang.Object
ucar.unidata.util.ColorTable
All Implemented Interfaces:
NamedObject

public class ColorTable extends Object implements NamedObject
Holds a name and a 2D float array that represents a color table
Author:
IDV development team
  • Field Details

  • Constructor Details

    • ColorTable

      public ColorTable(ColorTable otherTable)
      Copy constructor
      Parameters:
      otherTable - other table to copy
    • ColorTable

      public ColorTable()
      Default constructor
    • ColorTable

      public ColorTable(String name, String category, float[][] table)
      Create a new ColorTable.
      Parameters:
      name - name of the table
      category - category of the table
      table - table values
    • ColorTable

      public ColorTable(String id, String name, String category, float[][] table)
      Create a new ColorTable.
      Parameters:
      id - id of the table
      name - name of the table
      category - category of the table
      table - table values
    • ColorTable

      public ColorTable(String id, String name, String category, float[][] table, boolean tableFlipped)
      Create a new ColorTable.
      Parameters:
      id - id of the table
      name - name of the table
      category - category of the table
      table - table values
      tableFlipped - flipped flag
  • Method Details

    • init

      public ColorTable init(String name, String category, ArrayList colors, ArrayList breakpoints, Range r)
      Initialize a color table a new ColorTable.
      Parameters:
      name - name of the table
      category - category of the table
      colors - table colors
      breakpoints - breakpoints
      r - Range of values
      Returns:
      filled in ColorTable
    • init

      public ColorTable init(String name, String category, ArrayList colors, ArrayList scales, ArrayList breakpoints, Range r)
      Initialize a color table a new ColorTable.
      Parameters:
      name - name of the table
      category - category of the table
      colors - table colors
      scales - scale factors
      breakpoints - breakpoints
      r - Range of values
      Returns:
      filled in ColorTable
    • equalsTable

      public boolean equalsTable(ColorTable other)
      See if another color table is equivalent to this one
      Parameters:
      other - other table to check
      Returns:
      true ifthey are equal.
    • setRange

      public void setRange(Range r)
      Set the range for this table.
      Parameters:
      r - range
    • getRange

      public Range getRange()
      Get the Range for this color table.
      Returns:
      the range
    • setActive

      public void setActive(boolean a)
      Set the active flag.
      Parameters:
      a - true for active
    • getActive

      public boolean getActive()
      Get the active flag.
      Returns:
      true if active
    • setBreakpoints

      public void setBreakpoints(ArrayList l)
      Set the breakpoints for this color table.
      Parameters:
      l - list of breakpoints
    • getBreakpoints

      public ArrayList getBreakpoints()
      Get the breakpoints for this table.
      Returns:
      the breakpoints
    • getNonAlphaTable

      public float[][] getNonAlphaTable()
      Get the table without alpha values.
      Returns:
      table with alpha removed.
    • getAlphaTable

      public float[][] getAlphaTable()
      Get the table with alpha.
      Returns:
      the alpha table
    • getColorTable

      public float[][] getColorTable()
      Get the color table pallette. This applies any scale factor.
      Returns:
      the table of values
    • setTable

      public void setTable(float[][] table)
      Set the color table palette Note: this is around for legacy purposes and we will move to a new setTableArray/getTableArray method
      Parameters:
      table - table of values
    • getTable

      public float[][] getTable()
      Get the color table palette Note: this is around for legacy purposes and we will move to a new setTableArray/getTableArray method
      Returns:
      get the color table as a float array
    • setTableArray

      public void setTableArray(float[][] table)
      Set the table array
      Parameters:
      table - the table as a float array
    • getName

      public String getName()
      Get the name of this table.
      Specified by:
      getName in interface NamedObject
      Returns:
      the name of this table
    • setName

      public void setName(String name)
      Set the name of this table
      Specified by:
      setName in interface NamedObject
      Parameters:
      name - the new name
    • getId

      public String getId()
      Get the ID of this table
      Returns:
      the id
    • setId

      public void setId(String id)
      Set the id of this table
      Parameters:
      id - the table id
    • getDescription

      public String getDescription()
      Get the table description
      Specified by:
      getDescription in interface NamedObject
      Returns:
      the table description
    • setDescription

      public void setDescription(String description)
      Set the table description
      Parameters:
      description - the table description
    • getCategory

      public String getCategory()
      Get the table category.
      Returns:
      the table category
    • setCategory

      public void setCategory(String category)
      Set the table category.
      Parameters:
      category - the new category
    • dataToString

      public String dataToString()
      Output the table as a String.
      Returns:
      the table values as a string.
    • print

      public String print()
      Print the table info
      Returns:
      the table info
    • toString

      public String toString()
      Get a descriptive String for this object.
      Overrides:
      toString in class Object
      Returns:
      a descriptive String for this object.
    • setTable

      public void setTable(ArrayList colors)
      Set the table with a list of colors
      Parameters:
      colors - list of colors
    • getColorList

      public ArrayList<Color> getColorList()
      Convert the colorTable into a list of Color-s
      Returns:
      list of colors
    • getColorList

      public ArrayList<Color> getColorList(boolean includeAlpha)
      Convert the colorTable into a list of Color-s
      Parameters:
      includeAlpha - true to use alpha
      Returns:
      list of colors
    • addAlpha

      public static final float[][] addAlpha(ColorTable colorTable)
      Wrapper around addAlpha(float[][]).
      Parameters:
      colorTable - color table to use
      Returns:
      color table values
    • removeAlpha

      public static final float[][] removeAlpha(float[][] colorTable)
      Remove the alpha values
      Parameters:
      colorTable - color table values
      Returns:
      color table values without alpha
    • addAlpha

      public static final float[][] addAlpha(float[][] colorTable)
      Make a color-alpha table for VisAD displays mapped to Display.RGBA; the 4th entry at each level being alpha (1.0) for transparency.
      Parameters:
      colorTable - a float [3][len], any usual VisAd color table
      Returns:
      float[4][len] the color table
    • setTransparency

      public void setTransparency(float alpha)
      Set the transparency
      Parameters:
      alpha - the alpha value
    • changeTransparency

      public static final float[][] changeTransparency(float[][] colorTable, float alpha)
      Revise a color-alpha table for VisAD displays mapped to Display.RGBA; the 4th entry at each level (alpha) is reset to input arg alpha
      Parameters:
      colorTable - a float [4][len], a VisAd color-alpha table
      alpha - the new alpha value
      Returns:
      float[4][len] the revised color table: same colors; new alpha
    • setScaleFactor

      public void setScaleFactor(float[] value)
      Set the ScaleFactor property.
      Parameters:
      value - The new value for ScaleFactor
    • getScaleFactor

      public float[] getScaleFactor()
      Get the ScaleFactor property.
      Returns:
      The ScaleFactor