public class TerrainProfileLayer extends AbstractLayer implements PositionListener, SelectListener
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...
Modifier and Type | Class and Description |
---|---|
protected class |
TerrainProfileLayer.OrderedIcon |
Modifier and Type | Field and Description |
---|---|
protected int |
borderWidth |
protected java.lang.String |
buttonMaximize |
protected java.lang.String |
buttonMinimize |
protected java.awt.Color |
color |
protected java.awt.Font |
defaultFont |
protected LatLon |
endLatLon |
protected java.lang.String |
follow |
static java.lang.String |
FOLLOW_CURSOR |
static java.lang.String |
FOLLOW_EYE |
static java.lang.String |
FOLLOW_NONE |
static java.lang.String |
FOLLOW_OBJECT |
static java.lang.String |
FOLLOW_PATH |
static java.lang.String |
FOLLOW_VIEW |
protected boolean |
initialized |
protected boolean |
isMaximized |
protected boolean |
isMinimized |
protected boolean |
keepProportions |
protected double |
length |
protected java.awt.Point |
locationCenter |
protected Vec4 |
locationOffset |
protected double |
maxElevation |
static double |
METER_TO_FEET |
protected double |
minElevation |
protected static int |
MINIMIZED_SIZE |
protected Angle |
objectHeading |
protected Position |
objectPosition |
protected TerrainProfileLayer.OrderedIcon |
orderedImage |
protected java.util.ArrayList<? extends LatLon> |
pathPositions |
protected int |
pathType |
protected int |
pickedSample |
protected PickSupport |
pickSupport |
protected java.lang.String |
position |
protected Position[] |
positions |
protected double |
profileLengthFactor |
protected java.lang.String |
resizeBehavior |
protected int |
samples |
protected boolean |
showEyePosition |
protected boolean |
showPickedLine |
protected boolean |
showProfileLine |
protected java.awt.Dimension |
size |
protected LatLon |
startLatLon |
protected double |
toViewportScale |
protected java.lang.String |
unit |
static java.lang.String |
UNIT_IMPERIAL |
static java.lang.String |
UNIT_METRIC |
protected WorldWindow |
wwd |
protected boolean |
zeroBased |
Constructor and Description |
---|
TerrainProfileLayer()
Renders a terrain profile graphic in a screen corner.
|
Modifier and Type | Method and Description |
---|---|
protected Position |
computeCursorPosition(DrawContext dc) |
protected Vec4 |
computeLocation(java.awt.Rectangle viewport,
double scale) |
protected void |
computeMirroredPositions(LatLon centerLatLon) |
protected int |
computeObjectSample(LatLon pos)
Compute the sample number along the path closest to the given
LatLon . |
protected double |
computePathLength() |
protected void |
computePathPositions() |
protected Position |
computePickPosition(DrawContext dc,
Vec4 locationSW,
java.awt.Dimension mapSize)
Computes the Position of the pickPoint over the graph and updates pickedSample indice
|
protected void |
computeProfile(DrawContext dc)
Compute the terrain profile.
|
protected double |
computeScale(java.awt.Rectangle viewport) |
protected Position |
computeViewCenterPosition(DrawContext dc) |
void |
doPick(DrawContext dc,
java.awt.Point pickPoint) |
void |
doRender(DrawContext dc) |
protected void |
drawFilledRectangle(DrawContext dc,
Vec4 origin,
java.awt.Dimension dimension,
java.awt.Color color) |
protected void |
drawGraph(DrawContext dc,
java.awt.Dimension dimension) |
protected void |
drawGrid(DrawContext dc,
java.awt.Dimension dimension) |
protected void |
drawGUI(DrawContext dc,
java.awt.Dimension dimension) |
protected void |
drawHorizontalLine(DrawContext dc,
java.awt.Dimension dimension,
double y) |
protected void |
drawLabel(DrawContext dc,
java.lang.String text,
Vec4 screenPoint,
int align) |
protected void |
drawLine(DrawContext dc,
double x1,
double y1,
double x2,
double y2) |
void |
drawProfile(DrawContext dc) |
protected void |
drawVerticalLine(DrawContext dc,
java.awt.Dimension dimension,
double x) |
protected java.awt.Color |
getBackgroundColor(java.awt.Color color) |
int |
getBorderWidth() |
java.awt.Color |
getColor()
Get the graphic color.
|
LatLon |
getEndLatLon()
Get the profile end position lat/lon when
FOLLOW_NONE . |
java.lang.String |
getFollow()
Get the graph center point placement behavior.
|
java.awt.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.
|
java.awt.Point |
getLocationCenter()
Get the screen location of the graph center if set (can be null).
|
Vec4 |
getLocationOffset()
Returns the current location offset.
|
Angle |
getObjectHeading()
Get the object heading the graph follows when it is set to
FOLLOW_OBJECT . |
Position |
getObjectPosition()
Get the object position the graph follows when it is set to
FOLLOW_OBJECT . |
double |
getOpacity()
Returns the layer's opacity value.
|
java.util.List<? extends LatLon> |
getPathPositions()
Get the path positions that the profile follows if set to
FOLLOW_PATH . |
int |
getPathType() |
gov.nasa.worldwind.render.Polyline |
getPickedLine()
Get the
Polyline used to render the picked position on the terrain. |
java.lang.String |
getPosition() |
double |
getProfileLenghtFactor()
Get the profile length factor.
|
gov.nasa.worldwind.render.Polyline |
getProfileLine()
Get the
Polyline used to render the profile line on the ground. |
java.lang.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 or object position is shown on the graph when
FOLLOW_EYE or FOLLOW_OBJECT . |
java.awt.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.
|
java.lang.String |
getUnit() |
boolean |
getZeroBased()
Get whether the profile graph should include sea level.
|
protected void |
initialize(DrawContext dc) |
boolean |
isShowPickedLine()
Get whether the picked line is displayed over the ground.
|
boolean |
isShowProfileLine()
Get whether the profile line is displayed over the ground.
|
void |
moved(PositionEvent event) |
void |
propertyChange(java.beans.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(java.awt.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(java.lang.String behavior)
Set the graph center point placement behavior.
|
void |
setFont(java.awt.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 whether the profile graph should be minimized.
|
void |
setKeepProportions(boolean state)
Set whether distance/elevation proportions are maintained.
|
void |
setLocationCenter(java.awt.Point point)
Set the screen location of the graph center - overrides
setPosition(java.lang.String) if not null. |
void |
setLocationOffset(Vec4 locationOffset)
Specifies a placement offset from the layer position on the screen.
|
void |
setObjectHeading(Angle heading)
Set the object heading the graph follows when it is set to
FOLLOW_OBJECT . |
void |
setObjectPosition(Position pos)
Set the object position the graph follows when it is set to
FOLLOW_OBJECT . |
void |
setOpacity(double opacity)
Sets the layer opacity, which is applied to the layer's chart.
|
void |
setPathPositions(java.util.ArrayList<? extends LatLon> positions)
Set the path positions that the profile should follow if
FOLLOW_PATH . |
void |
setPathType(int type)
Sets the type of path to follow, one of
Polyline.GREAT_CIRCLE , which computes each segment of the path as
a great circle, or Polyline.RHUMB_LINE , which computes each segment of the path as a line of constant
heading. |
protected void |
setPosition(int index,
LatLon latLon) |
void |
setPosition(java.lang.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 or FOLLOW_PATH |
void |
setResizeBehavior(java.lang.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(java.lang.Boolean state)
Set whether the eye or object position should be shown on the graph when
FOLLOW_EYE or FOLLOW_OBJECT . |
void |
setShowPickedLine(boolean state)
Set whether the picked line should be displayed over the ground.
|
void |
setShowProfileLine(boolean state)
Set whether the profile line should be displayed over the terrain.
|
void |
setSize(java.awt.Dimension size)
Set the graphic Dimension (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(java.lang.String unit)
Sets the unit the graphic uses to display distances and elevations.
|
void |
setZeroBased(boolean state)
Set whether the profile graph should include sea level.
|
java.lang.String |
toString() |
createLayerConfigElements, dispose, doPreRender, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getRestorableState, getScale, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, render, restoreState, setDataFileStore, setEnabled, setExpiryTime, setMaxActiveAltitude, setMinActiveAltitude, setName, setNetworkRetrievalEnabled, setPickEnabled, setScreenCredit
onMessage
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
onMessage
protected int borderWidth
protected final java.lang.String buttonMaximize
protected final java.lang.String buttonMinimize
protected java.awt.Color color
protected java.awt.Font defaultFont
protected LatLon endLatLon
protected java.lang.String follow
public static final java.lang.String FOLLOW_CURSOR
public static final java.lang.String FOLLOW_EYE
public static final java.lang.String FOLLOW_NONE
public static final java.lang.String FOLLOW_OBJECT
public static final java.lang.String FOLLOW_PATH
public static final java.lang.String FOLLOW_VIEW
protected boolean initialized
protected boolean isMaximized
protected boolean isMinimized
protected boolean keepProportions
protected double length
protected java.awt.Point locationCenter
protected Vec4 locationOffset
protected double maxElevation
public static final double METER_TO_FEET
protected double minElevation
protected static final int MINIMIZED_SIZE
protected Angle objectHeading
protected Position objectPosition
protected TerrainProfileLayer.OrderedIcon orderedImage
protected java.util.ArrayList<? extends LatLon> pathPositions
protected int pathType
protected int pickedSample
protected PickSupport pickSupport
protected java.lang.String position
protected Position[] positions
protected double profileLengthFactor
protected java.lang.String resizeBehavior
protected int samples
protected boolean showEyePosition
protected boolean showPickedLine
protected boolean showProfileLine
protected java.awt.Dimension size
protected LatLon startLatLon
protected double toViewportScale
protected java.lang.String unit
public static final java.lang.String UNIT_IMPERIAL
public static final java.lang.String UNIT_METRIC
protected WorldWindow wwd
protected boolean zeroBased
public TerrainProfileLayer()
protected Position computeCursorPosition(DrawContext dc)
protected Vec4 computeLocation(java.awt.Rectangle viewport, double scale)
protected void computeMirroredPositions(LatLon centerLatLon)
protected int computeObjectSample(LatLon pos)
LatLon
.pos
- the object LatLon
protected double computePathLength()
protected void computePathPositions()
protected Position computePickPosition(DrawContext dc, Vec4 locationSW, java.awt.Dimension mapSize)
dc
- the current DrawContextlocationSW
- the screen location of the bottom left corner of the graphmapSize
- the graph screen dimension in pixelsprotected void computeProfile(DrawContext dc)
If FOLLOW_VIEW
, FOLLOW_EYE
, FOLLOW_CURSOR
or FOLLOW_OBJECT
, collects terrain profile data along a great circle line centered at the current position (view,
eye, cursor or object) and perpendicular to the view heading - or object heading if FOLLOW_OBJECT
.
If FOLLOW_NONE
the profile is computed in between start and end latlon.
If FOLLOW_PATH
the
profile is computed along the path provided with setPathPositions(ArrayList)
dc
- the current DrawContext
protected double computeScale(java.awt.Rectangle viewport)
protected Position computeViewCenterPosition(DrawContext dc)
public void doPick(DrawContext dc, java.awt.Point pickPoint)
doPick
in class AbstractLayer
public void doRender(DrawContext dc)
doRender
in class AbstractLayer
protected void drawFilledRectangle(DrawContext dc, Vec4 origin, java.awt.Dimension dimension, java.awt.Color color)
protected void drawGraph(DrawContext dc, java.awt.Dimension dimension)
protected void drawGrid(DrawContext dc, java.awt.Dimension dimension)
protected void drawGUI(DrawContext dc, java.awt.Dimension dimension)
protected void drawHorizontalLine(DrawContext dc, java.awt.Dimension dimension, double y)
protected void drawLabel(DrawContext dc, java.lang.String text, Vec4 screenPoint, int align)
protected void drawLine(DrawContext dc, double x1, double y1, double x2, double y2)
public void drawProfile(DrawContext dc)
protected void drawVerticalLine(DrawContext dc, java.awt.Dimension dimension, double x)
protected java.awt.Color getBackgroundColor(java.awt.Color color)
public int getBorderWidth()
public java.awt.Color getColor()
public LatLon getEndLatLon()
FOLLOW_NONE
.public java.lang.String getFollow()
public java.awt.Font getFont()
public boolean getIsMaximized()
public boolean getIsMinimized()
public boolean getKeepProportions()
public java.awt.Point getLocationCenter()
public Vec4 getLocationOffset()
setLocationOffset(gov.nasa.worldwind.geom.Vec4)
for a description of the offset and its
values.public Angle getObjectHeading()
FOLLOW_OBJECT
. The profile graph will be
computed perpendicular to the object heading direction.public Position getObjectPosition()
FOLLOW_OBJECT
.public double getOpacity()
getOpacity
in interface Layer
getOpacity
in class AbstractLayer
getColor()
public java.util.List<? extends LatLon> getPathPositions()
FOLLOW_PATH
.public int getPathType()
public gov.nasa.worldwind.render.Polyline getPickedLine()
Polyline
used to render the picked position on the terrain.Polyline
used to render the picked position on the terrain.public java.lang.String getPosition()
public double getProfileLenghtFactor()
public gov.nasa.worldwind.render.Polyline getProfileLine()
Polyline
used to render the profile line on the ground.Polyline
used to render the profile line on the ground.public java.lang.String getResizeBehavior()
public int getSamples()
public boolean getShowEyePosition()
FOLLOW_EYE
or FOLLOW_OBJECT
.public java.awt.Dimension getSize()
public LatLon getStartLatLon()
FOLLOW_NONE
.public double getToViewportScale()
public java.lang.String getUnit()
public boolean getZeroBased()
protected void initialize(DrawContext dc)
public boolean isShowPickedLine()
public boolean isShowProfileLine()
public void moved(PositionEvent event)
moved
in interface PositionListener
public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
WWObjectImpl
propertyChange
in interface java.beans.PropertyChangeListener
propertyChange
in class WWObjectImpl
propertyChangeEvent
- the eventpublic void selected(SelectEvent event)
selected
in interface SelectListener
public void setBorderWidth(int borderWidth)
borderWidth
- the number of pixels to offset the graphic from the borders indicated by setPosition(String)
.public void setColor(java.awt.Color color)
color
- the graphic Color.public void setEndLatLon(LatLon latLon)
FOLLOW_NONE
.latLon
- the profile end position lat/lon.public void setEventSource(WorldWindow wwd)
public void setFollow(java.lang.String behavior)
FOLLOW_VIEW
(the default), FOLLOW_CURSOR
, FOLLOW_EYE
, FOLLOW_OBJECT
, FOLLOW_NONE
or FOLLOW_PATH
. If
FOLLOW_NONE
the profile will be computed between startLatLon and endLatLon. If FOLLOW_PATH
the
profile will be computed along the path defined with setPathPositions(java.util.ArrayList)
.behavior
- the graph center point placement behavior.public void setFont(java.awt.Font font)
font
- the graphic legend Font.public void setIsMaximized(boolean state)
state
- true if the profile should be maximized.public void setIsMinimized(boolean state)
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.
state
- true if the profile should be minimized.public void setKeepProportions(boolean state)
state
- true if the graph should maintains distance/elevation proportions.public void setLocationCenter(java.awt.Point point)
setPosition(java.lang.String)
if not null.point
- the screen location of the graph center (can be null).public void setLocationOffset(Vec4 locationOffset)
locationOffset
- the number of pixels to shift the layer image from its specified screen position. A
positive X value shifts the image to the right. A positive Y value shifts the image up. If
null, no offset is applied. The default offset is null.setLocationCenter(java.awt.Point)
,
setPosition(java.lang.String)
public void setObjectHeading(Angle heading)
FOLLOW_OBJECT
. The profile graph will be
computed perpendicular to the object heading direction.heading
- the object heading the graph follows.public void setObjectPosition(Position pos)
FOLLOW_OBJECT
.pos
- the object position the graph follows.public void setOpacity(double opacity)
setOpacity
in interface Layer
setOpacity
in class AbstractLayer
opacity
- the current opacity value, which is ignored by this layer.setColor(java.awt.Color)
public void setPathPositions(java.util.ArrayList<? extends LatLon> positions)
FOLLOW_PATH
.positions
- the path positions that the profile should follow.public void setPathType(int type)
Polyline.GREAT_CIRCLE
, which computes each segment of the path as
a great circle, or Polyline.RHUMB_LINE
, which computes each segment of the path as a line of constant
heading.type
- the type of path to follow.protected void setPosition(int index, LatLon latLon)
public void setPosition(java.lang.String position)
AVKey.NORTHEAST
, AVKey.NORTHWEST
, AVKey.SOUTHEAST
, or AVKey.SOUTHWEST
(the default). These indicate the corner of
the viewport.position
- the desired graphic position.public void setProfileLengthFactor(double factor)
FOLLOW_NONE
or FOLLOW_PATH
factor
- the new profile length factor.public void setResizeBehavior(java.lang.String resizeBehavior)
AVKey.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 AVKey.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 AVKey.RESIZE_SHRINK_ONLY
(the default), graphic sizing behaves as for AVKey.RESIZE_STRETCH
but it will
not grow larger than the size specified in its Dimension.resizeBehavior
- the desired resize behaviorpublic void setSamples(int number)
number
- the number of elevation samples in the profile.public void setShowEyePosition(java.lang.Boolean state)
FOLLOW_EYE
or FOLLOW_OBJECT
.state
- if true the eye or object position should be shown on the graph.public void setShowPickedLine(boolean state)
state
- if the picked line should be displayed over the ground.public void setShowProfileLine(boolean state)
state
- true if the profile line should be displayed over the terrain.public void setSize(java.awt.Dimension size)
size
- the graphic Dimension.public void setStartLatLon(LatLon latLon)
FOLLOW_NONE
.latLon
- the profile start position lat/lon.public void setToViewportScale(double toViewportScale)
AVKey.RESIZE_STRETCH
or AVKey.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.toViewportScale
- the graphic to viewport scale factor.public void setUnit(java.lang.String unit)
UNIT_METRIC
(the
default), or UNIT_IMPERIAL
.unit
- the desired unit.public void setZeroBased(boolean state)
state
- true if the profile graph should include sea level.public java.lang.String toString()
toString
in class AbstractLayer