|
NASA World Wind | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nasa.worldwind.render.AbstractAnnotation
public abstract class AbstractAnnotation
An Annotation
represent a text label and its rendering attributes. Annotations must be attached either to
a globe Position
(GlobeAnnotation
) or a viewport Point
(ScreenAnnotation).
GlobaAnnotation ga = new GlobeAnnotation("Lat-Lon zero", Position.fromDegrees(0, 0, 0))); ScreenAnnotation sa = new ScreenAnnotation("Message...", new Point(10,10));
Each Annotation refers to an AnnotationAttributes
object which defines how the text will be rendered.
ga.getAttributes().setTextColor(Color.WHITE); ga.getAttributes().setFont(Font.decode("Arial-BOLD-24"); ...Annotations are usually handled by an
AnnotationLayer
. Although they also implement the Renderable
and Pickable
interfaces and thus can be handled by a RenderableLayer
too.
AnnotationLayer layer = new AnnotationLayer(); layer.addAnnotation(new GlobeAnnotation("Text...", Position.fromDegrees(0, 0, 0)));Each Annotation starts its life with a fresh attribute set that can be altered to produce the desired effect. However,
AnnotationAttributes
can be set and shared between annotations allowing to control the rendering attributes
of many annotations from a single AnnotationAttributes
object.
AnnotationAttributes attr = new AnnotationAttributes(); attr.setTextColor(Color.WHITE); attr.setFont(Font.decode("Arial-BOLD-24"); ga.setAttributes(attr);In the above example changing the text color of the attributes set will affect all annotations refering it. However, changing the text color of one of those annotations will also affect all others since it will in fact change the common attributes set.
To use an attributes object only as default values for a serie of annotations use:
ga.getAttributes()setDefaults(attr);which can also be done in the Annotation constructor:
GlobeAnnotation ga = new GlobeAnnotation(text, position, attr);Finer control over attributes inheritence can be achieved using default or fallback attributes set.
Most attributes can be set to a 'use default' value which is minus one for numeric values and null
for attributes
refering objects (colors, dimensions, insets..). In such a case the value of an attribute will be that of the
default attribute set. New annotations have all their attributes set to use default values.
AnnotationAttributes
object points to a default static attributes set which is the fallback source for
attributes with null
or -1
values. This default attributes set can be set to any attributes object other than the
static one.
AnnotationAttributes geoFeature = new AnnotationAttributes(); geoFeature.setFrameShape(FrameFactory.SHAPE_ELLIPSE); geoFeature.setInsets(new Insets(12, 12, 12, 12)); AnnotationAttributes waterBody = new AnnotationAttributes(); waterBody.setTextColor(Color.BLUE); waterBoby.setDefaults(geoFeature); AnnotationAttributes mountain = new AnnotationAttributes(); mountain.setTextColor(Color.GREEN); mountain.setDefaults(geoFeature); layer.addAnnotation(new GlobeAnnotation("Spirit Lake", Position.fromDegrees(46.26, -122.15), waterBody); layer.addAnnotation(new GlobeAnnotation("Mt St-Helens", Position.fromDegrees(46.20, -122.19), mountain);In the above example all geographic features have an ellipse shape, water bodies and mountains use that attributes set has defaults and have their own text colors. They are in turn used as defaults by the two annotations. Mount Saint Helens attributes could be changed without affecting other mountains. However, changes on the geoFeatures attributes would affect all mountains and lakes.
AnnotationAttributes
,
AnnotationRenderer
Field Summary | |
---|---|
protected double |
alphaFactor
|
protected AnnotationAttributes |
attributes
|
protected java.lang.Object |
delegateOwner
|
protected java.awt.Rectangle |
drawRectangle
|
protected java.awt.Rectangle |
freeRectangle
|
protected gov.nasa.worldwind.render.AbstractAnnotation.RenderInfo |
renderInfo
|
protected double |
scaleFactor
Values used for drawing. |
protected java.lang.String |
text
|
Fields inherited from interface gov.nasa.worldwind.render.Annotation |
---|
ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST, ANTIALIAS_NICEST, IMAGE_REPEAT_NONE, IMAGE_REPEAT_X, IMAGE_REPEAT_XY, IMAGE_REPEAT_Y, SIZE_FIT_TEXT, SIZE_FIXED |
Constructor Summary | |
---|---|
AbstractAnnotation()
|
Method Summary | |
---|---|
protected void |
cacheRenderInfo(Annotation annotation,
gov.nasa.worldwind.render.AbstractAnnotation.RenderInfo renderInfo)
|
protected double |
computeLookAtDistance(DrawContext dc)
|
void |
dispose()
|
protected abstract void |
doDraw(DrawContext dc)
|
void |
draw(DrawContext dc)
Draw the annotation. |
protected void |
drawAnnotation(DrawContext dc,
java.awt.Point screenPoint,
double drawScale,
double drawAlpha,
Position pickPosition)
Draws an annotation at a screen point. |
AnnotationAttributes |
getAttributes()
|
java.lang.Object |
getDelegateOwner()
|
PickSupport |
getPickSupport()
|
protected java.awt.Rectangle |
getRectangleInViewportCoordinates(DrawContext dc,
java.awt.Rectangle r,
java.awt.Point screenPoint,
double scaleFactor)
|
protected gov.nasa.worldwind.render.AbstractAnnotation.RenderInfo |
getRenderInfo(DrawContext dc,
Annotation annotation)
|
java.lang.String |
getRestorableState()
Returns an XML state document String describing the public attributes of this AbstractAnnotation. |
java.lang.String |
getText()
|
protected TextRenderer |
getTextRenderer(DrawContext dc,
java.awt.Font font)
|
protected Texture |
initializeTexture(DrawContext dc,
Annotation annotation)
|
boolean |
isAlwaysOnTop()
|
void |
pick(DrawContext dc,
java.awt.Point pickPoint)
Pick at the annotation. |
void |
render(DrawContext dc)
Render the annotation. |
void |
restoreState(java.lang.String stateInXml)
Restores publicly settable attribute values found in the specified XML state document String. |
void |
setAlwaysOnTop(boolean alwaysOnTop)
|
void |
setAttributes(AnnotationAttributes attrs)
|
void |
setDelegateOwner(java.lang.Object delegateOwner)
|
protected void |
setDepthFunc(DrawContext dc,
Vec4 screenPoint)
|
protected void |
setDrawColor(DrawContext dc,
java.awt.Color color)
|
protected void |
setDrawColor(DrawContext dc,
float r,
float g,
float b,
float a)
|
void |
setPickSupport(PickSupport pickSupport)
|
void |
setText(java.lang.String text)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double alphaFactor
protected AnnotationAttributes attributes
protected java.lang.Object delegateOwner
protected java.awt.Rectangle drawRectangle
protected java.awt.Rectangle freeRectangle
protected gov.nasa.worldwind.render.AbstractAnnotation.RenderInfo renderInfo
protected double scaleFactor
Should be used by post drawing code.
protected java.lang.String text
Constructor Detail |
---|
public AbstractAnnotation()
Method Detail |
---|
protected void cacheRenderInfo(Annotation annotation, gov.nasa.worldwind.render.AbstractAnnotation.RenderInfo renderInfo)
protected double computeLookAtDistance(DrawContext dc)
public void dispose()
dispose
in interface Disposable
protected abstract void doDraw(DrawContext dc)
public void draw(DrawContext dc)
draw
in interface Annotation
dc
- the current DrawContext.protected void drawAnnotation(DrawContext dc, java.awt.Point screenPoint, double drawScale, double drawAlpha, Position pickPosition)
dc
- the current DrawContext.screenPoint
- the annotation position projected location on the viewport.pickPosition
- the Position
that will be associated with any PickedObject
produced during picking.public AnnotationAttributes getAttributes()
getAttributes
in interface Annotation
public java.lang.Object getDelegateOwner()
getDelegateOwner
in interface Annotation
public PickSupport getPickSupport()
protected java.awt.Rectangle getRectangleInViewportCoordinates(DrawContext dc, java.awt.Rectangle r, java.awt.Point screenPoint, double scaleFactor)
protected gov.nasa.worldwind.render.AbstractAnnotation.RenderInfo getRenderInfo(DrawContext dc, Annotation annotation)
public java.lang.String getRestorableState()
getRestorableState
in interface Restorable
public java.lang.String getText()
getText
in interface Annotation
protected TextRenderer getTextRenderer(DrawContext dc, java.awt.Font font)
protected Texture initializeTexture(DrawContext dc, Annotation annotation)
public boolean isAlwaysOnTop()
isAlwaysOnTop
in interface Annotation
public void pick(DrawContext dc, java.awt.Point pickPoint)
pick
in interface Pickable
dc
- the current DrawContext.public void render(DrawContext dc)
render
in interface Renderable
dc
- the current DrawContext.DrawContext
public void restoreState(java.lang.String stateInXml)
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.
restoreState
in interface Restorable
stateInXml
- an XML document String describing an AbstractAnnotation.
java.lang.IllegalArgumentException
- If stateInXml
is null, or if stateInXml
is not
a well formed XML document String.public void setAlwaysOnTop(boolean alwaysOnTop)
setAlwaysOnTop
in interface Annotation
public void setAttributes(AnnotationAttributes attrs)
setAttributes
in interface Annotation
public void setDelegateOwner(java.lang.Object delegateOwner)
setDelegateOwner
in interface Annotation
protected void setDepthFunc(DrawContext dc, Vec4 screenPoint)
protected void setDrawColor(DrawContext dc, java.awt.Color color)
protected void setDrawColor(DrawContext dc, float r, float g, float b, float a)
public void setPickSupport(PickSupport pickSupport)
setPickSupport
in interface Annotation
public void setText(java.lang.String text)
setText
in interface Annotation
|
NASA World Wind | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |