ucar.unidata.view.geoloc
Class MapProjectionDisplay

java.lang.Object
  extended by ucar.visad.display.DisplayMaster
      extended by ucar.unidata.view.geoloc.NavigatedDisplay
          extended by ucar.unidata.view.geoloc.MapProjectionDisplay
Direct Known Subclasses:
MapProjectionDisplayJ2D, MapProjectionDisplayJ3D

public abstract class MapProjectionDisplay
extends NavigatedDisplay

Provides a navigated VisAD DisplayImpl for displaying data. The Projection or MapProjection provides the transformation from lat/lon space to xy space. There are three modes that can be used with this display - MODE_3D (Java 3D), MODE_2Din3D (2D in Java 3D), MODE_2D (Java 2D). Performance is better in Java 3D modes. In the 3D mode, RealType.Altitude is mapped to the display Z axis.

Any displayable data must be able to map to RealType.Latitude, RealType.Longitude and/or RealType.Altitude.

Version:
$Revision: 1.121 $ $Date: 2007/04/13 22:19:09 $
Author:
Don Murray

Nested Class Summary
protected static class MapProjectionDisplay.MapProjection3DAdapter
          An adapter for visad.georef.MapProjection coordinate systems (ie: ones with * a reference of Lat/Lon).
 
Nested classes/interfaces inherited from class ucar.unidata.view.geoloc.NavigatedDisplay
NavigatedDisplay.VerticalMapSet
 
Field Summary
static String CURSOR_BEARING
          The name of the bearing from center property.
static RealType CURSOR_BEARING_TYPE
          The bearing from center RealType.
static String CURSOR_RANGE
          The name of the range from center property.
static RealType CURSOR_RANGE_TYPE
          The range from center RealType.
static boolean force2D
          flag for forcing 2D
 
Fields inherited from class ucar.unidata.view.geoloc.NavigatedDisplay
BOTTOM_VIEW, BOTTOM_VIEW_NAME, CURSOR_ALTITUDE, CURSOR_LATITUDE, CURSOR_LONGITUDE, EAST_VIEW, EAST_VIEW_NAME, MODE_2D, MODE_2Din3D, MODE_3D, NORTH_VIEW, NORTH_VIEW_NAME, SOUTH_VIEW, SOUTH_VIEW_NAME, TOP_VIEW, TOP_VIEW_NAME, WEST_VIEW, WEST_VIEW_NAME
 
Fields inherited from class ucar.visad.display.DisplayMaster
behavior, defaultMouseFunctions, POINT_MODE
 
Constructor Summary
protected MapProjectionDisplay()
          Constructs an instance with the specified MapProjection
protected MapProjectionDisplay(MapProjection projection, DisplayImpl display)
          Constructs an instance with the specified MapProjection CoordinateSystem and display.
 
Method Summary
abstract  void addKeyboardBehavior(KeyboardBehavior behavior)
          Add a KeyboardBehavior to this class
 void addVerticalMap(RealType newVertType)
          Add a new mapping of this type to the vertical coordinate
protected  void cursorMoved()
          Handles a change to the cursor position.
 void destroy()
          Destroy this class
protected  ScalarMap getAltitudeMap()
          Accessor method for the vertical coordinate ScalarMap (i.e., what getDisplayAltitudeType is mapped from).
 Real getCursorBearing()
          Gets the cursor bearing from center property.
 Real getCursorRange()
          Gets the cursor range from center property.
 DisplayRealType getDisplayAltitudeType()
          Accessor method for the DisplayAltitudeType (i.e., what RealType.Altitude is mapped to).
 CoordinateSystem getDisplayCoordinateSystem()
          Get the display coordinate system that turns lat/lon/alt to x/y/z
 DisplayRealType getDisplayLatitudeType()
          Accessor method for the DisplayLatitudeType (i.e., what RealType.Latitude is mapped to).
 DisplayRealType getDisplayLongitudeType()
          Accessor method for the DisplayLongitudeType (i.e., what RealType.Longitude is mapped to).
 EarthLocation getEarthLocation(double x, double y, double z, boolean setZToZeroIfOverhead)
          Get the earth location from the VisAD xyz coodinates
static MapProjectionDisplay getInstance(int mode)
          Get an instance of a MapProjectionDisplay using the mode specified and the default projection.
static MapProjectionDisplay getInstance(MapProjection p, int mode)
          Get an instance of a MapProjectionDisplay using the mode specified and the MapProjection.
static MapProjectionDisplay getInstance(MapProjection p, int mode, boolean offscreen, Dimension dimension)
          Get an instance of a MapProjectionDisplay using the mode specified and the MapProjection.
static MapProjectionDisplay getInstance(MapProjection p, int mode, boolean offscreen, Dimension dimension, GraphicsDevice screen)
          Get an instance of a MapProjectionDisplay using the mode specified and the MapProjection.
 MapProjection getMapProjection()
          Get the MapProjection that defines the xy mapping of this MapProjectionDisplay.
 RealTuple getSpatialCoordinates(EarthLocation el)
          Returns the spatial (XYZ) coordinates of the particular EarthLocation
 double[] getSpatialCoordinates(EarthLocation el, double[] xyz)
          Returns the spatial (XYZ) coordinates of the particular EarthLocation
 double[] getVerticalRange()
          Get the range of the vertical coordinate (Altitude)
protected  void init(MapProjection projection, DisplayImpl display)
          Initializes an instance with the specified MapProjection CoordinateSystem and display.
protected  void initializeClass()
          Set up the display.
static void main(String[] args)
          test by running java ucar.unidata.view.geoloc.MapProjectionDisplay
protected static MapProjection makeDefaultMapProjection()
          Make the default projection.
protected  void pointerMoved(int x, int y)
          Handles a change in the position of the mouse-pointer.
 void removeVerticalMap(RealType vertType)
          Remove a new mapping of this type to the vertical coordinate
 float[] scaleVerticalValues(float[] altValues)
          Scale vertical values using the range of the vertical scalar map.
protected  void setCursorBearing(Real bearing)
          Sets the cursor bearing (degrees) from center property.
protected  void setCursorRange(Real range)
          Sets the cursor range from center property.
 void setMapArea(ucar.unidata.geoloc.ProjectionRect mapArea)
          Set the map area from the projection rectangle
 void setMapProjection(MapProjection mapProjection)
          Define the map projection using a MapProjection type CoordinateSystem
 void setMapProjection(ucar.unidata.geoloc.ProjectionImpl projection)
          Define the map projection using a Projection interface
 void setMapRegion(Gridded2DSet region)
          Set the map region to be displayed.
 void setVerticalRange(double min, double max)
          Set the range of the vertical coordinate
 void setVerticalRangeUnit(Unit newUnit)
          Set the Unit of the vertical range
 void setView(int view)
          Set the view for 3D.
protected  void updateLocation(EarthLocation el)
          Update lat/lon/alt properties with the EarthLocation.
 
Methods inherited from class ucar.unidata.view.geoloc.NavigatedDisplay
animateMatrix, center, center, center, center, centerAndZoom, centerAndZoomTo, enableClipping, enableRubberBanding, flythrough, getAnimationStringOn, getAutoRotate, getBottomViewName, getBoxVisible, getCenterPoint, getCursorAltitude, getCursorLatitude, getCursorLongitude, getDisplayMode, getEarthLocation, getEarthLocation, getEarthLocation, getEastViewName, getIsAnimating, getLatLonBox, getLatLonRect, getNavigationToolBar, getNorthViewName, getRay, getRayDirection, getRayPositionAtZ, getRubberBandBox, getScaledValue, getScalesVisible, getScreenCenter, getScreenCoordinates, getScreenCoordinates, getScreenLowerLeft, getScreenLowerRight, getScreenUpperLeft, getScreenUpperRight, getSouthViewName, getSpatialCoordinatesFromScreen, getSpatialCoordinatesFromScreen, getTopViewName, getVerticalRangeUnit, getVisadBox, getWestViewName, init, isClippingEnabled, isPerspectiveView, moveToScreen, moveToScreen, moveToScreen, rotateView, rotateView, setAnimationStringOn, setAutoRotate, setBoxVisible, setCursorAltitude, setCursorLatitude, setCursorLongitude, setCursorStringOn, setForeground, setPerspectiveView, setRotateDelay, setRubberBandBox, setScalesVisible, setVerticalMapUnit
 
Methods inherited from class ucar.visad.display.DisplayMaster
addDisplayable, addDisplayListener, addPropertyChangeListener, addPropertyChangeListener, addScalarMap, addScalarMaps, addVetoableChangeListener, addVetoableChangeListener, buildAnimationSet, dataChange, draw, ensureInactive, equals, finalize, firePropertyChange, firePropertyChange, getAnimationSetFromDisplayables, getAnimationStringVisible, getBackground, getComponent, getDisplay, getDisplayableCount, getDisplayables, getDisplayables, getDisplayAspect, getDisplayComponent, getForeground, getImage, getMouseBehavior, getOffscreenDimension, getProjectionMatrix, getSavedProjectionMatrix, getScreenBounds, getStereoAvailable, getWaitMessageVisible, handleMouseWheelMoved, hashCode, indexOf, init, is3D, isActive, isPointMode, printMatrix, printMe, rebuild, rebuildDisplay, reDisplayAll, removeDisplayable, removeDisplayables, removePropertyChangeListener, removePropertyChangeListener, removeScalarMap, removeScalarMaps, removeVetoableChangeListener, removeVetoableChangeListener, replaceScalarMap, reScale, resetMouseFunctions, resetProjection, rotate, rotateX, rotateY, rotateZ, saveCurrentDisplay, saveCurrentDisplay, saveCurrentDisplay, saveProjection, setActive, setAnimation, setAnimationStringVisible, setBackground, setDefaultMouseFunctions, setDisplayables, setDisplayables, setDisplayActive, setDisplayAspect, setDisplayInactive, setEyePosition, setKeyboardBehavior, setKeyboardEventMap, setKeyboardEventMap, setMouseFunctions, setOffscreenDimension, setPointMode, setProjectionMatrix, setRebuildNecessary, setWaitMessageVisible, setWheelEventMap, translate, zoom, zoom
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURSOR_RANGE_TYPE

public static RealType CURSOR_RANGE_TYPE
The range from center RealType.


CURSOR_BEARING_TYPE

public static RealType CURSOR_BEARING_TYPE
The bearing from center RealType.


CURSOR_RANGE

public static final String CURSOR_RANGE
The name of the range from center property.

See Also:
Constant Field Values

CURSOR_BEARING

public static final String CURSOR_BEARING
The name of the bearing from center property.

See Also:
Constant Field Values

force2D

public static boolean force2D
flag for forcing 2D

Constructor Detail

MapProjectionDisplay

protected MapProjectionDisplay()
Constructs an instance with the specified MapProjection


MapProjectionDisplay

protected MapProjectionDisplay(MapProjection projection,
                               DisplayImpl display)
                        throws VisADException,
                               RemoteException
Constructs an instance with the specified MapProjection CoordinateSystem and display.

Parameters:
projection - map projection CS
display - display to use
Throws:
VisADException - Couldn't create necessary VisAD object
RemoteException - Couldn't create a remote object
Method Detail

init

protected void init(MapProjection projection,
                    DisplayImpl display)
             throws VisADException,
                    RemoteException
Initializes an instance with the specified MapProjection CoordinateSystem and display.

Parameters:
projection - map projection CS
display - display to use
Throws:
VisADException - Couldn't create necessary VisAD object
RemoteException - Couldn't create a remote object

initializeClass

protected void initializeClass()
                        throws VisADException,
                               RemoteException
Set up the display. Any additional work should be done in a subclass's intializeClass() method, which should call super.initializeClass() first.

Overrides:
initializeClass in class NavigatedDisplay
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

getInstance

public static MapProjectionDisplay getInstance(int mode)
                                        throws VisADException,
                                               RemoteException
Get an instance of a MapProjectionDisplay using the mode specified and the default projection.

Parameters:
mode - mode to use
Returns:
a MapProjectionDisplay
Throws:
VisADException - problem creating some VisAD object
RemoteException - problem creating remote object

getInstance

public static MapProjectionDisplay getInstance(MapProjection p,
                                               int mode)
                                        throws VisADException,
                                               RemoteException
Get an instance of a MapProjectionDisplay using the mode specified and the MapProjection.

Parameters:
mode - mode to use
p - initial MapProjection for display
Returns:
a MapProjection display of the correct mode and projection
Throws:
VisADException - problem creating some VisAD object
RemoteException - problem creating remote object

getInstance

public static MapProjectionDisplay getInstance(MapProjection p,
                                               int mode,
                                               boolean offscreen,
                                               Dimension dimension)
                                        throws VisADException,
                                               RemoteException
Get an instance of a MapProjectionDisplay using the mode specified and the MapProjection.

Parameters:
p - map projection
mode - mode
offscreen - true if offscreen
dimension - dimension of display
Returns:
the instance
Throws:
RemoteException - Java RMI problem
VisADException - problem creating the display or some component

getInstance

public static MapProjectionDisplay getInstance(MapProjection p,
                                               int mode,
                                               boolean offscreen,
                                               Dimension dimension,
                                               GraphicsDevice screen)
                                        throws VisADException,
                                               RemoteException
Get an instance of a MapProjectionDisplay using the mode specified and the MapProjection.

Parameters:
p - map projection
mode - mode
offscreen - true if offscreen
dimension - dimension of display
screen - screen to display it on
Returns:
the instance
Throws:
RemoteException - Java RMI problem
VisADException - problem creating the display or some component

destroy

public void destroy()
Destroy this class

Overrides:
destroy in class DisplayMaster

addKeyboardBehavior

public abstract void addKeyboardBehavior(KeyboardBehavior behavior)
Add a KeyboardBehavior to this class

Overrides:
addKeyboardBehavior in class DisplayMaster
Parameters:
behavior - behavior to add

addVerticalMap

public void addVerticalMap(RealType newVertType)
                    throws VisADException,
                           RemoteException
Add a new mapping of this type to the vertical coordinate

Overrides:
addVerticalMap in class NavigatedDisplay
Parameters:
newVertType - RealType of map
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

removeVerticalMap

public void removeVerticalMap(RealType vertType)
                       throws VisADException,
                              RemoteException
Remove a new mapping of this type to the vertical coordinate

Overrides:
removeVerticalMap in class NavigatedDisplay
Parameters:
vertType - RealType of map
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

setVerticalRangeUnit

public void setVerticalRangeUnit(Unit newUnit)
                          throws VisADException,
                                 RemoteException
Set the Unit of the vertical range

Overrides:
setVerticalRangeUnit in class NavigatedDisplay
Parameters:
newUnit - unit of range
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

setVerticalRange

public void setVerticalRange(double min,
                             double max)
                      throws VisADException,
                             RemoteException
Set the range of the vertical coordinate

Overrides:
setVerticalRange in class NavigatedDisplay
Parameters:
min - minimum value for vertical axis
max - maximum value for vertical axis
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

getVerticalRange

public double[] getVerticalRange()
Get the range of the vertical coordinate (Altitude)

Overrides:
getVerticalRange in class NavigatedDisplay
Returns:
array of {min, max} range.

setCursorRange

protected void setCursorRange(Real range)
                       throws VisADException,
                              RemoteException
Sets the cursor range from center property.

Parameters:
range - The cursor range from center.
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

getCursorRange

public Real getCursorRange()
Gets the cursor range from center property.

Returns:
The currently-selected range. May be null.

setCursorBearing

protected void setCursorBearing(Real bearing)
                         throws VisADException,
                                RemoteException
Sets the cursor bearing (degrees) from center property. This implementation uses a great circle distance.

Parameters:
bearing - The cursor bearing from center.
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

getCursorBearing

public Real getCursorBearing()
Gets the cursor bearing from center property.

Returns:
The currently-selected bearing. May be null.

setView

public void setView(int view)
Set the view for 3D. The views are based on the original display as follows:
                        NORTH
                      _________
                    W |       | E
                    E |  TOP  | A
                    S |       | S
                    T |_______| T
                        SOUTH
 

Specified by:
setView in class NavigatedDisplay
Parameters:
view - one of the static view fields (NORTH_VIEW, SOUTH_VIEW, .. etc).

getDisplayLatitudeType

public DisplayRealType getDisplayLatitudeType()
Accessor method for the DisplayLatitudeType (i.e., what RealType.Latitude is mapped to).

Specified by:
getDisplayLatitudeType in class NavigatedDisplay
Returns:
the DisplayRealType that RealType.Latitude is mapped to

getDisplayLongitudeType

public DisplayRealType getDisplayLongitudeType()
Accessor method for the DisplayLongitudeType (i.e., what RealType.Longitude is mapped to).

Specified by:
getDisplayLongitudeType in class NavigatedDisplay
Returns:
the DisplayRealType that RealType.Longitude is mapped to

getDisplayAltitudeType

public DisplayRealType getDisplayAltitudeType()
Accessor method for the DisplayAltitudeType (i.e., what RealType.Altitude is mapped to).

Specified by:
getDisplayAltitudeType in class NavigatedDisplay
Returns:
the DisplayRealType that RealType.Altitude is mapped to

getAltitudeMap

protected ScalarMap getAltitudeMap()
Accessor method for the vertical coordinate ScalarMap (i.e., what getDisplayAltitudeType is mapped from).

Specified by:
getAltitudeMap in class NavigatedDisplay
Returns:
the ScalarMap that the vertical coordinate is mapped to

setMapProjection

public void setMapProjection(ucar.unidata.geoloc.ProjectionImpl projection)
                      throws VisADException,
                             RemoteException
Define the map projection using a Projection interface

Overrides:
setMapProjection in class NavigatedDisplay
Parameters:
projection - Projection to use
Throws:
VisADException - Couldn't create necessary VisAD object
RemoteException - Couldn't create a remote object

