ucar.visad.display
Class ColorScale

java.lang.Object
  extended by ucar.visad.display.Displayable
      extended by ucar.visad.display.DisplayableData
          extended by ucar.visad.display.ColorScale

public class ColorScale
extends DisplayableData

Displayable for a color scale in a display. The scale can be horizontal or vertical and can have labels.

Version:
$Revision: 1.20 $
Author:
IDV Development Team

Field Summary
static String BOTTOM
          Bottom Placement
static Color DEFAULT_LABEL_COLOR
          default color
static int HORIZONTAL_ORIENT
          Key for displaying the scale horizonatally
static String LEFT
          Left Placement
static int PRIMARY
          Key for primary labeling side
static String RIGHT
          Right Placement
static int SECONDARY
          Key for secondary labeling side
static String TOP
          Top Placement
static int VERTICAL_ORIENT
          Key for displaying the scale vertically
 
Fields inherited from class ucar.visad.display.DisplayableData
LINE_WIDTH, MANIPULABLE, VISIBLE
 
Fields inherited from class ucar.visad.display.Displayable
DISPLAY, parent, SCALAR_MAP_SET
 
Constructor Summary
ColorScale(ColorScaleInfo info)
          Construct a new ColorScale from the ColorScaleInfo
ColorScale(String name)
          Construct a new ColorScale with the given name and default orientation.
ColorScale(String name, int orient)
          Construct a new ColorScale with the given name and orientation.
ColorScale(String name, int orient, double x, double y)
          Construct a new ColorScale with the given name and orientation and position.
ColorScale(String name, int orient, double x, double y, float[][] table)
          Construct a new ColorScale with the given name and orientation and position, using the color table.
ColorScale(String name, int orient, float[][] table)
          Construct a new ColorScale with the given name and orientation and color table.
 
Method Summary
 Displayable cloneForDisplay()
          Returns a clone of this instance suitable for another VisAD display.
protected  DataRenderer getDataRenderer()
          Get the renderer for this ColorScale
static int getDefaultOrient(String place)
          Get the default orientation for the given placement
static String getDefaultPlace(int orient)
          Get the default place for the given orientation
 Font getFont()
          Get the font used for rendering the labels
 Color getLabelColor()
          Get the color of the labels
 int getLabelSide()
          Get the color of the labels
 int getOrientation()
          Get the orientation of the ColorScale.
static float getX(int orient, String placement)
          Get the X position
static float getY(int orient, String placement)
          Get the Y position
 void reDisplay()
          Redisplay the colorbar using the defaults
 void setColorPalette(float[][] colorPalette)
          This method sets the color palette according to the color table in argument; pair this method with setRange(lo,high) to get a fixed association of color table and range of values.
 void setColorScaleInfo(ColorScaleInfo info)
          Set the parameters for this scale
 void setFont(Font font)
          Set the font used for rendering the labels
 void setFont(HersheyFont font)
          Set the font used for rendering the labels
 void setLabelColor(Color color)
          Set the color of the labels.
 void setLabelSide(int side)
          Set the labelling side.
 void setOrientation(int orient)
          Set the orientation of the ColorScale.
 void setRangeForColor(double low, double hi)
          Set the range of values for the color table.
 void setUseFastRendering(boolean fastRender)
          Set the flags for whether the Displayable uses it's methods to render quickly (eg, not account for projection seams).
 
Methods inherited from class ucar.visad.display.DisplayableData
addAction, dataChange, destroy, getActive, getAnimationSet, getData, getLineWidth, getName, getPointSize, hasData, hasDataObject, isManipulable, isPickable, myAddConstantMaps, myAddDataReferences, myRemoveDataReferences, removeAction, setActive, setData, setDataReference, setLineWidth, setManipulable, setPickable, setPointMode, setPointSize, setVisible, toString
 
Methods inherited from class ucar.visad.display.Displayable
addConstantMap, addConstantMaps, addDataReferences, addPropertyChangeListener, addPropertyChangeListener, addRefsInvoked, addScalarMap, addScalarMaps, applyColorUnit, applyDisplayUnit, checkUnit, combineConstantMaps, firePropertyChange, firePropertyChange, fireScalarMapSetChange, getColorUnit, getConstantMaps, getDisplay, getDisplayMaster, getDisplayUnit, getPointMode, getScalarMap, getScalarMap, getScalarMap, getScalarMapSet, getUseFastRendering, getUseTimesInAnimation, getVisible, isActive, isUnitCompatible, isVisible, logException, removeConstantMap, removeDataReferences, removePropertyChangeListener, removePropertyChangeListener, removeScalarMap, replaceScalarMap, setAdjustFlow, setColor, setColorPalette, setColorUnit, setConstantPosition, setContourInfo, setDisplay, setDisplayActive, setDisplayInactive, setDisplayMaster, setDisplayUnit, setOverrideAnimationSet, setOverrideAnimationSet, setParent, setRangeForColor, setScalarMapSet, setSelectedRange, setSelectedRange, setUseTimesInAnimation, toFront
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERTICAL_ORIENT

public static final int VERTICAL_ORIENT
Key for displaying the scale vertically

See Also:
Constant Field Values

HORIZONTAL_ORIENT

public static final int HORIZONTAL_ORIENT
Key for displaying the scale horizonatally

See Also:
Constant Field Values

PRIMARY

public static final int PRIMARY
Key for primary labeling side

See Also:
Constant Field Values

SECONDARY

public static final int SECONDARY
Key for secondary labeling side

See Also:
Constant Field Values

TOP

public static final String TOP
Top Placement

See Also:
Constant Field Values

BOTTOM

public static final String BOTTOM
Bottom Placement

See Also:
Constant Field Values

LEFT

public static final String LEFT
Left Placement

See Also:
Constant Field Values

RIGHT

public static final String RIGHT
Right Placement

See Also:
Constant Field Values

DEFAULT_LABEL_COLOR

public static final Color DEFAULT_LABEL_COLOR
default color

Constructor Detail

ColorScale

public ColorScale(String name)
           throws VisADException,
                  RemoteException
Construct a new ColorScale with the given name and default orientation.

Parameters:
name - name for this color scale object.
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

ColorScale

public ColorScale(String name,
                  int orient)
           throws VisADException,
                  RemoteException
Construct a new ColorScale with the given name and orientation.

Parameters:
name - name for this color scale object.
orient - orientation for this ColorScale
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

ColorScale

public ColorScale(String name,
                  int orient,
                  float[][] table)
           throws VisADException,
                  RemoteException
Construct a new ColorScale with the given name and orientation and color table.

Parameters:
name - name for this color scale object.
orient - orientation for this ColorScale
table - color table that defines the image
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

ColorScale

public ColorScale(String name,
                  int orient,
                  double x,
                  double y)
           throws VisADException,
                  RemoteException
Construct a new ColorScale with the given name and orientation and position.

Parameters:
name - name for this color scale object.
orient - orientation for this ColorScale
x - X position on the screen, % away from upper left corner
y - Y position on the screen, % away from upper left corner
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

ColorScale

public ColorScale(String name,
                  int orient,
                  double x,
                  double y,
                  float[][] table)
           throws VisADException,
                  RemoteException
Construct a new ColorScale with the given name and orientation and position, using the color table.

Parameters:
name - name for this color scale object.
orient - orientation for this ColorScale
x - X position on the screen, % away from upper left corner
y - Y position on the screen, % away from upper left corner
table - color table that defines the image
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

ColorScale

public ColorScale(ColorScaleInfo info)
           throws VisADException,
                  RemoteException
Construct a new ColorScale from the ColorScaleInfo

Parameters:
info - color scale info
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object
Method Detail

setRangeForColor

public void setRangeForColor(double low,
                             double hi)
                      throws VisADException,
                             RemoteException
Set the range of values for the color table.

Overrides:
setRangeForColor in class Displayable
Parameters:
low - minimum value
hi - maximum value
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

getOrientation

public int getOrientation()
Get the orientation of the ColorScale.

Returns:
orientation (HORIZONTAL_ORIENT, VERTICAL_ORIENT)

setOrientation

public void setOrientation(int orient)
                    throws RemoteException,
                           VisADException
Set the orientation of the ColorScale.

Parameters:
orient - orientation (HORIZONTAL_ORIENT, VERTICAL_ORIENT)
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

setColorScaleInfo

public void setColorScaleInfo(ColorScaleInfo info)
                       throws RemoteException,
                              VisADException
Set the parameters for this scale

Parameters:
info - ColorScaleInfo
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

setLabelColor

public void setLabelColor(Color color)
                   throws RemoteException,
                          VisADException
Set the color of the labels.

Parameters:
color - color for labels
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

getLabelColor

public Color getLabelColor()
Get the color of the labels

Returns:
label color (may be null)

setLabelSide

public void setLabelSide(int side)
                  throws RemoteException,
                         VisADException
Set the labelling side.

Parameters:
side - labelling side (PRIMARY, SECONDARY);
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

getLabelSide

public int getLabelSide()
Get the color of the labels

Returns:
label color

setColorPalette

public void setColorPalette(float[][] colorPalette)
                     throws RemoteException,
                            VisADException
This method sets the color palette according to the color table in argument; pair this method with setRange(lo,high) to get a fixed association of color table and range of values.

Overrides:
setColorPalette in class Displayable
Parameters:
colorPalette - the color table or color-alpha table desired
Throws:
VisADException - if a core VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.

cloneForDisplay

public Displayable cloneForDisplay()
                            throws RemoteException,
                                   VisADException
Returns a clone of this instance suitable for another VisAD display. Underlying data objects are not cloned.

Overrides:
cloneForDisplay in class DisplayableData
Returns:
A semi-deep clone of this instance.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

reDisplay

public void reDisplay()
Redisplay the colorbar using the defaults


getDataRenderer

protected DataRenderer getDataRenderer()
                                throws VisADException
Get the renderer for this ColorScale

Overrides:
getDataRenderer in class DisplayableData
Returns:
renderer
Throws:
VisADException - problem creating renderer

setFont

public void setFont(Font font)
Set the font used for rendering the labels

Parameters:
font - new font to use

setFont

public void setFont(HersheyFont font)
Set the font used for rendering the labels

Parameters:
font - new font to use

getFont

public Font getFont()
Get the font used for rendering the labels

Returns:
font use or null if using default text plot

setUseFastRendering

public void setUseFastRendering(boolean fastRender)
                         throws VisADException,
                                RemoteException
Set the flags for whether the Displayable uses it's methods to render quickly (eg, not account for projection seams).

Overrides:
setUseFastRendering in class DisplayableData
Parameters:
fastRender - Should the rendering be quick (and possibly inaccurate)
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getDefaultPlace

public static String getDefaultPlace(int orient)
Get the default place for the given orientation

Parameters:
orient - orientation
Returns:
the default place for the orientation

getDefaultOrient

public static int getDefaultOrient(String place)
Get the default orientation for the given placement

Parameters:
place - placement
Returns:
the default orientation for place

getX

public static float getX(int orient,
                         String placement)
Get the X position

Parameters:
orient - orientation
placement - placement
Returns:
corresponding X position

getY

public static float getY(int orient,
                         String placement)
Get the Y position

Parameters:
orient - orientation
placement - placement
Returns:
corresponding Y position