ucar.visad.display
Class Contour2DDisplayable

java.lang.Object
  extended by ucar.visad.display.Displayable
      extended by ucar.visad.display.DisplayableData
          extended by ucar.visad.display.LineDrawing
              extended by ucar.visad.display.ContourLines
                  extended by ucar.visad.display.Contour2DDisplayable
All Implemented Interfaces:
GridDisplayable

public class Contour2DDisplayable
extends ContourLines
implements GridDisplayable

A class to support showing 2D gridded data as colored contours on a plane in a NavigatedDisplay.

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

Field Summary
static String RGB_REAL_TYPE
          The name of the "RGB real-type" property.
 
Fields inherited from class ucar.visad.display.ContourLines
COLOR_FILL, CONTOUR_LEVELS, CONTOUR_REAL_TYPE, LABELING
 
Fields inherited from class ucar.visad.display.LineDrawing
COLOR, LINE_STYLE, LINE_WIDTH, POINT_SIZE
 
Fields inherited from class ucar.visad.display.DisplayableData
MANIPULABLE, VISIBLE
 
Fields inherited from class ucar.visad.display.Displayable
DISPLAY, parent, SCALAR_MAP_SET
 
Constructor Summary
protected Contour2DDisplayable(Contour2DDisplayable that)
          Constructs from a Contour2DDisplayable.
  Contour2DDisplayable(String name)
          Constructs an instance with the supplied name and null initial RealType.
  Contour2DDisplayable(String name, boolean alphaFlag)
          Constructs an instance with the supplied name and null initial RealType and given alphaFlag
  Contour2DDisplayable(String name, boolean alphaFlag, boolean colorFill)
          Constructs an instance with the supplied name and null initial RealType and given alphaFlag and colorFill
  Contour2DDisplayable(String name, RealType c2dRealType, float[][] colorPalette)
          Constructs from a name for the Displayable and the type of the parameter.
  Contour2DDisplayable(String name, RealType c2dRealType, float[][] colorPalette, boolean alphaFlag)
          Constructs from a name for the Displayable and the type of the parameter.
  Contour2DDisplayable(String name, RealType c2dRealType, float[][] colorPalette, float[] rangeLimits)
          Deprecated. rangeLimits not needed
 
Method Summary
 Displayable cloneForDisplay()
          Returns a clone of this instance suitable for another VisAD display.
 float[][] getColorPalette()
          Return the current color palette (color table).
 double[] getRangeforColor()
          Deprecated. use #getRangeForColor()
 double[] getRangeForColor()
          Get the color range
 RealType getRGBRealType()
          Returns the RealType of the RGB parameter.
 boolean hasRange()
          Returns whether this Displayable has a valid range (i.e., lowRange and highRange are both not NaN's
 void loadData(FieldImpl field)
          Set the appropriate ScalarMaps based on the data and then load the data into the DataReference.
 void setC2DRealType(RealType realType)
          Sets the RealType of the parameter.
 void setColor(Color color)
          Override setColor to actually set a color palette since this class has both
 void setColoredByAnother(boolean yesno)
          Set whether this GridDisplayable should have the data colored by another parameter.
 void setColorFill(boolean yesorno)
          Set whether the contours should be displayed as color-filled contours.
 void setColorPalette()
          This method with no argument sets the default Vis5D color spectrum.
 void setColorPalette(float[][] colorPalette)
          This method sets the color palette according to the color table in argument; pair this method with setRangeForColor below to get a fixed association of color table and range of values.
 void setColorUnit(Unit unit)
          Set the units for the displayed range
 void setContourInfo(ContourInfo contourInfo)
          Set appropriate contour levels info
 void setContourLevels(float interval, float base, float min, float max)
          Set appropriate contour levels with super class's methods (BOTH REQUIRED IN THIS ORDER) setRange(min, max); & setContourLevels (interval, base, min, max);
 void setContourLevels(float interval, float base, float min, float max, boolean dash)
          Set appropriate contour levels with super class's methods (BOTH REQUIRED IN THIS ORDER) setRange(min, max); setContourLevels (interval, base, min, max);
 void setDisplayUnit(Unit unit)
          Set the units for the displayed range
 void setGrid2D(FieldImpl field)
          Deprecated. Should use loadData now
 void setRangeForColor(double low, double high)
          To make a connection between a particular color and a particular data value or a range of data values ...
protected  void setRGBRealType(RealType realType)
          Sets the RealType of the RGB parameter.
protected  boolean useDisplayUnitForColor()
          Does this object use the displayUnit (or the colorUnit) for its display unit.
 
Methods inherited from class ucar.visad.display.ContourLines
getColorFillEnabled, getContourLevels, getContourRealType, getContourValues, isLabeling, setContourInterval, setContourInterval, setContourLevels, setContourRealType, setLabeling, setRange, setScalarMaps
 
Methods inherited from class ucar.visad.display.LineDrawing
getColor, getLineStyle, getLineWidth, getPointSize, setHSV, setHSV, setLineStyle, setLineWidth, setPointSize, setRGB, setRGB, setRGBA, setRGBA
 
Methods inherited from class ucar.visad.display.DisplayableData
addAction, dataChange, destroy, getActive, getAnimationSet, getData, getDataRenderer, getName, hasData, hasDataObject, isManipulable, isPickable, myAddConstantMaps, myAddDataReferences, myRemoveDataReferences, removeAction, setActive, setData, setDataReference, setManipulable, setPickable, setPointMode, setUseFastRendering, 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, setColorPalette, setConstantPosition, setDisplay, setDisplayActive, setDisplayInactive, setDisplayMaster, 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

RGB_REAL_TYPE

public static final String RGB_REAL_TYPE
The name of the "RGB real-type" property.

See Also:
Constant Field Values
Constructor Detail

Contour2DDisplayable

public Contour2DDisplayable(String name)
                     throws VisADException,
                            RemoteException
Constructs an instance with the supplied name and null initial RealType.

Parameters:
name - a String identifier
Throws:
VisADException - from construction of super class
RemoteException - from construction of super class

Contour2DDisplayable

public Contour2DDisplayable(String name,
                            boolean alphaFlag)
                     throws VisADException,
                            RemoteException
Constructs an instance with the supplied name and null initial RealType and given alphaFlag

Parameters:
name - a String identifier
alphaFlag - true if should use RGBA
Throws:
VisADException - from construction of super class
RemoteException - from construction of super class

Contour2DDisplayable

public Contour2DDisplayable(String name,
                            boolean alphaFlag,
                            boolean colorFill)
                     throws VisADException,
                            RemoteException
Constructs an instance with the supplied name and null initial RealType and given alphaFlag and colorFill

Parameters:
name - a String identifier
alphaFlag - true if should use RGBA
colorFill - true if contours should be color filled
Throws:
VisADException - from construction of super class
RemoteException - from construction of super class

Contour2DDisplayable

public Contour2DDisplayable(String name,
                            RealType c2dRealType,
                            float[][] colorPalette,
                            float[] rangeLimits)
                     throws VisADException,
                            RemoteException
Deprecated. rangeLimits not needed

Constructs from a name for the Displayable and the type of the parameter.

Parameters:
name - The name for the displayable.
c2dRealType - The type of the parameter. May be null.
colorPalette - The initial colorPalette to use. May be null (Vis5D palette used as default).
rangeLimits - limits of the color range
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

Contour2DDisplayable

public Contour2DDisplayable(String name,
                            RealType c2dRealType,
                            float[][] colorPalette)
                     throws VisADException,
                            RemoteException
Constructs from a name for the Displayable and the type of the parameter.

Parameters:
name - The name for the displayable.
c2dRealType - The type of the parameter. May be null.
colorPalette - The initial colorPalette to use. May be null (Vis5D palette used as default).
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

Contour2DDisplayable

public Contour2DDisplayable(String name,
                            RealType c2dRealType,
                            float[][] colorPalette,
                            boolean alphaFlag)
                     throws VisADException,
                            RemoteException
Constructs from a name for the Displayable and the type of the parameter.

Parameters:
name - The name for the displayable.
c2dRealType - The type of the parameter. May be null.
colorPalette - The initial colorPalette to use. May be null (Vis5D palette used as default).
alphaFlag - true if should use RGBA
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

Contour2DDisplayable

protected Contour2DDisplayable(Contour2DDisplayable that)
                        throws VisADException,
                               RemoteException
Constructs from a Contour2DDisplayable.

Parameters:
that - a Contour2DDisplayable.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
Method Detail

useDisplayUnitForColor

protected boolean useDisplayUnitForColor()
Does this object use the displayUnit (or the colorUnit) for its display unit.

Returns:
false if contour lines are colored by another field otherwise true

setC2DRealType

public void setC2DRealType(RealType realType)
                    throws RemoteException,
                           VisADException
Sets the RealType of the parameter.

Parameters:
realType - The RealType of the parameter. May not be null.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

setColorPalette

public void setColorPalette()
                     throws RemoteException,
                            VisADException
This method with no argument sets the default Vis5D color spectrum.

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

setColor

public void setColor(Color color)
              throws RemoteException,
                     VisADException
Override setColor to actually set a color palette since this class has both

Overrides:
setColor in class LineDrawing
Parameters:
color - Color to use
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

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 setRangeForColor below to get a fixed association of color table and range of values.

Overrides:
setColorPalette in class Displayable
Parameters:
colorPalette - The initial colorPalette to use. May be null (Vis5D palette used as default).
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

setRangeForColor

public void setRangeForColor(double low,
                             double high)
                      throws VisADException,
                             RemoteException
To make a connection between a particular color and a particular data value or a range of data values ... "This mapping is determined by the low and high values passed to ScalarMap.setRange(), and by the 'float[][] table' array passed to BaseColorControl.setTable(). The table values (length = table[0].length) are distributed evenly over the (low, high) range. If an application does not call setRange(), then the range is determined by the range of values in displayed data objects." (BH)

Overrides:
setRangeForColor in class Displayable
Parameters:
low - The minimum value of the parameter matched to the low end of the color table.
high - The maximum value of the parameter matched to the high end of the color table.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getRangeforColor

public double[] getRangeforColor()
Deprecated. use #getRangeForColor()

Get the color range

Returns:
an array of the low and high values for the range

getRangeForColor

public double[] getRangeForColor()
Get the color range

Returns:
an array of the low and high values for the range

getColorPalette

public float[][] getColorPalette()
Return the current color palette (color table).

Returns:
float[][] a VisAD color table

setGrid2D

public void setGrid2D(FieldImpl field)
               throws RemoteException,
                      VisADException
Deprecated. Should use loadData now

Set the data into the Displayable

Parameters:
field - a VisAD FieldImpl with a 2D nature.
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

loadData

public void loadData(FieldImpl field)
              throws VisADException,
                     RemoteException
Set the appropriate ScalarMaps based on the data and then load the data into the DataReference.

Specified by:
loadData in interface GridDisplayable
Parameters:
field - a 2D VisAD Field representing the data
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

setRGBRealType

protected void setRGBRealType(RealType realType)
                       throws RemoteException,
                              VisADException
Sets the RealType of the RGB parameter.

Parameters:
realType - The RealType of the RGB parameter. May not be null.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

setColorFill

public void setColorFill(boolean yesorno)
                  throws VisADException,
                         RemoteException
Set whether the contours should be displayed as color-filled contours. Need to override because if color filled is turned on, we need to make sure that the RGB type is the same as the Contour type.

Overrides:
setColorFill in class ContourLines
Parameters:
yesorno - true for color fill
Throws:
VisADException - unable to set this
RemoteException - unable to set this on remote display

getRGBRealType

public RealType getRGBRealType()
Returns the RealType of the RGB parameter.

Returns:
The RealType of the color parameter. May be null.

setContourLevels

public void setContourLevels(float interval,
                             float base,
                             float min,
                             float max)
                      throws VisADException,
                             RemoteException
Set appropriate contour levels with super class's methods (BOTH REQUIRED IN THIS ORDER) setRange(min, max); & setContourLevels (interval, base, min, max);

Parameters:
interval - delta value between contours
base - one contour must be of this value
min - no contour below this value
max - no contour above this value
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

setContourInfo

public void setContourInfo(ContourInfo contourInfo)
                    throws VisADException,
                           RemoteException
Set appropriate contour levels info

Overrides:
setContourInfo in class Displayable
Parameters:
contourInfo - Contains contour and labeling information
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

setContourLevels

public void setContourLevels(float interval,
                             float base,
                             float min,
                             float max,
                             boolean dash)
                      throws VisADException,
                             RemoteException
Set appropriate contour levels with super class's methods (BOTH REQUIRED IN THIS ORDER) setRange(min, max); setContourLevels (interval, base, min, max);

Parameters:
interval - delta value between contours
base - one contour must be of this value
min - no contour below this value
max - no contour above this value
dash - dash contours below base
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

hasRange

public boolean hasRange()
Returns whether this Displayable has a valid range (i.e., lowRange and highRange are both not NaN's

Returns:
true if the range for color has been set (i.e. not NaN)

setDisplayUnit

public void setDisplayUnit(Unit unit)
                    throws VisADException,
                           RemoteException
Set the units for the displayed range

Overrides:
setDisplayUnit in class ContourLines
Parameters:
unit - Unit for display
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

setColorUnit

public void setColorUnit(Unit unit)
                  throws VisADException,
                         RemoteException
Set the units for the displayed range

Overrides:
setColorUnit in class Displayable
Parameters:
unit - Unit for display
Throws:
RemoteException - Java RMI error
VisADException - problem creating VisAD object

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.

setColoredByAnother

public void setColoredByAnother(boolean yesno)
Set whether this GridDisplayable should have the data colored by another parameter.

Specified by:
setColoredByAnother in interface GridDisplayable
Parameters:
yesno - true if colored by another