NASA World Wind

gov.nasa.worldwind.layers
Class AbstractGraticuleLayer

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.AbstractGraticuleLayer
All Implemented Interfaces:
AVList, Disposable, MessageListener, Layer, Restorable, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
LatLonGraticuleLayer, UTMBaseGraticuleLayer

public class AbstractGraticuleLayer
extends AbstractLayer

Displays a graticule.


Nested Class Summary
protected  class AbstractGraticuleLayer.GridElement
           
 
Field Summary
protected  Globe globe
           
protected  GraticuleSupport graticuleSupport
           
protected  ArrayList<AbstractGraticuleLayer.GridElement> gridElements
           
protected  Vec4 lastEyePoint
           
protected  double lastVerticalExaggeration
           
protected  double lastViewFOV
           
protected  double lastViewHeading
           
protected  double lastViewPitch
           
static String LINE_STYLE_DASHED
          Dashed line rendering style.
static String LINE_STYLE_DOTTED
          Dotted line rendering style.
static String LINE_STYLE_SOLID
          Solid line rendering style.
protected  double polylineTerrainConformance
           
protected  boolean useSurfaceShapes
           
protected  Frustum viewFrustum
           
 
Constructor Summary
AbstractGraticuleLayer()
           
 
Method Summary
protected  void addRenderable(Object renderable, 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, ArrayList<Position> positions)
           
protected  Object createLineRenderable(Iterable<? extends LatLon> positions, int pathType)
           
 void doPreRender(DrawContext dc)
           
 void doRender(DrawContext dc)
           
protected  Angle getDeltaLongitude(LatLon p1, Angle longitude)
           
 Color getGraticuleLineColor(String key)
          Returns the graticule line Color.
 String getGraticuleLineStyle(String key)
          Returns the graticule line rendering style.
 double getGraticuleLineWidth(String key)
          Returns the graticule line width.
 Color getLabelColor(String key)
          Returns the graticule label Color.
 Font getLabelFont(String key)
          Returns the Font used for graticule labels.
