visad
Class ScalarMap
- java.lang.Object
-
- visad.ScalarMap
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable
- Direct Known Subclasses:
- ConstantMap
public class ScalarMap extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, java.lang.ComparableA ScalarMap object defines a mapping from a RealType to a DisplayRealType. A set of ScalarMap objects define how data are dislayed.The mapping of values is linear. Any non-linear mapping must be handled by Display CoordinateSystem-s.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ScalarMap(ScalarType scalar, DisplayRealType display_scalar)Construct aScalarMapthat maps the scalar to the display_scalar.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddScalarMapListener(ScalarMapListener listener)add a ScalarMapListener, to be notified whenever setRange is invokedbooleanbadRange()booleancheckTicks(DataRenderer r, DataDisplayLink link)return true if application called setRangejava.lang.Objectclone()Create and return a copy of this ScalarMap.intcompareTo(java.lang.Object o)Compares this ScalarMap with another object.voiddisableAutoScale()disable auto-scaling for this ScalarMapbooleandoInitialize()static voidequalizeFlow(java.util.Vector mapVector, DisplayTupleType flow_tuple)ensure that non-Manual components of flow_tuple have equal dataRanges symmetric about 0.0booleanequals(java.lang.Object o)Indicates if this ScalarMap is the same as another object.AxisScalegetAxisScale()Get the AxisScale associated with this ScalarMap.ControlgetControl()Gets the Control for the DisplayScalar.DisplayImplgetDisplay()Get the DisplayImpl this ScalarMap is linked toDisplayRealTypegetDisplayScalar()Get the DisplayRealType that is the map rangeUnitgetOverrideUnit()Return the override unit.double[]getRange()Returns the current range of theRealTypedata.ScalarTypegetScalar()Get the ScalarType that is the map domainjava.lang.StringgetScalarName()Get the name being used on the axis scale.booleangetScale(double[] so, double[] data, double[] display)return value is true if data (RealType) values are linearly scaled to display (DisplayRealType) values; if so, then values are scaled by: display_value = data_value * so[0] + so[1]; (data[0], data[1]) defines range of data values (either passed in to setRange or computed by autoscaling logic) and (display[0], display[1]) defines range of display values; so, data, display must each be passed in as double[2] arrays; note if overrideUnit != null, so and data are in overrideUnitbooleangetScaleEnable()See if the AxisScale is visible or not.intgetValueIndex()get index of DisplayScalar in value array used by ShadowType.doTransforminthashCode()Returns the hash code for this ScalarMap.longincTick()invoke incTick on every application call to setRangefloat[]inverseScaleValues(float[] values)return an array of data (RealType) values by inverse linear scaling (if applicable) the display_values array (DisplayRealType values); this is useful for direct manipulation and cursor labelsfloat[]inverseScaleValues(float[] values, boolean newArray)return an array of data (RealType) values by inverse linear scaling (if applicable) the display_values array (DisplayRealType values); this is useful for direct manipulation and cursor labelsbooleanisAutoScale()determine whether this ScalarMap is auto-scaledvoidmakeScale()Create the scale that is displayed.booleanpeekTicks(DataRenderer r, DataDisplayLink link)voidremoveScalarMapListener(ScalarMapListener listener)remove a ScalarMapListenervoidresetAutoScale()re-enable auto-scaling for this ScalarMapbyte[]scaleValues(byte[] values, int factor)return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values); results are scaled by the given scale factorfloat[]scaleValues(double[] values)return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values)float[]scaleValues(float[] values)return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values)float[]scaleValues(float[] values, boolean newArray)return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values)voidsetOverrideUnit(Unit unit)Set display Unit to override default Unit of Scalar; MUST be called before any data are displayedvoidsetRange(DataShadow shadow)set range used for linear map from Scalar to DisplayScalar values; this is the call for automatic scalingvoidsetRange(double low, double hi)Explicitly sets the range ofRealTypedata values that is mapped to the natural range ofDisplayRealTypedisplay values.voidsetRange(double low, double hi, int remoteId)explicitly set the range of data (RealType) values; used for linear map from Scalar to DisplayScalar values; if neither this nor setRangeByUnits is invoked, then the range will be computed from the initial values of Data objects linked to the Display by autoscaling logic; if the range of data values is (0.0, 1.0), for example, this method may be invoked with low = 1.0 and hi = 0.0 to invert the display scale .voidsetRangeByUnits()explicitly set the range of data (RealType) values according to Unit conversion between this ScalarMap's RealType and DisplayRealType (both must have Units and they must be convertable; if neither this nor setRange is invoked, then the range will be computed from the initial values of Data objects linked to the Display by autoscaling logic.voidsetScalarName(java.lang.String name)Set the name being used on the axis scale.voidsetScaleColor(float[] color)Set color of axis scales; color must be float[3] with red, green and blue components; DisplayScalar must be XAxis, YAxis or ZAxis.voidsetScaleEnable(boolean on)Enable the display of the scale for this map.voidsetTicks()set tickFlag according to OldTick and NewTickvoidsetUnderscoreToBlank(boolean u2b)Change underscore characters (_) in the Scalar name to blanks.voidsetValueIndex(int index)set index of DisplayScalar in value array used by ShadowType.doTransformjava.lang.StringtoString()Returns a string representation of the ScalarMap.java.lang.StringtoString(java.lang.String pre)Returns a string representation of the ScalarMap with the specified prefix prepended.
-
-
-
Constructor Detail
-
ScalarMap
public ScalarMap(ScalarType scalar, DisplayRealType display_scalar) throws VisADException
Construct aScalarMapthat maps the scalar to the display_scalar.- Parameters:
scalar- ScalarType (must be RealType at present)display_scalar- DisplayScalar to map to. If the display_scalar is one of the spatial axes (X, Y, Z) an AxisScale will be created.- Throws:
VisADException- VisAD error
-
-
Method Detail
-
resetAutoScale
public void resetAutoScale()
re-enable auto-scaling for this ScalarMap
-
disableAutoScale
public void disableAutoScale()
disable auto-scaling for this ScalarMap
-
isAutoScale
public boolean isAutoScale()
determine whether this ScalarMap is auto-scaled
-
doInitialize
public boolean doInitialize()
-
setOverrideUnit
public void setOverrideUnit(Unit unit) throws VisADException
Set display Unit to override default Unit of Scalar; MUST be called before any data are displayed- Parameters:
unit- unit that data will be displayed with- Throws:
VisADException-unitis not convertable with the default unit or scalar is not a RealType.
-
getOverrideUnit
public Unit getOverrideUnit()
Return the override unit.- Returns:
- Unit being used in the display.
-
getScalarName
public java.lang.String getScalarName()
Get the name being used on the axis scale.- Returns:
- name of the scale - either the default or the one set by
setScalarName - See Also:
setScalarName(String name)
-
setScalarName
public void setScalarName(java.lang.String name)
Set the name being used on the axis scale.- Parameters:
name- new name for the scalar.- See Also:
AxisScale.setTitle(String name)
-
incTick
public long incTick()
invoke incTick on every application call to setRange
-
setTicks
public void setTicks()
set tickFlag according to OldTick and NewTick
-
peekTicks
public boolean peekTicks(DataRenderer r, DataDisplayLink link)
-
checkTicks
public boolean checkTicks(DataRenderer r, DataDisplayLink link)
return true if application called setRange
-
getScalar
public ScalarType getScalar()
Get the ScalarType that is the map domain- Returns:
- ScalarType of map domain
-
getDisplayScalar
public DisplayRealType getDisplayScalar()
Get the DisplayRealType that is the map range- Returns:
- DisplayRealType of map range
-
getDisplay
public DisplayImpl getDisplay()
Get the DisplayImpl this ScalarMap is linked to- Returns:
- display that this ScalarMap is linked to
-
getControl
public Control getControl()
Gets the Control for the DisplayScalar. The Control is constructed when this ScalarMap is linked to a Display via an invocation of theDisplay.addMap(ScalarMap)method. Not all ScalarMaps have Controls, generally depending on the ScalarMap's DisplayRealType. If a ScalarMap is removed from a Display (via theDisplay.clearMaps()method, then, in general, any information in the ScalarMap's control will be lost and must be reestablished.- Returns:
- The Control for the DisplayScalar or
nullif one has not yet been set.
-
getScale
public boolean getScale(double[] so, double[] data, double[] display)return value is true if data (RealType) values are linearly scaled to display (DisplayRealType) values; if so, then values are scaled by: display_value = data_value * so[0] + so[1]; (data[0], data[1]) defines range of data values (either passed in to setRange or computed by autoscaling logic) and (display[0], display[1]) defines range of display values; so, data, display must each be passed in as double[2] arrays; note if overrideUnit != null, so and data are in overrideUnit- Parameters:
so- array to contain scale and offsetdata- array to contain the data rangedisplay- array to contain the display range- Returns:
- true if data are linearly scaled
-
getRange
public double[] getRange()
Returns the current range of theRealTypedata. The range is implicitly set by autoscaling logic or may be explicitly set by thesetRange(double,double)method. Note that if overrideUnit != null, then dataRange is in overrideUnit.- Returns:
- The current range of the
RealTypedata. The array is new and may be safely modified.
-
setRangeByUnits
public void setRangeByUnits() throws VisADException, java.rmi.RemoteExceptionexplicitly set the range of data (RealType) values according to Unit conversion between this ScalarMap's RealType and DisplayRealType (both must have Units and they must be convertable; if neither this nor setRange is invoked, then the range will be computed from the initial values of Data objects linked to the Display by autoscaling logic.- Throws:
VisADException- VisAD errorjava.rmi.RemoteException- Java RMI error
-
setRange
public void setRange(double low, double hi) throws VisADException, java.rmi.RemoteExceptionExplicitly sets the range ofRealTypedata values that is mapped to the natural range ofDisplayRealTypedisplay values. This method is used to define a linear map from Scalar to DisplayScalar values. If neither this norsetRangeByUnits()is invoked, then the range will be computed by autoscaling logic from the initial values of Data objects linked to the Display. If the range of data values is (0.0, 1.0), for example, this method may be invoked with low = 1.0 and hi = 0.0 to invert the display scale.- Parameters:
low- One end of the range of applicable data.hi- The other end of the range of applicable data.- Throws:
VisADException- VisAD failure.java.rmi.RemoteException- Java RMI failure.
-
setRange
public void setRange(double low, double hi, int remoteId) throws VisADException, java.rmi.RemoteExceptionexplicitly set the range of data (RealType) values; used for linear map from Scalar to DisplayScalar values; if neither this nor setRangeByUnits is invoked, then the range will be computed from the initial values of Data objects linked to the Display by autoscaling logic; if the range of data values is (0.0, 1.0), for example, this method may be invoked with low = 1.0 and hi = 0.0 to invert the display scale .- Parameters:
low- lower range value (see notes above)hi- upper range value (see notes above)remoteId- id of remote scale- Throws:
VisADException- VisAD errorjava.rmi.RemoteException- Java RMI error
-
setRange
public void setRange(DataShadow shadow) throws VisADException, java.rmi.RemoteException
set range used for linear map from Scalar to DisplayScalar values; this is the call for automatic scaling- Throws:
VisADExceptionjava.rmi.RemoteException
-
addScalarMapListener
public void addScalarMapListener(ScalarMapListener listener)
add a ScalarMapListener, to be notified whenever setRange is invoked- Parameters:
listener-ScalarMapListenerto recieve notification of changes.
-
removeScalarMapListener
public void removeScalarMapListener(ScalarMapListener listener)
remove a ScalarMapListener- Parameters:
listener-ScalarMapListenerto remove from the list
-
setUnderscoreToBlank
public void setUnderscoreToBlank(boolean u2b)
Change underscore characters (_) in the Scalar name to blanks. Can be used to change the displayed scalar name on the axis.- Parameters:
u2b- true to change, false to change back- See Also:
as an alternative
-
makeScale
public void makeScale() throws VisADExceptionCreate the scale that is displayed. This is called automatically whensetRange(lo, hi)andsetDisplayare called. It makes a call toAxisScale.makeScale()where the actual hard work is done.- Throws:
VisADException- VisAD error.
-
setScaleEnable
public void setScaleEnable(boolean on)
Enable the display of the scale for this map. This can be used to selectively turn on or off the scales in a display. Must be used in conjunction withGraphicsModeControl.setScaleEnable()orDisplayRenderer.setScaleOn(boolean on).- Parameters:
on- true will enable display of axis, false will disable display- See Also:
GraphicsModeControl.setScaleEnable(boolean enable),DisplayRenderer.setScaleOn(boolean on),AxisScale.setVisible(boolean visible)
-
getScaleEnable
public boolean getScaleEnable()
See if the AxisScale is visible or not.- Returns:
- true if the AxisScale is visible
-
setScaleColor
public void setScaleColor(float[] color) throws VisADExceptionSet color of axis scales; color must be float[3] with red, green and blue components; DisplayScalar must be XAxis, YAxis or ZAxis. Preferred method is to useAxisScale.setColormethods.- Parameters:
color- array of R,G,B values of color.- Throws:
VisADException- non-spatial DisplayScalar or wrong length of color array- See Also:
getAxisScale(),AxisScale.setColor(Color color),AxisScale.setColor(float[] color)
-
badRange
public boolean badRange()
-
scaleValues
public float[] scaleValues(double[] values)
return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values)- Parameters:
values- to scale as doubles- Returns:
- array of display values
-
scaleValues
public float[] scaleValues(float[] values)
return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values)- Parameters:
values- to scale as floats- Returns:
- array of display values
-
scaleValues
public float[] scaleValues(float[] values, boolean newArray)return an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values)- Parameters:
values- to scale as floatsnewArray- false to scale in place- Returns:
- array of display values
-
scaleValues
public byte[] scaleValues(byte[] values, int factor) throws VisADExceptionreturn an array of display (DisplayRealType) values by linear scaling (if applicable) the data_values array (RealType values); results are scaled by the given scale factor- Parameters:
values- to scale as bytes- Returns:
- array of display values
- Throws:
VisADException
-
inverseScaleValues
public float[] inverseScaleValues(float[] values)
return an array of data (RealType) values by inverse linear scaling (if applicable) the display_values array (DisplayRealType values); this is useful for direct manipulation and cursor labels- Parameters:
values- display values- Returns:
- data values
-
inverseScaleValues
public float[] inverseScaleValues(float[] values, boolean newArray)return an array of data (RealType) values by inverse linear scaling (if applicable) the display_values array (DisplayRealType values); this is useful for direct manipulation and cursor labels- Parameters:
values- display valuesnewArray- false to transform in place- Returns:
- data values
-
equalizeFlow
public static void equalizeFlow(java.util.Vector mapVector, DisplayTupleType flow_tuple) throws VisADException, java.rmi.RemoteExceptionensure that non-Manual components of flow_tuple have equal dataRanges symmetric about 0.0- Throws:
VisADExceptionjava.rmi.RemoteException
-
setValueIndex
public void setValueIndex(int index)
set index of DisplayScalar in value array used by ShadowType.doTransform
-
getValueIndex
public int getValueIndex()
get index of DisplayScalar in value array used by ShadowType.doTransform
-
compareTo
public int compareTo(java.lang.Object o)
Compares this ScalarMap with another object.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
o- The other object.- Returns:
- A value that is negative, zero, or positive depending on whether this instance is less than, equal to, or greater than the other object, respectively.
- Throws:
java.lang.ClassCastException- if the other object isn't aScalarMap.java.lang.NullPointerException- if the other object isnull.
-
equals
public boolean equals(java.lang.Object o)
Indicates if this ScalarMap is the same as another object.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- The other object.- Returns:
trueif and only if the other object is a ScalarMap and compares equal to this ScalarMap.
-
hashCode
public int hashCode()
Returns the hash code for this ScalarMap. IfscalarMap1.equals( scalarMap2)is true, thenscalarMap1.hashCode() == scalarMap2.hashCode().- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hash code for this ScalarMap.
-
clone
public java.lang.Object clone()
Create and return a copy of this ScalarMap.- Overrides:
clonein classjava.lang.Object- Returns:
- copy of the ScalarMap or
nullif a copy couldn't be created.
-
toString
public java.lang.String toString()
Returns a string representation of the ScalarMap.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string that "textually represents" this ScalarMap.
-
toString
public java.lang.String toString(java.lang.String pre)
Returns a string representation of the ScalarMap with the specified prefix prepended.- Parameters:
pre- prefix to prepend to the representation- Returns:
- a string that "textually represents" this ScalarMap with
preprepended.
-
getAxisScale
public AxisScale getAxisScale()
Get the AxisScale associated with this ScalarMap.- Returns:
- the AxisScale or null if not a spatial ScalarMap
-
-
DMelt 3.0 © DataMelt by jWork.ORG