public class LabeledPath extends Object implements Renderable
Annotation
on a specified path. The path itself is not drawn.
Instead, the annotation is drawn at the location that maximizes the annotation's visible area in the viewport. The
annotation is not drawn if the location list is null
, or if no location in the list is visible.
The caller must specify the screen annotation used to draw the path's label by calling setAnnotation(gov.nasa.worldwind.render.ScreenAnnotation)
. The path sets the specified annotation's screen point to
control the label's location, but otherwise does not modify the annotation.Modifier and Type | Field and Description |
---|---|
protected int |
altitudeMode
The altitude mode that defines how to interpret the altitude of locations that have an altitude component.
|
protected ScreenAnnotation |
annotation
The screen annotation to use as a label.
|
protected long |
frameNumber
The frame number used to place the label.
|
protected int |
labelLocationIndex
The index of the label's location in
locations , or -1 if the path has no label location. |
protected Iterable<? extends LatLon> |
locations
The labeled path's locations as specified by the application.
|
Constructor and Description |
---|
LabeledPath()
Creates a labeled path with no locations and no label annotation.
|
LabeledPath(Iterable<? extends LatLon> locations)
Creates a labeled path with specified locations.
|
LabeledPath(Iterable<? extends LatLon> locations,
ScreenAnnotation annotation)
Creates a labeled path with the specified label annotation and locations.
|
LabeledPath(ScreenAnnotation annotation)
Creates a labeled path with the specified label annotation and no locations.
|
Modifier and Type | Method and Description |
---|---|
protected Vec4 |
computePoint(DrawContext dc,
LatLon location)
Computes a model-coordinate point from a LatLon or Position, applying the path's altitude mode.
|
protected void |
determineLabelLocation(DrawContext dc)
Determines the screen location to place the label at, and stores the the index of the corresponding location in
labelLocationIndex . |
protected void |
drawLabel(DrawContext dc)
Causes the labeled path to draw its label at the path's current label location.
|
int |
getAltitudeMode()
Returns the labeled path's altitude mode.
|
ScreenAnnotation |
getAnnotation()
Returns the
ScreenAnnotation used to draw the label, or null if the
path doesn't draw a label. |
protected Vec4 |
getLabelPoint(DrawContext dc)
Returns the label's model-coordinate point form the path's location iterable, applying the path's altitude mode.
|
protected double |
getLabelVisibleArea(DrawContext dc)
Returns the approximate number of square pixels that are visible at the label's current location, or 0 if the
label is not visible.
|
Iterable<? extends LatLon> |
getLocations()
Returns the labeled path's locations.
|
protected boolean |
isLabelCompletelyVisible(DrawContext dc)
Returns
true if the label is completely visible at its current location, and false otherwise. |
void |
render(DrawContext dc)
Causes the labeled path to draw its label at one of the path locations.
|
protected void |
reset()
Resets the labeled path's cached location information.
|
void |
setAltitudeMode(int altitudeMode)
Specifies the labeled path's altitude mode, one of
WorldWind.ABSOLUTE , WorldWind.RELATIVE_TO_GROUND or WorldWind.CLAMP_TO_GROUND . |
void |
setAnnotation(ScreenAnnotation annotation)
Specifies the
ScreenAnnotation to use for drawing the label. |
protected void |
setLabelLocation(DrawContext dc,
Vec4 screenPoint)
Places the label at the specified screen point.
|
void |
setLocations(Iterable<? extends LatLon> locations)
Specifies the labeled path's locations, which replace the path's current locations, if any.
|
protected int altitudeMode
WorldWind.ABSOLUTE
.protected ScreenAnnotation annotation
null
if no annotation has been specified.protected long frameNumber
protected int labelLocationIndex
locations
, or -1 if the path has no label location.public LabeledPath()
public LabeledPath(Iterable<? extends LatLon> locations)
locations
- the labeled path's locations.IllegalArgumentException
- if locations is null
.public LabeledPath(Iterable<? extends LatLon> locations, ScreenAnnotation annotation)
locations
- the labeled path's locations.annotation
- the screen annotation to use for drawing the label, or null
if no label should be
drawn.IllegalArgumentException
- if locations is null
.public LabeledPath(ScreenAnnotation annotation)
annotation
- the screen annotation to use for drawing the label, or null
if no label should be
drawn.protected Vec4 computePoint(DrawContext dc, LatLon location)
dc
- the current draw context.location
- the location to compute a point for.protected void determineLabelLocation(DrawContext dc)
labelLocationIndex
. This assigns labelLocationIndex
to null
if the label cannot be
placed at any screen location corresponding to the path.dc
- the current draw context.protected void drawLabel(DrawContext dc)
dc
- the current draw context.public int getAltitudeMode()
setAltitudeMode(int)
public ScreenAnnotation getAnnotation()
ScreenAnnotation
used to draw the label, or null
if the
path doesn't draw a label.null
if no label is drawn.protected Vec4 getLabelPoint(DrawContext dc)
null
if the path has no
label location, or if the path's locations have changed and no longer contain a value at the cached location
index.dc
- the current draw context.protected double getLabelVisibleArea(DrawContext dc)
dc
- the current draw context.public Iterable<? extends LatLon> getLocations()
null
if no locations have been specified.protected boolean isLabelCompletelyVisible(DrawContext dc)
true
if the label is completely visible at its current location, and false
otherwise.dc
- the current draw context.true
if the label is completely visible at its current location, and false
otherwise.public void render(DrawContext dc)
render
in interface Renderable
dc
- the DrawContext
to be used.IllegalArgumentException
- if dc is null
.DrawContext
protected void reset()
public void setAltitudeMode(int altitudeMode)
WorldWind.ABSOLUTE
, WorldWind.RELATIVE_TO_GROUND
or WorldWind.CLAMP_TO_GROUND
.
Note: If the altitude mode is unrecognized, WorldWind.ABSOLUTE
is used.altitudeMode
- the altitude mode. The default value is WorldWind.ABSOLUTE
.public void setAnnotation(ScreenAnnotation annotation)
ScreenAnnotation
to use for drawing the label. The specified
screen annotation's screen point is controlled by the labled path. Otherwise the screen annotation's attributes
are not modified.annotation
- the screen annotation to use for drawing the label, or null
if no label should be
drawn.protected void setLabelLocation(DrawContext dc, Vec4 screenPoint)
dc
- the current draw context.screenPoint
- the screen point to use.public void setLocations(Iterable<? extends LatLon> locations)
locations
- the labeled path's locations.IllegalArgumentException
- if locations is null
.