NASA World Wind

gov.nasa.worldwind.render
Class AnnotationAttributes

java.lang.Object
  extended by gov.nasa.worldwind.render.AnnotationAttributes
All Implemented Interfaces:
Restorable

public class AnnotationAttributes
extends Object
implements Restorable

Annotation attributes set. All AbstractAnnotation objects 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 AnnotationAttributes refer this static bundle as their default values source when an attribute has not been set.

New AnnotationAttributes set 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 munerics and null for 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, FrameFactory, MultiLineTextRenderer

Constructor Summary
AnnotationAttributes()
           
 
Method Summary
 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.
 int getAntiAliasHint()
          Get the GL antialias hint used for rendering the callout border line.
 Color getBackgroundColor()
          Get the callout background Color.
 Color getBorderColor()
          Get the callout border Color.
 int getBorderStippleFactor()
          Get the stipple factor used for the callout border line.
 short getBorderStipplePattern()
          Get the stipple pattern used for the callout border line.
 double getBorderWidth()
          Get the callout border line width.
 int getCornerRadius()
          Get the callout shape rounded corners radius in pixels.
 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.
 double getDistanceMinOpacity()
          Get the minimum opacity an annotation can have when fading away from the eye (0 to 1).
 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.
 Point getDrawOffset()
          Get the callout displacement offset in pixels from the globe Position or screen point at which it is associated.
 String getEffect()
          Get the effect used to decorate the text.
 Font getFont()
          Get the Font used for text rendering.
 String getFrameShape()
          Get the callout frame shape.
 double getHighlightScale()
          Get the scaling factor applied to highlighted Annotations.
 Point getImageOffset()
          Get the background image offset in pixels (before background scaling).
 double getImageOpacity()
          Get the opacity of the background image (0 to 1).
 String getImageRepeat()
          Get the repeat behavior or the background image.
 double getImageScale()
          Get the background image scaling factor.
 Object getImageSource()
          Get the background image source.
 Insets getInsets()
          Get the callout Insets dimensions in pixels.
 String getLeader()
          Get the callout shape leader type.
 double getOpacity()
          Get the opacity factor applied to the annotation.
 String getPath()
          Get the path to the image used for background image.
 String getRestorableState()
          Returns an XML state document String describing attributes that have been set by the application (attributes not pointing to their default value).
 double getScale()
          Get the scaling factor applied to the annotation.
 Dimension getSize()
          Get the annotation callout preferred total dimension in pixels.
 int getTextAlign()
          Get the text alignement.
 Color getTextColor()
          Get the text Color.
 boolean isHighlighted()
          Get whether the Annotation is highlighted and should be drawn bigger - see setHighlightScale().
 boolean isVisible()
          Get whether the annotation is visible and should be rendered.
 void restoreState(String stateInXml)
          Restores attribute values found in the specified XML state document String.
 void setAdjustWidthToText(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.
 void setAntiAliasHint(int hint)
          Set the GL antialias hint used for rendering the callout border line.
 void setBackgroundColor(Color color)
          Set the callout background Color.
 void setBorderColor(Color color)
          Set the callout border Color.
 void setBorderStippleFactor(int factor)
          Set the stipple factor used for the callout border line.
 void setBorderStipplePattern(short pattern)
          Set the stipple pattern used for the callout border line.
 void setBorderWidth(double width)
          Set the callout border line width.
 void setCornerRadius(int radius)
          Set the callout shape rounded corners radius in pixels.
 void setDefaults(AnnotationAttributes attr)
          Set the fallback default attributes set.
 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.
 void setDistanceMinOpacity(double opacity)
          Set the minimum opacity an annotation can have when fading away from the eye (0 to 1).
 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.
 void setDrawOffset(Point offset)
          Set the callout displacement offset in pixels from the globe Position or screen point at which it is associated.
 void setEffect(String effect)
          Set the effect used to decorate the text.
 void setFont(Font font)
          Set the Font used for text rendering.
 void setFrameShape(String shape)
          Set the callout frame shape.
 void setHighlighted(boolean highlighted)
          Set whether the Annotation is highlighted and should be drawn bigger - see setHighlightScale().
 void setHighlightScale(double highlightScale)
          Set the scaling factor applied to highlighted Annotations.
 void setImageOffset(Point offset)
          Set the background image offset in pixels (before background scaling).
 void setImageOpacity(double opacity)
          Set the opacity of the background image (0 to 1).
 void setImageRepeat(String repeat)
          Set the repeat behavior or the background image.
 void setImageScale(double scale)
          Set the background image scaling factor.
 void setImageSource(Object imageSource)
          Set the background image source.
 void setInsets(Insets insets)
          Set the callout Insets dimensions in pixels.
 void setLeader(String leader)
          Set the callout shape leader type.
 void setOpacity(double opacity)
          Set the opacity factor to apply to the annotation.
 void setScale(double scale)
          Set the scaling factor to apply to the annotation.
 void setSize(Dimension size)
          Set the annotation callout preferred total dimension in pixels.
 void setTextAlign(int align)
          Set the text alignement.
 void setTextColor(Color color)
          Set the text Color.
 void setVisible(boolean visible)
          Set whether the annotation is visible and should be rendered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationAttributes

public AnnotationAttributes()
Method Detail

getAdjustWidthToText

public 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 of Annotation.SIZE_FIXED or SIZE_FIT_TEXT.

Returns:
whether the callout width is adjusted to follow the text bounding rectangle width.

getAntiAliasHint

public int getAntiAliasHint()
Get the GL antialias hint used for rendering the callout border line. Can be one of Annotation.ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST (default) or ANTIALIAS_NICEST.

Returns:
the GL antialias hint used for rendering the callout border line.

getBackgroundColor

public Color getBackgroundColor()
Get the callout background Color.

Returns:
the callout background Color.

getBorderColor

public Color getBorderColor()
Get the callout border Color.

Returns:
the callout border Color.

getBorderStippleFactor

public int getBorderStippleFactor()
Get the stipple factor used for the callout border line. A value of zero (default) means no pattern is applied.

Returns:
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.

getBorderWidth

public double getBorderWidth()
Get the callout border line width. A value of zero means no border is being drawn.

Returns:
the callout border line width.

getCornerRadius

public int getCornerRadius()
Get the callout shape rounded corners radius in pixels. A value of zero means no rounded corners.

Returns:
the callout shape rounded corners radius in pixels.

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

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.

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

getDrawOffset

public 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

getEffect

public String getEffect()
Get the effect used to decorate the text. Can be one of MultiLineTextRenderer.EFFECT_SHADOW, EFFECT_OUTLINE or EFFECT_NONE (default).

Returns:
the effect used for text rendering

getFont

public Font getFont()
Get the Font used for text rendering.

Returns:
the Font used for text rendering.

getFrameShape

public String getFrameShape()
Get the callout frame shape. Can be one of FrameFactory.SHAPE_RECTANGLE (default), SHAPE_ELLIPSE or SHAPE_NONE.

Returns:
the callout frame shape.

getHighlightScale

public double getHighlightScale()
Get the scaling factor applied to highlighted Annotations.

Returns:
the scaling factor applied to highlighted Annotations.

getImageOffset

public Point getImageOffset()
Get the background image offset in pixels (before background scaling).

Returns:
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).

getImageRepeat

public String getImageRepeat()
Get the repeat behavior or the background image. Can be one of Annotation.IMAGE_REPEAT_X, IMAGE_REPEAT_Y, IMAGE_REPEAT_XY (default) or IMAGE_REPEAT_NONE.

Returns:
the repeat behavior or the background image.

getImageScale

public double getImageScale()
Get the background image scaling factor.

Returns:
the background image scaling factor.

getImageSource

public Object getImageSource()
Get the background image source. Can be a String providing the path to a local image, a BufferedImage or null.

Returns:
the background image source.

getInsets

public Insets getInsets()
Get the callout Insets dimensions 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 Insets dimensions in pixels.

getLeader

public String getLeader()
Get the callout shape leader type. Can be one of FrameFactory.LEADER_TRIANGLE (default) or LEADER_NONE.

Returns:
the callout shape leader type.

getOpacity

public double getOpacity()
Get the opacity factor applied to the annotation. Default is 1.

Returns:
the opacity factor applied to the annotation

getPath

public String getPath()
Get the path to the image used for background image. Returns null if the image source is null or a memory BufferedImage.

Returns:
the path to the image used for background image.

getRestorableState

public 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:
getRestorableState in interface Restorable
Returns:
XML state document string describing this AnnotationAttributes.

getScale

public double getScale()
Get the scaling factor applied to the annotation. Default is 1.

Returns:
the scaling factor applied to the annotation

getSize

public Dimension getSize()
Get the annotation callout preferred total dimension in pixels.

Returns:
the callout preferred total dimension in pixels.

getTextAlign

public int getTextAlign()
Get the text alignement. Can be one of MultiLineTextRenderer.ALIGN_LEFT (default), ALIGN_CENTER or ALIGN_RIGHT.

Returns:
align the text alignement. Can be one of MultiLineTextRenderer.ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT.

getTextColor

public Color getTextColor()
Get the text Color.

Returns:
the text Color.

isHighlighted

public boolean isHighlighted()
Get whether the Annotation is highlighted and should be drawn bigger - see setHighlightScale().

Returns:
true if highlighted.

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.

restoreState

public void restoreState(String stateInXml)
Restores 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 an AnnotationAttributes.
Throws:
IllegalArgumentException - If stateInXml is null, or if stateInXml is not a well formed XML document String.

setAdjustWidthToText

public void setAdjustWidthToText(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 of Annotation.SIZE_FIXED (default) or SIZE_FIT_TEXT. Setting this attribute to SIZE_FIT_TEXT would 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.

setAntiAliasHint

public void setAntiAliasHint(int hint)
Set the GL antialias hint used for rendering the callout border line. Can be one of Annotation.ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST (default) or ANTIALIAS_NICEST. Set to minus one (-1) to use the default value.

Parameters:
hint - the GL antialias hint used for rendering the callout border line.

setBackgroundColor

public void setBackgroundColor(Color color)
Set the callout background Color. Set to null to use the default value.

Parameters:
color - the callout background Color.

setBorderColor

public void setBorderColor(Color color)
Set the callout border Color. Set to null to use the default value.

Parameters:
color - the callout border Color.

setBorderStippleFactor

public void setBorderStippleFactor(int factor)
Set the stipple factor used for the callout border line. A value of zero (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.

setBorderStipplePattern

public void setBorderStipplePattern(short pattern)
Set the stipple pattern used for the callout border line. Set to 0x0000 to use the default value.

Parameters:
pattern - the stipple pattern used for the callout border line.

setBorderWidth

public void setBorderWidth(double width)
Set the callout border line width. A value of zero means no border will is drawn. Set to minus one (-1) to use the default value.

Parameters:
width - the callout border line width.

setCornerRadius

public void setCornerRadius(int radius)
Set the callout shape rounded corners radius in pixels. A value of zero means 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.

setDefaults

public void setDefaults(AnnotationAttributes attr)
Set the fallback default attributes set.

Parameters:
attr - the default attributes set.

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

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.

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

setDrawOffset

public void setDrawOffset(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 to null to use the default offset.

Parameters:
offset - the callout displacement offset in pixels

setEffect

public void setEffect(String effect)
Set the effect used to decorate the text. Can be one of MultiLineTextRenderer.EFFECT_SHADOW, EFFECT_OUTLINE or EFFECT_NONE (default). Set to null to use the default value.

Parameters:
effect - the effect to use for text rendering

setFont

public void setFont(Font font)
Set the Font used for text rendering. Set to null to use the default value.

Parameters:
font - the Font used for text rendering.

setFrameShape

public void setFrameShape(String shape)
Set the callout frame shape. Can be one of FrameFactory.SHAPE_RECTANGLE (default), SHAPE_ELLIPSE or SHAPE_NONE. Set to null to use the default shape.

Note that SHAPE_ELLIPSE draws 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.

setHighlighted

public void setHighlighted(boolean highlighted)
Set whether the Annotation is highlighted and should be drawn bigger - see setHighlightScale().

Parameters:
highlighted - true if highlighted.

setHighlightScale

public void setHighlightScale(double highlightScale)
Set the scaling factor applied to highlighted Annotations. Set to minus one (-1) to use the default value.

Parameters:
highlightScale - the scaling factor applied to highlighted Annotations.

setImageOffset

public void setImageOffset(Point offset)
Set the background image offset in pixels (before background scaling). Set to null to use the default value.

Parameters:
offset - the background image offset in pixels

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).

setImageRepeat

public void setImageRepeat(String repeat)
Set the repeat behavior or the background image. Can be one of Annotation.IMAGE_REPEAT_X, IMAGE_REPEAT_Y, IMAGE_REPEAT_XY (default) or IMAGE_REPEAT_NONE. Set to null to use the default value.

Parameters:
repeat - the repeat behavior or the background image.

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.

setImageSource

public void setImageSource(Object imageSource)
Set the background image source. Can be a String providing the path to a local image or a BufferedImage. Set to null for no background image rendering.

Parameters:
imageSource - the background image source.

setInsets

public void setInsets(Insets insets)
Set the callout Insets dimensions in pixels. The text will be drawn inside the callout frame while keeping a distance from the callout border defined in the Insets. Set to null to use the default Insets.

Parameters:
insets - the callout Insets dimensions in pixels.

setLeader

public void setLeader(String leader)
Set the callout shape leader type. Can be one of FrameFactory.LEADER_TRIANGLE (default) or LEADER_NONE.

Parameters:
leader - the callout shape leader type.

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

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

setSize

public void setSize(Dimension size)
Set the annotation callout preferred total dimension in pixels.

If necessary, the text will be wraped into several lines so as not to exceed the callout preferred width (minus the Insets left and right dimensions - see setInsets()). However, if setAdjustWidthToText() is set to true, 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 height. A zero value (default) will have the callout follow the final text bounding rectangle height (including the Insets top and bottom).

Set to null to use the default size.

Parameters:
size - the callout preferred total dimension in pixels.

setTextAlign

public void setTextAlign(int align)
Set the text alignement. Can be one of MultiLineTextRenderer.ALIGN_LEFT (default), ALIGN_CENTER or ALIGN_RIGHT. Set to null to use the default value.

Parameters:
align - the text alignement.

setTextColor

public void setTextColor(Color color)
Set the text Color. Set to null to use the default value.

Parameters:
color - the text Color.

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.

NASA World Wind