NASA World Wind

gov.nasa.worldwind.layers
Class TerrainProfileLayer

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.layers.AbstractLayer
              extended by gov.nasa.worldwind.layers.TerrainProfileLayer
All Implemented Interfaces:
AVList, Disposable, PositionListener, SelectListener, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class TerrainProfileLayer
extends AbstractLayer
implements PositionListener, SelectListener

Displays a terrain profile graph in a screen corner.

Usage: do setEventSource(wwd) to have the graph activated and updated with position changes See public properties for options: keepProportions, follow, unit, start and end latlon...


Field Summary
static String FOLLOW_CURSOR
           
static String FOLLOW_EYE
           
static String FOLLOW_NONE
           
static String FOLLOW_OBJECT
           
static String FOLLOW_VIEW
           
static double METER_TO_FEET
           
static String NORTHEAST
           
static String NORTHWEST
           
static String RESIZE_KEEP_FIXED_SIZE
           
static String RESIZE_SHRINK_ONLY
           
static String RESIZE_STRETCH
           
static String SOUTHEAST
           
static String SOUTHWEST
           
static String UNIT_IMPERIAL
           
static String UNIT_METRIC
           
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
TerrainProfileLayer()
          Renders a terrain profile graphic in a screen corner
 
Method Summary
 void computeProfile(DrawContext dc)
          Compute the terrain profile.
 void dispose()
           
 void doPick(DrawContext dc, Point pickPoint)
           
 void doRender(DrawContext dc)
           
 void drawProfile(DrawContext dc)
           
 int getBorderWidth()
           
 Color getColor()
          Get the graphic color
 LatLon getEndLatLon()
          Get the profile end position lat/lon when FOLLOW_NONE
 String getFollow()
          Get the graph center point placement behavior
 boolean getFollowCursor()
          Get whether the graph center point follows the mouse cursor
 Font getFont()
          Get the graphic legend Font
 boolean getIsMaximized()
          Get whether the profile graph is maximized - displays over the whole viewport.
 boolean getIsMinimized()
          Get whether the profile graph is minimized
 boolean getKeepProportions()
          Get whether distance/elevation proportions are maintained
 Point getLocationCenter()
          Get the screen location of the graph center if set (can be null)
 Angle getObjectHeading()
           
 Position getObjectPosition()
           
 String getPosition()
           
 double getProfileLenghtFactor()
          Get the profile length factor
 String getResizeBehavior()
          Returns the layer's resize behavior.
 int getSamples()
          Get the number of elevation samples in the profile
 boolean getShowEyePosition()
          Get whether the eye position is shown on the graph when FOLLOW_EYE
 Dimension getSize()
          Get the graphic Dimension (in pixels)
 LatLon getStartLatLon()
          Get the profile start position lat/lon when FOLLOW_NONE
 double getToViewportScale()
          Returns the graphic-to-viewport scale factor.
 String getUnit()
           
 boolean getUpdate()
          Get whether the profile should be recomputed
 boolean getZeroBased()
          Get whether the profile graph should include sea level
 void moved(PositionEvent event)
           
 void propertyChange(PropertyChangeEvent propertyChangeEvent)
          The property change listener for this instance.
 void selected(SelectEvent event)
           
 void setBorderWidth(int borderWidth)
          Sets the graphic offset from the viewport border.
 void setColor(Color color)
          Set the graphic Color
 void setEndLatLon(LatLon latLon)
          Set the profile end position lat/lon when FOLLOW_NONE
 void setEventSource(WorldWindow wwd)
           
 void setFollow(String behavior)
          Set the graph center point placement behavior.
 void setFollowCursor(boolean state)
          Set whether the graph center point should follows the mouse cursor
 void setFont(Font font)
          Set the graphic legend Font
 void setIsMaximized(boolean state)
          Set wheter the profile graph should be maximized - displays over the whole viewport.
 void setIsMinimized(boolean state)
          Set wheter the profile graph should be minimized.
 void setKeepProportions(boolean state)
          Set whether distance/elevation proportions are maintained
 void setLocationCenter(Point point)
          Set the screen location of the graph center - overrides SetPosition if not null
 void setObjectHeading(Angle heading)
           
 void setObjectPosition(Position pos)
           
 void setPosition(String position)
          Sets the relative viewport location to display the graphic.
 void setProfileLengthFactor(double factor)
          Set the profile length factor - has no effect if FOLLOW_NONE
 void setResizeBehavior(String resizeBehavior)
          Sets the behavior the layer uses to size the graphic when the viewport size changes, typically when the World Wind window is resized.
 void setSamples(int number)
          Set the number of elevation samples in the profile
 void setShowEyePosition(Boolean state)
          Set whether the eye position is shown on the graph when FOLLOW_EYE
 void setSize(Dimension size)
          Set the graphic Dimenion (in pixels)
 void setStartLatLon(LatLon latLon)
          Set the profile start position lat/lon when FOLLOW_NONE
 void setToViewportScale(double toViewportScale)
          Sets the scale factor applied to the viewport size to determine the displayed size of the graphic.
 void setUnit(String unit)
          Sets the unit the graphic uses to display distances and elevations.
 void setUpdate(boolean state)
          Set wheter the profile should be recomputed
 void setZeroBased(boolean state)
          Set whether the profile graph should include sea level.
 String toString()
           
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
getMaxActiveAltitude, getMinActiveAltitude, getName, getOpacity, getRestorableState, getScale, isAtMaxResolution, isEnabled, isLayerActive, isLayerInView, isMultiResolution, isPickEnabled, pick, render, restoreState, setEnabled, setMaxActiveAltitude, setMinActiveAltitude, setName, setOpacity, setPickEnabled
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

FOLLOW_CURSOR

public static final String FOLLOW_CURSOR
See Also:
Constant Field Values

FOLLOW_EYE

public static final String FOLLOW_EYE
See Also:
Constant Field Values

FOLLOW_NONE

public static final String FOLLOW_NONE
See Also:
Constant Field Values

FOLLOW_OBJECT

public static final String FOLLOW_OBJECT
See Also:
Constant Field Values

FOLLOW_VIEW

public static final String FOLLOW_VIEW
See Also:
Constant Field Values

METER_TO_FEET

public static final double METER_TO_FEET
See Also:
Constant Field Values

NORTHEAST

public static final String NORTHEAST
See Also:
Constant Field Values

NORTHWEST

public static final String NORTHWEST
See Also:
Constant Field Values

RESIZE_KEEP_FIXED_SIZE

public static final String RESIZE_KEEP_FIXED_SIZE
See Also:
Constant Field Values

RESIZE_SHRINK_ONLY

public static final String RESIZE_SHRINK_ONLY
See Also:
Constant Field Values

RESIZE_STRETCH

public static final String RESIZE_STRETCH
See Also:
Constant Field Values

SOUTHEAST

public static final String SOUTHEAST
See Also:
Constant Field Values

SOUTHWEST

public static final String SOUTHWEST
See Also:
Constant Field Values

UNIT_IMPERIAL

public static final String UNIT_IMPERIAL
See Also:
Constant Field Values

UNIT_METRIC

public static final String UNIT_METRIC
See Also:
Constant Field Values
Constructor Detail

TerrainProfileLayer

public TerrainProfileLayer()
Renders a terrain profile graphic in a screen corner

Method Detail

computeProfile

public void computeProfile(DrawContext dc)
Compute the terrain profile.

