public class TextElement extends AnnotationElement
Modifier and Type | Field and Description |
---|---|
static java.awt.Font |
DEFAULT_FONT
The default font.
|
Constructor and Description |
---|
TextElement(java.lang.String text,
java.awt.Font font,
java.awt.geom.Point2D base,
double[] align,
double angle)
Creates a new text element with the specified properties.
|
TextElement(java.lang.String text,
java.awt.geom.Point2D base)
Creates a new text element with the specified string and base
point.
|
Modifier and Type | Method and Description |
---|---|
java.awt.geom.Area |
getArea(java.awt.Graphics2D g)
Gets the element bounding area.
|
java.awt.geom.Point2D |
getBasePoint()
Gets the text base point.
|
java.awt.Font |
getFont()
Gets the text font.
|
java.awt.font.TextLayout |
getLayout(java.awt.Graphics2D g)
Gets the text layout object for this element.
|
java.lang.String |
getText()
Gets the text string.
|
void |
render(java.awt.Graphics2D g2,
java.awt.Color foreground,
java.awt.Color background)
Renders the element graphics.
|
void |
setAlignment(double[] align)
Sets the text alignment.
|
void |
setAngle(double angle)
Sets the text orientation angle.
|
void |
setBasePoint(java.awt.geom.Point2D base)
Sets the text base point.
|
void |
setFont(java.awt.Font font)
Sets the text font.
|
void |
setText(java.lang.String text)
Sets the text string.
|
getBounds
public TextElement(java.lang.String text, java.awt.geom.Point2D base)
text
- the text string.base
- the text base point.public TextElement(java.lang.String text, java.awt.Font font, java.awt.geom.Point2D base, double[] align, double angle)
text
- the text string.font
- the text font.base
- the base point.align
- the text alignment as [horizontal, vertical]. The
alignment is a set of normalized values in the range [0..1] which
represent where in the bounding box of the text string the base
point is located. For example if the alignment is [0,0], then
the base point is at the lower-left corner of the text string.
If the alignment is [0.5, 0], then the base point is at the
bottom-center of the text string. If null, the alignment is set
to [0,0].angle
- the orientation angle. The angle is measured in
degrees and represents the angle between the horizontal and the
text string baseline direction. For example, and angle of 45
would draw text from lower-left to upper-right.public java.awt.font.TextLayout getLayout(java.awt.Graphics2D g)
g
- the graphics device for drawing.public java.lang.String getText()
public void setText(java.lang.String text)
public void setBasePoint(java.awt.geom.Point2D base)
public java.awt.geom.Point2D getBasePoint()
public void setAngle(double angle)
public void setFont(java.awt.Font font)
public java.awt.Font getFont()
public void setAlignment(double[] align)
public void render(java.awt.Graphics2D g2, java.awt.Color foreground, java.awt.Color background)
AnnotationElement
render
in class AnnotationElement
g2
- the graphics object for drawing.foreground
- the foreground element color.background
- the background element color or null for no
background.public java.awt.geom.Area getArea(java.awt.Graphics2D g)
AnnotationElement
getArea
in class AnnotationElement
g
- the graphics object for drawing.