visad
Class BaseColorControl

java.lang.Object
  extended by visad.Control
      extended by visad.BaseColorControl
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ColorAlphaControl, ColorControl

public class BaseColorControl
extends Control

BaseColorControl is the VisAD class for controlling N-component Color DisplayRealType-s.

See Also:
Serialized Form

Field Summary
static int ALPHA
          The index of the alpha channel.
static int BLUE
          The index of the color blue
static int DEFAULT_NUMBER_OF_COLORS
          The default number of colors
static int GREEN
          The index of the color green
static int RED
          The index of the color red
 
Constructor Summary
BaseColorControl(DisplayImpl d, int components)
          Create a basic color control.
 
Method Summary
 Object clone()
           
 boolean equals(Object o)
          Return true if this object is "equal" to the parameter.
 Function getFunction()
          Return the color lookup Function.
 int getNumberOfColors()
          Get the number of colors in the table.
 int getNumberOfComponents()
          Get the number of components of the range.
 String getSaveString()
          If the colors are defined using a color table, get a String that can be used to reconstruct this object later.
 float[][] getTable()
          Get the table of colors.
 void initGreyWedge()
          Initialize the colormap to a grey wedge
 void initGreyWedge(boolean invert)
           
 void initHSV()
          Initialize the colormap to Hue-Saturation-Value
static float[][] initTableGreyWedge(float[][] table)
          Initialize table to a grey wedge.
static float[][] initTableGreyWedge(float[][] table, boolean invert)
           
static float[][] initTableHSV(float[][] table)
          Initialize table to the Hue-Saturation-Value colormap.
static float[][] initTableVis5D(float[][] table)
          Initialize table to the Vis5D colormap (opaque blue-green-red rainbow).
 void initVis5D()
          Initialize the colormap to the VisAD sine waves
 float[][] lookupRange(int left, int right)
          Return a list of colors for the specified range.
 float[][] lookupValues(float[] values)
          Return a list of colors for specified values.
 void setFunction(Function func)
          Define the color lookup by a Function, whose MathType must have a 1-D domain and a 3-D or 4-D RealTupleType range; the domain and range Reals must vary over the range (0.0, 1.0)
 void setRange(int left, int right, float[][] colors)
          Set the specified range to the specified colors.
 void setSaveString(String save)
          Reconstruct this control using the specified save string.
 void setTable(float[][] t)
          Define the color lookup by an array of floats which must have the form float[components][table_length]; values should be in the range (0.0, 1.0)
 void syncControl(Control rmt)
          Copy the state of a remote control to this control.
 String toString()
           
 
Methods inherited from class visad.Control
addControlListener, animation_string, changeControl, checkTicks, getDisplay, getDisplayRenderer, getInstanceNumber, incTick, nullControl, peekTicks, removeControlListener, resetTicks, setTicks, subCheckTicks, subPeekTicks, subResetTicks, subSetTicks
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RED

public static final int RED
The index of the color red

See Also:
Constant Field Values

GREEN

public static final int GREEN
The index of the color green

See Also:
Constant Field Values

BLUE

public static final int BLUE
The index of the color blue

See Also:
Constant Field Values

ALPHA

public static final int ALPHA
The index of the alpha channel.

NOTE: ALPHA will always be the last index.

See Also:
Constant Field Values

DEFAULT_NUMBER_OF_COLORS

public static final int DEFAULT_NUMBER_OF_COLORS
The default number of colors

See Also:
Constant Field Values
Constructor Detail

BaseColorControl

public BaseColorControl(DisplayImpl d,
                        int components)
Create a basic color control.

Parameters:
d - The display with which this control is associated.
components - Either 3 (if this is a red/green/blue control) or 4 (if there is also an alpha component).
Method Detail

initTableGreyWedge

public static float[][] initTableGreyWedge(float[][] table)
Initialize table to a grey wedge.

Parameters:
table - Table to be initialized.
Returns:
the initialized table.

initTableGreyWedge

public static float[][] initTableGreyWedge(float[][] table,
                                           boolean invert)

initGreyWedge

