NASA World Wind

gov.nasa.worldwindx.examples.util
Class DirectedPath

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.render.AbstractShape
              extended by gov.nasa.worldwind.render.Path
                  extended by gov.nasa.worldwindx.examples.util.DirectedPath
All Implemented Interfaces:
AVList, MessageListener, Exportable, ExtentHolder, Movable, GeographicExtent, Highlightable, OrderedRenderable, Renderable, Restorable, WWObject, PropertyChangeListener, EventListener

public class DirectedPath
extends Path

A Path that draws arrowheads between the path positions to indicate direction. All arrowheads are drawn at a constant geographic size (the arrows get smaller as the view moves away from the path, and larger as the view get closer to the path). One arrowhead is drawn on each path segment, unless the path segment is smaller than the arrowhead, in which the arrowhead is not drawn.


Nested Class Summary
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.Path
Path.PathData, Path.PathPickSupport, Path.PickablePositions, Path.PositionColors
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractShape
AbstractShape.AbstractShapeData
 
Field Summary
protected  Angle arrowAngle
          The angle of the arrowhead tip.
protected  double arrowLength
          The length, in meters, of the arrowhead, from tip to base.
protected static String ARROWS_KEY
           
static Angle DEFAULT_ARROW_ANGLE
          Default arrow angle.
static double DEFAULT_ARROW_LENGTH
          Default arrow length, in meters.
static double DEFAULT_MAX_SCREEN_SIZE
          Default maximum screen size of the arrowheads, in pixels.
protected  double maxScreenSize
          The maximum screen size, in pixels, of the direction arrowheads.
 
Fields inherited from class gov.nasa.worldwind.render.Path
DEFAULT_DRAW_POSITIONS_SCALE, DEFAULT_DRAW_POSITIONS_THRESHOLD, DEFAULT_INTERIOR_MATERIAL, DEFAULT_NUM_SUBSEGMENTS, DEFAULT_OUTLINE_MATERIAL, DEFAULT_PATH_TYPE, DEFAULT_TERRAIN_CONFORMANCE, drawVerticals, extrude, followTerrain, numPositions, numSubsegments, pathType, pickPositionColors, positionColors, positions, showPositions, showPositionsScale, showPositionsThreshold, SURFACE_PATH_DEPTH_OFFSET, terrainConformance
 
Fields inherited from class gov.nasa.worldwind.render.AbstractShape
activeAttributes, altitudeMode, BEogsh, currentData, DEFAULT_ALTITUDE_MODE, DEFAULT_GEOMETRY_GENERATION_INTERVAL, DEFAULT_HIGHLIGHT_MATERIAL, DEFAULT_OUTLINE_PICK_WIDTH, defaultAttributes, delegateOwner, enableBatchPicking, enableBatchRendering, enableDepthOffset, highlightAttrs, highlighted, maxExpiryTime, minExpiryTime, normalAttrs, outlinePickWidth, outlineShapeRenderer, pickLayer, pickSupport, referencePosition, sector, shapeDataCache, VBO_THRESHOLD, viewDistanceExpiration, visible
 
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
 
Constructor Summary
DirectedPath()
          Creates a path with no positions.
DirectedPath(Iterable<? extends Position> positions)
          Creates a path with specified positions.
DirectedPath(Position.PositionList positions)
          Creates a path with positions specified via a generic list.
DirectedPath(Position posA, Position posB)
          Creates a path between two positions.
 
Method Summary
protected  void computeArrowheadGeometry(DrawContext dc, Vec4 polePtA, Vec4 polePtB, Vec4 ptA, Vec4 ptB, double arrowLength, double arrowBase, FloatBuffer buffer, Path.PathData pathData)
          Compute the geometry of a direction arrow between two points.
protected  void computeDirectionArrows(DrawContext dc, Path.PathData pathData)
          Compute the geometry of the direction arrows.
