Class 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.
Author:
Unidata Development Team
  • Field Details

    • 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:
  • Constructor Details

    • DisplayConventions

      public DisplayConventions(IntegratedDataViewer idv)
      Create this object with the given idv
      Parameters:
      idv - The IDV
  • Method Details

    • 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
    • formatLatLonPoint

      public String formatLatLonPoint(LatLonPoint llp, boolean includeLabel)
      format the latlon point
      Parameters:
      llp - the llp
      includeLabel - include the label
      Returns:
      formatted point
    • 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
    • formatEarthLocation

      public String formatEarthLocation(EarthLocation el, boolean includeAlt, boolean includeLabel)
      format the earth location
      Parameters:
      el - the earth location
      includeAlt - include the altitude
      includeLabel - include that lat/lon label
      Returns:
      formatted earth location
    • 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
    • getLatLonFormat

      public DecimalFormat getLatLonFormat()
      get the latlon formatter
      Returns:
      the latlon formatter
    • 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
    • formatLatLonCardinal

      public String formatLatLonCardinal(double value, int type)
      Format the lat/lon labels with cardinal points (N,S,E,W).
      Parameters:
      value - the value
      type - (LATITUDE or LONGITUDE)
      Returns:
      the formatted string
    • formatLatLonCardinal

      public String formatLatLonCardinal(Real latorlon, int type)
      Format an lat or lon with cardinal id (N,S,E,W)
      Parameters:
      latorlon - The lat or lon
      type - (LATITUDE or LONGITUDE)
      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)
      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 deprecated use formatLatLon(double)
    • 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:
      VisADException - the VisAD exception
      RemoteException - the remote exception
    • 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
    • makeUnitBox

      public JComboBox makeUnitBox(Unit unit, Unit unit1, Unit defaultUnit)
      When I need to add the alt unit to have option of pressure unit
      Parameters:
      unit - The current unit
      unit1 - The unit of pressure
      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
    • selectUnit

      public Unit selectUnit(Unit unit, Unit unit1, Unit defaultUnit)
      Popup a unit selection gui. This will also save off persistently any new unit names typed in.
      Parameters:
      unit - The current unit
      unit1 - The next 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