public class SurfaceText extends AbstractSurfaceObject implements GeographicText, Movable, Draggable
AbstractSurfaceObject.CacheEntry, AbstractSurfaceObject.SurfaceObjectStateKey
Modifier and Type | Field and Description |
---|---|
protected java.awt.Color |
bgColor
Background color for the text.
|
protected java.awt.Color |
color
Color to use to draw the text.
|
static java.awt.Color |
DEFAULT_COLOR
Default text color.
|
static java.awt.Font |
DEFAULT_FONT
Default font.
|
static Offset |
DEFAULT_OFFSET
Default offset.
|
static double |
DEFAULT_TEXT_SIZE_IN_METERS
Default text size.
|
protected boolean |
dragEnabled
Dragging Support
|
protected DraggableSupport |
draggableSupport |
protected LatLon |
drawLocation
The lower-left location of the text box after applying offset.
|
protected java.awt.Font |
font
Font to use to draw the text.
|
protected Position |
location
Location at which to draw the text.
|
protected Offset |
offset
Offset that specifies where to place the text in relation to it's geographic position.
|
protected double |
pixelSizeInMeters
Geographic size of a pixel.
|
protected double |
priority
Text priority.
|
protected double |
scale
Scaling factor applied to the text to maintain a constant geographic size.
|
protected boolean |
spansAntimeridian
Indicates whether this text spans the dateline.
|
protected java.lang.CharSequence |
text
The text to draw.
|
protected java.awt.geom.Rectangle2D |
textBounds
Bounds of the text in pixels.
|
protected double |
textSizeInMeters
The height of the text in meters.
|
delegateOwner, drawBoundingSectors, enableBatchPicking, extentCache, lastModifiedTime, nextUniqueId, pickLayer, pickSupport, pickTileBuilder, uniqueId, visible
Constructor and Description |
---|
SurfaceText(java.lang.String text,
Position position)
Create a new surface text object.
|
SurfaceText(java.lang.String text,
Position position,
java.awt.Font font,
java.awt.Color color)
Create a new surface text object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
applyDrawTransform(DrawContext dc,
SurfaceTileDrawContext sdc)
Apply a transform to the GL state to draw the text at the proper location and scale.
|
protected java.awt.Color |
computeBackgroundColor(java.awt.Color color)
Compute a background color that contrasts with the text color.
|
protected void |
computeGeometry(DrawContext dc,
SurfaceTileDrawContext sdc)
Compute the text size and position.
|
protected double |
computePixelSize(DrawContext dc,
SurfaceTileDrawContext sdc)
Compute the size of a pixel in the surface tile.
|
protected Sector[] |
computeSector(DrawContext dc)
Compute the sector covered by this surface text.
|
protected java.awt.Color |
determineBackgroundColor(java.awt.Color color)
Determine the text background color.
|
protected void |
doDrag(DragContext dragContext) |
void |
drag(DragContext dragContext)
Drag the object given the provided
DragContext . |
protected void |
drawGeographic(DrawContext dc,
SurfaceTileDrawContext sdc)
Causes the SurfaceObject to render itself to the specified region in geographic coordinates.
|
protected void |
drawText(DrawContext dc)
Draw the text.
|
java.awt.Color |
getBackgroundColor()
Indicates the background color used to draw the text.
|
java.awt.Color |
getColor()
Indicates the color used to draw the text.
|
java.awt.Font |
getFont()
Indicates the font used to draw the text.
|
Offset |
getOffset()
Returns the text offset.
|
Position |
getPosition()
Indicates the geographic position of the text.
|
double |
getPriority()
Indicates the text priority.
|
Position |
getReferencePosition()
A position associated with the object that indicates its aggregate geographic position.
|
java.util.List<Sector> |
getSectors(DrawContext dc)
Returns a list of sectors indicating the geographic region that bounds this renderable for the specified draw
context.
|
java.lang.CharSequence |
getText()
Indicates the text contained in this object.
|
protected TextRenderer |
getTextRenderer(DrawContext dc)
Get the text renderer to use to draw text.
|
double |
getTextSize() |
boolean |
isDragEnabled()
Indicates whether the object is enabled for dragging.
|
protected boolean |
isSmall()
Determine if the text is too small to draw.
|
void |
move(Position position)
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.
|
void |
preRender(DrawContext dc)
Causes the surface object to prepare a representation of itself which can be drawn on the surface terrain, using
the provided draw context.
|
void |
setBackgroundColor(java.awt.Color background)
Specifies the background color used to draw the text.
|
void |
setColor(java.awt.Color color)
Specifies the color used to draw the text.
|
void |
setDragEnabled(boolean enabled)
Controls whether the object is enabled for dragging.
|
void |
setFont(java.awt.Font font)
Specifies the font used to draw the text.
|
void |
setOffset(Offset offset)
Specifies a location relative to the label position at which to align the label.
|
void |
setPosition(Position position)
Specifies the geographic position of the text.
|
void |
setPriority(double priority)
Specifies the text priority.
|
void |
setText(java.lang.CharSequence text)
Specifies the text.
|
void |
setTextSize(double meters) |
protected void |
updateTextBounds(DrawContext dc)
Determine the text bounds.
|
buildPickRepresentation, clearCaches, computeExtent, computeExtent, createPickedObject, createPickTileBuilder, drawBoundingSectors, drawOrderedRenderable, drawPickRepresentation, getDelegateOwner, getDistanceFromEye, getExtent, getStateKey, getUniqueId, intersectsFrustum, intersectsPickFrustum, intersectsVisibleSector, isDrawBoundingSectors, isEnableBatchPicking, isVisible, makeOrderedPreRenderable, makeOrderedRenderable, nextUniqueId, onShapeChanged, pick, pickBatched, pickOrderedRenderable, render, setDelegateOwner, setDrawBoundingSectors, setEnableBatchPicking, setVisible, updateModifiedTime
onMessage, propertyChange
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isVisible, setVisible
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
protected java.awt.Color bgColor
protected java.awt.Color color
DEFAULT_COLOR
.public static final java.awt.Color DEFAULT_COLOR
public static final java.awt.Font DEFAULT_FONT
public static final Offset DEFAULT_OFFSET
public static final double DEFAULT_TEXT_SIZE_IN_METERS
protected boolean dragEnabled
protected DraggableSupport draggableSupport
protected LatLon drawLocation
protected java.awt.Font font
DEFAULT_FONT
.protected Position location
protected Offset offset
protected double pixelSizeInMeters
protected double priority
protected double scale
protected boolean spansAntimeridian
protected java.lang.CharSequence text
protected java.awt.geom.Rectangle2D textBounds
protected double textSizeInMeters
public SurfaceText(java.lang.String text, Position position)
text
- Text to draw.position
- Geographic location at which to draw the text.public SurfaceText(java.lang.String text, Position position, java.awt.Font font, java.awt.Color color)
text
- Text to draw.position
- Geographic location at which to draw the text.font
- Font to use when drawing text.color
- Color to use when drawing text.protected void applyDrawTransform(DrawContext dc, SurfaceTileDrawContext sdc)
dc
- Current draw context.sdc
- Current surface tile draw context.protected java.awt.Color computeBackgroundColor(java.awt.Color color)
color
- text color.protected void computeGeometry(DrawContext dc, SurfaceTileDrawContext sdc)
dc
- Current draw context.sdc
- Current surface tile draw context.protected double computePixelSize(DrawContext dc, SurfaceTileDrawContext sdc)
dc
- Current draw context.sdc
- Current surface tile draw context.protected Sector[] computeSector(DrawContext dc)
dc
- Current draw context.protected java.awt.Color determineBackgroundColor(java.awt.Color color)
color
- text color.protected void doDrag(DragContext dragContext)
public void drag(DragContext dragContext)
Draggable
DragContext
.drag
in interface Draggable
dragContext
- the DragContext
of this dragging event.protected void drawGeographic(DrawContext dc, SurfaceTileDrawContext sdc)
drawGeographic
in class AbstractSurfaceObject
dc
- the current draw context.sdc
- the context containing a geographic region and screen viewport corresponding to a surface tile.protected void drawText(DrawContext dc)
dc
- Current draw context.public java.awt.Color getBackgroundColor()
getBackgroundColor
in interface GeographicText
public java.awt.Color getColor()
getColor
in interface GeographicText
public java.awt.Font getFont()
getFont
in interface GeographicText
public Offset getOffset()
setOffset(Offset)
public Position getPosition()
getPosition
in interface GeographicText
public double getPriority()
getPriority
in interface GeographicText
public Position getReferencePosition()
getReferencePosition
in interface Movable
public java.util.List<Sector> getSectors(DrawContext dc)
getSectors
in interface SurfaceRenderable
dc
- the draw context for which to determine this renderable's geographic bounds.public java.lang.CharSequence getText()
getText
in interface GeographicText
protected TextRenderer getTextRenderer(DrawContext dc)
dc
- Current draw context.public double getTextSize()
public boolean isDragEnabled()
Draggable
isDragEnabled
in interface Draggable
protected boolean isSmall()
true
if the height of the text is less than one pixel.public void move(Position position)
public void moveTo(Position position)
public void preRender(DrawContext dc)
preRender
in interface PreRenderable
preRender
in interface SurfaceObject
preRender
in class AbstractSurfaceObject
dc
- the current draw context.public void setBackgroundColor(java.awt.Color background)
setBackgroundColor
in interface GeographicText
background
- New background color.public void setColor(java.awt.Color color)
setColor
in interface GeographicText
color
- New color.public void setDragEnabled(boolean enabled)
Draggable
setDragEnabled
in interface Draggable
enabled
- true
if the object is enabled, else false
.public void setFont(java.awt.Font font)
setFont
in interface GeographicText
font
- New font.public void setOffset(Offset offset)
offset
- Offset that controls where to position the label relative to its geographic location.public void setPosition(Position position)
setPosition
in interface GeographicText
position
- New text position.setOffset(Offset)
public void setPriority(double priority)
setPriority
in interface GeographicText
priority
- New priority.public void setText(java.lang.CharSequence text)
setText
in interface GeographicText
text
- New text.public void setTextSize(double meters)
protected void updateTextBounds(DrawContext dc)
dc
- Current draw context.