Class DirectedPath
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.AbstractShape
-
- gov.nasa.worldwind.render.Path
-
- gov.nasa.worldwindx.examples.util.DirectedPath
-
- All Implemented Interfaces:
AVList
,Draggable
,MessageListener
,Exportable
,ExtentHolder
,Movable
,Movable2
,Attributable
,GeographicExtent
,Highlightable
,OrderedRenderable
,PreRenderable
,Renderable
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
public class DirectedPath extends Path
APath
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 case 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
Fields Modifier and Type Field Description 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 java.lang.String
ARROWS_EXTENT
protected static java.lang.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_NUM_SUBSEGMENTS, DEFAULT_PATH_INTERIOR_MATERIAL, DEFAULT_PATH_OUTLINE_MATERIAL, DEFAULT_PATH_TYPE, DEFAULT_TERRAIN_CONFORMANCE, drawVerticals, extrude, followTerrain, measurer, numPositions, numSubsegments, offset, pathType, pickPositionColors, positionColors, positions, positionsSpanDateline, 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_INTERIOR_MATERIAL, DEFAULT_OUTLINE_MATERIAL, DEFAULT_OUTLINE_PICK_WIDTH, defaultAttributes, delegateOwner, dragEnabled, draggableSupport, enableBatchPicking, enableBatchRendering, enableDepthOffset, highlightAttrs, highlighted, maxExpiryTime, minExpiryTime, normalAttrs, outlinePickWidth, outlineShapeRenderer, pickLayer, pickSupport, referencePosition, sector, shapeDataCache, surfaceShape, VBO_THRESHOLD, viewDistanceExpiration, visible
-
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description DirectedPath()
Creates a path with no 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.DirectedPath(java.lang.Iterable<? extends Position> positions)
Creates a path with specified positions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
computeArrowheadGeometry(DrawContext dc, int poleA, int poleB, Vec4 polePtA, Vec4 polePtB, java.nio.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, java.util.List<Position> positions, Path.PathData pathData)
Computes the shape's model-coordinate path from a list of positions.protected SurfaceShape
createSurfaceShape()
Returns aSurfaceShape
that corresponds to this Path and is used for drawing on 2D globes.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
intersectsFrustum(DrawContext dc)
Determines whether this shape intersects the view frustum.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.protected void
updateSurfaceShape()
Sets surface shape parameters prior to picking and rendering the 2D shape used to represent this shape on 2D globes.-
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, getLength, getLength, getMeasurer, getNumSubsegments, getOrdinal, getPathType, getPosition, getPositionColors, getPositions, getReferencePosition, getSector, getShowPositionsScale, getShowPositionsThreshold, getTerrainConformance, initialize, intersect, isDrawVerticals, isExtrude, isFollowTerrain, isOrderedRenderableValid, isSegmentVisible, isShowPositions, isSmall, isSurfacePath, isSurfacePath, makeClosed, makePath2DIndices, makePositions, makeSegment, makeTessellatedPositions, move, moveTo, moveTo, mustApplyLighting, mustApplyTexture, mustDrawInterior, mustRegenerateGeometry, prepareToDrawPoints, reset, resolvePickedPosition, setDrawVerticals, setExtrude, setFollowTerrain, setNumSubsegments, setOffset, setPathType, setPositionColors, setPositions, setShowPositions, setShowPositionsScale, setShowPositionsThreshold, setSurfacePath, setTerrainConformance, shouldUseVBOs
-
Methods inherited from class gov.nasa.worldwind.render.AbstractShape
beginDrawing, checkViewDistanceExpiration, clearCachedVbos, computeExtentFromPositions, computePoint, computePoint, countTriangleVertices, createPickedObject, doDrag, doGetRestorableState, doRestoreState, drag, drawBatched, drawInterior, drawOrderedRenderable, drawOutline, endDrawing, export, exportAsKML, getActiveAttributes, getAltitudeMode, getAttributes, getCurrentData, getDelegateOwner, getDistanceFromEye, getExtent, getGeometryRegenerationInterval, getHighlightAttributes, getOutlinePickWidth, getReferencePoint, getRestorableState, getVboIds, isDragEnabled, isEnableBatchPicking, isEnableBatchRendering, isEnableDepthOffset, isExportFormatSupported, isHighlighted, isTerrainDependent, isViewDistanceExpiration, isVisible, makeOrderedRenderable, makeTexture, mustApplyLighting, mustCreateNormals, mustCreateNormals, mustDrawOutline, pick, prepareToDrawInterior, prepareToDrawOutline, preRender, render, restoreState, setAltitudeMode, setAttributes, setDelegateOwner, setDragEnabled, 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, 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
-
DEFAULT_ARROW_LENGTH
public static final double DEFAULT_ARROW_LENGTH
Default arrow length, in meters.- See Also:
- Constant Field Values
-
DEFAULT_ARROW_ANGLE
public static final Angle DEFAULT_ARROW_ANGLE
Default arrow angle.
-
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
-
arrowLength
protected double arrowLength
The length, in meters, of the arrowhead, from tip to base.
-
arrowAngle
protected Angle arrowAngle
The angle of the arrowhead tip.
-
maxScreenSize
protected double maxScreenSize
The maximum screen size, in pixels, of the direction arrowheads.
-
ARROWS_KEY
protected static final java.lang.String ARROWS_KEY
- See Also:
- Constant Field Values
-
ARROWS_EXTENT
protected static final java.lang.String ARROWS_EXTENT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DirectedPath
public DirectedPath()
Creates a path with no positions.
-
DirectedPath
public DirectedPath(java.lang.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:
java.lang.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:
java.lang.IllegalArgumentException
- if positions is null.
-
-
Method Detail
-
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.
-
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.
-
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 thanmaxScreenSize
pixels.- Returns:
- The maximum screen size, in pixels, of the direction arrowheads, measured tip to base.
-
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 thanmaxScreenSize
pixels.- Parameters:
maxScreenSize
- the maximum screen size, in pixels, of the direction arrowheads, measured tip to base.
-
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.
-
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.
-
intersectsFrustum
protected boolean intersectsFrustum(DrawContext dc)
Description copied from class:AbstractShape
Determines whether this shape intersects the view frustum.A
AbstractShape.AbstractShapeData
must be current when this method is called.- Overrides:
intersectsFrustum
in classAbstractShape
- Parameters:
dc
- the current draw context.- Returns:
- true if this shape intersects the frustum, otherwise false.
-
computePath
protected void computePath(DrawContext dc, java.util.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 classPath
- Parameters:
dc
- the current draw context.positions
- the positions to create a path for.pathData
- the current globe-specific path data.
-
createSurfaceShape
protected SurfaceShape createSurfaceShape()
Returns aSurfaceShape
that corresponds to this Path and is used for drawing on 2D globes.Overridden to return a
DirectedSurfacePolyline
.- Overrides:
createSurfaceShape
in classPath
- Returns:
- The surface shape to represent this Path on a 2D globe.
-
updateSurfaceShape
protected void updateSurfaceShape()
Sets surface shape parameters prior to picking and rendering the 2D shape used to represent this shape on 2D globes. Subclasses should override this method if they need to update more than the highlighted state, visibility state and delegate owner.Overridden to update the arrow properties of
DirectedSurfacePolyline
.- Overrides:
updateSurfaceShape
in classPath
-
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.
-
computeArrowheadGeometry
protected void computeArrowheadGeometry(DrawContext dc, int poleA, int poleB, Vec4 polePtA, Vec4 polePtB, java.nio.FloatBuffer buffer, Path.PathData pathData)
Compute the geometry of a direction arrow between two points.- Parameters:
dc
- current draw contextpoleA
- The first pole.poleB
- The second pole.polePtA
- the first pole position. This is one of the application defined path positions.polePtB
- second pole positionbuffer
- buffer in which to place computed pointspathData
- the current globe-specific path data.
-
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 contextarrowPt
- point at which to draw direction arrownumPixels
- the number of pixels which is considered to be "small"- Returns:
true
if an arrow drawn atarrowPt
would occupy less than or equal tonumPixels
.
-
doDrawOutline
protected void doDrawOutline(DrawContext dc)
Draws this shape's outline. Called immediately after callingAbstractShape.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 classPath
- Parameters:
dc
- Current draw context.
-
drawDirectionArrows
protected void drawDirectionArrows(DrawContext dc, Path.PathData pathData)
Draws this DirectedPath's direction arrows. Called fromdoDrawOutline(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.
-
-