public class TacticalGraphicLabel
extends java.lang.Object
orientationPosition
for the label.
The label will be drawn along a line connecting the label's position to the orientation position.Modifier and Type | Class and Description |
---|---|
protected class |
TacticalGraphicLabel.OrderedLabel |
Modifier and Type | Field and Description |
---|---|
protected OGLStackHandler |
BEogsh
Stack handler used for beginDrawing/endDrawing state.
|
protected java.awt.geom.Rectangle2D |
bounds
Size of the label.
|
static java.awt.Font |
DEFAULT_FONT
Default font.
|
static java.awt.Insets |
DEFAULT_INSETS
Default insets around the label.
|
static double |
DEFAULT_INTERIOR_OPACITY
Default interior opacity.
|
static Offset |
DEFAULT_OFFSET
Default offset.
|
static java.lang.String |
DEFAULT_TEXT_EFFECT
Default text effect (shadow).
|
protected java.lang.Object |
delegateOwner
Indicates an object that represents the label during picking.
|
protected boolean |
drawInterior
Indicates whether or not to draw the label interior.
|
protected java.lang.String |
effect
Effect applied to the text.
|
protected boolean |
enableBatchPicking
Indicates whether or not batch picking is enabled.
|
protected boolean |
enableBatchRendering
Indicates whether or not batch rendering is enabled.
|
protected java.awt.Font |
font
Font used to draw the label.
|
protected long |
frameTimeStamp |
protected java.awt.Insets |
insets
Insets that separate the text from its frame.
|
protected double |
interiorOpacity |
protected java.awt.geom.Rectangle2D[] |
lineBounds
Cached bounds for each line of text.
|
protected int |
lineHeight
Height of a line of text, computed in
computeBoundsIfNeeded(gov.nasa.worldwind.render.DrawContext) . |
protected java.lang.String[] |
lines
Text split into separate lines.
|
protected int |
lineSpacing
Space (in pixels) between lines in a multi-line label.
|
protected Material |
material
Material used to draw the label.
|
protected Offset |
offset
Offset from the geographic position at which to draw the label.
|
protected double |
opacity
Opacity of the text, as a value between 0 and 1.
|
protected Position |
orientationPosition
The label is drawn along a line from the label position to the orientation position.
|
protected Layer |
pickLayer
Active layer.
|
protected PickSupport |
pickSupport
Support object used during picking.
|
protected Position |
position
The label's geographic position.
|
protected java.lang.String |
textAlign
Text alignment for multi-line labels.
|
protected TacticalGraphicLabel.OrderedLabel |
thisFramesOrderedLabel |
Constructor and Description |
---|
TacticalGraphicLabel()
Create a new empty label.
|
TacticalGraphicLabel(java.lang.String text)
Create a new label.
|
Modifier and Type | Method and Description |
---|---|
protected void |
beginDrawing(DrawContext dc)
Establish the OpenGL state needed to draw text.
|
protected java.awt.Color |
computeBackgroundColor(java.awt.Color color)
Compute a contrasting background color to draw the label's outline.
|
protected void |
computeBoundsIfNeeded(DrawContext dc)
Compute the bounds of the text, if necessary.
|
protected void |
computeGeometry(DrawContext dc,
TacticalGraphicLabel.OrderedLabel olbl)
Compute the label's screen position from its geographic position.
|
protected void |
computeGeometryIfNeeded(DrawContext dc) |
protected java.awt.Rectangle |
computeRotatedScreenExtent(java.awt.Rectangle rect,
int x,
int y,
Angle rotation)
Compute the bounding screen extent of a rotated rectangle.
|
protected Angle |
computeRotation(Vec4 screenPoint,
Vec4 orientationScreenPoint)
Compute the amount of rotation to apply to a label in order to keep it oriented toward its orientation position.
|
protected java.awt.Rectangle |
computeTextExtent(int x,
int y,
TacticalGraphicLabel.OrderedLabel olbl)
Determine the screen rectangle covered by a label.
|
protected void |
doDrawOrderedRenderable(DrawContext dc,
PickSupport pickSupport,
TacticalGraphicLabel.OrderedLabel olbl)
Draw this label during ordered rendering.
|
protected void |
doDrawText(TextRenderer textRenderer,
TacticalGraphicLabel.OrderedLabel olbl)
Draw the label's text.
|
protected void |
doPick(DrawContext dc,
PickSupport pickSupport,
TacticalGraphicLabel.OrderedLabel olbl)
Draw labels for picking.
|
protected void |
drawBatched(DrawContext dc,
TacticalGraphicLabel.OrderedLabel firstLabel)
Draws this ordered renderable and all subsequent Label ordered renderables in the ordered renderable list.
|
protected void |
drawBatchedText(DrawContext dc,
TextRenderer textRenderer,
TacticalGraphicLabel.OrderedLabel firstLabel)
Draws text for subsequent Label ordered renderables in the ordered renderable list.
|
protected void |
drawInterior(DrawContext dc,
TacticalGraphicLabel.OrderedLabel olbl)
Render the label interior as a filled rectangle.
|
protected void |
drawMultiLineText(TextRenderer textRenderer,
int x,
int y,
TacticalGraphicLabel.OrderedLabel olbl) |
protected void |
drawOrderedRenderable(DrawContext dc,
TacticalGraphicLabel.OrderedLabel olbl)
Draws the graphic as an ordered renderable.
|
protected void |
drawText(DrawContext dc,
TextRenderer textRenderer,
TacticalGraphicLabel.OrderedLabel olbl)
Draw the label's text.
|
protected void |
endDrawing(DrawContext dc)
Pop the state set in beginDrawing.
|
java.awt.Rectangle |
getBounds(DrawContext dc)
Get the label bounding
Rectangle using OGL coordinates - bottom-left corner x and y relative to
the WorldWindow bottom-left corner. |
java.lang.Object |
getDelegateOwner()
Returns the delegate owner of this label.
|
java.lang.String |
getEffect()
Indicates an effect used to decorate the text.
|
java.awt.Font |
getFont()
Indicates the font used to draw the label.
|
java.awt.Insets |
getInsets()
Indicates the amount of space between the label's content and its frame, in pixels.
|
double |
getInteriorOpacity()
Indicates the opacity of label's interior as a floating-point value in the range 0.0 to 1.0.
|
int |
getLineSpacing()
Indicates the line spacing applied to multi-line labels.
|
Material |
getMaterial()
Indicates the material used to draw the label.
|
Offset |
getOffset()
Indicates the offset from the geographic position at which to draw the label.
|
double |
getOpacity()
Indicates the opacity of the text as a floating-point value in the range 0.0 to 1.0.
|
Position |
getOrientationPosition()
Indicates the orientation position.
|
protected java.lang.Object |
getPickedObject()
Indicates the object that represents this label during picking.
|
Position |
getPosition()
Indicates the label's position.
|
java.lang.String |
getText()
Indicates the text of this label.
|
java.lang.String |
getTextAlign()
Indicates the current text alignment.
|
protected boolean |
intersectsFrustum(DrawContext dc,
TacticalGraphicLabel.OrderedLabel olbl)
Determine if this label intersects the view or pick frustum.
|
boolean |
isDrawInterior()
Indicates whether or not to draw a colored frame behind the label.
|
boolean |
isEnableBatchPicking()
Indicates whether batch picking is enabled.
|
boolean |
isEnableBatchRendering()
Indicates whether batch rendering is enabled.
|
protected void |
makeOrderedRenderable(DrawContext dc)
Draws the graphic as an ordered renderable.
|
void |
pick(DrawContext dc,
java.awt.Point pickPoint,
TacticalGraphicLabel.OrderedLabel olbl) |
void |
render(DrawContext dc) |
void |
setDelegateOwner(java.lang.Object owner)
Specifies the delegate owner of this label.
|
void |
setDrawInterior(boolean drawInterior)
Specifies whether or not to draw a colored frame behind the label.
|
void |
setEffect(java.lang.String effect)
Specifies an effect used to decorate the text.
|
void |
setEnableBatchPicking(boolean enableBatchPicking)
Specifies whether adjacent Labels in the ordered renderable list may be pick-tested together if they are
contained in the same layer.
|
void |
setEnableBatchRendering(boolean enableBatchRendering)
Specifies whether adjacent Labels in the ordered renderable list may be rendered together if they are contained
in the same layer.
|
void |
setFont(java.awt.Font font)
Specifies the font used to draw the label.
|
void |
setInsets(java.awt.Insets insets)
Specifies the amount of space (in pixels) between the label's content and the edges of the label's frame.
|
void |
setInteriorOpacity(double interiorOpacity)
Specifies the opacity of the label's interior as a floating-point value in the range 0.0 to 1.0.
|
void |
setLineSpacing(int lineSpacing)
Specifies the line spacing applied to multi-line labels.
|
void |
setMaterial(Material material)
Specifies the material used to draw the label.
|
void |
setOffset(Offset offset)
Specifies the offset from the geographic position at which to draw the label.
|
void |
setOpacity(double opacity)
Specifies the opacity of the text as a floating-point value in the range 0.0 to 1.0.
|
void |
setOrientationPosition(Position orientationPosition)
Specifies the orientation position.
|
void |
setPosition(Position position)
Indicates the label's geographic position.
|
void |
setText(java.lang.String text)
Specifies the text of this label.
|
void |
setTextAlign(java.lang.String textAlign)
Specifies the text alignment.
|
protected OGLStackHandler BEogsh
protected java.awt.geom.Rectangle2D bounds
public static final java.awt.Font DEFAULT_FONT
public static final java.awt.Insets DEFAULT_INSETS
public static final double DEFAULT_INTERIOR_OPACITY
public static final Offset DEFAULT_OFFSET
AVKey.LEFT
, then the left edge of the text
will be aligned with the geographic position, and the label will be centered vertically.public static final java.lang.String DEFAULT_TEXT_EFFECT
protected java.lang.Object delegateOwner
protected boolean drawInterior
protected java.lang.String effect
AVKey.TEXT_EFFECT_SHADOW
or AVKey.TEXT_EFFECT_NONE
.protected boolean enableBatchPicking
protected boolean enableBatchRendering
protected java.awt.Font font
protected long frameTimeStamp
protected java.awt.Insets insets
protected double interiorOpacity
protected java.awt.geom.Rectangle2D[] lineBounds
protected int lineHeight
computeBoundsIfNeeded(gov.nasa.worldwind.render.DrawContext)
.protected java.lang.String[] lines
protected int lineSpacing
protected Material material
protected Offset offset
protected double opacity
protected Position orientationPosition
protected Layer pickLayer
protected PickSupport pickSupport
protected Position position
protected java.lang.String textAlign
protected TacticalGraphicLabel.OrderedLabel thisFramesOrderedLabel
public TacticalGraphicLabel()
public TacticalGraphicLabel(java.lang.String text)
text
- Label text.protected void beginDrawing(DrawContext dc)
dc
- the current draw context.protected java.awt.Color computeBackgroundColor(java.awt.Color color)
color
- Label color.color
.protected void computeBoundsIfNeeded(DrawContext dc)
dc
- the current DrawContext.protected void computeGeometry(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
dc
- Current draw context.olbl
- The ordered label to compute geometry for.protected void computeGeometryIfNeeded(DrawContext dc)
protected java.awt.Rectangle computeRotatedScreenExtent(java.awt.Rectangle rect, int x, int y, Angle rotation)
rect
- Rectangle to rotate.x
- X coordinate of the rotation point.y
- Y coordinate of the rotation point.rotation
- Rotation angle.rect
when rotated by the specified angle.protected Angle computeRotation(Vec4 screenPoint, Vec4 orientationScreenPoint)
screenPoint
- Geographic position of the text, projected onto the screen.orientationScreenPoint
- Orientation position, projected onto the screen.protected java.awt.Rectangle computeTextExtent(int x, int y, TacticalGraphicLabel.OrderedLabel olbl)
x
- X coordinate at which to draw the label.y
- Y coordinate at which to draw the label.olbl
- The ordered label to compute extents for.protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickSupport, TacticalGraphicLabel.OrderedLabel olbl)
dc
- Current draw context.pickSupport
- Support object used during picking.olbl
- The ordered label to draw.protected void doDrawText(TextRenderer textRenderer, TacticalGraphicLabel.OrderedLabel olbl)
textRenderer
- renderer to use.olbl
- The ordered label to draw.protected void doPick(DrawContext dc, PickSupport pickSupport, TacticalGraphicLabel.OrderedLabel olbl)
dc
- Current draw context.pickSupport
- the PickSupport instance to be used.olbl
- The ordered label to pick.protected void drawBatched(DrawContext dc, TacticalGraphicLabel.OrderedLabel firstLabel)
drawBatchedText
in that this method
re-initializes the text renderer to draw the next label, while drawBatchedText
re-uses the active text
renderer context. That is, drawBatchedText
attempts to draw as many labels as possible that share same
text renderer configuration as this label, and this method attempts to draw as many labels as possible regardless
of the text renderer configuration of the subsequent labels.dc
- the current draw context.firstLabel
- the label drawn prior to calling this method.protected void drawBatchedText(DrawContext dc, TextRenderer textRenderer, TacticalGraphicLabel.OrderedLabel firstLabel)
drawBatched
in that this method reuses the active text renderer context to draw as many labels as possible
without switching text renderer state.dc
- the current draw context.textRenderer
- Text renderer used to draw the label.firstLabel
- The first ordered renderable in the batch.protected void drawInterior(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
dc
- Current draw context.olbl
- The ordered label to draw.protected void drawMultiLineText(TextRenderer textRenderer, int x, int y, TacticalGraphicLabel.OrderedLabel olbl)
protected void drawOrderedRenderable(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
dc
- the current draw context.olbl
- The ordered label to draw.protected void drawText(DrawContext dc, TextRenderer textRenderer, TacticalGraphicLabel.OrderedLabel olbl)
doDrawText
to actually draw the text.dc
- Current draw context.textRenderer
- Text renderer.olbl
- The ordered label to draw.protected void endDrawing(DrawContext dc)
dc
- the current draw context.public java.awt.Rectangle getBounds(DrawContext dc)
Rectangle
using OGL coordinates - bottom-left corner x and y relative to
the WorldWindow
bottom-left corner. If the label is rotated then the returned
rectangle is the bounding rectangle of the rotated label.dc
- the current DrawContext.Rectangle
using OGL viewport coordinates.java.lang.IllegalArgumentException
- if dc
is null.public java.lang.Object getDelegateOwner()
public java.lang.String getEffect()
AVKey.TEXT_EFFECT_SHADOW
(default), or
AVKey.TEXT_EFFECT_NONE
.public java.awt.Font getFont()
public java.awt.Insets getInsets()
setInsets(java.awt.Insets)
public double getInteriorOpacity()
public int getLineSpacing()
public Material getMaterial()
public Offset getOffset()
setOffset
for more information on how the offset is interpreted.public double getOpacity()
public Position getOrientationPosition()
protected java.lang.Object getPickedObject()
public Position getPosition()
getOffset()
public java.lang.String getText()
public java.lang.String getTextAlign()
AVKey.LEFT
(default), AVKey.CENTER
or AVKey.RIGHT
.protected boolean intersectsFrustum(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
dc
- Current draw context.olbl
- The ordered label to intersect.public boolean isDrawInterior()
true
if the label's interior is drawn, otherwise false
.setDrawInterior(boolean)
public boolean isEnableBatchPicking()
setEnableBatchPicking(boolean)
public boolean isEnableBatchRendering()
setEnableBatchRendering(boolean)
protected void makeOrderedRenderable(DrawContext dc)
dc
- the current draw context.public void pick(DrawContext dc, java.awt.Point pickPoint, TacticalGraphicLabel.OrderedLabel olbl)
public void render(DrawContext dc)
public void setDelegateOwner(java.lang.Object owner)
owner
- the object to use as the pickable object returned during picking, or null to return the label.public void setDrawInterior(boolean drawInterior)
drawInterior
- true
if the label's interior is drawn, otherwise false
.isDrawInterior()
public void setEffect(java.lang.String effect)
AVKey.TEXT_EFFECT_SHADOW
(default), or
AVKey.TEXT_EFFECT_NONE
.effect
- the effect to use for text renderingpublic void setEnableBatchPicking(boolean enableBatchPicking)
SelectEvent
even if several of the labels are at the pick position.
Batch rendering (setEnableBatchRendering(boolean)
) must be enabled in order for batch picking to occur.
enableBatchPicking
- true to enable batch rendering, otherwise false.public void setEnableBatchRendering(boolean enableBatchRendering)
enableBatchRendering
- true to enable batch rendering, otherwise false.public void setFont(java.awt.Font font)
font
- New font.public void setInsets(java.awt.Insets insets)
insets
- the desired padding between the label's content and its frame, in pixels.java.lang.IllegalArgumentException
- if insets
is null
.getInsets()
public void setInteriorOpacity(double interiorOpacity)
interiorOpacity
- the opacity of label's interior as a floating-point value from 0.0 to 1.0.java.lang.IllegalArgumentException
- if opacity
is less than 0.0 or greater than 1.0.public void setLineSpacing(int lineSpacing)
lineSpacing
- New line spacing.public void setMaterial(Material material)
material
- New material.public void setOffset(Offset offset)
AVKey.LEFT
., then the left edge of the text will be aligned with the geographic position, and the
label will be centered vertically.
When the text is rotated a horizontal offset moves the text along the orientation line, and a vertical offset moves the text perpendicular to the orientation line.
offset
- The offset at which to draw the label.public void setOpacity(double opacity)
opacity
- the opacity of text as a floating-point value from 0.0 to 1.0.java.lang.IllegalArgumentException
- if opacity
is less than 0.0 or greater than 1.0.public void setOrientationPosition(Position orientationPosition)
orientationPosition
- Draw label oriented toward this position.public void setPosition(Position position)
position
- New position.getOffset()
public void setText(java.lang.String text)
text
- New text.public void setTextAlign(java.lang.String textAlign)
textAlign
- New text alignment.