|
||||||||||
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.OMGraphicAdapter com.bbn.openmap.omGraphics.OMText
public class 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
|
static java.awt.Stroke |
DEFAULT_TEXT_MATTE_STROKE
The default text matte stroke that is used to surround each character with the color set in the textMatteColor attribute. |
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. |
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 double |
lat
The latitude location for the text, used for lat/lon or offset rendertype texts, in decimal degrees. |
protected double |
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.geom.Point2D |
pt
The projected xy window location of the bottom left corner of the first letter of the text string. |
protected java.lang.Double |
renderRotationAngle
The rotation angle used at render time, depending on rotate-ability. |
protected double |
rotationAngle
The angle by which the text is to be rotated, in radians |
protected java.awt.Color |
textMatteColor
The text matte color surrounds each character of the string with this color. |
protected java.awt.Stroke |
textMatteStroke
The stroke used to paint the outline of each character. |
protected boolean |
useMaxWidthForBounds
|
protected int[] |
widths
cached string widths. |
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter |
---|
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask |
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry |
---|
attributes, lineType, needToRegenerate, shape, visible |
Constructor Summary | |
---|---|
OMText()
Default constructor. |
|
OMText(double lt,
double ln,
float offX,
float offY,
java.lang.String aString,
java.awt.Font font,
int just)
Creates a Text object, with lat/lon placement with XY offset. |
|
OMText(double lt,
double ln,
float offX,
float offY,
java.lang.String aString,
int just)
Creates a Text object, with lat/lon placement with XY offset, and default SansSerif font. |
|
OMText(double lt,
double ln,
java.lang.String stuff,
java.awt.Font font,
int just)
Creates a text object, with Lat/Lon placement. |
|
OMText(double lt,
double 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 java.awt.Polygon |
computeBounds(java.awt.Polygon currentPolyBounds)
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 occurrences of a character in a string. |
float |
distance(double x,
double y)
Return the shortest distance from the OMText to an XY-point. |
void |
evaluateRotationAngle(Projection proj)
Set the renderRotationAngle based on the projection angle and OMText settings. |
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. |
double |
getLat()
Get the latitude location of the string. |
int[] |
getLineWidths()
Return a copy of the pixel lengths of the text line(s). |
double |
getLon()
Return the longitude. |
java.awt.geom.Point2D |
getMapLocation()
Not for the faint hearted. |
java.lang.Integer |
getMaxLineWidth()
Get the pixel width of the longest line. |
java.awt.Polygon |
getPolyBounds()
Get the text bounds. |
double |
getRotationAngle()
Get the current rotation of the text. |
java.awt.Color |
getTextMatteColor()
Returns the color used to matte the actual text of this class. |
java.awt.Stroke |
getTextMatteStroke()
Returns the stroke used to paint the outline of the characters in this text. |
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. |
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. |
protected void |
renderString(java.awt.Graphics g,
java.lang.String string,
double x,
double y)
|
void |
restore(OMGeometry source)
Takes the generic OMGraphic settings from another OMGraphic and pushes them to this one. |
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(double l)
Set the latitude. |
void |
setLon(double l)
Set the longitude. |
void |
setMapLocation(java.awt.geom.Point2D 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 |
setTextMatteColor(java.awt.Color textMatteColor)
Sets the color used to paint the outline of the characters in this text. |
void |
setTextMatteStroke(java.awt.Stroke textMatteStroke)
Sets the stroke used to paint the outline of the characters in this text For best effect the stroke thickness should be larger than 1 and it should be continuous. |
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, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, 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, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, 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 transient java.awt.Font DEFAULT_FONT
public static final transient java.awt.Stroke DEFAULT_TEXT_MATTE_STROKE
protected java.awt.geom.Point2D pt
protected java.awt.Point point
protected java.awt.Font f
protected FontSizer fontSizer
protected double lat
protected double lon
protected java.lang.String data
protected int justify
protected int baseline
protected int fmHeight
protected boolean useMaxWidthForBounds
protected double rotationAngle
protected java.lang.Double renderRotationAngle
protected java.awt.Color textMatteColor
protected transient java.awt.Stroke textMatteStroke
protected transient java.awt.Polygon polyBounds
protected transient java.awt.FontMetrics fm
protected transient java.lang.String[] parsedData
protected transient int[] widths
Constructor Detail |
---|
public OMText()
public OMText(double lt, double 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(double lt, double 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(double lt, double ln, float offX, float 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(double lt, double ln, float offX, float 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 currentPolyBounds
. 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 double getLat()
public void setLat(double l)
l
- latitude for new location, in decimal degrees.public double getLon()
public void setLon(double l)
l
- the longitude location for the string, in decimal degrees.public java.awt.geom.Point2D getMapLocation()
public void setMapLocation(java.awt.geom.Point2D point)
point
- the point on the map where the text being placed.public java.awt.Color getTextMatteColor()
public void setTextMatteColor(java.awt.Color textMatteColor)
textMatteColor
- public java.awt.Stroke getTextMatteStroke()
public void setTextMatteStroke(java.awt.Stroke textMatteStroke)
textMatteStroke
- the new strokepublic java.lang.String getData()
public void setData(java.lang.String d)
parsedData
,widths
, and
currentPolyBounds
. 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 currentPolyBounds
.
j
- one of JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHTpolyBounds
public int getBaseline()
public void setBaseline(int b)
fm
,widths
, and
currentPolyBounds
.
b
- one of BASELINE_BOTTOM, BASELINE_MIDDLE or BASELINE_TOP.polyBounds
public void setUseMaxWidthForBounds(boolean value)
value
- if true, bounds for multi-line text will be rectangular
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 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 currentPolyBounds
.
generate
in interface OMGeometry
generate
in class OMGraphicAdapter
proj
- the projection of the window.
pt
public void evaluateRotationAngle(Projection proj)
proj
- the current projection.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 interface OMGeometry
render
in class OMGraphicAdapter
g
- the java.awt.Graphics to put the string on.fm
protected void renderString(java.awt.Graphics g, java.lang.String string, double x, double y)
protected java.awt.Polygon computeBounds(java.awt.Polygon currentPolyBounds)
currentPolyBounds
.
currentPolyBounds
- the current polygon bounds, new ones will be
created if it's null
polyBounds
public float distance(double x, double 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 OMGraphicAdapter
x
- X coordinate of the point.y
- Y coordinate of the point.
public boolean hasLineTypeChoice()
OMGraphicAdapter
hasLineTypeChoice
in interface OMGraphic
hasLineTypeChoice
in class OMGraphicAdapter
public int[] getLineWidths()
public java.lang.Integer getMaxLineWidth()
public void restore(OMGeometry source)
OMGraphicAdapter
restore
in interface OMGeometry
restore
in class OMGraphicAdapter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |