NASA World Wind

gov.nasa.worldwind.render
Class Polyline

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.render.Polyline
All Implemented Interfaces:
AVList, ExtentHolder, MeasurableLength, Movable, OrderedRenderable, Renderable, Restorable

public class Polyline
extends AVListImpl
implements Renderable, OrderedRenderable, Movable, Restorable, MeasurableLength, ExtentHolder


Nested Class Summary
protected static class Polyline.ExtentInfo
           
 
Field Summary
static int ANTIALIAS_DONT_CARE
           
static int ANTIALIAS_FASTEST
           
static int ANTIALIAS_NICEST
           
protected  int antiAliasHint
           
protected  boolean closed
           
protected  Color color
           
protected  List<List<Vec4>> currentSpans
           
protected  Object delegateOwner
           
protected  HashMap<Globe,Polyline.ExtentInfo> extents
           
protected  double eyeDistance
           
protected  boolean filled
           
protected  boolean followTerrain
           
protected  long frameNumber
           
protected  long geomGenTimeStamp
           
protected  double geomGenVE
           
static int GREAT_CIRCLE
           
protected  Color highlightColor
           
protected  boolean highlighted
           
static int LINEAR
           
protected  double lineWidth
           
static int LOXODROME
           
protected  LengthMeasurer measurer
           
protected  int numSubsegments
           
protected  double offset
           
protected  int pathType
           
protected  Layer pickLayer
           
protected  PickSupport pickSupport
           
protected  ArrayList<Position> positions
           
protected  Vec4 referenceCenterPoint
           
static int RHUMB_LINE
           
protected  int stippleFactor
           
protected  short stipplePattern
           
protected  double terrainConformance
           
 
Constructor Summary
Polyline()
           
Polyline(Iterable<? extends LatLon> positions, double elevation)
           
Polyline(Iterable<? extends Position> positions)
           
 
Method Summary
protected  ArrayList<Vec4> addPointToSpan(Vec4 p, ArrayList<Vec4> span)
           
protected  void addSpan(ArrayList<Vec4> span)
           
protected  ArrayList<Vec4> clipAndAdd(DrawContext dc, Vec4 ptA, Vec4 ptB, ArrayList<Vec4> span)
           
protected static double[] computeElevationExtremes(Iterable<? extends Position> positions)
           
protected  Extent computeExtent(DrawContext dc)
           
protected  Extent computeExtent(Globe globe, double verticalExaggeration)
           
protected  Vec4 computePoint(DrawContext dc, Position pos, boolean applyOffset)
           
protected  void computeReferenceCenter(DrawContext dc)
           
protected  double computeSegmentLength(DrawContext dc, Position posA, Position posB)
           
protected  void draw(DrawContext dc)
          If the scene controller is rendering ordered renderables, this method draws this placemark's image as an ordered renderable.
protected  void drawOrderedRenderable(DrawContext dc)
           
 int getAntiAliasHint()
           
 Color getColor()
           
 Object getDelegateOwner()
          Returns the delegate owner of this Polyline.
 double getDistanceFromEye()
          Returns the ordered renderable's distance from the current view's eye point.
 Extent getExtent(DrawContext dc)
          Returns this Polyline's enclosing volume as an Extent in model coordinates, given a specified DrawContext.
 Extent getExtent(Globe globe, double verticalExaggeration)
          Returns this Polyline's enclosing volume as an Extent in model coordinates, given a specified Globe and vertical exaggeration (see SceneController.getVerticalExaggeration().
 Color getHighlightColor()
           
 double getLength()
          Returns the length of the line as drawn.
 double getLength(Globe globe)
          Returns the object's length in meters.
 double getLineWidth()
           
 LengthMeasurer getMeasurer()
           
 int getNumSubsegments()
           
 double getOffset()
           
 int getPathType()
           
 String getPathTypeString()
           
 Iterable<Position> getPositions()
           
 Position getReferencePosition()
          A position associated with the object that indicates its aggregate geographic position.
 String getRestorableState()
          Returns an XML state document String describing the public attributes of this Polyline.
 int getStippleFactor()
           
 short getStipplePattern()
           
 double getTerrainConformance()
           