protected  GraticuleRenderingParams getRenderingParams(String key)
           
 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(String key)
          Returns whether or not graticule lines will be rendered.
 boolean isDrawLabels(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 preRenderGraticule(DrawContext dc)
           
protected  void removeAllRenderables()
           
protected  void renderGraticule(DrawContext dc)
           
 void restoreState(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 elements
 void setDrawGraticule(boolean drawGraticule, String key)
          Sets whether or not graticule lines will be rendered.
 void setDrawLabels(boolean drawLabels, String key)
          Sets whether or not graticule labels will be rendered.
 void setGraticuleLineColor(Color color, String key)
          Sets the graticule line Color.
 void setGraticuleLineStyle(String lineStyle, String key)
          Sets the graticule line rendering style.
 void setGraticuleLineWidth(double lineWidth, String key)
          Sets the graticule line width.
 void setLabelColor(Color color, String key)
          Sets the graticule label Color.
 void setLabelFont(Font font, String key)
          Sets the Font used for graticule labels.
protected  void setRenderingParams(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, 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
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

globe

protected Globe globe

graticuleSupport

protected GraticuleSupport graticuleSupport

gridElements

protected ArrayList<AbstractGraticuleLayer.GridElement> gridElements

lastEyePoint

protected Vec4 lastEyePoint

lastVerticalExaggeration

protected double lastVerticalExaggeration

lastViewFOV

protected double lastViewFOV

lastViewHeading

protected double lastViewHeading

lastViewPitch

protected double lastViewPitch

LINE_STYLE_DASHED

public static final 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 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

LINE_STYLE_SOLID

public static final 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

polylineTerrainConformance

protected double polylineTerrainConformance

useSurfaceShapes

protected boolean useSurfaceShapes

viewFrustum

protected Frustum viewFrustum
Constructor Detail

AbstractGraticuleLayer

public AbstractGraticuleLayer()
Method Detail

addRenderable

protected void addRenderable(Object renderable,
                             String paramsKey)

clear

protected void clear(DrawContext dc)

computeAltitudeAboveGround

protected double computeAltitudeAboveGround(DrawContext dc)

computeLabelOffset

protected LatLon computeLabelOffset(DrawContext dc)

computeTerrainConformance

protected double computeTerrainConformance(DrawContext dc)

computeTruncatedSegment

protected void computeTruncatedSegment(Position p1,
                                       Position p2,
                                       Sector sector,
                                       ArrayList<Position> positions)

createLineRenderable

protected Object createLineRenderable(Iterable<? extends LatLon> positions,
                                      int pathType)

doPreRender

public void doPreRender(DrawContext dc)
Overrides:
doPreRender in class AbstractLayer

doRender

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

getDeltaLongitude

protected Angle getDeltaLongitude(LatLon p1,
                                  Angle longitude)

getGraticuleLineColor

public Color getGraticuleLineColor(String key)
Returns the graticule line Color.

Parameters:
key - the rendering parameters key.
Returns:
Color used to render graticule lines.
Throws:
IllegalArgumentException - key is null.

getGraticuleLineStyle

public String getGraticuleLineStyle(String key)
Returns the graticule line rendering style.

Parameters:
key - the rendering parameters key.
Returns:
rendering style of the graticule lines.
Throws:
IllegalArgumentException - key is null.

getGraticuleLineWidth

public double getGraticuleLineWidth(String key)
Returns the graticule line width.

Parameters:
key - the rendering parameters key.
Returns:
width of the graticule lines.
Throws:
IllegalArgumentException - key is null.

getLabelColor

public Color getLabelColor(String key)
Returns the graticule label Color.

Parameters:
key - the rendering parameters key.
Returns:
Color used to render graticule labels.
Throws:
IllegalArgumentException - key is null.

getLabelFont

public Font getLabelFont(String key)
Returns the Font used for graticule labels.

Parameters:
key - the rendering parameters key.
Returns:
Font used to render graticule labels.
Throws:
IllegalArgumentException - key is null.

getRenderingParams

protected GraticuleRenderingParams getRenderingParams(String key)

getRestorableState

public String getRestorableState()
Description copied from interface: Restorable
Returns an XML document string describing the object's state. This state can be restored later by calling restoreState and passing the XML document.

Specified by:
getRestorableState in interface Restorable
Overrides:
getRestorableState in class AbstractLayer
Returns:
an XML document string describing the object's state.

getSurfacePoint

protected Vec4 getSurfacePoint(DrawContext dc,
                               Angle latitude,
                               Angle longitude)

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 latitude Angle
Returns:
the intersection Position or null if there was no intersection found.

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 longitude Angle
Returns:
the intersection Position or null if there was no intersection found.

greatCircleMidPoint

protected LatLon greatCircleMidPoint(LatLon p1,
                                     LatLon p2)

isDrawGraticule

public boolean isDrawGraticule(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:
IllegalArgumentException - key is null.

isDrawLabels

public boolean isDrawLabels(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:
IllegalArgumentException - key is null.

needsToUpdate

protected boolean needsToUpdate(DrawContext dc)
Determines whether the grid should be updated. It returns true if:
Parameters:
dc - the current DrawContext.
Returns:
true if the graticule should be updated.

preRenderGraticule

protected void preRenderGraticule(DrawContext dc)

removeAllRenderables

protected void removeAllRenderables()

renderGraticule

protected void renderGraticule(DrawContext dc)

restoreState

public void restoreState(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 interface Restorable
Overrides:
restoreState in class AbstractLayer
Parameters:
stateInXml - an XML document string describing an object's state.

selectRenderables

protected void selectRenderables(DrawContext dc)
Select the visible grid elements

Parameters:
dc - the current DrawContext.

setDrawGraticule

public void setDrawGraticule(boolean drawGraticule,
                             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:
IllegalArgumentException - key is null.

setDrawLabels

public void setDrawLabels(boolean drawLabels,
                          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:
IllegalArgumentException - key is null.

setGraticuleLineColor

public void setGraticuleLineColor(Color color,
                                  String key)
Sets the graticule line Color.

Parameters:
color - Color that will be used to render graticule lines.
key - the rendering parameters key.
Throws:
IllegalArgumentException - if color or key is null.

setGraticuleLineStyle

public void setGraticuleLineStyle(String lineStyle,
                                  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:
IllegalArgumentException - if lineStyle or key is null.

setGraticuleLineWidth

public void setGraticuleLineWidth(double lineWidth,
                                  String key)
Sets the graticule line width.

Parameters:
lineWidth - width of the graticule lines.
key - the rendering parameters key.
Throws:
IllegalArgumentException - key is null.

setLabelColor

public void setLabelColor(Color color,
                          String key)
Sets the graticule label Color.

Parameters:
color - Color that will be used to render graticule labels.
key - the rendering parameters key.
Throws:
IllegalArgumentException - if color or key is null.

setLabelFont

public void setLabelFont(Font font,
                         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:
IllegalArgumentException - if font or key is null.

setRenderingParams

protected void setRenderingParams(String key,
                                  GraticuleRenderingParams renderingParams)

NASA World Wind