setMapProjection

public void setMapProjection(MapProjection mapProjection)
                      throws VisADException,
                             RemoteException
Define the map projection using a MapProjection type CoordinateSystem

Specified by:
setMapProjection in class NavigatedDisplay
Parameters:
mapProjection - map projection coordinate system
Throws:
VisADException - Couldn't create necessary VisAD object
RemoteException - Couldn't create a remote object

getMapProjection

public MapProjection getMapProjection()
Get the MapProjection that defines the xy mapping of this MapProjectionDisplay.

Returns:
MapProjection being used.

setMapArea

public void setMapArea(ucar.unidata.geoloc.ProjectionRect mapArea)
                throws VisADException,
                       RemoteException
Set the map area from the projection rectangle

Overrides:
setMapArea in class NavigatedDisplay
Parameters:
mapArea - map area as lat/lon lines
Throws:
RemoteException - problem setting remote data
VisADException - problem creating VisAD data object

setMapRegion

public void setMapRegion(Gridded2DSet region)
                  throws VisADException,
                         RemoteException
Set the map region to be displayed. The MathType of the domain of the set must be either RealTupleType.SpatialCartesian2DTuple, RealTupleType.SpatialEarth2DTuple, or RealTupleType.LatitudeLongitudeTuple.

Parameters:
region - Gridded2DSet containing the range of for the axis.
Throws:
VisADException - invalid domain or null set
RemoteException - Couldn't create a remote object

scaleVerticalValues

public float[] scaleVerticalValues(float[] altValues)
Scale vertical values using the range of the vertical scalar map.

Parameters:
altValues - altitude map values
Returns:
z values (may transform in place);

cursorMoved

protected void cursorMoved()
                    throws VisADException,
                           RemoteException
Handles a change to the cursor position.

Overrides:
cursorMoved in class NavigatedDisplay
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

updateLocation

protected void updateLocation(EarthLocation el)
                       throws VisADException,
                              RemoteException
Update lat/lon/alt properties with the EarthLocation.

Overrides:
updateLocation in class NavigatedDisplay
Parameters:
el - EarthLocation to use.
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

pointerMoved

protected void pointerMoved(int x,
                            int y)
                     throws UnitException,
                            VisADException,
                            RemoteException
Handles a change in the position of the mouse-pointer.

Overrides:
pointerMoved in class NavigatedDisplay
Parameters:
x - x mouse position
y - y mouse position
Throws:
RemoteException - Java RMI problem
UnitException - Unit conversion problem
VisADException - VisAD problem

getEarthLocation

public EarthLocation getEarthLocation(double x,
                                      double y,
                                      double z,
                                      boolean setZToZeroIfOverhead)
Get the earth location from the VisAD xyz coodinates

Specified by:
getEarthLocation in class NavigatedDisplay
Parameters:
x - x
y - y
z - z
setZToZeroIfOverhead - If in the overhead view then set Z to 0
Returns:
corresponding EarthLocation

getSpatialCoordinates

public RealTuple getSpatialCoordinates(EarthLocation el)
Returns the spatial (XYZ) coordinates of the particular EarthLocation

Specified by:
getSpatialCoordinates in class NavigatedDisplay
Parameters:
el - earth location to transform
Returns:
RealTuple of display coordinates.

getSpatialCoordinates

public double[] getSpatialCoordinates(EarthLocation el,
                                      double[] xyz)
                               throws VisADException,
                                      RemoteException
Returns the spatial (XYZ) coordinates of the particular EarthLocation

Specified by:
getSpatialCoordinates in class NavigatedDisplay
Parameters:
el - earth location to transform
xyz - The in value to set. May be null.
Returns:
xyz array
Throws:
RemoteException - Java RMI problem
VisADException - VisAD problem

makeDefaultMapProjection

protected static MapProjection makeDefaultMapProjection()
                                                 throws VisADException
Make the default projection.

Returns:
Default projectcion
Throws:
VisADException - couldn't create MapProjection

getDisplayCoordinateSystem

public CoordinateSystem getDisplayCoordinateSystem()
Get the display coordinate system that turns lat/lon/alt to x/y/z

Overrides:
getDisplayCoordinateSystem in class NavigatedDisplay
Returns:
the coordinate system (may be null)

main

public static void main(String[] args)
                 throws Exception
test by running java ucar.unidata.view.geoloc.MapProjectionDisplay

Parameters:
args - include an argument for a 3D display
Throws:
Exception - problem creating the display