Class GlobeAnnotation
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.render.AbstractAnnotation
-
- gov.nasa.worldwind.render.GlobeAnnotation
-
- All Implemented Interfaces:
AVList
,Disposable
,Draggable
,Locatable
,Movable
,Annotation
,Renderable
,Restorable
- Direct Known Subclasses:
DialogAnnotation
,MeasureTool.ControlPoint
,SARAnnotation
,WWOMeasureToolControlPoints.ControlPoint
public class GlobeAnnotation extends AbstractAnnotation implements Locatable, Movable, Draggable
Represent a text label attached to a Position on the globe and its rendering attributes.- See Also:
AbstractAnnotation
,AnnotationAttributes
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractAnnotation
AbstractAnnotation.TextCacheKey
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Integer
altitudeMode
protected boolean
dragEnabled
protected DraggableSupport
draggableSupport
protected double
heightInMeter
protected Position
position
-
Fields inherited from class gov.nasa.worldwind.render.AbstractAnnotation
alwaysOnTop, attributes, childList, delegateOwner, layoutManager, maxActiveAltitude, minActiveAltitude, pickEnabled, pickSupport, text, textBoundsMap, vertexBuffer, wrappedTextMap
-
Fields inherited from interface gov.nasa.worldwind.render.Annotation
ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST, ANTIALIAS_NICEST
-
-
Constructor Summary
Constructors Constructor Description GlobeAnnotation(java.lang.String text, Position position)
Creates aGlobeAnnotation
with the given text, at the given globePosition
.GlobeAnnotation(java.lang.String text, Position position, AnnotationAttributes defaults)
Creates aGlobeAnnotation
with the given text, at the given globePosition
.GlobeAnnotation(java.lang.String text, Position position, java.awt.Font font)
Creates aGlobeAnnotation
with the given text, at the given globePosition
.GlobeAnnotation(java.lang.String text, Position position, java.awt.Font font, java.awt.Color textColor)
Creates aGlobeAnnotation
with the given text, at the given globePosition
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.Rectangle
computeBounds(DrawContext dc)
protected double[]
computeDistanceScaleAndOpacity(DrawContext dc, Vec4 point, java.awt.Dimension size)
protected java.lang.Double
computeLookAtDistance(DrawContext dc)
protected void
doDrag(DragContext dragContext)
protected void
doRenderNow(DrawContext dc)
void
drag(DragContext dragContext)
Drag the object given the providedDragContext
.java.lang.Integer
getAltitudeMode()
Get the annotation's altitude mode.Vec4
getAnnotationDrawPoint(DrawContext dc)
Get the final Vec4 point at which an annotation will be drawn.protected Vec4
getAnnotationDrawPointLegacy(DrawContext dc)
Compute the draw point using the legacy altitude mode.double
getHeightInMeter()
Returns the real world height of the annotation frame in meter.Position
getPosition()
Position
getReferencePosition()
A position associated with the object that indicates its aggregate geographic position.java.lang.String
getRestorableState()
Returns an XML state document String describing the public attributes of this GlobeAnnotation.boolean
isDragEnabled()
Indicates whether the object is enabled for dragging.void
move(Position position)
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
restoreState(java.lang.String stateInXml)
Restores publicly settable attribute values found in the specified XML state document String.void
setAltitudeMode(java.lang.Integer altitudeMode)
Set the annotation's altitude mode.protected void
setDepthFunc(DrawContext dc, Vec4 screenPoint)
void
setDragEnabled(boolean enabled)
Controls whether the object is enabled for dragging.void
setHeightInMeter(double meters)
Set the real world height of the annotation frame in meter.void
setPosition(Position position)
-
Methods inherited from class gov.nasa.worldwind.render.AbstractAnnotation
addChild, adjustSizeToChildren, adjustSizeToText, applyBackgroundTextureState, applyColor, applyScreenTransform, beginDraw, beginDrawChildren, bindPickableObject, computeBoundingRectangle, computeFreeBounds, computeInsetBounds, computeOpacity, computeScale, computeTextBounds, dispose, doDraw, doDrawBackgroundTexture, doDrawChildren, draw, drawBackground, drawBackgroundImage, drawBorder, drawCallout, drawChildren, drawContent, drawHTML, drawPlainText, drawText, drawText, drawTopLevelAnnotation, endDraw, endDrawChildren, getAttributes, getBounds, getChildren, getDelegateOwner, getLayout, getMaxActiveAltitude, getMinActiveAltitude, getMultiLineTextRenderer, getPickSupport, getPreferredSize, getText, getTextBounds, getTextRenderer, getWrappedText, glPointFromAWTPoint, isAlwaysOnTop, isPickEnabled, modulateColorOpacity, pick, removeAllChildren, removeChild, render, renderNow, setAlwaysOnTop, setAttributes, setDelegateOwner, setLayout, setMaxActiveAltitude, setMinActiveAltitude, setPickEnabled, setPickSupport, setText, transformBackgroundImageCoordsToAnnotationCoords, transformByModelview, transformImageCoordsToBackgroundImageCoords, wrapText
-
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
-
-
-
-
Field Detail
-
position
protected Position position
-
dragEnabled
protected boolean dragEnabled
-
draggableSupport
protected DraggableSupport draggableSupport
-
heightInMeter
protected double heightInMeter
-
altitudeMode
protected java.lang.Integer altitudeMode
-
-
Constructor Detail
-
GlobeAnnotation
public GlobeAnnotation(java.lang.String text, Position position)
Creates aGlobeAnnotation
with the given text, at the given globePosition
.- Parameters:
text
- the annotation text.position
- the annotationPosition
.
-
GlobeAnnotation
public GlobeAnnotation(java.lang.String text, Position position, java.awt.Font font)
Creates aGlobeAnnotation
with the given text, at the given globePosition
. Specify theFont
to be used.- Parameters:
text
- the annotation text.position
- the annotationPosition
.font
- theFont
to use.
-
GlobeAnnotation
public GlobeAnnotation(java.lang.String text, Position position, java.awt.Font font, java.awt.Color textColor)
Creates aGlobeAnnotation
with the given text, at the given globePosition
. Specify theFont
and textColor
to be used.- Parameters:
text
- the annotation text.position
- the annotationPosition
.font
- theFont
to use.textColor
- the textColor
.
-
GlobeAnnotation
public GlobeAnnotation(java.lang.String text, Position position, AnnotationAttributes defaults)
Creates aGlobeAnnotation
with the given text, at the given globePosition
. Specify the defaultAnnotationAttributes
set.- Parameters:
text
- the annotation text.position
- the annotationPosition
.defaults
- the defaultAnnotationAttributes
set.
-
-
Method Detail
-
getPosition
public Position getPosition()
- Specified by:
getPosition
in interfaceLocatable
-
setPosition
public void setPosition(Position position)
-
getAltitudeMode
public java.lang.Integer getAltitudeMode()
Get the annotation's altitude mode. The altitude mode may be null, indicating that the legacy altitude mode described below will be used.Legacy altitude mode
If the annotation Position elevation is lower then the highest elevation on the globe, the annotation will be drawn above the ground using its elevation as an offset, scaled by the current vertical exaggeration. Otherwise, the original elevation will be used. This functionality is supported for backward compatibility. New code that uses Globe Annotation should specify an altitude mode.- Returns:
- The altitude mode, one of
WorldWind.CLAMP_TO_GROUND
,WorldWind.RELATIVE_TO_GROUND
,WorldWind.ABSOLUTE
, ornull
. - See Also:
setAltitudeMode(Integer)
-
setAltitudeMode
public void setAltitudeMode(java.lang.Integer altitudeMode)
Set the annotation's altitude mode.- Parameters:
altitudeMode
- The altitude mode, one ofWorldWind.CLAMP_TO_GROUND
,WorldWind.RELATIVE_TO_GROUND
, orWorldWind.ABSOLUTE
.null
indicates that the legacy altitude mode should be used. SeegetAltitudeMode()
for details on this mode.- See Also:
getAltitudeMode()
-
getHeightInMeter
public double getHeightInMeter()
Returns the real world height of the annotation frame in meter. If this dimension is greater then zero, the annotation will be scaled so as to maintain this fixed dimension, which makes it appear as part of the surrounding terrain. This overrides min and max distance scaling - however min distance opacity is still accounted for.If this dimension is zero, the annotation always maintains the same apparent size with possible scaling relative to the viewport center point if min and max distance scale factors are not one.
- Returns:
- the real world height of the annotation frame in meter.
-
setHeightInMeter
public void setHeightInMeter(double meters)
Set the real world height of the annotation frame in meter. If this dimension is greater then zero, the annotation will be scaled so as to maintain this fixed dimension, which makes it appear as part of the surrounding terrain. This overrides min and max distance scaling - however min distance opacity is still accounted for.If this dimension is zero, the annotation always maintains the same apparent size with possible scaling relative to the viewport center point if min and max distance scale factors are not one.
- Parameters:
meters
- the real world height of the annotation frame in meter.
-
move
public void move(Position position)
Description copied from interface:Movable
Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
-
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.
-
isDragEnabled
public boolean isDragEnabled()
Description copied from interface:Draggable
Indicates whether the object is enabled for dragging.- Specified by:
isDragEnabled
in interfaceDraggable
- Returns:
- true if the object is enabled, else false.
-
setDragEnabled
public void setDragEnabled(boolean enabled)
Description copied from interface:Draggable
Controls whether the object is enabled for dragging.- Specified by:
setDragEnabled
in interfaceDraggable
- Parameters:
enabled
-true
if the object is enabled, elsefalse
.
-
drag
public void drag(DragContext dragContext)
Description copied from interface:Draggable
Drag the object given the providedDragContext
.- Specified by:
drag
in interfaceDraggable
- Parameters:
dragContext
- theDragContext
of this dragging event.
-
doDrag
protected void doDrag(DragContext dragContext)
-
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 interfaceMovable
- Returns:
- the object's reference position, or null if no reference position is available.
-
computeBounds
protected java.awt.Rectangle computeBounds(DrawContext dc)
- Specified by:
computeBounds
in classAbstractAnnotation
-
doRenderNow
protected void doRenderNow(DrawContext dc)
- Specified by:
doRenderNow
in classAbstractAnnotation
-
computeDistanceScaleAndOpacity
protected double[] computeDistanceScaleAndOpacity(DrawContext dc, Vec4 point, java.awt.Dimension size)
-
computeLookAtDistance
protected java.lang.Double computeLookAtDistance(DrawContext dc)
-
setDepthFunc
protected void setDepthFunc(DrawContext dc, Vec4 screenPoint)
-
getAnnotationDrawPoint
public Vec4 getAnnotationDrawPoint(DrawContext dc)
Get the final Vec4 point at which an annotation will be drawn. The altitude mode will be used to determine the annotation point, if an altitude mode has been set. If the altitude mode is null, then the legacy altitude mode described ingetAltitudeMode()
will be used to determine the point.- Parameters:
dc
- the current DrawContext.- Returns:
- the annotation draw Cartesian point
- See Also:
getAltitudeMode()
-
getAnnotationDrawPointLegacy
protected Vec4 getAnnotationDrawPointLegacy(DrawContext dc)
Compute the draw point using the legacy altitude mode. SeegetAltitudeMode()
for details on the legacy mode.- Parameters:
dc
- the current DrawContext.- Returns:
- the annotation draw Cartesian point
- See Also:
getAltitudeMode()
-
getRestorableState
public java.lang.String getRestorableState()
Returns an XML state document String describing the public attributes of this GlobeAnnotation.- Specified by:
getRestorableState
in interfaceRestorable
- Overrides:
getRestorableState
in classAbstractAnnotation
- Returns:
- XML state document string describing this GlobeAnnotation.
-
restoreState
public void restoreState(java.lang.String stateInXml)
Restores publicly settable attribute values found in the specified XML state document String. The document specified bystateInXml
must be a well formed XML document String, or this will throw an IllegalArgumentException. Unknown structures instateInXml
are benign, because they will simply be ignored.- Specified by:
restoreState
in interfaceRestorable
- Overrides:
restoreState
in classAbstractAnnotation
- Parameters:
stateInXml
- an XML document String describing a GlobeAnnotation.- Throws:
java.lang.IllegalArgumentException
- IfstateInXml
is null, or ifstateInXml
is not a well formed XML document String.
-
-