NASA World Wind

gov.nasa.worldwind.symbology
Class AbstractTacticalGraphic

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.symbology.AbstractTacticalGraphic
All Implemented Interfaces:
AVList, Movable, Highlightable, Renderable, TacticalGraphic
Direct Known Subclasses:
AbstractMilStd2525TacticalGraphic

public abstract class AbstractTacticalGraphic
extends AVListImpl
implements TacticalGraphic, Renderable

Base class for tactical graphics. See the TacticalGraphic Usage Guide for instructions on using TacticalGraphic in an application. This base class provides functionality for creating and rendering a graphic that is made up of one or more shapes, and text labels.

Implementations must implement at least doRenderGraphic and applyDelegateOwner(Object).


Field Summary
protected  TacticalGraphicAttributes activeOverrides
          Override attributes for the current frame.
protected  ShapeAttributes activeShapeAttributes
          Shape attributes shared by all shapes that make up this graphic.
protected static Material DEFAULT_HIGHLIGHT_MATERIAL
          The default highlight color.
protected static double DEFAULT_LABEL_INTERIOR_OPACITY
          Opacity of label interiors.
protected  Object delegateOwner
          Object returned during picking to represent this graphic.
protected  long frameTimestamp
          Current frame timestamp.
protected  TacticalGraphicAttributes highlightAttributes
          Attributes to apply when the graphic is highlighted.
protected  boolean highlighted
          Indicates whether or not the graphic is highlighted.
protected  Offset labelOffset
          Offset applied to the graphic's main label.
protected  List<TacticalGraphicLabel> labels
          Labels to render with the graphic.
protected  AVList modifiers
          Map of modifiers applied to this graphic.
protected  boolean mustCreateLabels
          Flag to indicate that labels must be recreated before the graphic is rendered.
protected  TacticalGraphicAttributes normalAttributes
          Attributes to apply when the graphic is not highlighted.
protected  boolean showGraphicModifiers
          Indicates whether or not to render graphic modifiers.
protected  boolean showHostileIndicator
          Indicates whether or not to render the hostile/enemy modifier.
protected  boolean showLocation
          Indicates whether or not to render the location modifier.
protected  boolean showTextModifiers
          Indicates whether or not to render text modifiers.
protected  String text
          The graphic's text string.
protected  UnitsFormat unitsFormat
          Unit format used to format location and altitude for text modifiers.
protected  boolean visible
          Indicates whether or not to render the graphic.
 
Constructor Summary
AbstractTacticalGraphic()
           
 
Method Summary
protected  TacticalGraphicLabel addLabel(String text)
           
protected  void applyDefaultAttributes(ShapeAttributes attributes)
          Apply defaults to the active attributes bundle.
protected abstract  void applyDelegateOwner(Object owner)
          Invoked each frame to apply to the current delegate owner to all renderable objects used to draw the graphic.
protected  void applyLabelAttributes()
          Apply the active attributes to the graphic's labels.
protected  void applyOverrideAttributes(TacticalGraphicAttributes graphicAttributes, ShapeAttributes shapeAttributes)
          Apply override attributes specified in a TacticalGraphicAttributes bundle to the active ShapeAttributes.
protected  void computeGeometry(DrawContext dc)
           
protected  double computeLabelInteriorOpacity(double textOpacity)
          Compute the opacity for the label interior.
protected  void createLabels()
           
protected  void determineActiveAttributes()
          Determine active attributes for this frame.
protected  void determineDelegateOwner()
          Determine the delegate owner for the current frame, and apply the owner to all renderable objects used to draw the graphic.
protected  void determineLabelPositions(DrawContext dc)
          Determine positions for the start and end labels.
protected  void determinePerFrameAttributes(DrawContext dc)
          Determine geometry and attributes for this frame.
protected abstract  void doRenderGraphic(DrawContext dc)
          Render this graphic, without modifiers.
protected  void doRenderGraphicModifiers(DrawContext dc)
          Render the graphic modifiers.
protected  void doRenderTextModifiers(DrawContext dc)
          Render the text modifiers.
protected  Object getActiveDelegateOwner()
          Indicates the object attached to the pick list to represent this graphic.
protected  TacticalGraphicAttributes getActiveOverrideAttributes()
          Get the override attributes that are active for this frame.
protected  ShapeAttributes getActiveShapeAttributes()
          Get the active shape attributes for this frame.
 TacticalGraphicAttributes getAttributes()
          Indicates this graphic's attributes when it is in the normal (as opposed to highlighted) state.
protected  Offset getDefaultLabelOffset()
          Indicates the default offset applied to the graphic's main label.
 Object getDelegateOwner()
          Returns the delegate owner of the graphic.
 TacticalGraphicAttributes getHighlightAttributes()
          Indicate this graphic's attributes when it is in the highlighted state.
protected  Material getLabelMaterial()
          Get the Material that should be used to draw labels.
 Offset getLabelOffset()
          Indicates an offset used to position the graphic's main label relative to the label's geographic position.
 Object getModifier(String modifier)
          Indicates the current value of a text or graphic modifier.
 String getText()
          Convenience method to access the text modifier of the graphic.
 UnitsFormat getUnitsFormat()
          Indicates the unit format used to format values in text modifiers.
 boolean isHighlighted()
          Indicates whether to highlight the shape.
 boolean isShowGraphicModifiers()
          Indicates whether this graphic draws its supplemental graphic modifiers.
 boolean isShowHostileIndicator()
          Indicates whether or not this graphic will display a text indicator when the graphic represents a hostile entity.
 boolean isShowLocation()
          Indicates whether or not the graphic should display its location as a text modifier.
 boolean isShowTextModifiers()
          Indicates whether this graphic draws its supplemental text modifiers.
 boolean isVisible()
          Indicates whether this graphic is drawn when in view.
 void move(Position delta)
          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.
protected  void onModifierChanged()
          Invoked when a modifier is changed.
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void setAttributes(TacticalGraphicAttributes attributes)
          Specifies attributes for this graphic in the normal (as opposed to highlighted) state.
 void setDelegateOwner(Object owner)
          Specifies the delegate owner of the graphic.
 void setHighlightAttributes(TacticalGraphicAttributes attributes)
          Specifies attributes for this graphic in the highlighted state.
 void setHighlighted(boolean highlighted)
          Specifies whether to highlight the shape.
 void setLabelOffset(Offset labelOffset)
          Specifies an offset used to position this graphic's main label relative to the label's geographic position.
 void setModifier(String modifier, Object value)
          Specifies the value of a text or graphic modifier.
 void setShowGraphicModifiers(boolean showModifiers)
          Specifies whether to draw this graphic's supplemental graphic modifiers.
 void setShowHostileIndicator(boolean showHostileIndicator)
          Specifies whether or not to display a text indicator when the symbol or graphic represents a hostile entity.
 void setShowLocation(boolean showLocation)
          Specifies whether or not the graphic should display its location as a text modifier.
 void setShowTextModifiers(boolean showModifiers)
          Specifies whether to draw this graphic's supplemental text modifiers.
 void setText(String text)
          Convenience method to specify a text modifier for the graphic.
 void setUnitsFormat(UnitsFormat unitsFormat)
          Specifies the unit format used to format values in text modifiers.
 void setVisible(boolean visible)
          Specifies whether this graphic is drawn when in view.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.symbology.TacticalGraphic
getIdentifier, getPositions, setPositions
 
Methods inherited from interface gov.nasa.worldwind.Movable
getReferencePosition
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

activeOverrides

protected TacticalGraphicAttributes activeOverrides
Override attributes for the current frame.


activeShapeAttributes

protected ShapeAttributes activeShapeAttributes
Shape attributes shared by all shapes that make up this graphic. The graphic's active attributes are copied into this attribute bundle on each frame.


DEFAULT_HIGHLIGHT_MATERIAL

protected static final Material DEFAULT_HIGHLIGHT_MATERIAL
The default highlight color.


DEFAULT_LABEL_INTERIOR_OPACITY

protected static final double DEFAULT_LABEL_INTERIOR_OPACITY
Opacity of label interiors. This value is multiplied by the label text opacity to determine the final interior opacity.

See Also:
Constant Field Values

delegateOwner

protected Object delegateOwner
Object returned during picking to represent this graphic.


frameTimestamp

protected long frameTimestamp
Current frame timestamp.


highlightAttributes

protected TacticalGraphicAttributes highlightAttributes
Attributes to apply when the graphic is highlighted. These attributes override defaults determined by the graphic's symbol code.


highlighted

protected boolean highlighted
Indicates whether or not the graphic is highlighted.


labelOffset

protected Offset labelOffset
Offset applied to the graphic's main label.


labels

protected List<TacticalGraphicLabel> labels
Labels to render with the graphic.


modifiers

protected AVList modifiers
Map of modifiers applied to this graphic. Note that implementations may not store all modifiers in this map. Some modifiers may be handled specially.


mustCreateLabels

protected boolean mustCreateLabels
Flag to indicate that labels must be recreated before the graphic is rendered.


normalAttributes

protected TacticalGraphicAttributes normalAttributes
Attributes to apply when the graphic is not highlighted. These attributes override defaults determined by the graphic's symbol code.


showGraphicModifiers

protected boolean showGraphicModifiers
Indicates whether or not to render graphic modifiers.


showHostileIndicator

protected boolean showHostileIndicator
Indicates whether or not to render the hostile/enemy modifier. This modifier is displayed by default.


showLocation

protected boolean showLocation
Indicates whether or not to render the location modifier.


showTextModifiers

protected boolean showTextModifiers
Indicates whether or not to render text modifiers.


text

protected String text
The graphic's text string. This field corresponds to the SymbologyConstants.UNIQUE_DESIGNATION modifier. Note that this field is not used if an Iterable is specified as the unique designation.


unitsFormat

protected UnitsFormat unitsFormat
Unit format used to format location and altitude for text modifiers.


visible

protected boolean visible
Indicates whether or not to render the graphic.

Constructor Detail

AbstractTacticalGraphic

public AbstractTacticalGraphic()
Method Detail

addLabel

protected TacticalGraphicLabel addLabel(String text)

applyDefaultAttributes

protected void applyDefaultAttributes(ShapeAttributes attributes)
Apply defaults to the active attributes bundle. The default attributes are determined by the type of graphic. This method is called each frame to reset the active shape attributes to the appropriate default state. Override attributes specified by the application may be applied after the defaults have been set.

Parameters:
attributes - Attributes bundle to receive defaults.

applyDelegateOwner

protected abstract void applyDelegateOwner(Object owner)
Invoked each frame to apply to the current delegate owner to all renderable objects used to draw the graphic. This base class will apply the delegate owner to Label objects. Subclasses must implement this method to apply the delegate owner to any Renderables that they will draw in order to render the graphic.

Parameters:
owner - Current delegate owner.

applyLabelAttributes

protected void applyLabelAttributes()
Apply the active attributes to the graphic's labels.


applyOverrideAttributes

protected void applyOverrideAttributes(TacticalGraphicAttributes graphicAttributes,
                                       ShapeAttributes shapeAttributes)
Apply override attributes specified in a TacticalGraphicAttributes bundle to the active ShapeAttributes. Any non-null properties of graphicAttributes will be applied to shapeAttributes.

Parameters:
graphicAttributes - Override attributes.
shapeAttributes - Shape attributes to receive overrides.

computeGeometry

protected void computeGeometry(DrawContext dc)

computeLabelInteriorOpacity

protected double computeLabelInteriorOpacity(double textOpacity)
Compute the opacity for the label interior. By default, the label interior is opacity is computed as 70% of the text opacity.

Parameters:
textOpacity - Opacity of the label text.
Returns:
Opacity of the label interior as a floating point number between 0.0 and 1.0.

createLabels

protected void createLabels()

determineActiveAttributes

protected void determineActiveAttributes()
Determine active attributes for this frame.


determineDelegateOwner

protected void determineDelegateOwner()
Determine the delegate owner for the current frame, and apply the owner to all renderable objects used to draw the graphic.


determineLabelPositions

protected void determineLabelPositions(DrawContext dc)
Determine positions for the start and end labels.

Parameters:
dc - Current draw context.

determinePerFrameAttributes

protected void determinePerFrameAttributes(DrawContext dc)
Determine geometry and attributes for this frame. This method only determines attributes the first time that it is called for each frame. Multiple calls in the same frame will have no effect.

Parameters:
dc - Current draw context.

doRenderGraphic

protected abstract void doRenderGraphic(DrawContext dc)
Render this graphic, without modifiers.

Parameters:
dc - Current draw context.
See Also:
doRenderTextModifiers(gov.nasa.worldwind.render.DrawContext), doRenderGraphicModifiers(gov.nasa.worldwind.render.DrawContext)

doRenderGraphicModifiers

protected void doRenderGraphicModifiers(DrawContext dc)
Render the graphic modifiers. This base class does not render anything, but subclasses may override this method to draw graphic modifiers.

Parameters:
dc - Current draw context.

doRenderTextModifiers

protected void doRenderTextModifiers(DrawContext dc)
Render the text modifiers.

Parameters:
dc - Current draw context.

getActiveDelegateOwner

protected Object getActiveDelegateOwner()
Indicates the object attached to the pick list to represent this graphic.

Returns:
Delegate owner, if specified, or this if an owner is not specified.

getActiveOverrideAttributes

protected TacticalGraphicAttributes getActiveOverrideAttributes()
Get the override attributes that are active for this frame.

Returns:
Override attributes. Values set in this bundle override defaults specified by the symbol set.

getActiveShapeAttributes

protected ShapeAttributes getActiveShapeAttributes()
Get the active shape attributes for this frame. The active attributes are created by applying application specified overrides to the default attributes specified by the symbol set.

Returns:
Active shape attributes.

getAttributes

public TacticalGraphicAttributes getAttributes()
Indicates this graphic's attributes when it is in the normal (as opposed to highlighted) state.

Specified by:
getAttributes in interface TacticalGraphic
Returns:
this graphic's attributes. May be null.

getDefaultLabelOffset

protected Offset getDefaultLabelOffset()
Indicates the default offset applied to the graphic's main label. This offset may be overridden by the graphic attributes.

Returns:
Offset to apply to the main label.

getDelegateOwner

public Object getDelegateOwner()
Returns the delegate owner of the graphic. If non-null, the returned object replaces the graphic as the pickable object returned during picking. If null, the graphic itself is the pickable object returned during picking.

Specified by:
getDelegateOwner in interface TacticalGraphic
Returns:
the object used as the pickable object returned during picking, or null to indicate the the graphic is returned during picking.

getHighlightAttributes

public TacticalGraphicAttributes getHighlightAttributes()
Indicate this graphic's attributes when it is in the highlighted state.

Specified by:
getHighlightAttributes in interface TacticalGraphic
Returns:
this graphic's highlight attributes. May be null.

getLabelMaterial

protected Material getLabelMaterial()
Get the Material that should be used to draw labels. If no override material has been specified, the graphic's outline Material is used for the labels.

Returns:
The Material that should be used when drawing labels. May change each frame.

getLabelOffset

public Offset getLabelOffset()
Indicates an offset used to position the graphic's main label relative to the label's geographic position. See comments on setLabelOffset for more information.

Specified by:
getLabelOffset in interface TacticalGraphic
Returns:
The offset that determines how the graphic's label is placed relative to the graphic.

getModifier

public Object getModifier(String modifier)
Indicates the current value of a text or graphic modifier.

