ucar.unidata.idv
Class DisplayConventions

java.lang.Object
  extended by ucar.unidata.ui.WindowHolder
      extended by ucar.unidata.idv.IdvManager
          extended by ucar.unidata.idv.DisplayConventions
All Implemented Interfaces:
ActionListener, EventListener, IdvConstants

public class DisplayConventions
extends IdvManager

Provides a set of display conventions (e.g., contour interval, default color map, etc) typically based on parameter names (e.g., "rh", "temp", etc.). Some of the conventions are hardcoded but others are defined using property files.

Version:
$Revision
Author:
Unidata Development Team

Field Summary
static String PREF_UNITLIST
          The preference id to hold the list of units that the user uses when changing units
 
Fields inherited from class ucar.unidata.ui.WindowHolder
contents, dialog, frame, window
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_BUNDLE, ARG_CATALOG, ARG_CHOOSER, ARG_CLEARDEFAULT, ARG_CODE, ARG_CONNECT, ARG_CURRENTTIME, ARG_DATA, ARG_DEBUG, ARG_DEFAULT, ARG_DISPLAY, ARG_DXML, ARG_FIXEDTIME, ARG_HELP, ARG_IMAGE, ARG_IMAGESERVER, ARG_INSTALLPLUGIN, ARG_ISLFILE, ARG_ISLINTERACTIVE, ARG_LISTRESOURCES, ARG_MAINCLASS, ARG_MOVIE, ARG_MSG_DEBUG, ARG_MSG_RECORD, ARG_NODEFAULT, ARG_NOGUI, ARG_NOONEINSTANCE, ARG_NOPLUGINS, ARG_NOPREF, ARG_ONEINSTANCEPORT, ARG_PLUGIN, ARG_PORT, ARG_PRINTJNLP, ARG_PROPERTIES, ARG_SCRIPT, ARG_SERVER, ARG_SETFILES, ARG_SITEPATH, ARG_TEMPLATE, ARG_TEST, ARG_TESTEVAL, ARG_TRACE, ARG_TRACEONLY, ARG_USERPATH, DEFAULT_DATE_FORMAT, DEFAULT_DOCPATH, DEFAULT_TIMEZONE, FILE_VMSTATE, FILTER_CPT, FILTER_ISL, FILTER_JNLP, FILTER_XIDV, FILTER_XIDVZIDV, FILTER_XML, FILTER_ZIDV, ID_COMMANDSTORUN, ID_DATASOURCES, ID_DISPLAYCONTROLS, ID_IDV, ID_JYTHON, ID_MESSAGE, ID_MISCHASHTABLE, ID_VERSION, ID_VIEWMANAGERS, ID_WINDOWS, INITIAL_PROBE_EARTHLOCATION, NULL_DATA_SELECTION, NULL_STRING, PREF_ARCHIVEDIR, PREF_ARCHIVENAME, PREF_AUTODISPLAYS_ENABLE, PREF_AUTODISPLAYS_SHOWGUI, PREF_AUTOSELECTDATA, PREF_CACHESIZE, PREF_CONTROLSINTABS, PREF_DATAPREFIX, PREF_DATE_FORMAT, PREF_DISTANCEUNIT, PREF_DOCACHE, PREF_EMBEDDATACHOOSERINDASHBOARD, PREF_EMBEDFIELDSELECTORINDASHBOARD, PREF_EMBEDLEGENDINDASHBOARD, PREF_EMBEDQUICKLINKSINDASHBOARD, PREF_EVENT_KEYBOARDMAP, PREF_EVENT_MOUSEMAP, PREF_EVENT_WHEELMAP, PREF_FAST_RENDER, PREF_FIELD_CACHETHRESHOLD, PREF_FILEREADDIR, PREF_FILEWRITEDIR, PREF_HISTORY, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAXIMAGESIZE, PREF_OPEN_ASK, PREF_OPEN_MERGE, PREF_OPEN_REMOVE, PREF_PROJ_LIST, PREF_SAMPLINGMODE, PREF_SHOWCONTROLWINDOW, PREF_SHOWDASHBOARD, PREF_SHOWDECODEDIALOG, PREF_SHOWHIDDENFILES, PREF_SHOWQUITCONFIRM, PREF_SITEPATH, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_ZIDV_ASK, PREF_ZIDV_DIRECTORY, PREF_ZIDV_SAVETOTMP, PROP_3DMODE, PROP_ABOUTTEXT, PROP_APPRESOURCEPATH, PROP_CHOOSERS, PROP_CHOOSERS_ALL, PROP_CONTROLDESCRIPTORS, PROP_CONTROLDESCRIPTORS_ALL, PROP_DATAHOLDERBOUNDS, PROP_DEFAULTLOCATIONS, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_VERSIONFILE, PROP_WINDOW_SCREENSIZEOFFSET, PROP_WINDOW_SIZEHEIGHT, PROP_WINDOW_SIZEWIDTH, PROP_WINDOW_USESCREENSIZE, SUFFIX_BAT, SUFFIX_CPT, SUFFIX_ISL, SUFFIX_JNLP, SUFFIX_RBI, SUFFIX_SH, SUFFIX_XIDV, SUFFIX_XML, SUFFIX_ZIDV
 
Constructor Summary
DisplayConventions(IntegratedDataViewer idv)
          Create this object with the given idv
 
Method Summary
 void addToUnitList(Object selected)
          Add the given object to the list of units
 ContourInfo findContourInfo(String paramName, RealType rangeType, Unit displayUnit, Range range)
          Find pre-determined contouring values for this parameter by name from the paramdefaults.xml file, or compute reasonable values of contouring values from the data itself.
 ContourInfo findContourInfo(String paramName, RealType rangeType, Unit displayUnit, Range range, ContourInfo contourInfo)
          Find pre-determined contouring values for this parameter by name from the paramdefaults.xml file, or compute reasonable values of contouring values from the data itself.
 ContourInfo findDefaultContourInfo(String paramName)
          Find the default contour inf
 ContourInfo findDefaultContourInfo(String paramName, ContourInfo contourInfo)
          Find the default contour inf
 String format(double v)
          Format of a double.
 String formatAltitude(Real alt)
          Format an Altitude
 String formatAngle(double d)
          Format the given angle with the angleFormat
 String formatDistance(double d)
          Format the given distance using the distanceFormat
 String formatEarthLocation(EarthLocation el, boolean includeAlt)
          Format a EarthLocation as a lat/lon/(alt) string.
 String formatEarthLocationShort(EarthLocation el)
          Format a EarthLocation as a lat/lon/(alt) string.
 String formatLatLon(double d)
          Format the given lat or lon using the latLonFormat
 String formatLatLon(Real latorlon)
          Format an lat or lon
 String formatLatLonPoint(LatLonPoint llp)
          Format an LatLonPoint as a lat/lon string.
 String formatLatLonShort(LatLonPoint llp)
          Format a LatLonPoint as a lat/lon string.
 String formatLatOrLon(double ll)
          Deprecated. use formatLatLon(double)
static Color getColor()
          Cycle through the color list.
 Color getColor(String name)
          Get the color that corresponds to the given name (e.g., red, blue, etc.)
 String getColorName(Color color)
          Get the name that corresponds to the given color
 Vector getColorNameList()
          Return the list of color names.
 List getDefaultUnitList()
          Return the list of TwoFacedObjects that make up the list of units.
static DisplayConventions getDisplayConventions()
          Get the singleton object
 Unit getDisplayUnit(String paramName, Unit unit)
          Get the default display unit for a parameter with the given name.
 String getMapProjectionLabel(MapProjection mp, DisplayControl display)
          Create a label for a map projection based on a DisplayControl.
 String getMapProjectionName(MapProjection projection)
          Get the name for the projection in question.
 ColorTable getParamColorTable(String paramName)
          Get the default ColorTable that should be used for the given parameter name.
 ParamDefaultsEditor getParamDefaultsEditor()
          Wrapper around IdvBase.getParamDefaultsEditor
 Range getParamRange(String paramName, Unit unit)
          Set range of values for lower and upper parameter values locked to lower and upper entries in color table
 Font getWindowLabelFont()
          Get the font used for window labels
 JComboBox makeColorSelector(Color dflt)
          A helper to make a color selector combo box
 JComboBox makeUnitBox(Unit unit, Unit defaultUnit)
          Popup a unit selection gui.
 Unit selectDisplayUnit(String paramName, Unit unit)
          For the given parameter name, select the common unit to display; for example Celsius replacing Kelvin.
 Unit selectUnit(Unit unit, Unit defaultUnit)
          Popup a unit selection gui.
 
Methods inherited from class ucar.unidata.idv.IdvManager
getArgsManager, getCollabManager, getColorTableManager, getDataManager, getIdv, getIdvChooserManager, getIdvClass, getIdvProjectionManager, getIdvUIManager, getImageGenerator, getJythonManager, getPersistenceManager, getPreferenceManager, getProperty, getProperty, getProperty, getPublishManager, getResourceManager, getStateManager, getStationModelManager, getStore, getVMManager, logException, showNormalCursor, showWaitCursor, waitUntilDisplaysAreDone
 
Methods inherited from class ucar.unidata.ui.WindowHolder
actionPerformed, close, doMakeContents, getContents, getDialog, getFrame, getWindow, getWindowTitle, isShowing, removeAll, setWindowTitle, shouldMakeDialog, show, show, showModal, toFront, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_UNITLIST

public static final String PREF_UNITLIST
The preference id to hold the list of units that the user uses when changing units

See Also:
Constant Field Values
Constructor Detail

DisplayConventions

public DisplayConventions(IntegratedDataViewer idv)
Create this object with the given idv

Parameters:
idv - The IDV
Method Detail

getDisplayConventions

public static DisplayConventions getDisplayConventions()
Get the singleton object

Returns:
The singleton object

formatLatLonPoint

public String formatLatLonPoint(LatLonPoint llp)
Format an LatLonPoint as a lat/lon string.

Parameters:
llp - LatLonPoint to format
Returns:
The formatted LatLonPoint

formatEarthLocation

public String formatEarthLocation(EarthLocation el,
                                  boolean includeAlt)
Format a EarthLocation as a lat/lon/(alt) string.

Parameters:
el - EarthLocation to format
includeAlt - include Altitude in the return
Returns:
The formatted lat/lon/alt

formatLatLonShort

public String formatLatLonShort(LatLonPoint llp)
Format a LatLonPoint as a lat/lon string.

Parameters:
llp - LatLonPoint to format
Returns:
The formatted lat/lon

formatEarthLocationShort

public String formatEarthLocationShort(EarthLocation el)
Format a EarthLocation as a lat/lon/(alt) string.

Parameters:
el - EarthLocation to format
Returns:
The formatted lat/lon/alt

formatLatLon

public String formatLatLon(double d)
Format the given lat or lon using the latLonFormat

Parameters:
d - The lat or lon value (degrees?)
Returns:
The formatted version

formatLatLon

public String formatLatLon(Real latorlon)
Format an lat or lon

Parameters:
latorlon - The lat or lon
Returns:
The formatted lat or lon

formatAltitude

public String formatAltitude(Real alt)
Format an Altitude

Parameters:
alt - The altitude
Returns:
The formatted alt

formatDistance

public String formatDistance(double d)
Format the given distance using the distanceFormat

Parameters:
d - The distance to format
Returns:
The formatted version

formatAngle

public String formatAngle(double d)
Format the given angle with the angleFormat

Parameters:
d - The angle to format
Returns:
The formatted version

formatLatOrLon

public String formatLatOrLon(double ll)
Deprecated. use formatLatLon(double)

Format a double to a String, for values such as -179.123

Parameters:
ll - a double (such as a lat or lon in decimal degrees)
Returns:
The formatted value

format

public String format(double v)
Format of a double.

Parameters:
v - The value
Returns:
Its format

findDefaultContourInfo

public ContourInfo findDefaultContourInfo(String paramName)
Find the default contour inf

Parameters:
paramName - variable name from the data source
Returns:
The default contour info for the param

findDefaultContourInfo

public ContourInfo findDefaultContourInfo(String paramName,
                                          ContourInfo contourInfo)
Find the default contour inf

Parameters:
paramName - variable name from the data source
contourInfo - The contour info to use
Returns:
The default contour info for the param

findContourInfo

public ContourInfo findContourInfo(String paramName,
                                   RealType rangeType,
                                   Unit displayUnit,
                                   Range range)
Find pre-determined contouring values for this parameter by name from the paramdefaults.xml file, or compute reasonable values of contouring values from the data itself. min no contour line below this value; base a contour line must have this value (even if not seen), other values are this value +/- some multiple of the interval; max no contour with greater value than this; interval if negative, means show dashed lines below base value.

Parameters:
paramName - variable name from the data source
rangeType - one of them ViaAD RealType thingys for the data
displayUnit - the unit the data will appear on screen
range - The range
Returns:
a ContourInfo object with appropriate contouring values

