public class TextFragment extends Object implements Serializable
TextLine). Instances of the class are immutable.| Modifier and Type | Field and Description |
|---|---|
static Font |
DEFAULT_FONT
The default font.
|
static Paint |
DEFAULT_PAINT
The default text color.
|
protected static LogContext |
logger
Access to logging facilities.
|
| Constructor and Description |
|---|
TextFragment(String text)
Creates a new text fragment.
|
TextFragment(String text,
Font font)
Creates a new text fragment.
|
TextFragment(String text,
Font font,
Paint paint)
Creates a new text fragment.
|
TextFragment(String text,
Font font,
Paint paint,
float baselineOffset)
Creates a new text fragment.
|
| Modifier and Type | Method and Description |
|---|---|
float |
calculateBaselineOffset(Graphics2D g2,
TextAnchor anchor)
Calculates the vertical offset between the baseline and the specified
text anchor.
|
Size2D |
calculateDimensions(Graphics2D g2)
Calculates the dimensions of the text fragment.
|
void |
draw(Graphics2D g2,
float anchorX,
float anchorY,
TextAnchor anchor,
float rotateX,
float rotateY,
double angle)
Draws the text fragment.
|
boolean |
equals(Object obj)
Tests this instance for equality with an arbitrary object.
|
float |
getBaselineOffset()
Returns the baseline offset.
|
Font |
getFont()
Returns the font.
|
Paint |
getPaint()
Returns the text paint.
|
String |
getText()
Returns the text.
|
int |
hashCode()
Returns a hash code for this object.
|
public static final Font DEFAULT_FONT
public static final Paint DEFAULT_PAINT
protected static final LogContext logger
public TextFragment(String text)
text - the text (null not permitted).public TextFragment(String text, Font font)
text - the text (null not permitted).font - the font (null not permitted).public TextFragment(String text, Font font, Paint paint)
text - the text (null not permitted).font - the font (null not permitted).paint - the text color (null not permitted).public TextFragment(String text, Font font, Paint paint, float baselineOffset)
text - the text (null not permitted).font - the font (null not permitted).paint - the text color (null not permitted).baselineOffset - the baseline offset.public float getBaselineOffset()
public void draw(Graphics2D g2, float anchorX, float anchorY, TextAnchor anchor, float rotateX, float rotateY, double angle)
g2 - the graphics device.anchorX - the x-coordinate of the anchor point.anchorY - the y-coordinate of the anchor point.anchor - the location of the text that is aligned to the anchor
point.rotateX - the x-coordinate of the rotation point.rotateY - the y-coordinate of the rotation point.angle - the angle.public Size2D calculateDimensions(Graphics2D g2)
g2 - the graphics device.public float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor)
g2 - the graphics device.anchor - the anchor.