protected  void computePath(DrawContext dc, List<Position> positions, Path.PathData pathData)
          Computes the shape's model-coordinate path from a list of positions.
protected  void doDrawOutline(DrawContext dc)
          Draws this shape's outline.
protected  void drawDirectionArrows(DrawContext dc, Path.PathData pathData)
          Draws this DirectedPath's direction arrows.
 Angle getArrowAngle()
          Indicates the angle of the direction arrowheads.
 double getArrowLength()
          Indicates the length, in meters, of the direction arrowheads, from base to tip.
 double getMaxScreenSize()
          Indicates the maximum screen size, in pixels, of the direction arrowheads.
protected  boolean isArrowheadSmall(DrawContext dc, Vec4 arrowPt, int numPixels)
          Determines if an direction arrow drawn a point will be less than a specified number of pixels.
 void setArrowAngle(Angle arrowAngle)
          Specifies the angle of the direction arrowheads.
 void setArrowLength(double arrowLength)
          Specifies the length, in meters, of the direction arrowheads, from base to tip.
 void setMaxScreenSize(double maxScreenSize)
          Specifies the maximum screen size, in pixels, of the direction arrowheads.
 
Methods inherited from class gov.nasa.worldwind.render.Path
addOrderedRenderable, addPickablePositions, addTessellatedPosition, appendTerrainPoint, computeAbsolutePoints, computeExtent, computeEyeDistance, computePointsRelativeToTerrain, computePositionCount, computeReferenceCenter, computeSegmentLength, createCacheEntry, determineActiveAttributes, doDrawInterior, doDrawInteriorVA, doDrawInteriorVBO, doDrawOrderedRenderable, doDrawOutlineVA, doDrawOutlineVBO, doExportAsKML, doMakeOrderedRenderable, drawPointsVA, drawPointsVBO, drawVerticalOutlineVA, drawVerticalOutlineVBO, fillVBO, getColor, getCurrentPathData, getDistanceMetric, getExtent, getNumSubsegments, getOrdinal, getPathType, getPosition, getPositionColors, getPositions, getReferencePosition, getSector, getShowPositionsScale, getShowPositionsThreshold, getTerrainConformance, initialize, intersect, isDrawVerticals, isExtrude, isFollowTerrain, isOrderedRenderableValid, isSegmentVisible, isShowPositions, isSmall, isSurfacePath, makePositions, makeSegment, makeTessellatedPositions, move, moveTo, mustApplyLighting, mustApplyTexture, mustDrawInterior, mustRegenerateGeometry, prepareToDrawPoints, reset, resolvePickedPosition, setDrawVerticals, setExtrude, setFollowTerrain, setNumSubsegments, setPathType, setPositionColors, setPositions, setShowPositions, setShowPositionsScale, setShowPositionsThreshold, setTerrainConformance, shouldUseVBOs
 
Methods inherited from class gov.nasa.worldwind.render.AbstractShape
beginDrawing, checkViewDistanceExpiration, clearCachedVbos, computeExtentFromPositions, computePoint, countTriangleVertices, createPickedObject, doGetRestorableState, doRestoreState, drawBatched, drawInterior, drawOrderedRenderable, drawOutline, endDrawing, export, exportAsKML, getActiveAttributes, getAltitudeMode, getAttributes, getCurrentData, getDelegateOwner, getDistanceFromEye, getExtent, getGeometryRegenerationInterval, getHighlightAttributes, getOutlinePickWidth, getReferencePoint, getRestorableState, getVboIds, intersectsFrustum, isEnableBatchPicking, isEnableBatchRendering, isEnableDepthOffset, isExportFormatSupported, isHighlighted, isTerrainDependent, isViewDistanceExpiration, isVisible, makeOrderedRenderable, makeTexture, mustApplyLighting, mustCreateNormals, mustCreateNormals, mustDrawOutline, pick, prepareToDrawInterior, prepareToDrawOutline, render, restoreState, setAltitudeMode, setAttributes, setDelegateOwner, setEnableBatchPicking, setEnableBatchRendering, setEnableDepthOffset, setGeometryRegenerationInterval, setHighlightAttributes, setHighlighted, setOutlinePickWidth, setReferencePosition, setViewDistanceExpiration, setVisible
 
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, toString, 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