protected  boolean intersectsFrustum(DrawContext dc)
          Indicates whether the shape is visible in the current view.
 boolean isClosed()
           
 boolean isFilled()
           
 boolean isFollowTerrain()
           
 boolean isHighlighted()
           
protected  boolean isSegmentVisible(DrawContext dc, Position posA, Position posB, Vec4 ptA, Vec4 ptB)
           
protected  ArrayList<Vec4> makeSegment(DrawContext dc, Position posA, Position posB, Vec4 ptA, Vec4 ptB)
           
protected  void makeVertices(DrawContext dc)
           
 void move(Position delta)
          Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
 void moveTo(Position position)
          Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
 void pick(DrawContext dc, Point pickPoint)
          Executes a pick of the ordered renderable.
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void restoreState(String stateInXml)
          Restores publicly settable attribute values found in the specified XML state document String.
 void setAntiAliasHint(int hint)
           
 void setClosed(boolean closed)
           
 void setColor(Color color)
           
 void setDelegateOwner(Object owner)
          Specifies the delegate owner of this Polyline.
 void setFilled(boolean filled)
           
 void setFollowTerrain(boolean followTerrain)
          Indicates whether the path should follow the terrain's surface.
 void setHighlightColor(Color highlightColor)
           
 void setHighlighted(boolean highlighted)
           
 void setLineWidth(double lineWidth)
           
 void setNumSubsegments(int numSubsegments)
          Specifies the number of intermediate segments to draw for each segment between positions.
 void setOffset(double offset)
          Specifies an offset, in meters, to add to the path points when the path's follow-terrain attribute is true.
 void setPathType(int pathType)
          Sets the type of path to draw, one of GREAT_CIRCLE, which draws each segment of the path as a great circle, LINEAR, which determines the intermediate positions between segments by interpolating the segment endpoints, or RHUMB_LINE, which draws each segment of the path as a line of constant heading.
 void setPathType(String pathType)
          Sets the type of path to draw, one of AVKey.GREAT_CIRCLE, which draws each segment of the path as a great circle, AVKey.LINEAR, which determines the intermediate positions between segments by interpolating the segment endpoints, or AVKey.RHUMB_LINE, which draws each segment of the path as a line of constant heading.
 void setPositions(Iterable<? extends LatLon> inPositions, double altitude)
          Sets the paths positions as latitude and longitude values at a constant altitude.
 void setPositions(Iterable<? extends Position> inPositions)
          Specifies the path's positions.
 void setStippleFactor(int stippleFactor)
          Sets the stipple factor for specifying line types other than solid.
 void setStipplePattern(short stipplePattern)
          Sets the stipple pattern for specifying line types other than solid.
 void setTerrainConformance(double terrainConformance)
          Specifies the precision to which the path follows the terrain when the follow-terrain attribute is true.
 
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
 

Field Detail

ANTIALIAS_DONT_CARE

public static final int ANTIALIAS_DONT_CARE
See Also:
Constant Field Values

ANTIALIAS_FASTEST

public static final int ANTIALIAS_FASTEST
See Also:
Constant Field Values

ANTIALIAS_NICEST

public static final int ANTIALIAS_NICEST
See Also:
Constant Field Values

antiAliasHint

protected int antiAliasHint

closed

protected boolean closed

color

protected Color color

currentSpans

protected List<List<Vec4>> currentSpans

delegateOwner

protected Object delegateOwner

extents

protected HashMap<Globe,Polyline.ExtentInfo> extents

eyeDistance

protected double eyeDistance

filled

protected boolean filled

followTerrain

protected boolean followTerrain

frameNumber

protected long frameNumber

geomGenTimeStamp

protected long geomGenTimeStamp

geomGenVE

protected double geomGenVE

GREAT_CIRCLE

public static final int GREAT_CIRCLE
See Also:
Constant Field Values

highlightColor

protected Color highlightColor

