public class ScreenRelativeAnnotation extends ScreenAnnotation
The annotation can be forced to remain fully visible even if its relative position would place a portion of it outside the window. X and Y margins can be specified to ensure distance between the annotation's edges and the window edges.
AbstractAnnotation.TextCacheKey
position, screenPoint
alwaysOnTop, attributes, childList, delegateOwner, layoutManager, maxActiveAltitude, minActiveAltitude, pickEnabled, pickSupport, text, textBoundsMap, vertexBuffer, wrappedTextMap
ANTIALIAS_DONT_CARE, ANTIALIAS_FASTEST, ANTIALIAS_NICEST
Constructor and Description |
---|
ScreenRelativeAnnotation(java.lang.String text,
double xFraction,
double yFraction)
Create an annotation with spedified text and relative position.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getRestorableState()
Returns an XML state document String describing the public attributes of this ScreenAnnotation.
|
protected java.awt.Point |
getScreenPoint(DrawContext dc)
Computes and returns the screen point in pixels corresponding to the annotation's relative position coordinates
and the current window size.
|
double |
getXFraction()
Returns the annotation's relative X position.
|
int |
getXMargin()
Returns the annotation's X margin.
|
double |
getYFraction()
Returns the annotation's relative Y position.
|
int |
getYMargin()
Returns the annotation's Y margin.
|
boolean |
isKeepFullyVisible()
Indicates whether the annotation is kept fully visible in the window.
|
void |
restoreState(java.lang.String stateInXml)
Restores publicly settable attribute values found in the specified XML state document String.
|
void |
setKeepFullyVisible(boolean keepFullyVisible)
Specifies whether to adjust the annotation's position so that it is always fully visible when the window has
sufficient area to display it, even if it would be fully or partially obscured when placed according to its
relative coordinates.
|
void |
setXFraction(double xFraction)
Specifies the annotation's relative X position.
|
void |
setXMargin(int xMargin)
Specifies the annotation's X margin, the minimum distance to maintain between the annotation's leading and
trailing edges and the respective window edge.
|
void |
setYFraction(double yFraction)
Specifies the annotation's relative Y position.
|
void |
setYMargin(int yMargin)
Specifies the annotation's Y margin, the minimum distance to maintain between the annotation's top and bottom
edges and the respective window edge.
|
computeAnnotationPosition, computeBounds, computeOffset, computeSize, doRenderNow, getPosition, getScreenPoint, setPosition, setScreenPoint
addChild, adjustSizeToChildren, adjustSizeToText, applyBackgroundTextureState, applyColor, applyScreenTransform, beginDraw, beginDrawChildren, bindPickableObject, computeBoundingRectangle, computeFreeBounds, computeInsetBounds, computeOpacity, computeScale, computeTextBounds, dispose, doDraw, doDrawBackgroundTexture, doDrawChildren, draw, drawBackground, drawBackgroundImage, drawBorder, drawCallout, drawChildren, drawContent, drawHTML, drawPlainText, drawText, drawText, drawTopLevelAnnotation, endDraw, endDrawChildren, getAttributes, getBounds, getChildren, getDelegateOwner, getLayout, getMaxActiveAltitude, getMinActiveAltitude, getMultiLineTextRenderer, getPickSupport, getPreferredSize, getText, getTextBounds, getTextRenderer, getWrappedText, glPointFromAWTPoint, isAlwaysOnTop, isPickEnabled, modulateColorOpacity, pick, removeAllChildren, removeChild, render, renderNow, setAlwaysOnTop, setAttributes, setDelegateOwner, setLayout, setMaxActiveAltitude, setMinActiveAltitude, setPickEnabled, setPickSupport, setText, transformBackgroundImageCoordsToAnnotationCoords, transformByModelview, transformImageCoordsToBackgroundImageCoords, wrapText
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
public ScreenRelativeAnnotation(java.lang.String text, double xFraction, double yFraction)
text
- the text to display in the annotation.xFraction
- the relative X position of the annotation. A value of 0 indicates the window's left edge, a
value of 1 indicates its right edge. The annotation is centered horizontally on this position
prior to applying any X offest specified in the annotation's attributes.yFraction
- the relative Y position of the annotation. A value of 0 indicates the window's bottom edge, a
value of 1 indicates the window's top edge. The annotation's lower edge is justified to this
position prior to applying any Y offset specified in the annotation's attributes.java.lang.IllegalArgumentException
- if the text string is null.public java.lang.String getRestorableState()
getRestorableState
in interface Restorable
getRestorableState
in class ScreenAnnotation
protected java.awt.Point getScreenPoint(DrawContext dc)
getScreenPoint
in class ScreenAnnotation
dc
- the current draw context.public double getXFraction()
setXFraction(double)
.public int getXMargin()
public double getYFraction()
setYFraction(double)
.public int getYMargin()
public boolean isKeepFullyVisible()
public void restoreState(java.lang.String stateInXml)
stateInXml
must be a well formed XML document String, or this will throw an
IllegalArgumentException. Unknown structures in stateInXml
are benign, because they will simply be
ignored.restoreState
in interface Restorable
restoreState
in class ScreenAnnotation
stateInXml
- an XML document String describing a ScreenAnnotation.java.lang.IllegalArgumentException
- If stateInXml
is null, or if stateInXml
is not a well
formed XML document String.public void setKeepFullyVisible(boolean keepFullyVisible)
keepFullyVisible
- true to keep the annotation fully visible, otherwise false.public void setXFraction(double xFraction)
xFraction
- the annotation's relative X position.public void setXMargin(int xMargin)
keepFullyVisible
flag is true.xMargin
- the X margin, in pixels.public void setYFraction(double yFraction)
yFraction
- the annotation's relative Y position.public void setYMargin(int yMargin)
keepFullyVisible
flag is true.yMargin
- the Y margin, in pixels.