Specified by:
getModifier in interface TacticalGraphic
Parameters:
modifier - Key that identifies the modifier to retrieve. The possible modifiers depends on the symbol set.
Returns:
The value of the modifier, or null if the modifier is not set.

getText

public String getText()
Convenience method to access the text modifier of the graphic. Calling this method is equivalent to calling getModifier(SymbologyConstants.UNIQUE_DESIGNATION).

Specified by:
getText in interface TacticalGraphic
Returns:
Descriptive text for this graphic.
See Also:
TacticalGraphic.getModifier(String)

getUnitsFormat

public UnitsFormat getUnitsFormat()
Indicates the unit format used to format values in text modifiers.

Specified by:
getUnitsFormat in interface TacticalGraphic
Returns:
Units format used to format text modifiers.

isHighlighted

public boolean isHighlighted()
Indicates whether to highlight the shape.

Specified by:
isHighlighted in interface Highlightable
Returns:
true to highlight the shape, otherwise false.

isShowGraphicModifiers

public boolean isShowGraphicModifiers()
Indicates whether this graphic draws its supplemental graphic modifiers.

Specified by:
isShowGraphicModifiers in interface TacticalGraphic
Returns:
true if this graphic draws its graphic modifiers, otherwise false.

isShowHostileIndicator

public boolean isShowHostileIndicator()
Indicates whether or not this graphic will display a text indicator when the graphic represents a hostile entity. See comments on setShowHostileIndicator for more information.

Specified by:
isShowHostileIndicator in interface TacticalGraphic
Returns:
true if an indicator may be drawn when this graphic represents a hostile entity, if supported by the graphic implementation. Note that some graphics may not display an indicator, even when representing a hostile entity.

isShowLocation

public boolean isShowLocation()
Indicates whether or not the graphic should display its location as a text modifier. Not all graphics support the location modifier.

Specified by:
isShowLocation in interface TacticalGraphic
Returns:
true if the graphic will display the location modifier. Note that not all graphics support this modifier.

isShowTextModifiers

public boolean isShowTextModifiers()
Indicates whether this graphic draws its supplemental text modifiers.

Specified by:
isShowTextModifiers in interface TacticalGraphic
Returns:
true if this graphic draws its text modifiers, otherwise false.

isVisible

public boolean isVisible()
Indicates whether this graphic is drawn when in view.

Specified by:
isVisible in interface TacticalGraphic
Returns:
true if this graphic is drawn when in view, otherwise false.

move

public void move(Position delta)
Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
move in interface Movable
Parameters:
delta - the latitude and longitude to add to the shape's reference position.

moveTo

public void moveTo(Position position)
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
moveTo in interface Movable
Parameters:
position - the new position of the shape's reference position.

onModifierChanged

protected void onModifierChanged()
Invoked when a modifier is changed. This implementation marks the label text as invalid causing it to be recreated based on the new modifiers.


render

public void render(DrawContext dc)
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

setAttributes

public void setAttributes(TacticalGraphicAttributes attributes)
Specifies attributes for this graphic in the normal (as opposed to highlighted) state. If any fields in the attribute bundle are null, the default attribute will be used instead. For example, if the attribute bundle includes a setting for outline material but not for interior material the new outline material will override the default outline material, but the interior material will remain the default. The default attributes are determined by the symbol set, and may differ depending on the type of graphic.

Specified by:
setAttributes in interface TacticalGraphic
Parameters:
attributes - new attributes. May be null, in which case default attributes are used.

setDelegateOwner

public void setDelegateOwner(Object owner)
Specifies the delegate owner of the graphic. If non-null, the delegate owner replaces the graphic as the pickable object returned during picking. If null, the graphic itself is the pickable object returned during picking.

Specified by:
setDelegateOwner in interface TacticalGraphic
Parameters:
owner - the object to use as the pickable object returned during picking, or null to return the graphic.

setHighlightAttributes