highlighted

protected boolean highlighted

LINEAR

public static final int LINEAR
See Also:
Constant Field Values

lineWidth

protected double lineWidth

LOXODROME

public static final int LOXODROME
See Also:
Constant Field Values

measurer

protected LengthMeasurer measurer

numSubsegments

protected int numSubsegments

offset

protected double offset

pathType

protected int pathType

pickLayer

protected Layer pickLayer

pickSupport

protected PickSupport pickSupport

positions

protected ArrayList<Position> positions

referenceCenterPoint

protected Vec4 referenceCenterPoint

RHUMB_LINE

public static final int RHUMB_LINE
See Also:
Constant Field Values

stippleFactor

protected int stippleFactor

stipplePattern

protected short stipplePattern

terrainConformance

protected double terrainConformance
Constructor Detail

Polyline

public Polyline()

Polyline

public Polyline(Iterable<? extends LatLon> positions,
                double elevation)

Polyline

public Polyline(Iterable<? extends Position> positions)
Method Detail

addPointToSpan

protected ArrayList<Vec4> addPointToSpan(Vec4 p,
                                         ArrayList<Vec4> span)

addSpan

protected void addSpan(ArrayList<Vec4> span)

clipAndAdd

protected ArrayList<Vec4> clipAndAdd(DrawContext dc,
                                     Vec4 ptA,
                                     Vec4 ptB,
                                     ArrayList<Vec4> span)

computeElevationExtremes

protected static double[] computeElevationExtremes(Iterable<? extends Position> positions)

computeExtent

protected Extent computeExtent(DrawContext dc)

computeExtent

protected Extent computeExtent(Globe globe,
                               double verticalExaggeration)

computePoint

protected Vec4 computePoint(DrawContext dc,
                            Position pos,
                            boolean applyOffset)

computeReferenceCenter

protected void computeReferenceCenter(DrawContext dc)

computeSegmentLength

protected double computeSegmentLength(DrawContext dc,
                                      Position posA,
                                      Position posB)

draw

protected void draw(DrawContext dc)
If the scene controller is rendering ordered renderables, this method draws this placemark's image as an ordered renderable. Otherwise the method determines whether this instance should be added to the ordered renderable list.

The Cartesian and screen points of the placemark are computed during the first call per frame and re-used in subsequent calls of that frame.

Parameters:
dc - the current draw context.

drawOrderedRenderable

protected void drawOrderedRenderable(DrawContext dc)

getAntiAliasHint

public int getAntiAliasHint()

getColor

public Color getColor()

getDelegateOwner

public Object getDelegateOwner()
Returns the delegate owner of this Polyline. If non-null, the returned object replaces the Polyline as the pickable object returned during picking. If null, the Polyline itself is the pickable object returned during picking.

Returns:
the object used as the pickable object returned during picking, or null to indicate that the Polyline is returned during picking.

getDistanceFromEye

public double getDistanceFromEye()
Description copied from interface: OrderedRenderable
Returns the ordered renderable's distance from the current view's eye point. Intended to be used only to sort a list of ordered renderables according to eye distance, and only during frame generation when a view is active.

Specified by:
getDistanceFromEye in interface OrderedRenderable
Returns:
the distance of the ordered renderable from the current view's eye point.

getExtent

public Extent getExtent(DrawContext dc)
Returns this Polyline's enclosing volume as an Extent in model coordinates, given a specified DrawContext. The returned Extent may be different than the Extent returned by calling getExtent(gov.nasa.worldwind.globes.Globe, double) with the DrawContext's Globe and vertical exaggeration. Additionally, this may cache the computed extent and is therefore potentially faster than calling getExtent(gov.nasa.worldwind.globes.Globe, double).

Parameters:
dc - the current DrawContext.
Returns:
this Polyline's Extent in model coordinates.
Throws:
IllegalArgumentException - if the DrawContext is null, or if the Globe held by the DrawContext is null.

getExtent

public Extent getExtent(Globe globe,
                        double verticalExaggeration)
Returns this Polyline's enclosing volume as an Extent in model coordinates, given a specified Globe and vertical exaggeration (see SceneController.getVerticalExaggeration().

Specified by:
getExtent in interface ExtentHolder
Parameters:
globe - the Globe this Polyline is related to.
verticalExaggeration - the vertical exaggeration to apply.
Returns:
this Polyline's Extent in model coordinates.
Throws:
IllegalArgumentException - if the Globe is null.

getHighlightColor

public Color getHighlightColor()

getLength

public double getLength()
Returns the length of the line as drawn. If the path follows the terrain, the length returned is the distance one would travel if on the surface. If the path does not follow the terrain, the length returned is the distance along the full length of the path at the path's elevations and current path type.

Returns:
the path's length in meters.

getLength

public double getLength(Globe globe)
Description copied from interface: MeasurableLength
Returns the object's length in meters. If the object conforms to terrain, the length is that along the terrain, including its hillsides and other undulations.

Specified by:
getLength in interface MeasurableLength
Parameters:
globe - The globe the object is related to.
Returns:
the object's length in meters.

getLineWidth

public double getLineWidth()

getMeasurer

public LengthMeasurer getMeasurer()

getNumSubsegments

public int getNumSubsegments()

getOffset

public double getOffset()

getPathType

public int getPathType()

getPathTypeString

public String getPathTypeString()

getPositions

public Iterable<Position> getPositions()

getReferencePosition

public Position getReferencePosition()
Description copied from interface: Movable
A position associated with the object that indicates its aggregate geographic position. The chosen position varies among implementers of this interface. For objects defined by a list of positions, the reference position is typically the first position in the list. For symmetric objects the reference position is often the center of the object. In many cases the object's reference position may be explicitly specified by the application.

Specified by:
getReferencePosition in interface Movable
Returns:
the object's reference position, or null if no reference position is available.

getRestorableState

public String getRestorableState()
Returns an XML state document String describing the public attributes of this Polyline.

Specified by:
getRestorableState in interface Restorable
Returns:
XML state document string describing this Polyline.

getStippleFactor

public int getStippleFactor()

getStipplePattern

public short getStipplePattern()

getTerrainConformance

public double getTerrainConformance()

intersectsFrustum

protected boolean intersectsFrustum(DrawContext dc)
Indicates whether the shape is visible in the current view.

Parameters:
dc - the draw context.
Returns:
true if the shape is visible, otherwise false.

isClosed

public boolean isClosed()

isFilled

public boolean isFilled()

isFollowTerrain

public boolean isFollowTerrain()

isHighlighted

public boolean isHighlighted()

isSegmentVisible

protected boolean isSegmentVisible(DrawContext dc,
                                   Position posA,
                                   Position posB,
                                   Vec4 ptA,
                                   Vec4 ptB)

makeSegment

protected ArrayList<Vec4> makeSegment(DrawContext dc,
                                      Position posA,
                                      Position posB,
                                      Vec4 ptA,
                                      Vec4 ptB)

makeVertices

protected void makeVertices(DrawContext dc)

move

public void move(Position delta)
Description copied from interface: Movable
Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
move in interface Movable
Parameters:
delta - the latitude and longitude to add to the shape's reference position.

moveTo

public void moveTo(Position position)
Description copied from interface: Movable
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
moveTo in interface Movable
Parameters:
position - the new position of the shape's reference position.

pick

public void pick(DrawContext dc,
                 Point pickPoint)
Description copied from interface: OrderedRenderable
Executes a pick of the ordered renderable.

Specified by:
pick in interface OrderedRenderable
Parameters:
dc - the current draw context.
pickPoint - the pick point.

render

public void render(DrawContext dc)
Description copied from interface: Renderable
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

restoreState

public void restoreState(String stateInXml)
Restores publicly settable attribute values found in the specified XML state document String. The document specified by stateInXml must be a well formed XML document String, or this will throw an IllegalArgumentException. Unknown structures in stateInXml are benign, because they will simply be ignored.

Specified by:
restoreState in interface Restorable
Parameters:
stateInXml - an XML document String describing a Polyline.
Throws:
IllegalArgumentException - If stateInXml is null, or if stateInXml is not a well formed XML document String.

setAntiAliasHint

public void setAntiAliasHint(int hint)

setClosed

public void setClosed(boolean closed)

setColor

public void setColor(Color color)

setDelegateOwner

public void setDelegateOwner(Object owner)
Specifies the delegate owner of this Polyline. If non-null, the delegate owner replaces the Polyline as the pickable object returned during picking. If null, the Polyline itself is the pickable object returned during picking.

Parameters:
owner - the object to use as the pickable object returned during picking, or null to return the Polyline.

setFilled

public void setFilled(boolean filled)

setFollowTerrain

public void setFollowTerrain(boolean followTerrain)
Indicates whether the path should follow the terrain's surface. If the value is true, the elevation values in this path's positions are ignored and the path is drawn on the terrain surface. Otherwise the path is drawn according to the elevations given in the path's positions. If following the terrain, the path may also have an offset. See setOffset(double);

Parameters:
followTerrain - true to follow the terrain, otherwise false.

setHighlightColor

public void setHighlightColor(Color highlightColor)

setHighlighted

public void setHighlighted(boolean highlighted)

setLineWidth

public void setLineWidth(double lineWidth)

setNumSubsegments

public void setNumSubsegments(int numSubsegments)
Specifies the number of intermediate segments to draw for each segment between positions. The end points of the intermediate segments are calculated according to the current path type and follow-terrain setting.

Parameters:
numSubsegments - the number of intermediate subsegments.

setOffset

public void setOffset(double offset)
Specifies an offset, in meters, to add to the path points when the path's follow-terrain attribute is true. See setFollowTerrain(boolean).

Parameters:
offset - the path pffset in meters.

setPathType

public void setPathType(int pathType)
Sets the type of path to draw, one of GREAT_CIRCLE, which draws each segment of the path as a great circle, LINEAR, which determines the intermediate positions between segments by interpolating the segment endpoints, or RHUMB_LINE, which draws each segment of the path as a line of constant heading.

Parameters:
pathType - the type of path to draw.
See Also:
Path Types

setPathType

public void setPathType(String pathType)
Sets the type of path to draw, one of AVKey.GREAT_CIRCLE, which draws each segment of the path as a great circle, AVKey.LINEAR, which determines the intermediate positions between segments by interpolating the segment endpoints, or AVKey.RHUMB_LINE, which draws each segment of the path as a line of constant heading.

Parameters:
pathType - the type of path to draw.
See Also:
Path Types

setPositions

public void setPositions(Iterable<? extends LatLon> inPositions,
                         double altitude)
Sets the paths positions as latitude and longitude values at a constant altitude.

Parameters:
inPositions - the latitudes and longitudes of the positions.
altitude - the elevation to assign each position.

setPositions

public void setPositions(Iterable<? extends Position> inPositions)
Specifies the path's positions.

Parameters:
inPositions - the path positions.

setStippleFactor

public void setStippleFactor(int stippleFactor)
Sets the stipple factor for specifying line types other than solid. See the OpenGL specification or programming guides for a description of this parameter. Stipple is also affected by the path's stipple pattern, setStipplePattern(short).

Parameters:
stippleFactor - the stipple factor.

setStipplePattern

public void setStipplePattern(short stipplePattern)
Sets the stipple pattern for specifying line types other than solid. See the OpenGL specification or programming guides for a description of this parameter. Stipple is also affected by the path's stipple factor, setStippleFactor(int).

Parameters:
stipplePattern - the stipple pattern.

setTerrainConformance

public void setTerrainConformance(double terrainConformance)
Specifies the precision to which the path follows the terrain when the follow-terrain attribute is true. The conformance value indicates the approximate length of each sub-segment of the path as it's drawn, in pixels. Lower values specify higher precision, but at the cost of performance.

Parameters:
terrainConformance - the path conformance in pixels.

NASA World Wind