public interface TacticalGraphic extends Renderable, Highlightable, Movable, AVList
See the Symbology
and
TacticalGraphics
example applications for examples of how to use
tactical graphics.
TacticalGraphicFactory
. Each graphic within a symbol
set is identified by a string identifier. The format of this identifier depends on the symbol set. For example, a
MIL-STD-2525 Symbol Identification Code (SIDC) is a string of 15 characters.
You will need to instantiate the appropriate factory for the symbol set that you intend to use. For example, MilStd2525GraphicFactory
creates graphics for the MIL-STD-2525 symbology
set.
The TacticalGraphic interface provides access to settings common to all tactical graphics. TacticalGraphic extends
the Renderable
interface, so you can add a TacticalGraphic directly to a RenderableLayer
. Here's an example of creating a graphic from the MIL-STD-2525 symbol set:
// Create a graphic factory for MIL-STD-2525
TacticalGraphicFactory factory = new MilStd2525GraphicFactory();
// Specify the control points for the line
List<Position> positions = Arrays.asList(
Position.fromDegrees(34.7327, -117.8347, 0),
Position.fromDegrees(34.7328, -117.7305, 0));
// Specify a text modifier
AVList modifiers = new AVListImpl();
modifiers.setValue(SymbologyConstants.UNIQUE_DESIGNATION, "Alpha");
// Create a graphic for a MIL-STD-2525 hostile phase line. The first argument is the symbol identification code
// (SIDC) that identifies the type of graphic to create.
TacticalGraphic graphic = factory.createGraphic("GHGPGLP----AUSX", positions, modifiers);
// Create a renderable layer to display the tactical graphic. This example adds only a single graphic, but many
// graphics can be added to a single layer.
RenderableLayer graphicLayer = new RenderableLayer();
graphicLayer.addRenderable(graphic);
// Add the layer to the WorldWindow's model and request that the layer redraw itself. The WorldWindow draws the
// graphic on the globe at the specified position. Interactions between the graphic and the cursor are returned in
// the WorldWindow's picked object list, and reported to the WorldWindow's select listeners.
WorldWindow wwd = ... // A reference to your application's WorldWind instance.
wwd.getModel().getLayers().add(graphicLayer);
wwd.redraw();
The symbol identifier (GHGPGLP----AUSX
) tells the factory what type of graphic to create, and how the graphic
should be styled. In the example above we added a text modifier of "Alpha" to identify our shape. These parameters
can be specified using a parameter list when the TacticalGraphic is created, as shown above. They can also be set
after creation using setters in the TacticalGraphic interface.
Many graphics support text or graphic modifiers. Each modifier is identified by a String key. The set of possible
modifiers is determined by the symbol set. Modifiers can be specified in the parameter list when a graphic is
created, or using setModifier
after the graphic has been created.
For example, a MIL-STD-2525 General Area graphic can have a text modifier that identifies the area. Here's an example of how to specify the modifier when the graphic is created:
AVList modifiers = new AVListImpl();
modifiers.setValue(SymbologyConstants.UNIQUE_DESIGNATION, "Boston"); // Text that identifies the area enclosed by
// the graphic.
List<Position> positions = ...; // List of positions that define the boundary of the area.
TacticalGraphic graphic = milstd2525Factory.createGraphic("GHGPGAG----AUSX", positions, modifiers);
The modifier can also be set (or changed) after the graphic is created:
// Create the graphic
TacticalGraphic graphic = milstd2525Factory.createGraphic("GHGPGAG----AUSX", positions, null);
graphic.setModifier(SymbologyConstants.UNIQUE_DESIGNATION, "Boston");
Each tactical graphic is positioned by one or more control points. How many points are required depends on the type of graphic. A point graphic will only require one point. A more complex shape may require three or four, and a line or area may allow any number.
Here is an example of how to create a point graphic in the MIL-STD-2525 symbol set:
Position position = Position.fromDegrees(34.9362, -118.2559, 0);
TacticalGraphic graphic = milstd2525Factory.createPoint("GFGPAPD----AUSX", position, null);
More complicated graphics will require more control points. MIL-STD-2525 defines a template for each type of tactical graphic. Each template identifies how many control points are required for the graphic, and how the points are interpreted. The TacticalGraphic requires a list of Position objects, which identify the control points in the same order as in the specification. For example, in order to create a graphic that requires three control points we need to create a list of positions that specifies the three points in order:
List<Position> positions = Arrays.asList(
Position.fromDegrees(34.5073, -117.8380, 0), // PT. 1
Position.fromDegrees(34.8686, -117.5088, 0), // PT. 2
Position.fromDegrees(34.4845, -117.8495, 0)); // PT. 3
TacticalGraphic graphic = milstd2525Factory.createGraphic("GFGPSLA----AUSX", positions, null);
TacticalGraphic describes any tactical graphic in the most general terms: a list of positions and modifiers. However, this general interface is not convenient for all graphics. For example, when creating a circle graphic it is more convenient to access the radius of the circle directly than to set a modifier that affects the radius. Sub-interfaces of tactical graphic provide more convenient methods for manipulating common types of graphics. Instances of these sub-interfaces can be created directly using a TacticalGraphicFactory. The sub-interfaces are:
TacticalPoint
- Graphics positioned by a single point.TacticalCircle
- Graphics
positioned by a center point and radius.TacticalQuad
- Rectangles with a length and width.TacticalRoute
- A series of point graphics connected by lines and treated as a single graphic.TacticalGraphicFactory
Modifier and Type | Method and Description |
---|---|
TacticalGraphicAttributes |
getAttributes()
Indicates this graphic's attributes when it is in the normal (as opposed to highlighted) state.
|
java.lang.Object |
getDelegateOwner()
Returns the delegate owner of the graphic.
|
TacticalGraphicAttributes |
getHighlightAttributes()
Indicate this graphic's attributes when it is in the highlighted state.
|
java.lang.String |
getIdentifier()
Indicates a string identifier for this graphic.
|
Offset |
getLabelOffset()
Indicates an offset used to position the graphic's main label relative to the label's geographic position.
|
java.lang.Object |
getModifier(java.lang.String modifier)
Indicates the current value of a text or graphic modifier.
|
java.lang.Iterable<? extends Position> |
getPositions()
Indicates the positions of the control points that place and orient the graphic.
|
java.lang.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 |
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 |
setAttributes(TacticalGraphicAttributes attributes)
Specifies attributes for this graphic in the normal (as opposed to highlighted) state.
|
void |
setDelegateOwner(java.lang.Object owner)
Specifies the delegate owner of the graphic.
|
void |
setHighlightAttributes(TacticalGraphicAttributes attributes)
Specifies attributes for this graphic in the highlighted state.
|
void |
setLabelOffset(Offset offset)
Specifies an offset used to position this graphic's main label relative to the label's geographic position.
|
void |
setModifier(java.lang.String modifier,
java.lang.Object value)
Specifies the value of a text or graphic modifier.
|
void |
setPositions(java.lang.Iterable<? extends Position> positions)
Specifies the positions of the control points that place and orient the graphic.
|
void |
setShowGraphicModifiers(boolean showGraphicModifiers)
Specifies whether to draw this graphic's supplemental graphic modifiers.
|
void |
setShowHostileIndicator(boolean show)
Specifies whether or not to display a text indicator when the symbol or graphic represents a hostile entity.
|
void |
setShowLocation(boolean show)
Specifies whether or not the graphic should display its location as a text modifier.
|
void |
setShowTextModifiers(boolean showTextModifiers)
Specifies whether to draw this graphic's supplemental text modifiers.
|
void |
setText(java.lang.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.
|
render
isHighlighted, setHighlighted
getReferencePosition, move, moveTo
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
TacticalGraphicAttributes getAttributes()
java.lang.Object getDelegateOwner()
TacticalGraphicAttributes getHighlightAttributes()
java.lang.String getIdentifier()
Offset getLabelOffset()
setLabelOffset
for more information.java.lang.Object getModifier(java.lang.String modifier)
modifier
- Key that identifies the modifier to retrieve. The possible modifiers depends on the symbol set.null
if the modifier is not set.java.lang.Iterable<? extends Position> getPositions()
java.lang.String getText()
getModifier(SymbologyConstants.UNIQUE_DESIGNATION)
.getModifier(String)
UnitsFormat getUnitsFormat()
boolean isShowGraphicModifiers()
boolean isShowHostileIndicator()
setShowHostileIndicator
for more information.boolean isShowLocation()
boolean isShowTextModifiers()
boolean isVisible()
void setAttributes(TacticalGraphicAttributes attributes)
attributes
- new attributes. May be null, in which case default attributes are used.void setDelegateOwner(java.lang.Object owner)
owner
- the object to use as the pickable object returned during picking, or null to return the graphic.void setHighlightAttributes(TacticalGraphicAttributes attributes)
setAttributes
for more information on how the attributes are
interpreted.attributes
- Attributes to apply to the graphic when it is highlighted. May be null, in which default
attributes are used.void setLabelOffset(Offset offset)
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.
offset
- The offset that determines how the graphic's label is placed relative to the graphic.void setModifier(java.lang.String modifier, java.lang.Object value)
modifier
- Key that identifies the modifier to set. The possible modifiers depends on the symbol set.value
- New value for the modifier.void setPositions(java.lang.Iterable<? extends Position> positions)
positions
- Positions that orient the graphic. How many positions are returned depends on the type of
graphic. Some graphics require only a single position, others require many. The positions must
be specified in the same order as the control points defined by the symbology set's template for
this type of graphic.void setShowGraphicModifiers(boolean showGraphicModifiers)
showGraphicModifiers
- true if this graphic should draw its graphic modifiers, otherwise false.void setShowHostileIndicator(boolean show)
show
- 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.void setShowLocation(boolean show)
show
- true if the graphic will display the location modifier. Note that not all graphics support this
modifier.void setShowTextModifiers(boolean showTextModifiers)
showTextModifiers
- true if this graphic should draw its text modifiers, otherwise false.void setText(java.lang.String text)
setModifier(SymbologyConstants.UNIQUE_DESIGNATION, text)
.text
- New text modifier. May be null.setModifier(String, Object)
void setUnitsFormat(UnitsFormat unitsFormat)
unitsFormat
- Format used to format text modifiers.void setVisible(boolean visible)
visible
- true if this graphic should be drawn when in view, otherwise false.