If {@link #FOLLOW_VIEW ], {@link #FOLLOW_EYE] or {@link #FOLLOW_CURSOR] collects terrain profile data along a great circle line centered at the current position (view, eye or cursor) and perpendicular to the view heading. If {@link #FOLLOW_NONE] the profile is computed in between start and end latlon

Parameters:
dc - the current DrawContext.

dispose

public void dispose()
Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractLayer

doPick

public void doPick(DrawContext dc,
                   Point pickPoint)
Overrides:
doPick in class AbstractLayer

doRender

public void doRender(DrawContext dc)
Specified by:
doRender in class AbstractLayer

drawProfile

public void drawProfile(DrawContext dc)

getBorderWidth

public int getBorderWidth()

getColor

public Color getColor()
Get the graphic color

Returns:
the graphic Color

getEndLatLon

public LatLon getEndLatLon()
Get the profile end position lat/lon when FOLLOW_NONE

Returns:
the profile end position lat/lon

getFollow

public String getFollow()
Get the graph center point placement behavior

Returns:
the graph center point placement behavior

getFollowCursor

public boolean getFollowCursor()
Get whether the graph center point follows the mouse cursor

Returns:
true if the graph center point follows the mouse cursor

getFont

public Font getFont()
Get the graphic legend Font

Returns:
the graphic legend Font

getIsMaximized

public boolean getIsMaximized()
Get whether the profile graph is maximized - displays over the whole viewport.

Returns:
true if the profile graph is maximized

getIsMinimized

public boolean getIsMinimized()
Get whether the profile graph is minimized

Returns:
true if the profile graph is minimized

getKeepProportions

public boolean getKeepProportions()
Get whether distance/elevation proportions are maintained

Returns:
true if the graph maintains distance/elevation proportions

getLocationCenter

public Point getLocationCenter()
Get the screen location of the graph center if set (can be null)

Returns:
the screen location of the graph center if set (can be null)

getObjectHeading

public Angle getObjectHeading()

getObjectPosition

public Position getObjectPosition()

getPosition

public String getPosition()

getProfileLenghtFactor

public double getProfileLenghtFactor()
Get the profile length factor

Returns:
the profile length factor

getResizeBehavior

public String getResizeBehavior()
Returns the layer's resize behavior.

Returns:
the layer's resize behavior

getSamples

public int getSamples()
Get the number of elevation samples in the profile

Returns:
the number of elevation samples in the profile

getShowEyePosition

public boolean getShowEyePosition()
Get whether the eye position is shown on the graph when FOLLOW_EYE

Returns:
true if the eye position is shown on the grap

getSize

public Dimension getSize()
Get the graphic Dimension (in pixels)

Returns:
the scalebar graphic Dimension

getStartLatLon

public LatLon getStartLatLon()
Get the profile start position lat/lon when FOLLOW_NONE

Returns:
the profile start position lat/lon

getToViewportScale

public double getToViewportScale()
Returns the graphic-to-viewport scale factor.

Returns:
the graphic-to-viewport scale factor

getUnit

public String getUnit()

getUpdate

public boolean getUpdate()
Get whether the profile should be recomputed

Returns:
true if the profile should be recomputed

getZeroBased

public boolean getZeroBased()
Get whether the profile graph should include sea level

Returns:
whether the profile graph should include sea level

moved

public void moved(PositionEvent event)
Specified by:
moved in interface PositionListener

propertyChange

public void propertyChange(PropertyChangeEvent propertyChangeEvent)
Description copied from class: WWObjectImpl
The property change listener for this instance. Recieves property change notifications that this instance has registered with other proprty change notifiers.

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class WWObjectImpl
Parameters:
propertyChangeEvent - the event

selected

public void selected(SelectEvent event)
Specified by:
selected in interface SelectListener

setBorderWidth

public void setBorderWidth(int borderWidth)
Sets the graphic offset from the viewport border.

Parameters:
borderWidth - the number of pixels to offset the graphic from the borders indicated by setPosition(String).

setColor

public void setColor(Color color)
Set the graphic Color

Parameters:
color - the graphic Color

setEndLatLon

public void setEndLatLon(LatLon latLon)
Set the profile end position lat/lon when FOLLOW_NONE

Parameters:
latLon - the profile end position lat/lon

setEventSource

public void setEventSource(WorldWindow wwd)

setFollow

public void setFollow(String behavior)
Set the graph center point placement behavior. Can be one of FOLLOW_VIEW (the default), FOLLOW_CURSOR, FOLLOW_EYE or FOLLOW_NONE. If FOLLOW_NONE the profile will be computed between startLatLon and endLatLon.

Parameters:
behavior - the graph center point placement behavior

setFollowCursor

public void setFollowCursor(boolean state)
Set whether the graph center point should follows the mouse cursor

Parameters:
state - true if the graph center point should follows the mouse cursor

setFont

public void setFont(Font font)
Set the graphic legend Font

Parameters:
font - the graphic legend Font

setIsMaximized

public void setIsMaximized(boolean state)
Set wheter the profile graph should be maximized - displays over the whole viewport.

Parameters:
state - true if the profile should be maximized

setIsMinimized

public void setIsMinimized(boolean state)
Set wheter the profile graph should be minimized.

Note that the graph can be both minimized and maximized at the same time. The minimized state will take precedence and the graph will display as an icon. When 'un-minimized' it will display as maximized.

Parameters:
state - true if the profile should be minimized
See Also:
this.setIsMaximized()

setKeepProportions

public void setKeepProportions(boolean state)
Set whether distance/elevation proportions are maintained

Parameters:
state - true if the graph should maintains distance/elevation proportions

setLocationCenter

public void setLocationCenter(Point point)
Set the screen location of the graph center - overrides SetPosition if not null

Parameters:
point - the screen location of the graph center (can be null)

setObjectHeading

public void setObjectHeading(Angle heading)

setObjectPosition

public void setObjectPosition(Position pos)

setPosition

public void setPosition(String position)
Sets the relative viewport location to display the graphic. Can be one of NORTHEAST (the default), NORTHWEST, SOUTHEAST, or SOUTHWEST. These indicate the corner of the viewport.

Parameters:
position - the desired graphic position

setProfileLengthFactor

public void setProfileLengthFactor(double factor)
Set the profile length factor - has no effect if FOLLOW_NONE

Parameters:
factor - the new factor

setResizeBehavior

public void setResizeBehavior(String resizeBehavior)
Sets the behavior the layer uses to size the graphic when the viewport size changes, typically when the World Wind window is resized. If the value is RESIZE_KEEP_FIXED_SIZE, the graphic size is kept to the size specified in its Dimension scaled by the layer's current icon scale. If the value is RESIZE_STRETCH, the graphic is resized to have a constant size relative to the current viewport size. If the viewport shrinks the graphic size decreases; if it expands then the graphic enlarges. If the value is RESIZE_SHRINK_ONLY (the default), graphic sizing behaves as for RESIZE_STRETCH but it will not grow larger than the size specified in its Dimension.

Parameters:
resizeBehavior - the desired resize behavior

setSamples

public void setSamples(int number)
Set the number of elevation samples in the profile

Parameters:
number - the number of elevation samples in the profile

setShowEyePosition

public void setShowEyePosition(Boolean state)
Set whether the eye position is shown on the graph when FOLLOW_EYE

Parameters:
state - if true the eye position is shown on the graph

setSize

public void setSize(Dimension size)
Set the graphic Dimenion (in pixels)

Parameters:
size - the graphic Dimension

setStartLatLon

public void setStartLatLon(LatLon latLon)
Set the profile start position lat/lon when FOLLOW_NONE

Parameters:
latLon - the profile start position lat/lon

setToViewportScale

public void setToViewportScale(double toViewportScale)
Sets the scale factor applied to the viewport size to determine the displayed size of the graphic. This scale factor is used only when the layer's resize behavior is RESIZE_STRETCH or RESIZE_SHRINK_ONLY. The graphic's width is adjusted to occupy the proportion of the viewport's width indicated by this factor. The graphic's height is adjusted to maintain the graphic's Dimension aspect ratio.

Parameters:
toViewportScale - the graphic to viewport scale factor

setUnit

public void setUnit(String unit)
Sets the unit the graphic uses to display distances and elevations. Can be one of UNIT_METRIC (the default), or UNIT_IMPERIAL.

Parameters:
unit - the desired unit

setUpdate

public void setUpdate(boolean state)
Set wheter the profile should be recomputed

Parameters:
state - true if the profile should be recomputed

setZeroBased

public void setZeroBased(boolean state)
Set whether the profile graph should include sea level. True is the default.

Parameters:
state - true if the profile graph should include sea level

toString

public String toString()
Overrides:
toString in class AbstractLayer

NASA World Wind