Class AnnotationAttributes
- java.lang.Object
-
- gov.nasa.worldwind.render.AnnotationAttributes
-
- All Implemented Interfaces:
Restorable
public class AnnotationAttributes extends java.lang.Object implements Restorable
Annotationattributes set. AllAbstractAnnotationobjects start life referencing a new instance of this object.This class also defines a static default attributes bundle containing default values for all attributes. New
AnnotationAttributesrefer this static bundle as their default values source when an attribute has not been set.New
AnnotationAttributesset have all their attributes pointing to the default values until they are set by the application. Most attributes refer to the default value by using minus one (-1) for numerics andnullfor objects.The default attributes set can be changed for a non static one under the application control. The process can be extended or cascaded to handle multiple levels of inheritance for default attributes.
- See Also:
AbstractAnnotation,MultiLineTextRenderer
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanunresolved
-
Constructor Summary
Constructors Constructor Description AnnotationAttributes()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAdjustWidthToText()Get whether the callout width should adjust to follow the wrapped text bounding rectangle width, which may be smaller or larger then the preferred size depending on the text.protected intgetAntiAliasHint()Get theGLantialias hint used for rendering the callout border line.java.awt.ColorgetBackgroundColor()Get the callout backgroundColor.WWTexturegetBackgroundTexture(DrawContext dc)Get the background image as aWWTexturefor the specified draw context.java.awt.ColorgetBorderColor()Get the callout borderColor.intgetBorderStippleFactor()Get the stipple factor used for the callout border line.shortgetBorderStipplePattern()Get the stipple pattern used for the callout border line.doublegetBorderWidth()Get the callout border line width.intgetCornerRadius()Get the callout shape rounded corners radius in pixels.doublegetDistanceMaxScale()Get the maximum scale that can be applied to an annotation when it gets closer to the eye than the view lookat point.doublegetDistanceMinOpacity()Get the minimum opacity an annotation can have when fading away from the eye (0 to 1).doublegetDistanceMinScale()Get the minimum scale that can be applied to an annotation when it gets farther away from the eye than the view lookat point.java.awt.PointgetDrawOffset()Get the callout displacement offset in pixels from the globe Position or screen point at which it is associated.java.lang.StringgetEffect()Get the effect used to decorate the text.java.awt.FontgetFont()Get theFontused for text rendering.java.lang.StringgetFrameShape()Get the callout frame shape.doublegetHighlightScale()Get the scaling factor applied to highlightedAnnotations.java.awt.PointgetImageOffset()Get the background image offset in pixels (before background scaling).doublegetImageOpacity()Get the opacity of the background image (0 to 1).java.lang.StringgetImageRepeat()Get the repeat behavior or the background image.doublegetImageScale()Get the background image scaling factor.java.lang.ObjectgetImageSource()Get the background image source.java.awt.InsetsgetInsets()Get the calloutInsetsdimensions in pixels.java.lang.StringgetLeader()Get the callout shape leader type.intgetLeaderGapWidth()Get the callout shape leader gap width in pixels.doublegetOpacity()Get the opacity factor applied to the annotation.java.lang.StringgetPath()Get the path to the image used for background image.java.lang.StringgetRestorableState()Returns an XML state document String describing attributes that have been set by the application (attributes not pointing to their default value).doublegetScale()Get the scaling factor applied to the annotation.java.awt.DimensiongetSize()Get the annotation callout preferred total dimension in pixels.java.lang.StringgetTextAlign()Get the text alignement.java.awt.ColorgetTextColor()Get the textColor.booleanisHighlighted()Get whether theAnnotationis highlighted and should be drawn bigger - see setHighlightScale().booleanisUnresolved()Indicates whether one or more members of this remain unresolved because they must be retrieved from an external source.booleanisVisible()Get whether the annotation is visible and should be rendered.voidrestoreState(java.lang.String stateInXml)Restores attribute values found in the specified XML state document String.voidsetAdjustWidthToText(java.lang.String state)Set whether the callout width should adjust to follow the wrapped text bounding rectangle width which may be smaller or larger then the preferred size depending on the text.protected voidsetAntiAliasHint(int hint)Set theGLantialias hint used for rendering the callout border line.voidsetBackgroundColor(java.awt.Color color)Set the callout backgroundColor.voidsetBorderColor(java.awt.Color color)Set the callout borderColor.voidsetBorderStippleFactor(int factor)Set the stipple factor used for the callout border line.voidsetBorderStipplePattern(short pattern)Set the stipple pattern used for the callout border line.voidsetBorderWidth(double width)Set the callout border line width.voidsetCornerRadius(int radius)Set the callout shape rounded corners radius in pixels.voidsetDefaults(AnnotationAttributes attr)Set the fallback default attributes set.voidsetDistanceMaxScale(double scale)Set the maximum scale that can be applied to an annotation when it gets closer to the eye than the view lookat point.voidsetDistanceMinOpacity(double opacity)Set the minimum opacity an annotation can have when fading away from the eye (0 to 1).voidsetDistanceMinScale(double scale)Set the minimum scale that can be applied to an annotation when it gets farther away from the eye than the view lookat point.voidsetDrawOffset(java.awt.Point offset)Set the callout displacement offset in pixels from the globe Position or screen point at which it is associated.voidsetEffect(java.lang.String effect)Set the effect used to decorate the text.voidsetFont(java.awt.Font font)Set theFontused for text rendering.voidsetFrameShape(java.lang.String shape)Set the callout frame shape.voidsetHighlighted(boolean highlighted)Set whether theAnnotationis highlighted and should be drawn bigger - see setHighlightScale().voidsetHighlightScale(double highlightScale)Set the scaling factor applied to highlightedAnnotations.voidsetImageOffset(java.awt.Point offset)Set the background image offset in pixels (before background scaling).voidsetImageOpacity(double opacity)Set the opacity of the background image (0 to 1).voidsetImageRepeat(java.lang.String repeat)Set the repeat behavior or the background image.voidsetImageScale(double scale)Set the background image scaling factor.voidsetImageSource(java.lang.Object imageSource)Set the background image source.voidsetInsets(java.awt.Insets insets)Set the calloutInsetsdimensions in pixels.voidsetLeader(java.lang.String leader)Set the callout shape leader type.voidsetLeaderGapWidth(int width)Set the callout shape leader gap width in pixels.voidsetOpacity(double opacity)Set the opacity factor to apply to the annotation.voidsetScale(double scale)Set the scaling factor to apply to the annotation.voidsetSize(java.awt.Dimension size)Set the annotation callout preferred total dimension in pixels.voidsetTextAlign(java.lang.String align)Set the text alignement.voidsetTextColor(java.awt.Color color)Set the textColor.voidsetUnresolved(boolean unresolved)Specifies whether one or more fields of this remain unresolved because they must be retrieved from an external source.voidsetVisible(boolean visible)Set whether the annotation is visible and should be rendered.
-
-
-
Method Detail
-
setDefaults
public void setDefaults(AnnotationAttributes attr)
Set the fallback default attributes set.- Parameters:
attr- the default attributes set.
-
getFrameShape
public java.lang.String getFrameShape()
Get the callout frame shape. Can be one ofAVKey.SHAPE_RECTANGLE(default),AVKey.SHAPE_ELLIPSEorAVKey.SHAPE_NONE.- Returns:
- the callout frame shape.
-
setFrameShape
public void setFrameShape(java.lang.String shape)
Set the callout frame shape. Can be one ofAVKey.SHAPE_RECTANGLE(default),AVKey.SHAPE_ELLIPSEorAVKey.SHAPE_NONE. Set tonullto use the default shape.Note that
AVKey.SHAPE_ELLIPSEdraws an ellipse inside the callout bounding rectangle set by its size (see setSize()) or its text bounding rectangle (see setAdjustWidthToText() and setSize() with height set to zero). It is often necessary to have larger Insets dimensions (see setInsets()) to avoid having the text drawn outside the shape border.- Parameters:
shape- the callout frame shape.
-
isHighlighted
public boolean isHighlighted()
Get whether theAnnotationis highlighted and should be drawn bigger - see setHighlightScale().- Returns:
- true if highlighted.
-
setHighlighted
public void setHighlighted(boolean highlighted)
Set whether theAnnotationis highlighted and should be drawn bigger - see setHighlightScale().- Parameters:
highlighted- true if highlighted.
-
getHighlightScale
public double getHighlightScale()
Get the scaling factor applied to highlightedAnnotations.- Returns:
- the scaling factor applied to highlighted
Annotations.
-
setHighlightScale
public void setHighlightScale(double highlightScale)
Set the scaling factor applied to highlightedAnnotations. Set to minus one (-1) to use the default value.- Parameters:
highlightScale- the scaling factor applied to highlightedAnnotations.
-
getSize
public java.awt.Dimension getSize()
Get the annotation callout preferred total dimension in pixels.- Returns:
- the callout preferred total dimension in pixels.
-
setSize
public void setSize(java.awt.Dimension size)
Set the annotation callout preferred total dimension in pixels.If necessary, the text will be wrapped into several lines so as not to exceed the callout preferred
width(minus theInsetsleftandrightdimensions - seesetInsets). However, ifsetAdjustWidthToTextis set to AVKey.SIZE_FIT_TEXT, the final callout width will follow that of the final text bounding rectangle.If necessary, the text will also be truncated so as not to exceed the given
Set toheight. Azerovalue (default) will have the callout follow the final text bounding rectangle height (including theInsetstopandbottom).nullto use the default size.- Parameters:
size- the callout preferred total dimension in pixels.
-
getScale
public double getScale()
Get the scaling factor applied to the annotation. Default is 1.- Returns:
- the scaling factor applied to the annotation
-
setScale
public void setScale(double scale)
Set the scaling factor to apply to the annotation. Default is 1. Set to minus one (-1) to use the default value.- Parameters:
scale- the scaling factor to apply to the annotation
-
getOpacity
public double getOpacity()
Get the opacity factor applied to the annotation. Default is 1.- Returns:
- the opacity factor applied to the annotation
-
setOpacity
public void setOpacity(double opacity)
Set the opacity factor to apply to the annotation. Default is 1. Set to minus one (-1) to use the default value.- Parameters:
opacity- the opacity factor to apply to the annotation
-
getLeader
public java.lang.String getLeader()
Get the callout shape leader type. Can be one ofAVKey.SHAPE_TRIANGLE(default) orAVKey.SHAPE_NONE.- Returns:
- the callout shape leader type.
-
setLeader
public void setLeader(java.lang.String leader)
Set the callout shape leader type. Can be one ofAVKey.SHAPE_TRIANGLE(default) orAVKey.SHAPE_NONE.- Parameters:
leader- the callout shape leader type.
-
getLeaderGapWidth
public int getLeaderGapWidth()
Get the callout shape leader gap width in pixels. Default is 40.- Returns:
- the callout shape leader gap width.
-
setLeaderGapWidth
public void setLeaderGapWidth(int width)
Set the callout shape leader gap width in pixels. Set this attribute to minus one (-1) to use the default value.- Parameters:
width- the callout shape leader gap width in pixels.
-
getCornerRadius
public int getCornerRadius()
Get the callout shape rounded corners radius in pixels. A value ofzeromeans no rounded corners.- Returns:
- the callout shape rounded corners radius in pixels.
-
setCornerRadius
public void setCornerRadius(int radius)
Set the callout shape rounded corners radius in pixels. A value ofzeromeans no rounded corners. Set this attribute to minus one (-1) to use the default value.- Parameters:
radius- the callout shape rounded corners radius in pixels.
-
getAdjustWidthToText
public java.lang.String getAdjustWidthToText()
Get whether the callout width should adjust to follow the wrapped text bounding rectangle width, which may be smaller or larger then the preferred size depending on the text. Can be one ofAVKey.SIZE_FIXEDorAVKey.SIZE_FIT_TEXT.- Returns:
- whether the callout width is adjusted to follow the text bounding rectangle width.
-
setAdjustWidthToText
public void setAdjustWidthToText(java.lang.String state)
Set whether the callout width should adjust to follow the wrapped text bounding rectangle width which may be smaller or larger then the preferred size depending on the text. Can be one ofAVKey.SIZE_FIXED(default) orAVKey.SIZE_FIT_TEXT. Setting this attribute toSIZE_FIT_TEXTwould have the callout drawn at its exact width (see setSize()).- Parameters:
state- whether the callout width should adjust to follow the text bounding rectangle width.
-
getDrawOffset
public java.awt.Point getDrawOffset()
Get the callout displacement offset in pixels from the globe Position or screen point at which it is associated. When the callout has a leader (see setLeader(String leader)), it will lead to the original point. In the actual implementation, the callout is drawn above its associated point and the leader connects at the bottom of the frame, in the middle. Positive X increases toward the right and positive Y in the up direction.- Returns:
- the callout displacement offset in pixels
-
setDrawOffset
public void setDrawOffset(java.awt.Point offset)
Set the callout displacement offset in pixels from the globe Position or screen point at which it is associated. When the callout has a leader (see setLeader(String leader)), it will lead to the original point. In the actual implementation, the callout is drawn above its associated point and the leader connects at the bottom of the frame, in the middle. Positive X increases toward the right and positive Y in the up direction. Set tonullto use the default offset.- Parameters:
offset- the callout displacement offset in pixels
-
getInsets
public java.awt.Insets getInsets()
Get the calloutInsetsdimensions in pixels. The text is drawn inside the callout frame while keeping a distance from the callout border defined in the Insets.- Returns:
- the callout
Insetsdimensions in pixels.
-
setInsets
public void setInsets(java.awt.Insets insets)
Set the calloutInsetsdimensions in pixels. The text will be drawn inside the callout frame while keeping a distance from the callout border defined in the Insets. Set tonullto use the default Insets.- Parameters:
insets- the calloutInsetsdimensions in pixels.
-
getBorderWidth
public double getBorderWidth()
Get the callout border line width. A value ofzeromeans no border is being drawn.- Returns:
- the callout border line width.
-
setBorderWidth
public void setBorderWidth(double width)
Set the callout border line width. A value ofzeromeans no border will is drawn. Set to minus one (-1) to use the default value.- Parameters:
width- the callout border line width.
-
getBorderStippleFactor
public int getBorderStippleFactor()
Get the stipple factor used for the callout border line. A value ofzero(default) means no pattern is applied.- Returns:
- the stipple factor used for the callout border line.
-
setBorderStippleFactor
public void setBorderStippleFactor(int factor)
Set the stipple factor used for the callout border line. A value ofzero(default) means no pattern will be applied. Set to minus one (-1) to use the default value.- Parameters:
factor- the stipple factor used for the callout border line.
-
getBorderStipplePattern
public short getBorderStipplePattern()
Get the stipple pattern used for the callout border line.- Returns:
- the stipple pattern used for the callout border line.
-
setBorderStipplePattern
public void setBorderStipplePattern(short pattern)
Set the stipple pattern used for the callout border line. Set to0x0000to use the default value.- Parameters:
pattern- the stipple pattern used for the callout border line.
-
getAntiAliasHint
protected int getAntiAliasHint()
Get theGLantialias hint used for rendering the callout border line. Can be one ofAnnotation.ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST (default) or ANTIALIAS_NICEST.- Returns:
- the
GLantialias hint used for rendering the callout border line.
-
setAntiAliasHint
protected void setAntiAliasHint(int hint)
Set theGLantialias hint used for rendering the callout border line. Can be one ofAnnotation.ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST (default) or ANTIALIAS_NICEST. Set to minus one (-1) to use the default value.- Parameters:
hint- theGLantialias hint used for rendering the callout border line.
-
isVisible
public boolean isVisible()
Get whether the annotation is visible and should be rendered.- Returns:
- true if the annotation is visible and should be rendered.
-
setVisible
public void setVisible(boolean visible)
Set whether the annotation is visible and should be rendered.- Parameters:
visible- true if the annotation is visible and should be rendered.
-
getFont
public java.awt.Font getFont()
Get theFontused for text rendering.- Returns:
- the
Fontused for text rendering.
-
setFont
public void setFont(java.awt.Font font)
Set theFontused for text rendering. Set tonullto use the default value.- Parameters:
font- theFontused for text rendering.
-
getTextAlign
public java.lang.String getTextAlign()
- Returns:
- align the text alignement. Can be one of MultiLineTextRenderer.ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT.
-
setTextAlign
public void setTextAlign(java.lang.String align)
Set the text alignement. Can be one ofAVKey.LEFT(default),AVKey.CENTERorAVKey.RIGHT. Set tonullto use the default value.- Parameters:
align- the text alignement.
-
getTextColor
public java.awt.Color getTextColor()
Get the textColor.- Returns:
- the text
Color.
-
setTextColor
public void setTextColor(java.awt.Color color)
Set the textColor. Set tonullto use the default value.- Parameters:
color- the textColor.
-
getBackgroundColor
public java.awt.Color getBackgroundColor()
Get the callout backgroundColor.- Returns:
- the callout background
Color.
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color color)
Set the callout backgroundColor. Set tonullto use the default value.- Parameters:
color- the callout backgroundColor.
-
getBorderColor
public java.awt.Color getBorderColor()
Get the callout borderColor.- Returns:
- the callout border
Color.
-
setBorderColor
public void setBorderColor(java.awt.Color color)
Set the callout borderColor. Set tonullto use the default value.- Parameters:
color- the callout borderColor.
-
getImageSource
public java.lang.Object getImageSource()
Get the background image source. Can be aStringproviding the path to a local image, aBufferedImageornull.- Returns:
- the background image source.
-
setImageSource
public void setImageSource(java.lang.Object imageSource)
Set the background image source. Can be aStringproviding the path to a local image or aBufferedImage. Set to null for no background image rendering.- Parameters:
imageSource- the background image source.
-
getBackgroundTexture
public WWTexture getBackgroundTexture(DrawContext dc)
Get the background image as aWWTexturefor the specified draw context. This returns null if the background image source returned bygetImageSource()is null.- Parameters:
dc- the current draw context.- Returns:
- the background image as a WWTexture, or null if this AnnotationAttributes has no background image source.
-
getImageScale
public double getImageScale()
Get the background image scaling factor.- Returns:
- the background image scaling factor.
-
setImageScale
public void setImageScale(double scale)
Set the background image scaling factor. Set to minus one (-1) to use the default value.- Parameters:
scale- the background image scaling factor.
-
getImageOffset
public java.awt.Point getImageOffset()
Get the background image offset in pixels (before background scaling).- Returns:
- the background image offset in pixels
-
setImageOffset
public void setImageOffset(java.awt.Point offset)
Set the background image offset in pixels (before background scaling). Set tonullto use the default value.- Parameters:
offset- the background image offset in pixels
-
getImageOpacity
public double getImageOpacity()
Get the opacity of the background image (0 to 1).- Returns:
- the opacity of the background image (0 to 1).
-
setImageOpacity
public void setImageOpacity(double opacity)
Set the opacity of the background image (0 to 1). Set to minus one (-1) to use the default value.- Parameters:
opacity- the opacity of the background image (0 to 1).
-
getImageRepeat
public java.lang.String getImageRepeat()
Get the repeat behavior or the background image. Can be one ofAnnotation.IMAGE_REPEAT_X, IMAGE_REPEAT_Y, IMAGE_REPEAT_XY (default) or IMAGE_REPEAT_NONE.- Returns:
- the repeat behavior or the background image.
-
setImageRepeat
public void setImageRepeat(java.lang.String repeat)
Set the repeat behavior or the background image. Can be one ofAnnotation.IMAGE_REPEAT_X, IMAGE_REPEAT_Y, IMAGE_REPEAT_XY (default) or IMAGE_REPEAT_NONE. Set tonullto use the default value.- Parameters:
repeat- the repeat behavior or the background image.
-
getPath
public java.lang.String getPath()
Get the path to the image used for background image. Returnsnullif the image source is null or a memory BufferedImage.- Returns:
- the path to the image used for background image.
-
getDistanceMinScale
public double getDistanceMinScale()
Get the minimum scale that can be applied to an annotation when it gets farther away from the eye than the view lookat point.- Returns:
- the minimum scale that can be applied to an annotation when it gets away from the eye
-
setDistanceMinScale
public void setDistanceMinScale(double scale)
Set the minimum scale that can be applied to an annotation when it gets farther away from the eye than the view lookat point. Set to minus one (-1) to use the default value.- Parameters:
scale- the minimum scale that can be applied to an annotation when it gets away from the eye
-
getDistanceMaxScale
public double getDistanceMaxScale()
Get the maximum scale that can be applied to an annotation when it gets closer to the eye than the view lookat point.- Returns:
- the maximum scale that can be applied to an annotation when it gets closer to the eye
-
setDistanceMaxScale
public void setDistanceMaxScale(double scale)
Set the maximum scale that can be applied to an annotation when it gets closer to the eye than the view lookat point. Set to minus one (-1) to use the default value.- Parameters:
scale- the maximum scale that can be applied to an annotation when it gets closer to the eye
-
getDistanceMinOpacity
public double getDistanceMinOpacity()
Get the minimum opacity an annotation can have when fading away from the eye (0 to 1).- Returns:
- the minimum opacity an annotation can have when fading away from the eye.
-
setDistanceMinOpacity
public void setDistanceMinOpacity(double opacity)
Set the minimum opacity an annotation can have when fading away from the eye (0 to 1). Set to minus one (-1) to use the default value.- Parameters:
opacity- the minimum opacity an annotation can have when fading away from the eye.
-
getEffect
public java.lang.String getEffect()
Get the effect used to decorate the text. Can be one ofAVKey.TEXT_EFFECT_SHADOW,AVKey.TEXT_EFFECT_OUTLINEorAVKey.TEXT_EFFECT_NONE(default).- Returns:
- the effect used for text rendering
-
setEffect
public void setEffect(java.lang.String effect)
Set the effect used to decorate the text. Can be one ofAVKey.TEXT_EFFECT_SHADOW,AVKey.TEXT_EFFECT_OUTLINEorAVKey.TEXT_EFFECT_NONE(default). Set tonullto use the default value.- Parameters:
effect- the effect to use for text rendering
-
isUnresolved
public boolean isUnresolved()
Indicates whether one or more members of this remain unresolved because they must be retrieved from an external source.- Returns:
- true if there are unresolved fields, false if no fields remain unresolved.
-
setUnresolved
public void setUnresolved(boolean unresolved)
Specifies whether one or more fields of this remain unresolved because they must be retrieved from an external source.- Parameters:
unresolved- true if there are unresolved fields, false if no fields remain unresolved.
-
getRestorableState
public java.lang.String getRestorableState()
Returns an XML state document String describing attributes that have been set by the application (attributes not pointing to their default value).- Specified by:
getRestorableStatein interfaceRestorable- Returns:
- XML state document string describing this AnnotationAttributes.
-
restoreState
public void restoreState(java.lang.String stateInXml)
Restores attribute values found in the specified XML state document String. The document specified bystateInXmlmust be a well formed XML document String, or this will throw an IllegalArgumentException. Unknown structures instateInXmlare benign, because they will simply be ignored.- Specified by:
restoreStatein interfaceRestorable- Parameters:
stateInXml- an XML document String describing an AnnotationAttributes.- Throws:
java.lang.IllegalArgumentException- IfstateInXmlis null, or ifstateInXmlis not a well formed XML document String.
-
-