findContourInfo

public ContourInfo findContourInfo(String paramName,
                                   RealType rangeType,
                                   Unit displayUnit,
                                   Range range,
                                   ContourInfo contourInfo)
Find pre-determined contouring values for this parameter by name from the paramdefaults.xml file, or compute reasonable values of contouring values from the data itself. min no contour line below this value; base a contour line must have this value (even if not seen), other values are this value +/- some multiple of the interval; max no contour with greater value than this; interval if negative, means show dashed lines below base value.

Parameters:
paramName - variable name from the data source
rangeType - one of them ViaAD RealType thingys for the data
displayUnit - the unit the data will appear on screen
range - The range
contourInfo - Default contour info
Returns:
a ContourInfo object with appropriate contouring values

getParamColorTable

public ColorTable getParamColorTable(String paramName)
Get the default ColorTable that should be used for the given parameter name.

Parameters:
paramName - The name of the parameter
Returns:
The color table to use

getParamRange

public Range getParamRange(String paramName,
                           Unit unit)
                    throws VisADException,
                           RemoteException
Set range of values for lower and upper parameter values locked to lower and upper entries in color table

Parameters:
paramName - name of parm to set range limits for
unit - DEFAULT VisAD unit not display unit
Returns:
The Range to use for the given parameter
Throws:
RemoteException
VisADException

getParamDefaultsEditor

public ParamDefaultsEditor getParamDefaultsEditor()
Wrapper around IdvBase.getParamDefaultsEditor

Returns:
the param defaults editor

selectDisplayUnit

public Unit selectDisplayUnit(String paramName,
                              Unit unit)
For the given parameter name, select the common unit to display; for example Celsius replacing Kelvin.

Parameters:
paramName - the String name of data parameter
unit - the VisAD Unit of the parameter (incoming or original)
Returns:
Unit

getDisplayUnit

public Unit getDisplayUnit(String paramName,
                           Unit unit)
Get the default display unit for a parameter with the given name. If none is found then return the given unit.

Parameters:
paramName - The parameter name
unit - The default unit
Returns:
The display unit

getColorNameList

public Vector getColorNameList()
Return the list of color names. This is used in comboboxes to choose a color.

Returns:
List of color names

makeColorSelector

public JComboBox makeColorSelector(Color dflt)
A helper to make a color selector combo box

Parameters:
dflt - The default color value
Returns:
The color selector combo box

getColor

public Color getColor(String name)
Get the color that corresponds to the given name (e.g., red, blue, etc.)

Parameters:
name - The color name
Returns:
The color (or blue if not found).

getColorName

public String getColorName(Color color)
Get the name that corresponds to the given color

Parameters:
color - The color
Returns:
Its name

getColor

public static Color getColor()
Cycle through the color list.

Returns:
The next color in the list

getWindowLabelFont

public Font getWindowLabelFont()
Get the font used for window labels

Returns:
The window label font

makeUnitBox

public JComboBox makeUnitBox(Unit unit,
                             Unit defaultUnit)
Popup a unit selection gui. This will also save off persistently ay new unit names typed in.

Parameters:
unit - The current unit
defaultUnit - The default unit to return if the user chooses "Default"
Returns:
The new unit or null on a cancel or an error

selectUnit

public Unit selectUnit(Unit unit,
                       Unit defaultUnit)
Popup a unit selection gui. This will also save off persistently any new unit names typed in.

Parameters:
unit - The current unit
defaultUnit - The default unit to return if the user chooses "Default"
Returns:
The new unit or null on a cancel or an error

addToUnitList

public void addToUnitList(Object selected)
Add the given object to the list of units

Parameters:
selected - Selected unit

getDefaultUnitList

public List getDefaultUnitList()
Return the list of TwoFacedObjects that make up the list of units.

Returns:
List of unit holding objects.

getMapProjectionName

public String getMapProjectionName(MapProjection projection)
Get the name for the projection in question. A little better than MapProjection.toString()

Parameters:
projection - MapProjection in question
Returns:
name for projection

getMapProjectionLabel

public String getMapProjectionLabel(MapProjection mp,
                                    DisplayControl display)
Create a label for a map projection based on a DisplayControl.

Parameters:
mp - MapProjection cannot be null
display - DisplayControl
Returns:
label String