Package gov.nasa.worldwind.layers
Class AbstractGraticuleLayer
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.layers.AbstractLayer
-
- gov.nasa.worldwind.layers.AbstractGraticuleLayer
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,Layer
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
GARSGraticuleLayer
,LatLonGraticuleLayer
,UTMBaseGraticuleLayer
public class AbstractGraticuleLayer extends AbstractLayer
Displays a graticule.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractGraticuleLayer.GridElement
-
Field Summary
Fields Modifier and Type Field Description protected long
frameTimeStamp
protected Globe
globe
protected GraticuleSupport
graticuleSupport
protected java.util.ArrayList<AbstractGraticuleLayer.GridElement>
gridElements
protected Vec4
lastEyePoint
protected GeographicProjection
lastProjection
protected double
lastVerticalExaggeration
protected double
lastViewFOV
protected double
lastViewHeading
protected double
lastViewPitch
static java.lang.String
LINE_STYLE_DASHED
Dashed line rendering style.static java.lang.String
LINE_STYLE_DOTTED
Dotted line rendering style.static java.lang.String
LINE_STYLE_SOLID
Solid line rendering style.protected double
terrainConformance
-
Constructor Summary
Constructors Constructor Description AbstractGraticuleLayer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addRenderable(java.lang.Object renderable, java.lang.String paramsKey)
protected void
clear(DrawContext dc)
protected double
computeAltitudeAboveGround(DrawContext dc)
protected LatLon
computeLabelOffset(DrawContext dc)
protected double
computeTerrainConformance(DrawContext dc)
protected void
computeTruncatedSegment(Position p1, Position p2, Sector sector, java.util.ArrayList<Position> positions)
protected java.lang.Object
createLineRenderable(java.lang.Iterable<? extends Position> positions, java.lang.String pathType)
void
doPreRender(DrawContext dc)
void
doRender(DrawContext dc)
protected Angle
getDeltaLongitude(LatLon p1, Angle longitude)
java.awt.Color
getGraticuleLineColor(java.lang.String key)
Returns the graticule line Color.java.lang.String
getGraticuleLineStyle(java.lang.String key)
Returns the graticule line rendering style.double
getGraticuleLineWidth(java.lang.String key)
Returns the graticule line width.java.awt.Color
getLabelColor(java.lang.String key)
Returns the graticule label Color.java.awt.Font
getLabelFont(java.lang.String key)
Returns the Font used for graticule labels.protected GraticuleRenderingParams
getRenderingParams(java.lang.String key)
java.lang.String
getRestorableState()
Returns an XML document string describing the object's state.protected Vec4
getSurfacePoint(DrawContext dc, Angle latitude, Angle longitude)
protected LatLon
greatCircleIntersectionAtLatitude(LatLon p1, LatLon p2, Angle latitude)
Computes the intersection point position between a great circle segment and a parallel.protected LatLon
greatCircleIntersectionAtLongitude(LatLon p1, LatLon p2, Angle longitude)
Computes the intersection point position between a great circle segment and a meridian.protected LatLon
greatCircleMidPoint(LatLon p1, LatLon p2)
boolean
isDrawGraticule(java.lang.String key)
Returns whether or not graticule lines will be rendered.boolean
isDrawLabels(java.lang.String key)
Returns whether or not graticule labels will be rendered.protected boolean
needsToUpdate(DrawContext dc)
Determines whether the grid should be updated.protected void
removeAllRenderables()
protected void
renderGraticule(DrawContext dc)
void
restoreState(java.lang.String stateInXml)
Restores the object's state to what is described in the specified XML document string.protected void
selectRenderables(DrawContext dc)
Select the visible grid elementsvoid
setDrawGraticule(boolean drawGraticule, java.lang.String key)
Sets whether or not graticule lines will be rendered.void
setDrawLabels(boolean drawLabels, java.lang.String key)
Sets whether or not graticule labels will be rendered.void
setGraticuleLineColor(java.awt.Color color, java.lang.String key)
Sets the graticule line Color.void
setGraticuleLineStyle(java.lang.String lineStyle, java.lang.String key)
Sets the graticule line rendering style.void
setGraticuleLineWidth(double lineWidth, java.lang.String key)
Sets the graticule line width.void
setLabelColor(java.awt.Color color, java.lang.String key)
Sets the graticule label Color.void
setLabelFont(java.awt.Font font, java.lang.String key)
Sets the Font used for graticule labels.protected void
setRenderingParams(java.lang.String key, GraticuleRenderingParams renderingParams)
-
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, dispose, doPick, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getOpacity, getScale, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, render, setDataFileStore, setEnabled, setExpiryTime, setMaxActiveAltitude, setMinActiveAltitude, setName, setNetworkRetrievalEnabled, setOpacity, setPickEnabled, setScreenCredit, toString
-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
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
-
Methods inherited from class java.lang.Object
clone, equals, 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
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
LINE_STYLE_SOLID
public static final java.lang.String LINE_STYLE_SOLID
Solid line rendering style. This style specifies that a line will be drawn without any breaks.
_________
is an example of a solid line.- See Also:
- Constant Field Values
-
LINE_STYLE_DASHED
public static final java.lang.String LINE_STYLE_DASHED
Dashed line rendering style. This style specifies that a line will be drawn as a series of long strokes, with space in between.
- - - - -
is an example of a dashed line.- See Also:
- Constant Field Values
-
LINE_STYLE_DOTTED
public static final java.lang.String LINE_STYLE_DOTTED
Dotted line rendering style. This style specifies that a line will be drawn as a series of evenly spaced "square" dots.
is an example of a dotted line.. . . . .
- See Also:
- Constant Field Values
-
gridElements
protected java.util.ArrayList<AbstractGraticuleLayer.GridElement> gridElements
-
graticuleSupport
protected GraticuleSupport graticuleSupport
-
terrainConformance
protected double terrainConformance
-
globe
protected Globe globe
-
lastEyePoint
protected Vec4 lastEyePoint
-
lastViewHeading
protected double lastViewHeading
-
lastViewPitch
protected double lastViewPitch
-
lastViewFOV
protected double lastViewFOV
-
lastVerticalExaggeration
protected double lastVerticalExaggeration
-
lastProjection
protected GeographicProjection lastProjection
-
frameTimeStamp
protected long frameTimeStamp
-
-
Method Detail
-
isDrawGraticule
public boolean isDrawGraticule(java.lang.String key)
Returns whether or not graticule lines will be rendered.- Parameters:
key
- the rendering parameters key.- Returns:
- true if graticule lines will be rendered; false otherwise.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setDrawGraticule
public void setDrawGraticule(boolean drawGraticule, java.lang.String key)
Sets whether or not graticule lines will be rendered.- Parameters:
drawGraticule
- true to render graticule lines; false to disable rendering.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
getGraticuleLineColor
public java.awt.Color getGraticuleLineColor(java.lang.String key)
Returns the graticule line Color.- Parameters:
key
- the rendering parameters key.- Returns:
- Color used to render graticule lines.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setGraticuleLineColor
public void setGraticuleLineColor(java.awt.Color color, java.lang.String key)
Sets the graticule line Color.- Parameters:
color
- Color that will be used to render graticule lines.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
- ifcolor
orkey
is null.
-
getGraticuleLineWidth
public double getGraticuleLineWidth(java.lang.String key)
Returns the graticule line width.- Parameters:
key
- the rendering parameters key.- Returns:
- width of the graticule lines.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setGraticuleLineWidth
public void setGraticuleLineWidth(double lineWidth, java.lang.String key)
Sets the graticule line width.- Parameters:
lineWidth
- width of the graticule lines.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
getGraticuleLineStyle
public java.lang.String getGraticuleLineStyle(java.lang.String key)
Returns the graticule line rendering style.- Parameters:
key
- the rendering parameters key.- Returns:
- rendering style of the graticule lines.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setGraticuleLineStyle
public void setGraticuleLineStyle(java.lang.String lineStyle, java.lang.String key)
Sets the graticule line rendering style.- Parameters:
lineStyle
- rendering style of the graticule lines. One of LINE_STYLE_PLAIN, LINE_STYLE_DASHED, or LINE_STYLE_DOTTED.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
- iflineStyle
orkey
is null.
-
isDrawLabels
public boolean isDrawLabels(java.lang.String key)
Returns whether or not graticule labels will be rendered.- Parameters:
key
- the rendering parameters key.- Returns:
- true if graticule labels will be rendered; false otherwise.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setDrawLabels
public void setDrawLabels(boolean drawLabels, java.lang.String key)
Sets whether or not graticule labels will be rendered.- Parameters:
drawLabels
- true to render graticule labels; false to disable rendering.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
getLabelColor
public java.awt.Color getLabelColor(java.lang.String key)
Returns the graticule label Color.- Parameters:
key
- the rendering parameters key.- Returns:
- Color used to render graticule labels.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setLabelColor
public void setLabelColor(java.awt.Color color, java.lang.String key)
Sets the graticule label Color.- Parameters:
color
- Color that will be used to render graticule labels.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
- ifcolor
orkey
is null.
-
getLabelFont
public java.awt.Font getLabelFont(java.lang.String key)
Returns the Font used for graticule labels.- Parameters:
key
- the rendering parameters key.- Returns:
- Font used to render graticule labels.
- Throws:
java.lang.IllegalArgumentException
-key
is null.
-
setLabelFont
public void setLabelFont(java.awt.Font font, java.lang.String key)
Sets the Font used for graticule labels.- Parameters:
font
- Font that will be used to render graticule labels.key
- the rendering parameters key.- Throws:
java.lang.IllegalArgumentException
- iffont
orkey
is null.
-
getRestorableState
public java.lang.String getRestorableState()
Description copied from interface:Restorable
Returns an XML document string describing the object's state. This state can be restored later by callingrestoreState
and passing the XML document.- Specified by:
getRestorableState
in interfaceRestorable
- Overrides:
getRestorableState
in classAbstractLayer
- Returns:
- an XML document string describing the object's state.
-
restoreState
public void restoreState(java.lang.String stateInXml)
Description copied from interface:Restorable
Restores the object's state to what is described in the specified XML document string.- Specified by:
restoreState
in interfaceRestorable
- Overrides:
restoreState
in classAbstractLayer
- Parameters:
stateInXml
- an XML document string describing an object's state.
-
getRenderingParams
protected GraticuleRenderingParams getRenderingParams(java.lang.String key)
-
setRenderingParams
protected void setRenderingParams(java.lang.String key, GraticuleRenderingParams renderingParams)
-
addRenderable
protected void addRenderable(java.lang.Object renderable, java.lang.String paramsKey)
-
removeAllRenderables
protected void removeAllRenderables()
-
doPreRender
public void doPreRender(DrawContext dc)
- Overrides:
doPreRender
in classAbstractLayer
-
doRender
public void doRender(DrawContext dc)
- Specified by:
doRender
in classAbstractLayer
-
renderGraticule
protected void renderGraticule(DrawContext dc)
-
selectRenderables
protected void selectRenderables(DrawContext dc)
Select the visible grid elements- Parameters:
dc
- the currentDrawContext
.
-
needsToUpdate
protected boolean needsToUpdate(DrawContext dc)
Determines whether the grid should be updated. It returns true if:- the eye has moved more than 1% of its altitude above ground
- the view FOV, heading or pitch have changed more than 1 degree
- vertical exaggeration has changed
- Parameters:
dc
- the currentDrawContext
.- Returns:
- true if the graticule should be updated.
-
clear
protected void clear(DrawContext dc)
-
computeTerrainConformance
protected double computeTerrainConformance(DrawContext dc)
-
computeLabelOffset
protected LatLon computeLabelOffset(DrawContext dc)
-
createLineRenderable
protected java.lang.Object createLineRenderable(java.lang.Iterable<? extends Position> positions, java.lang.String pathType)
-
getSurfacePoint
protected Vec4 getSurfacePoint(DrawContext dc, Angle latitude, Angle longitude)
-
computeAltitudeAboveGround
protected double computeAltitudeAboveGround(DrawContext dc)
-
computeTruncatedSegment
protected void computeTruncatedSegment(Position p1, Position p2, Sector sector, java.util.ArrayList<Position> positions)
-
greatCircleIntersectionAtLongitude
protected LatLon greatCircleIntersectionAtLongitude(LatLon p1, LatLon p2, Angle longitude)
Computes the intersection point position between a great circle segment and a meridian.- Parameters:
p1
- the great circle segment start position.p2
- the great circle segment end position.longitude
- the meridian longitudeAngle
- Returns:
- the intersection
Position
or null if there was no intersection found.
-
greatCircleIntersectionAtLatitude
protected LatLon greatCircleIntersectionAtLatitude(LatLon p1, LatLon p2, Angle latitude)
Computes the intersection point position between a great circle segment and a parallel.- Parameters:
p1
- the great circle segment start position.p2
- the great circle segment end position.latitude
- the parallel latitudeAngle
- Returns:
- the intersection
Position
or null if there was no intersection found.
-
-