public void initGreyWedge()
Initialize the colormap to a grey wedge


initGreyWedge

public void initGreyWedge(boolean invert)

initTableVis5D

public static float[][] initTableVis5D(float[][] table)
Initialize table to the Vis5D colormap (opaque blue-green-red rainbow).

Parameters:
table - Table to be initialized.
Returns:
the initialized table.

initVis5D

public void initVis5D()
Initialize the colormap to the VisAD sine waves


initTableHSV

public static float[][] initTableHSV(float[][] table)
Initialize table to the Hue-Saturation-Value colormap.

Parameters:
table - Table to be initialized.
Returns:
the initialized table.

initHSV

public void initHSV()
Initialize the colormap to Hue-Saturation-Value


getNumberOfComponents

public int getNumberOfComponents()
Get the number of components of the range.

Returns:
Either 3 or 4

getNumberOfColors

public int getNumberOfColors()
Get the number of colors in the table.

Returns:
The number of colors in the colormap.

setFunction

public void setFunction(Function func)
                 throws RemoteException,
                        VisADException
Define the color lookup by a Function, whose MathType must have a 1-D domain and a 3-D or 4-D RealTupleType range; the domain and range Reals must vary over the range (0.0, 1.0)

Parameters:
func - The new Function.
Throws:
RemoteException - If there was an RMI-related problem.
VisADException - If there was a problem with the function.

getFunction

public Function getFunction()
Return the color lookup Function.

Returns:
The function which defines this object's colors.

setTable

public void setTable(float[][] t)
              throws RemoteException,
                     VisADException
Define the color lookup by an array of floats which must have the form float[components][table_length]; values should be in the range (0.0, 1.0)

Parameters:
t - The new table of colors.
Throws:
RemoteException - If there was a problem changing the control.
VisADException - If there is a problem with the table.

getTable

public float[][] getTable()
Get the table of colors.

Returns:
The color table.

getSaveString

public String getSaveString()
If the colors are defined using a color table, get a String that can be used to reconstruct this object later. If the colors are defined using a Function, return null.

Specified by:
getSaveString in class Control
Returns:
The save string describing this object.

setSaveString

public void setSaveString(String save)
                   throws RemoteException,
                          VisADException
Reconstruct this control using the specified save string.

Specified by:
setSaveString in class Control
Parameters:
save - The save string.
Throws:
VisADException - If the save string is not valid.
RemoteException - If there was a problem setting the table.

lookupValues

public float[][] lookupValues(float[] values)
                       throws RemoteException,
                              VisADException
Return a list of colors for specified values.

Parameters:
values - The values to look up. It is expected that they nominally lie in the range of 0 through 1. Values outside this range will be assigned the color of the nearest end. NaN values will be assigned NaN colors.
Returns:
The list of colors. Element [i][j] is the value of the i-th color component for values[j], where i is RED, GREEN, BLUE, or ALPHA. A component value is in the range from 0 through 1, or is NaN.
Throws:
RemoteException - If there was an RMI-related problem.
VisADException - If the function encountered a problem.

lookupRange

public float[][] lookupRange(int left,
                             int right)
                      throws VisADException,
                             RemoteException
Return a list of colors for the specified range.

Throws:
VisADException
RemoteException

setRange

public void setRange(int left,
                     int right,
                     float[][] colors)
              throws VisADException,
                     RemoteException
Set the specified range to the specified colors.

Throws:
VisADException
RemoteException

syncControl

public void syncControl(Control rmt)
                 throws VisADException
Copy the state of a remote control to this control.

Specified by:
syncControl in class Control
Parameters:
rmt - The control to be copied.
Throws:
VisADException - If the remote control cannot be copied.

equals

public boolean equals(Object o)
Return true if this object is "equal" to the parameter.

Overrides:
equals in class Control
Parameters:
o - Object to compare.
Returns:
true if this object "equals" o.

clone

public Object clone()
Overrides:
clone in class Control
Returns:
a copy of this Control

toString

public String toString()
Overrides:
toString in class Control
Returns:
a simple String representation of this Control