|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bbn.openmap.omGraphics.geom.BasicGeometry | +--com.bbn.openmap.omGraphics.OMGraphic | +--com.bbn.openmap.omGraphics.OMText
The OMText graphic type lets you put text on the screen. The location of the string is really the location of the lower left corner of the first letter of the string.
Field Summary | |
static int |
ASCENT
Parameter of Font to count toward footprint of height of Text. |
static int |
ASCENT_DESCENT
Parameter of Font to count toward footprint of height of Text. |
static int |
ASCENT_LEADING
Parameter of Font to count toward footprint of height of Text. |
protected int |
baseline
Location of the baseline of the text compared to the location point of the OMText object. |
static int |
BASELINE_BOTTOM
Parameter that dictates where the font baseline will be set compared to the location of the OMText. |
static int |
BASELINE_MIDDLE
Parameter that dictates where the font baseline will be set compared to the location of the OMText. |
static int |
BASELINE_TOP
Parameter that dictates where the font baseline will be set compared to the location of the OMText. |
protected java.lang.String |
data
The string to be displayed. |
static java.awt.Font |
DEFAULT_FONT
|
protected java.awt.Font |
f
The Font type that the string should be displayed with. |
protected java.awt.FontMetrics |
fm
The Metrics of the current font. |
protected int |
fmHeight
The fmHeight is the FontMetric height to use for calculating the footprint for the line. |
protected FontSizer |
fontSizer
The FontSizer set in the OMText, changing the font size appropriate for a projection scale. |
protected Projection |
hackProj
|
static int |
HEIGHT
Parameter of Font to count toward footprint of height of Text. |
protected int |
justify
Justification of the string. |
static int |
JUSTIFY_CENTER
Align the text centered on the location. |
static int |
JUSTIFY_LEFT
Align the text to the right of the location. |
static int |
JUSTIFY_RIGHT
Align the text to the left of the location. |
protected float |
lat
The latitude location for the text, used for lat/lon or offset rendertype texts, in decimal degrees. |
protected float |
lon
The longitude location for the text, used for lat/lon or offset rendertype texts, in decimal degrees. |
protected java.lang.String[] |
parsedData
The text split by newlines. |
protected java.awt.Point |
point
The X/Y point or the offset amount depending on render type. |
protected java.awt.Polygon |
polyBounds
The bounding rectangle of this Text. |
protected java.awt.Point |
pt
The projected xy window location of the bottom left corner of the first letter of the text string. |
protected double |
rotationAngle
The angle by which the text is to be rotated, in radians |
protected boolean |
useMaxWidthForBounds
|
protected int[] |
widths
cached string widths. |
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphic |
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask |
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
APP_OBJECT_KEY, appObject, ATT_MAP_KEY, lineType, needToRegenerate, shape, visible |
Constructor Summary | |
OMText()
Default constructor. |
|
OMText(float lt,
float ln,
int offX,
int offY,
java.lang.String aString,
java.awt.Font font,
int just)
Creates a Text object, with lat/lon placement with XY offset. |
|
OMText(float lt,
float ln,
int offX,
int offY,
java.lang.String aString,
int just)
Creates a Text object, with lat/lon placement with XY offset, and default SansSerif font. |
|
OMText(float lt,
float ln,
java.lang.String stuff,
java.awt.Font font,
int just)
Creates a text object, with Lat/Lon placement. |
|
OMText(float lt,
float ln,
java.lang.String stuff,
int just)
Creates a text object, with Lat/Lon placement, and default SansSerif font. |
|
OMText(int px1,
int py1,
java.lang.String stuff,
java.awt.Font font,
int just)
Creates a text object, with XY placement. |
|
OMText(int px1,
int py1,
java.lang.String stuff,
int just)
Creates a text object, with XY placement, and default SansSerif font. |
Method Summary | |
protected void |
computeBounds()
Computes the bounding polygon. |
protected void |
computeStringWidths(java.awt.FontMetrics fm)
Computes the widths of each line of the text. |
protected int |
countChar(java.lang.String str,
int ch)
Counts occurences of a character in a string. |
float |
distance(int x,
int y)
Return the shortest distance from the OMText to an XY-point. |
static java.lang.String |
fontToXFont(java.awt.Font font)
In some applications, fonts are represented by a string. |
boolean |
generate(Projection proj)
Prepares the text for rendering. |
int |
getBaseline()
Gets the baseline location of this OMText. |
java.lang.String |
getData()
Return the string. |
int |
getFMHeight()
Get the fmHeight used for the footprint. |
java.awt.Font |
getFont()
Get the font of the text object, which might have been scaled by the font sizer. |
FontSizer |
getFontSizer()
Get the FontSizer object, which provides different font sizes at different scales. |
int |
getJustify()
Gets the justification of this OMText. |
float |
getLat()
Get the latitude location of the string. |
float |
getLon()
Return the longitude. |
java.awt.Point |
getMapLocation()
Not for the faint hearted. |
java.awt.Polygon |
getPolyBounds()
Get the text bounds. |
double |
getRotationAngle()
Get the current rotation of the text. |
boolean |
getShowBounds()
Deprecated. use isMatted() instead. |
double |
getTheta()
Deprecated. use getRotationAngle instead. |
boolean |
getUseMaxWidthForBounds()
Get flag to specify that the bounds, if displayed, should be rectangular. |
int |
getX()
Get the x location. |
int |
getY()
Get the y location. |
protected boolean |
hasLineTypeChoice()
Used by the GraphicAttributes object to provide a choice on whether the line type choice can be changed. |
protected void |
parseData()
Breaks the text down into separate lines. |
void |
prepareForRender(java.awt.Graphics g)
This function can be called to initialize the internals such as height and width of OMText. |
static java.awt.Font |
rebuildFont(java.lang.String fontString)
Build a font out of an X Font description string. |
void |
render(java.awt.Graphics g)
Renders the text onto the given graphics. |
void |
setBaseline(int b)
Sets the location of the baseline of this OMText. |
void |
setData(java.lang.String d)
Sets the string contents that are presented. |
void |
setFMHeight(int fmh)
Set the fmHeight to use for the footprint. |
void |
setFont(float scale)
If the font sizer is not null, sets the scaled font with the proper value for the given scale. |
void |
setFont(java.awt.Font aFont)
Set the base font. |
void |
setFontSizer(FontSizer fs)
Set the FontSizer object, which provides different font sizes at different scales. |
void |
setJustify(int j)
Sets the justification of this OMText. |
void |
setLat(float l)
Set the latitude. |
void |
setLon(float l)
Set the longitude. |
void |
setMapLocation(java.awt.Point point)
Not for the faint hearted. |
void |
setRotationAngle(double angle)
Set the angle by which the text is to rotated. |
protected void |
setScaledFont(java.awt.Font aFont)
Sets the scaled font, which is the one that is used for rendering. |
void |
setShowBounds(boolean show)
Deprecated. use setMatted(boolean) instead. |
void |
setTheta(double theta)
Deprecated. use setRotationAngle instead. |
void |
setUseMaxWidthForBounds(boolean value)
Set flag to specify that the bounds, if displayed, should be rectangular. |
void |
setX(int newX)
Set the x location. |
void |
setY(int newY)
Set the y location. |
Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, checkAttributeMap, checkAttributeMap, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, draw, fill, getAppObject, getAppObject, getAttribute, getAttributeMap, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, isVisible, putAttribute, removeAttribute, replaceAppObjectWithAttributeMap, setAppObject, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setVisible |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry |
clearAttributes, contains, draw, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setVisible |
Field Detail |
public static final transient int JUSTIFY_LEFT
public static final transient int JUSTIFY_CENTER
public static final transient int JUSTIFY_RIGHT
public static final transient int HEIGHT
public static final transient int ASCENT_DESCENT
public static final transient int ASCENT_LEADING
public static final transient int ASCENT
public static final transient int BASELINE_BOTTOM
public static final transient int BASELINE_MIDDLE
public static final transient int BASELINE_TOP
public static final java.awt.Font DEFAULT_FONT
protected java.awt.Point pt
protected java.awt.Point point
protected java.awt.Font f
protected FontSizer fontSizer
protected float lat
protected float lon
protected java.lang.String data
protected int justify
protected int baseline
protected int fmHeight
protected boolean useMaxWidthForBounds
protected double rotationAngle
protected transient java.awt.Polygon polyBounds
protected transient java.awt.FontMetrics fm
protected transient java.lang.String[] parsedData
protected transient int[] widths
protected Projection hackProj
Constructor Detail |
public OMText()
public OMText(float lt, float ln, java.lang.String stuff, int just)
lt
- latitude of the string, in decimal degrees.ln
- longitude of the string, in decimal degrees.stuff
- the string to be displayed.just
- the justification of the stringpublic OMText(float lt, float ln, java.lang.String stuff, java.awt.Font font, int just)
lt
- latitude of the string, in decimal degrees.ln
- longitude of the string, in decimal degrees.stuff
- the string to be displayed.font
- the Font description for the string.just
- the justification of the stringpublic OMText(int px1, int py1, java.lang.String stuff, int just)
px1
- horizontal window pixel location of the string.py1
- vertical window pixel location of the string.stuff
- the string to be displayed.just
- the justification of the stringpublic OMText(int px1, int py1, java.lang.String stuff, java.awt.Font font, int just)
px1
- horizontal window pixel location of the string.py1
- vertical window pixel location of the string.stuff
- the string to be displayed.font
- the Font description for the string.just
- the justification of the stringpublic OMText(float lt, float ln, int offX, int offY, java.lang.String aString, int just)
lt
- latitude of the string, in decimal degrees.ln
- longitude of the string, in decimal degrees.offX
- horizontal offset of stringoffY
- vertical offset of stringaString
- the string to be displayed.just
- the justification of the stringpublic OMText(float lt, float ln, int offX, int offY, java.lang.String aString, java.awt.Font font, int just)
lt
- latitude of the string, in decimal degrees.ln
- longitude of the string, in decimal degrees.offX
- horizontal offset of stringoffY
- vertical offset of stringaString
- the string to be displayed.font
- the Font description for the string.just
- the justification of the stringMethod Detail |
public java.awt.Font getFont()
public void setFont(java.awt.Font aFont)
fm
,
widths
, and polyBounds
. Calls
setScaledFont.
aFont
- font to be used for the text.fm
,
widths
,
polyBounds
protected void setScaledFont(java.awt.Font aFont)
public void setFont(float scale)
public void setFontSizer(FontSizer fs)
public FontSizer getFontSizer()
public int getX()
public void setX(int newX)
newX
- the horizontal pixel location of the window to
place the string.public int getY()
public void setY(int newY)
newY
- the vertical pixel location of the window to place
the string.public float getLat()
public void setLat(float l)
l
- latitude for new location, in decimal degrees.public float getLon()
public void setLon(float l)
l
- the longitude location for the string, in decimal
degrees.public java.awt.Point getMapLocation()
public void setMapLocation(java.awt.Point point)
point
- the point on the map where the text being placed.public java.lang.String getData()
public void setData(java.lang.String d)
parsedData
,widths
, and
polyBounds
. HACK synchronized so that it
doesn't interfere with other methods that are using parsedData.
d
- the text to be displayedparsedData
,
widths
,
polyBounds
public int getJustify()
public void setJustify(int j)
fm
,widths
, and
polyBounds
.
j
- one of JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHTpolyBounds
public int getBaseline()
public void setBaseline(int b)
fm
,widths
, and
polyBounds
.
b
- one of BASELINE_BOTTOM, BASELINE_MIDDLE or
BASELINE_TOP.polyBounds
public boolean getShowBounds()
public void setShowBounds(boolean show)
true
, the
bounding box of this text is displayed.
show
- true to show, false to hide.OMGraphic.setFillColor(java.awt.Color)
public void setUseMaxWidthForBounds(boolean value)
value
- if true, bounds for multi-line text will be
retangular instead of closely following text.public boolean getUseMaxWidthForBounds()
public java.awt.Polygon getPolyBounds()
public void setFMHeight(int fmh)
fmh
- the setting for fmHeight, out of the parameters
stated above.public int getFMHeight()
public void setTheta(double theta)
theta
- the number of radians the text is to be rotated.
Measured clockwise from horizontal.public double getTheta()
public void setRotationAngle(double angle)
angle
- the number of radians the text is to be rotated.
Measured clockwise from horizontal. Positive numbers
move the positive x axis toward the positive y axis.public double getRotationAngle()
public boolean generate(Projection proj)
pt
. Flushes the cache field
polyBounds
.
generate
in interface OMGeometry
generate
in class OMGraphic
proj
- the projection of the window.
pt
public static java.awt.Font rebuildFont(java.lang.String fontString)
fontString
- the X font description.public static java.lang.String fontToXFont(java.awt.Font font)
font
- the Java font to convert to an XFont string.
protected int countChar(java.lang.String str, int ch)
str
- the Stringch
- the character to count
protected void parseData()
parsedData
.
parsedData
protected void computeStringWidths(java.awt.FontMetrics fm)
widths
.
fm
- the metrics to use for computation.widths
public void prepareForRender(java.awt.Graphics g)
g
- the java.awt.Graphics to put the string on.public void render(java.awt.Graphics g)
fm
.
render
in class OMGraphic
g
- the java.awt.Graphics to put the string on.fm
protected void computeBounds()
polyBounds
.
polyBounds
public float distance(int x, int y)
This method uses the OMText's internal Shape object, created from the boundary of the text, as its boundary.
distance
in interface OMGeometry
distance
in class OMGraphic
x
- X coordinate of the point.y
- Y coordinate of the point.
protected boolean hasLineTypeChoice()
OMGraphic
hasLineTypeChoice
in class OMGraphic
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |