ucar.visad.display
Class ScalarMapAdapter

java.lang.Object
  extended by ucar.visad.display.MapAdapter
      extended by ucar.visad.display.ScalarMapAdapter
All Implemented Interfaces:
Comparable, Propertied
Direct Known Subclasses:
AxisScalarMap, IsoContourScalarMap, SelectRangeScalarMap, SelectValueScalarMap

public abstract class ScalarMapAdapter
extends MapAdapter

Provides support for adapting VisAD ScalarMap-s to something that is (hopefully) easier to use. Unlike instances of VisAD ScalarMap, one can modify the associated ScalarType of an instance of this class.

Instances of this class have the following, bound, JavaBean properties:

Name Type Access Default Description
scalarType ScalarType set/get construction-dependent The ScalarType of the underlying ScalarMap of this instance
scalarMap ScalarMap construction-dependent The underlying ScalarMap of this instance

Version:
$Revision: 1.10 $
Author:
Steven R. Emmerson

Field Summary
static String SCALAR_MAP
          The name of the ScalarMap property.
static String SCALAR_TYPE
          The name of the ScalarType property.
 
Constructor Summary
protected ScalarMapAdapter(ScalarType st, DisplayRealType drt, DisplayAdapter displayAdapter)
          Constructs.
 
Method Summary
 void addScalarMapListener(ScalarMapListener listener)
          Adds a ScalarMapListener to the underlying ScalarMap.
 int compareTo(Object obj)
          Compares this instance to another object.
 boolean equals(Object obj)
          Indicates if this instance is semantically identical to another object.
protected  Control getControl()
          Returns the control of the underlying ScalarMap.
 DisplayRealType getDisplayType()
          Returns the DisplayRealType of the underlying ScalarMap.
 ScalarType getScalarType()
          Returns the ScalarType of the underlying ScalarMap.
 int hashCode()
          Returns the hash code of this instance.
 void removeScalarMapListener(ScalarMapListener listener)
          Removes a ScalarMapListener from the underlying ScalarMap.
protected  void scalarMapChange()
          Handles a change to the underlying ScalarMap.
protected abstract  void setControl()
          Sets the control of the underlying ScalarMap.
 void setRange(Real lower, Real upper)
          Explicitly sets the range of RealType data values that is mapped to the natural range of DisplayRealType display values.
protected  void setScalarType(ScalarType scalarType)
          Sets the ScalarType that is mapped to the associated DisplayRealType.
 
Methods inherited from class ucar.visad.display.MapAdapter
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getDisplayRealType, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCALAR_TYPE

public static final String SCALAR_TYPE
The name of the ScalarType property.

See Also:
Constant Field Values

SCALAR_MAP

public static final String SCALAR_MAP
The name of the ScalarMap property.

See Also:
Constant Field Values
Constructor Detail

ScalarMapAdapter

protected ScalarMapAdapter(ScalarType st,
                           DisplayRealType drt,
                           DisplayAdapter displayAdapter)
                    throws VisADException,
                           RemoteException
Constructs.

Parameters:
st - The ScalarType to be associated with the DisplayRealType.
drt - The DisplayRealType to be associated with the ScalarType.
displayAdapter - The associated, adapted, VisAD display.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
Method Detail

setRange

public void setRange(Real lower,
                     Real upper)
              throws VisADException,
                     RemoteException
Explicitly sets the range of RealType data values that is mapped to the natural range of DisplayRealType display values. This method is used to define a linear map from Scalar to DisplayScalar values.

Parameters:
lower - The data value to be mapped to the low end of the natural range of the DisplayRealType.
upper - The data value to be mapped to the upper end of the natural range of the DisplayRealType.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

scalarMapChange

protected void scalarMapChange()
Handles a change to the underlying ScalarMap. This method should be overridden in subclasses when appropriate.


setScalarType

protected void setScalarType(ScalarType scalarType)
                      throws VisADException,
                             RemoteException
Sets the ScalarType that is mapped to the associated DisplayRealType. If the new ScalarType differs from the previous ScalarType, then the underlying ScalarMap is changed to conform. All ScalarMapListeners registered with this instance are removed from the previous, underlying ScalarMap and transferred to the new, underlying ScalarType. This method fires PropertyChangeEvents for SCALAR_TYPE and SCALAR_MAP with this instance as the source and the old and new values appropriately set. This is done synchronously -- so watch out for deadlock.

Parameters:
scalarType - The ScalarType to be mapped to the DisplayRealType.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.
See Also:
DisplayAdapter.accept(ScalarMapAdapter)

getScalarType

public ScalarType getScalarType()
Returns the ScalarType of the underlying ScalarMap.

Returns:
The ScalarType of the underlying ScalarMap.

getDisplayType

public DisplayRealType getDisplayType()
Returns the DisplayRealType of the underlying ScalarMap.

Returns:
The DisplayRealType of the underlying ScalarMap.

addScalarMapListener

public void addScalarMapListener(ScalarMapListener listener)
Adds a ScalarMapListener to the underlying ScalarMap. If the underlying ScalarMap changes, then the ScalarMapListeners added by this instance are removed from the previous, underlying ScalarType and transferred to the new, underlying ScalarType.

Parameters:
listener - The ScalarMapListener to be added to the underlying ScalarMap.

removeScalarMapListener

public void removeScalarMapListener(ScalarMapListener listener)
Removes a ScalarMapListener from the underlying ScalarMap.

Parameters:
listener - The ScalarMapListener to be removed from the underlying ScalarMap.

compareTo

public int compareTo(Object obj)
Compares this instance to another object. The comparison is based solely on the underlying ScalarMap.

Parameters:
obj - The other object.
Returns:
A value less-than, equal-to, or greater-than zero depending on whether this instance is considered less-than, equal-to, or greater-than the other object.

equals

public boolean equals(Object obj)
Indicates if this instance is semantically identical to another object. Two instances of this class are equal if their underlying ScalarMap-s are equal.

Overrides:
equals in class Object
Parameters:
obj - The other object.
Returns:
true if and only if the other object is an instance of this class and its underlying ScalarMap is equal to this instance's.

hashCode

public int hashCode()
Returns the hash code of this instance.

Overrides:
hashCode in class Object
Returns:
The hash code of this instance.

getControl

protected Control getControl()
Returns the control of the underlying ScalarMap.

Returns:
The control of the underlying ScalarMap.

setControl

protected abstract void setControl()
                            throws RemoteException,
                                   VisADException
Sets the control of the underlying ScalarMap.

Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.