arrowAngle

protected Angle arrowAngle
The angle of the arrowhead tip.


arrowLength

protected double arrowLength
The length, in meters, of the arrowhead, from tip to base.


ARROWS_KEY

protected static final String ARROWS_KEY
See Also:
Constant Field Values

DEFAULT_ARROW_ANGLE

public static final Angle DEFAULT_ARROW_ANGLE
Default arrow angle.


DEFAULT_ARROW_LENGTH

public static final double DEFAULT_ARROW_LENGTH
Default arrow length, in meters.

See Also:
Constant Field Values

DEFAULT_MAX_SCREEN_SIZE

public static final double DEFAULT_MAX_SCREEN_SIZE
Default maximum screen size of the arrowheads, in pixels.

See Also:
Constant Field Values

maxScreenSize

protected double maxScreenSize
The maximum screen size, in pixels, of the direction arrowheads.

Constructor Detail

DirectedPath

public DirectedPath()
Creates a path with no positions.


DirectedPath

public DirectedPath(Iterable<? extends Position> positions)
Creates a path with specified positions.

Note: If fewer than two positions is specified, no path is drawn.

Parameters:
positions - the path positions. This reference is retained by this shape; the positions are not copied. If any positions in the set change, Path.setPositions(Iterable) must be called to inform this shape of the change.
Throws:
IllegalArgumentException - if positions is null.

DirectedPath

public DirectedPath(Position.PositionList positions)
Creates a path with positions specified via a generic list.

Note: If fewer than two positions is specified, the path is not drawn.

Parameters:
positions - the path positions. This reference is retained by this shape; the positions are not copied. If any positions in the set change, Path.setPositions(Iterable) must be called to inform this shape of the change.
Throws:
IllegalArgumentException - if positions is null.

DirectedPath

public DirectedPath(Position posA,
                    Position posB)
Creates a path between two positions.

Parameters:
posA - the first position.
posB - the second position.
Throws:
IllegalArgumentException - if either position is null.
Method Detail

computeArrowheadGeometry

protected void computeArrowheadGeometry(DrawContext dc,
                                        Vec4 polePtA,
                                        Vec4 polePtB,
                                        Vec4 ptA,
                                        Vec4 ptB,
                                        double arrowLength,
                                        double arrowBase,
                                        FloatBuffer buffer,
                                        Path.PathData pathData)
Compute the geometry of a direction arrow between two points.

Parameters:
dc - current draw context
polePtA - the first pole position. This is one of the application defined path positions.
polePtB - second pole position
ptA - first position of the tessellated path midway between the poles
ptB - second position of the tessellated path midway between the poles
arrowLength - length of the arrowhead, in meters. The arrow head may not be rendered at full size, because is it may not exceed maxScreenSize pixels in length.
arrowBase - length of the arrowhead base
buffer - buffer in which to place computed points
pathData - the current globe-specific path data.

computeDirectionArrows

protected void computeDirectionArrows(DrawContext dc,
                                      Path.PathData pathData)
Compute the geometry of the direction arrows.

Parameters:
dc - current draw context.
pathData - the current globe-specific path data.

computePath

protected void computePath(DrawContext dc,
                           List<Position> positions,
                           Path.PathData pathData)
Computes the shape's model-coordinate path from a list of positions. Applies the path's terrain-conformance settings. Adds extrusion points -- those on the ground -- when the path is extruded.

Overridden to also compute the geometry of the direction arrows.

Overrides:
computePath in class Path
Parameters:
dc - the current draw context.
positions - the positions to create a path for.
pathData - the current globe-specific path data.

doDrawOutline

