ucar.unidata.util
Class ColorTable

java.lang.Object
  extended by 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

Nested Class Summary
static class ColorTable.Breakpoint
          Class Breakpoint _more_
 
Field Summary
static String CATEGORY_ATD_RADAR
          the Atd-Radar category
static String CATEGORY_BASIC
          The "Basic" category
static String CATEGORY_MISC
          The Miscellaneous category
static String CATEGORY_RADAR
          The Radar category
static String CATEGORY_SATELLITE
          The Satellite category
static String CATEGORY_SOLID
          The solid category
static int IDX_ALPHA
          _more_
static int IDX_BLUE
          _more_
static int IDX_GREEN
          _more_
static int IDX_RED
          _more_
 
Constructor Summary
ColorTable()
          Default constructor
ColorTable(ColorTable otherTable)
          Copy constructor
ColorTable(String name, String category, float[][] table)
          Create a new ColorTable.
ColorTable(String id, String name, String category, float[][] table)
          Create a new ColorTable.
ColorTable(String id, String name, String category, float[][] table, boolean tableFlipped)
          Create a new ColorTable.
 
Method Summary
static float[][] addAlpha(ColorTable colorTable)
          Wrapper around addAlpha(float[][]).
static 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.
static 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
 String dataToString()
          Output the table as a String.
 boolean equalsTable(ColorTable other)
          See if another color table is equivalent to this one
 boolean getActive()
          Get the active flag.
 float[][] getAlphaTable()
          Get the table with alpha.
 ArrayList getBreakpoints()
          Get the breakpoints for this table.
 String getCategory()
          Get the table category.
 ArrayList getColorList()
          Convert the colorTable into a list of Color-s
 float[][] getColorTable()
          Get the color table pallette.
 String getDescription()
          Get the table description
 String getId()
          Get the ID of this table
 String getName()
          Get the name of this table.
 float[][] getNonAlphaTable()
          Get the table without alpha values.
 Range getRange()
          Get the Range for this color table.
 float[] getScaleFactor()
          Get the ScaleFactor property.
 float[][] getTable()
          Set the color table pallette Note: this is around for legacy purposes and we will move to a new setTableArray/getTableArray method
 ColorTable init(String name, String category, ArrayList colors, ArrayList scales, ArrayList breakpoints, Range r)
          Initialize a color table a new ColorTable.
 ColorTable init(String name, String category, ArrayList colors, ArrayList breakpoints, Range r)
          Initialize a color table a new ColorTable.
 String print()
          Print the table info
static float[][] removeAlpha(float[][] colorTable)
          Remove the alpha values
 void setActive(boolean a)
          Set the active flag.
 void setBreakpoints(ArrayList l)
          Set the breakpoints for this color table.
 void setCategory(String category)
          Set the table category.
 void setDescription(String description)
          Set the table description
 void setId(String id)
          Set the id of this table
 void setName(String name)
          Set the name of this table
 void setRange(Range r)
          Set the range for this table.
 void setScaleFactor(float[] value)
          Set the ScaleFactor property.
 void setTable(ArrayList colors)
          Set the table with a list of colors
 void setTable(float[][] table)
          Set the color table pallette Note: this is around for legacy purposes and we will move to a new setTableArray/getTableArray method
 void setTableArray(float[][] table)
          _more_
 void setTransparency(float alpha)
          _more_
 String toString()
          Get a descriptive String for this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDX_RED

public static final int IDX_RED
_more_

See Also:
Constant Field Values

IDX_GREEN

public static final int IDX_GREEN
_more_

See Also:
Constant Field Values

IDX_BLUE

public static final int IDX_BLUE
_more_

See Also:
Constant Field Values

IDX_ALPHA

public static final int IDX_ALPHA
_more_

See Also:
Constant Field Values

CATEGORY_BASIC

public static final String CATEGORY_BASIC
The "Basic" category

See Also:
Constant Field Values

CATEGORY_MISC

public static final String CATEGORY_MISC
The Miscellaneous category

See Also:
Constant Field Values

CATEGORY_SATELLITE

public static final String CATEGORY_SATELLITE
The Satellite category

See Also:
Constant Field Values

CATEGORY_RADAR

public static final String CATEGORY_RADAR
The Radar category

See Also:
Constant Field Values

CATEGORY_SOLID

public static final String CATEGORY_SOLID
The solid category

See Also:
Constant Field Values

CATEGORY_ATD_RADAR

public static final String CATEGORY_ATD_RADAR
the Atd-Radar category

See Also:
Constant Field Values
Constructor Detail

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 Detail

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 - _more_
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 pallette 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()
Set the color table pallette Note: this is around for legacy purposes and we will move to a new setTableArray/getTableArray method

Returns:
_more_

setTableArray

public void setTableArray(float[][] table)
_more_

Parameters:
table - _more_

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 getColorList()
Convert the colorTable into a list of Color-s

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)
_more_

Parameters:
alpha - _more_

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