Package gov.nasa.worldwind.symbology
Class TacticalGraphicLabel
- java.lang.Object
-
- gov.nasa.worldwind.symbology.TacticalGraphicLabel
-
public class TacticalGraphicLabel extends java.lang.Object
A label drawn as part of a tactical graphic. The label is drawn at constant screen size. The label can include multiple lines of text, and can optionally be kept aligned with features on the globe. To align a label with the globe specify anorientationPosition
for the label. The label will be drawn along a line connecting the label's position to the orientation position.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
TacticalGraphicLabel.OrderedLabel
-
Field Summary
Fields Modifier and Type Field 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 incomputeBoundsIfNeeded(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 Summary
Constructors Constructor Description TacticalGraphicLabel()
Create a new empty label.TacticalGraphicLabel(java.lang.String text)
Create a new label.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 boundingRectangle
using OGL coordinates - bottom-left corner x and y relative to theWorldWindow
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)
Causes thisRenderable
to render itself using the provided draw context.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.
-
-
-
Field Detail
-
DEFAULT_FONT
public static final java.awt.Font DEFAULT_FONT
Default font.
-
DEFAULT_OFFSET
public static final Offset DEFAULT_OFFSET
Default offset. The default offset aligns the label horizontal with the text alignment position, and centers the label vertically. For example, if the text alignment isAVKey.LEFT
, then the left edge of the text will be aligned with the geographic position, and the label will be centered vertically.
-
DEFAULT_INSETS
public static final java.awt.Insets DEFAULT_INSETS
Default insets around the label.
-
DEFAULT_INTERIOR_OPACITY
public static final double DEFAULT_INTERIOR_OPACITY
Default interior opacity.- See Also:
- Constant Field Values
-
DEFAULT_TEXT_EFFECT
public static final java.lang.String DEFAULT_TEXT_EFFECT
Default text effect (shadow).- See Also:
- Constant Field Values
-
lines
protected java.lang.String[] lines
Text split into separate lines.
-
position
protected Position position
The label's geographic position.
-
offset
protected Offset offset
Offset from the geographic position at which to draw the label.
-
textAlign
protected java.lang.String textAlign
Text alignment for multi-line labels.
-
orientationPosition
protected Position orientationPosition
The label is drawn along a line from the label position to the orientation position.
-
material
protected Material material
Material used to draw the label.
-
opacity
protected double opacity
Opacity of the text, as a value between 0 and 1.
-
interiorOpacity
protected double interiorOpacity
-
font
protected java.awt.Font font
Font used to draw the label.
-
lineSpacing
protected int lineSpacing
Space (in pixels) between lines in a multi-line label.
-
effect
protected java.lang.String effect
Effect applied to the text. May beAVKey.TEXT_EFFECT_SHADOW
orAVKey.TEXT_EFFECT_NONE
.
-
insets
protected java.awt.Insets insets
Insets that separate the text from its frame. Only applies when the text interior is rendered.
-
drawInterior
protected boolean drawInterior
Indicates whether or not to draw the label interior.
-
enableBatchRendering
protected boolean enableBatchRendering
Indicates whether or not batch rendering is enabled.
-
enableBatchPicking
protected boolean enableBatchPicking
Indicates whether or not batch picking is enabled.
-
delegateOwner
protected java.lang.Object delegateOwner
Indicates an object that represents the label during picking.
-
frameTimeStamp
protected long frameTimeStamp
-
thisFramesOrderedLabel
protected TacticalGraphicLabel.OrderedLabel thisFramesOrderedLabel
-
bounds
protected java.awt.geom.Rectangle2D bounds
Size of the label.
-
lineBounds
protected java.awt.geom.Rectangle2D[] lineBounds
Cached bounds for each line of text.
-
lineHeight
protected int lineHeight
Height of a line of text, computed incomputeBoundsIfNeeded(gov.nasa.worldwind.render.DrawContext)
.
-
BEogsh
protected OGLStackHandler BEogsh
Stack handler used for beginDrawing/endDrawing state.
-
pickSupport
protected PickSupport pickSupport
Support object used during picking.
-
pickLayer
protected Layer pickLayer
Active layer.
-
-
Method Detail
-
getText
public java.lang.String getText()
Indicates the text of this label.- Returns:
- The label's text.
-
setText
public void setText(java.lang.String text)
Specifies the text of this label. The text may include multiple lines, separated by newline characters.- Parameters:
text
- New text.
-
getPosition
public Position getPosition()
Indicates the label's position. The label is drawn at an offset from this position.- Returns:
- The label's geographic position.
- See Also:
getOffset()
-
setPosition
public void setPosition(Position position)
Indicates the label's geographic position. The label is drawn at an offset from this position.- Parameters:
position
- New position.- See Also:
getOffset()
-
getTextAlign
public java.lang.String getTextAlign()
Indicates the current text alignment. Can be one ofAVKey.LEFT
(default),AVKey.CENTER
orAVKey.RIGHT
.- Returns:
- the current text alignment.
-
setTextAlign
public void setTextAlign(java.lang.String textAlign)
- Parameters:
textAlign
- New text alignment.
-
getOffset
public Offset getOffset()
Indicates the offset from the geographic position at which to draw the label. SeesetOffset
for more information on how the offset is interpreted.- Returns:
- The offset at which to draw the label.
-
setOffset
public void setOffset(Offset offset)
Specifies the offset from the geographic position at which to draw the label. The default offset aligns the label horizontal with the text alignment position, and centers the label vertically. For example, if the text alignment isAVKey.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.
- Parameters:
offset
- The offset at which to draw the label.
-
getFont
public java.awt.Font getFont()
Indicates the font used to draw the label.- Returns:
- The label's font.
-
setFont
public void setFont(java.awt.Font font)
Specifies the font used to draw the label.- Parameters:
font
- New font.
-
getLineSpacing
public int getLineSpacing()
Indicates the line spacing applied to multi-line labels.- Returns:
- The space (in pixels) between lines of a multi-line label.
-
setLineSpacing
public void setLineSpacing(int lineSpacing)
Specifies the line spacing applied to multi-line labels.- Parameters:
lineSpacing
- New line spacing.
-
getMaterial
public Material getMaterial()
Indicates the material used to draw the label.- Returns:
- The label's material.
-
setMaterial
public void setMaterial(Material material)
Specifies the material used to draw the label.- Parameters:
material
- New material.
-
isDrawInterior
public boolean isDrawInterior()
Indicates whether or not to draw a colored frame behind the label.- Returns:
true
if the label's interior is drawn, otherwisefalse
.- See Also:
setDrawInterior(boolean)
-
setDrawInterior
public void setDrawInterior(boolean drawInterior)
Specifies whether or not to draw a colored frame behind the label.- Parameters:
drawInterior
-true
if the label's interior is drawn, otherwisefalse
.- See Also:
isDrawInterior()
-
getOpacity
public double getOpacity()
Indicates the opacity of the text as a floating-point value in the range 0.0 to 1.0. A value of 1.0 specifies a completely opaque text, and 0.0 specifies a completely transparent text. Values in between specify a partially transparent text.- Returns:
- the opacity of the text as a floating-point value from 0.0 to 1.0.
-
setOpacity
public void setOpacity(double opacity)
Specifies the opacity of the text as a floating-point value in the range 0.0 to 1.0. A value of 1.0 specifies a completely opaque text, and 0.0 specifies a completely transparent text. Values in between specify a partially transparent text.- Parameters:
opacity
- the opacity of text as a floating-point value from 0.0 to 1.0.- Throws:
java.lang.IllegalArgumentException
- ifopacity
is less than 0.0 or greater than 1.0.
-
getInteriorOpacity
public double getInteriorOpacity()
Indicates the opacity of label's interior as a floating-point value in the range 0.0 to 1.0. A value of 1.0 specifies a completely opaque interior, and 0.0 specifies a completely transparent interior. Values in between specify a partially transparent interior.- Returns:
- the opacity of the interior as a floating-point value from 0.0 to 1.0.
-
setInteriorOpacity
public 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. A value of 1.0 specifies a completely opaque interior, and 0.0 specifies a completely transparent interior. Values in between specify a partially transparent interior.- Parameters:
interiorOpacity
- the opacity of label's interior as a floating-point value from 0.0 to 1.0.- Throws:
java.lang.IllegalArgumentException
- ifopacity
is less than 0.0 or greater than 1.0.
-
getOrientationPosition
public Position getOrientationPosition()
Indicates the orientation position. The label oriented on a line drawn from the label's position to the orientation position.- Returns:
- Position used to orient the label. May be null.
-
setOrientationPosition
public void setOrientationPosition(Position orientationPosition)
Specifies the orientation position. The label is oriented on a line drawn from the label's position to the orientation position. If the orientation position is null then the label is drawn with no rotation.- Parameters:
orientationPosition
- Draw label oriented toward this position.
-
getInsets
public java.awt.Insets getInsets()
Indicates the amount of space between the label's content and its frame, in pixels.- Returns:
- the padding between the label's content and its frame, in pixels.
- See Also:
setInsets(java.awt.Insets)
-
setInsets
public 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.- Parameters:
insets
- the desired padding between the label's content and its frame, in pixels.- Throws:
java.lang.IllegalArgumentException
- ifinsets
isnull
.- See Also:
getInsets()
-
getEffect
public java.lang.String getEffect()
Indicates an effect used to decorate the text. Can be one ofAVKey.TEXT_EFFECT_SHADOW
(default), orAVKey.TEXT_EFFECT_NONE
.- Returns:
- the effect used for text rendering
-
setEffect
public void setEffect(java.lang.String effect)
Specifies an effect used to decorate the text. Can be one ofAVKey.TEXT_EFFECT_SHADOW
(default), orAVKey.TEXT_EFFECT_NONE
.- Parameters:
effect
- the effect to use for text rendering
-
getDelegateOwner
public java.lang.Object getDelegateOwner()
Returns the delegate owner of this label. If non-null, the returned object replaces the label as the pickable object returned during picking. If null, the label itself is the pickable object returned during picking.- Returns:
- the object used as the pickable object returned during picking, or null to indicate the the label is returned during picking.
-
setDelegateOwner
public void setDelegateOwner(java.lang.Object owner)
Specifies the delegate owner of this label. If non-null, the delegate owner replaces the label as the pickable object returned during picking. If null, the label itself is the pickable object returned during picking.- Parameters:
owner
- the object to use as the pickable object returned during picking, or null to return the label.
-
isEnableBatchPicking
public boolean isEnableBatchPicking()
Indicates whether batch picking is enabled.- Returns:
- true if batch rendering is enabled, otherwise false.
- See Also:
setEnableBatchPicking(boolean)
-
setEnableBatchPicking
public 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. This increases performance but allows only the top-most of the label to be reported in aSelectEvent
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.- Parameters:
enableBatchPicking
- true to enable batch rendering, otherwise false.
-
isEnableBatchRendering
public boolean isEnableBatchRendering()
Indicates whether batch rendering is enabled.- Returns:
- true if batch rendering is enabled, otherwise false.
- See Also:
setEnableBatchRendering(boolean)
-
setEnableBatchRendering
public 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. This increases performance and there is seldom a reason to disable it.- Parameters:
enableBatchRendering
- true to enable batch rendering, otherwise false.
-
getBounds
public java.awt.Rectangle getBounds(DrawContext dc)
Get the label boundingRectangle
using OGL coordinates - bottom-left corner x and y relative to theWorldWindow
bottom-left corner. If the label is rotated then the returned rectangle is the bounding rectangle of the rotated label.- Parameters:
dc
- the current DrawContext.- Returns:
- the label bounding
Rectangle
using OGL viewport coordinates. - Throws:
java.lang.IllegalArgumentException
- ifdc
is null.
-
computeGeometryIfNeeded
protected void computeGeometryIfNeeded(DrawContext dc)
-
computeBoundsIfNeeded
protected void computeBoundsIfNeeded(DrawContext dc)
Compute the bounds of the text, if necessary.- Parameters:
dc
- the current DrawContext.
-
computeGeometry
protected void computeGeometry(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
Compute the label's screen position from its geographic position.- Parameters:
dc
- Current draw context.olbl
- The ordered label to compute geometry for.
-
intersectsFrustum
protected boolean intersectsFrustum(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
Determine if this label intersects the view or pick frustum.- Parameters:
dc
- Current draw context.olbl
- The ordered label to intersect.- Returns:
- True if this label intersects the active frustum (view or pick). Otherwise false.
-
computeRotation
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.- Parameters:
screenPoint
- Geographic position of the text, projected onto the screen.orientationScreenPoint
- Orientation position, projected onto the screen.- Returns:
- The rotation angle to apply when drawing the label.
-
render
public void render(DrawContext dc)
Causes thisRenderable
to render itself using the provided draw context.- Parameters:
dc
- theDrawContext
to be used- Throws:
java.lang.IllegalArgumentException
- if the draw context is null.- See Also:
DrawContext
-
pick
public void pick(DrawContext dc, java.awt.Point pickPoint, TacticalGraphicLabel.OrderedLabel olbl)
-
makeOrderedRenderable
protected void makeOrderedRenderable(DrawContext dc)
Draws the graphic as an ordered renderable.- Parameters:
dc
- the current draw context.
-
drawOrderedRenderable
protected void drawOrderedRenderable(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
Draws the graphic as an ordered renderable.- Parameters:
dc
- the current draw context.olbl
- The ordered label to draw.
-
doDrawOrderedRenderable
protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickSupport, TacticalGraphicLabel.OrderedLabel olbl)
Draw this label during ordered rendering.- Parameters:
dc
- Current draw context.pickSupport
- Support object used during picking.olbl
- The ordered label to draw.
-
beginDrawing
protected void beginDrawing(DrawContext dc)
Establish the OpenGL state needed to draw text.- Parameters:
dc
- the current draw context.
-
endDrawing
protected void endDrawing(DrawContext dc)
Pop the state set in beginDrawing.- Parameters:
dc
- the current draw context.
-
doPick
protected void doPick(DrawContext dc, PickSupport pickSupport, TacticalGraphicLabel.OrderedLabel olbl)
Draw labels for picking.- Parameters:
dc
- Current draw context.pickSupport
- the PickSupport instance to be used.olbl
- The ordered label to pick.
-
drawText
protected void drawText(DrawContext dc, TextRenderer textRenderer, TacticalGraphicLabel.OrderedLabel olbl)
Draw the label's text. This method sets up the text renderer, and then callsdoDrawText
to actually draw the text.- Parameters:
dc
- Current draw context.textRenderer
- Text renderer.olbl
- The ordered label to draw.
-
drawInterior
protected void drawInterior(DrawContext dc, TacticalGraphicLabel.OrderedLabel olbl)
Render the label interior as a filled rectangle.- Parameters:
dc
- Current draw context.olbl
- The ordered label to draw.
-
doDrawText
protected void doDrawText(TextRenderer textRenderer, TacticalGraphicLabel.OrderedLabel olbl)
Draw the label's text. This method assumes that the text renderer context has already been set up.- Parameters:
textRenderer
- renderer to use.olbl
- The ordered label to draw.
-
drawMultiLineText
protected void drawMultiLineText(TextRenderer textRenderer, int x, int y, TacticalGraphicLabel.OrderedLabel olbl)
-
drawBatched
protected void drawBatched(DrawContext dc, TacticalGraphicLabel.OrderedLabel firstLabel)
Draws this ordered renderable and all subsequent Label ordered renderables in the ordered renderable list. This method differs fromdrawBatchedText
in that this method re-initializes the text renderer to draw the next label, whiledrawBatchedText
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.- Parameters:
dc
- the current draw context.firstLabel
- the label drawn prior to calling this method.
-
drawBatchedText
protected void drawBatchedText(DrawContext dc, TextRenderer textRenderer, TacticalGraphicLabel.OrderedLabel firstLabel)
Draws text for subsequent Label ordered renderables in the ordered renderable list. This method is called after the text renderer has been set up (after beginRendering has been called), so this method can only draw text for subsequent labels that use the same font and rotation as this label. This method differs fromdrawBatched
in that this method reuses the active text renderer context to draw as many labels as possible without switching text renderer state.- Parameters:
dc
- the current draw context.textRenderer
- Text renderer used to draw the label.firstLabel
- The first ordered renderable in the batch.
-
getPickedObject
protected java.lang.Object getPickedObject()
Indicates the object that represents this label during picking.- Returns:
- If a delegate owner is set, returns the delegate owner. Otherwise returns this label.
-
computeTextExtent
protected java.awt.Rectangle computeTextExtent(int x, int y, TacticalGraphicLabel.OrderedLabel olbl)
Determine the screen rectangle covered by a label. The input coordinate identifies either the top left, top center, or top right corner of the label, depending on the text alignment. If the label is rotated to align with features on the surface then the extent will be the smallest screen rectangle that completely encloses the rotated label.- Parameters:
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.- Returns:
- The rectangle, in OGL screen coordinates (origin at bottom left corner), that is covered by the label.
-
computeRotatedScreenExtent
protected java.awt.Rectangle computeRotatedScreenExtent(java.awt.Rectangle rect, int x, int y, Angle rotation)
Compute the bounding screen extent of a rotated rectangle.- Parameters:
rect
- Rectangle to rotate.x
- X coordinate of the rotation point.y
- Y coordinate of the rotation point.rotation
- Rotation angle.- Returns:
- The smallest rectangle that completely contains
rect
when rotated by the specified angle.
-
computeBackgroundColor
protected java.awt.Color computeBackgroundColor(java.awt.Color color)
Compute a contrasting background color to draw the label's outline.- Parameters:
color
- Label color.- Returns:
- A color that contrasts with
color
.
-
-