protected void doDrawOutline(DrawContext dc)
Draws this shape's outline. Called immediately after calling AbstractShape.prepareToDrawOutline(DrawContext, ShapeAttributes, ShapeAttributes), which establishes OpenGL state for lighting, blending, pick color and line attributes. Subclasses should execute the drawing commands specific to the type of shape.

A AbstractShape.AbstractShapeData must be current when this method is called.

If this Path is entirely located on the terrain, this applies an offset to the Path's depth values to to ensure it shows over the terrain. This does not apply a depth offset in any other case to avoid incorrectly drawing the path over objects it should be behind, including the terrain. In addition to applying a depth offset, this disables writing to the depth buffer to avoid causing subsequently drawn ordered renderables to incorrectly fail the depth test. Since this Path is located on the terrain, the terrain already provides the necessary depth values and we can be certain that other ordered renderables should appear on top of it.

Overridden to also draw direction arrows.

Overrides:
doDrawOutline in class Path
Parameters:
dc - Current draw context.

drawDirectionArrows

protected void drawDirectionArrows(DrawContext dc,
                                   Path.PathData pathData)
Draws this DirectedPath's direction arrows. Called from doDrawOutline(gov.nasa.worldwind.render.DrawContext) before drawing the Path's actual outline.

If this Path is entirely located on the terrain, this applies an offset to the arrow's depth values to to ensure they shows over the terrain. This does not apply a depth offset in any other case to avoid incorrectly drawing the arrows over objects they should be behind, including the terrain. In addition to applying a depth offset, this disables writing to the depth buffer to avoid causing subsequently drawn ordered renderables to incorrectly fail the depth test. Since the arrows are located on the terrain, the terrain already provides the necessary depth values and we can be certain that other ordered renderables should appear on top of them.

Parameters:
dc - Current draw context.
pathData - the current globe-specific path data.

getArrowAngle

public Angle getArrowAngle()
Indicates the angle of the direction arrowheads. A larger angle draws a fat arrowhead, and a smaller angle draws a narrow arrow head.

Returns:
The angle of the direction arrowhead tip.

getArrowLength

public double getArrowLength()
Indicates the length, in meters, of the direction arrowheads, from base to tip.

Returns:
The geographic length of the direction arrowheads.

getMaxScreenSize

public double getMaxScreenSize()
Indicates the maximum screen size, in pixels, of the direction arrowheads. The arrowheads are drawn a fixed geographic, but they are not allowed to get bigger than maxScreenSize pixels.

Returns:
The maximum screen size, in pixels, of the direction arrowheads, measured tip to base.

isArrowheadSmall

protected boolean isArrowheadSmall(DrawContext dc,
                                   Vec4 arrowPt,
                                   int numPixels)
Determines if an direction arrow drawn a point will be less than a specified number of pixels.

Parameters:
dc - current draw context
arrowPt - point at which to draw direction arrow
numPixels - the number of pixels which is considered to be "small"
Returns:
true if an arrow drawn at arrowPt would occupy less than or equal to numPixels.

setArrowAngle

public void setArrowAngle(Angle arrowAngle)
Specifies the angle of the direction arrowheads. A larger angle draws a fat arrowhead, and a smaller angle draws a narrow arrow.

Parameters:
arrowAngle - angle of the direction arrowhead tip. Valid values are between 0 degrees and 90 degrees.

setArrowLength

public void setArrowLength(double arrowLength)
Specifies the length, in meters, of the direction arrowheads, from base to tip.

Parameters:
arrowLength - length, in meters, of the direction arrowheads. The length must be greater than zero.

setMaxScreenSize

public void setMaxScreenSize(double maxScreenSize)
Specifies the maximum screen size, in pixels, of the direction arrowheads. The arrowheads are drawn at a fixed geographic size, but they will not allowed to get bigger than maxScreenSize pixels.

Parameters:
maxScreenSize - the maximum screen size, in pixels, of the direction arrowheads, measured tip to base.

NASA World Wind