public void setHighlightAttributes(TacticalGraphicAttributes attributes)
Specifies attributes for this graphic in the highlighted state. See comments on setAttributes for more information on how the attributes are interpreted.

Specified by:
setHighlightAttributes in interface TacticalGraphic
Parameters:
attributes - Attributes to apply to the graphic when it is highlighted. May be null, in which default attributes are used.

setHighlighted

public void setHighlighted(boolean highlighted)
Specifies whether to highlight the shape.

Specified by:
setHighlighted in interface Highlightable
Parameters:
highlighted - true to highlight the shape, otherwise false.

setLabelOffset

public void setLabelOffset(Offset labelOffset)
Specifies an offset used to position this graphic's main label relative to the label's geographic position. The geographic position is determined by the type of graphic. For example, the label for an area graphic is typically placed at the center of the area polygon. Note that not all graphics have labels.

The offset can specify an absolute pixel value, or a an offset relative to the size of the label. For example, an offset of (-0.5, -0.5) in fraction units will center the label on its geographic position both horizontally and vertically.

Specified by:
setLabelOffset in interface TacticalGraphic
Parameters:
labelOffset - The offset that determines how the graphic's label is placed relative to the graphic.

setModifier

public void setModifier(String modifier,
                        Object value)
Specifies the value of a text or graphic modifier.

Specified by:
setModifier in interface TacticalGraphic
Parameters:
modifier - Key that identifies the modifier to set. The possible modifiers depends on the symbol set.
value - New value for the modifier.

setShowGraphicModifiers

public void setShowGraphicModifiers(boolean showModifiers)
Specifies whether to draw this graphic's supplemental graphic modifiers.

Specified by:
setShowGraphicModifiers in interface TacticalGraphic
Parameters:
showModifiers - true if this graphic should draw its graphic modifiers, otherwise false.

setShowHostileIndicator

public void setShowHostileIndicator(boolean showHostileIndicator)
Specifies whether or not to display a text indicator when the symbol or graphic represents a hostile entity. In the case of MIL-STD-2525C, the indicator is the letters "ENY". The indicator is determined by the symbology set, and may not apply to all graphics in the symbol set.

Specified by:
setShowHostileIndicator in interface TacticalGraphic
Parameters:
showHostileIndicator - true if this graphic should display an indicator when this graphic represents a hostile entity and the graphic implementation supports such an indicator. Note that some graphics may not display an indicator, even when representing a hostile entity.

setShowLocation

public void setShowLocation(boolean showLocation)
Specifies whether or not the graphic should display its location as a text modifier. Not all graphics support the location modifier. Setting showLocation on a graphic that does not support the modifier will have no effect.

Specified by:
setShowLocation in interface TacticalGraphic
Parameters:
showLocation - true if the graphic will display the location modifier. Note that not all graphics support this modifier.

setShowTextModifiers

public void setShowTextModifiers(boolean showModifiers)
Specifies whether to draw this graphic's supplemental text modifiers.

Specified by:
setShowTextModifiers in interface TacticalGraphic
Parameters:
showModifiers - true if this graphic should draw its text modifiers, otherwise false.

setText

public void setText(String text)
Convenience method to specify a text modifier for the graphic. Calling this method is equivalent to calling setModifier(SymbologyConstants.UNIQUE_DESIGNATION, text).

Specified by:
setText in interface TacticalGraphic
Parameters:
text - New text modifier. May be null.
See Also:
TacticalGraphic.setModifier(String, Object)

setUnitsFormat

public void setUnitsFormat(UnitsFormat unitsFormat)
Specifies the unit format used to format values in text modifiers.

Specified by:
setUnitsFormat in interface TacticalGraphic
Parameters:
unitsFormat - Format used to format text modifiers.

setVisible

public void setVisible(boolean visible)
Specifies whether this graphic is drawn when in view.

Specified by:
setVisible in interface TacticalGraphic
Parameters:
visible - true if this graphic should be drawn when in view, otherwise false.

NASA World Wind