public class TextFragment
extends java.lang.Object
implements java.io.Serializable
TextLine
). Instances of the class are immutable.Modifier and Type | Field and Description |
---|---|
private float |
baselineOffset
The baseline offset (can be used to simulate subscripts and
superscripts).
|
static java.awt.Font |
DEFAULT_FONT
The default font.
|
static java.awt.Paint |
DEFAULT_PAINT
The default text color.
|
private java.awt.Font |
font
The font.
|
protected static LogContext |
logger
Access to logging facilities.
|
private java.awt.Paint |
paint
The text color.
|
private static long |
serialVersionUID
For serialization.
|
private java.lang.String |
text
The text.
|
Constructor and Description |
---|
TextFragment(java.lang.String text)
Creates a new text fragment.
|
TextFragment(java.lang.String text,
java.awt.Font font)
Creates a new text fragment.
|
TextFragment(java.lang.String text,
java.awt.Font font,
java.awt.Paint paint)
Creates a new text fragment.
|
TextFragment(java.lang.String text,
java.awt.Font font,
java.awt.Paint paint,
float baselineOffset)
Creates a new text fragment.
|
Modifier and Type | Method and Description |
---|---|
float |
calculateBaselineOffset(java.awt.Graphics2D g2,
TextAnchor anchor)
Calculates the vertical offset between the baseline and the specified
text anchor.
|
Size2D |
calculateDimensions(java.awt.Graphics2D g2)
Calculates the dimensions of the text fragment.
|
void |
draw(java.awt.Graphics2D g2,
float anchorX,
float anchorY,
TextAnchor anchor,
float rotateX,
float rotateY,
double angle)
Draws the text fragment.
|
boolean |
equals(java.lang.Object obj)
Tests this instance for equality with an arbitrary object.
|
float |
getBaselineOffset()
Returns the baseline offset.
|
java.awt.Font |
getFont()
Returns the font.
|
java.awt.Paint |
getPaint()
Returns the text paint.
|
java.lang.String |
getText()
Returns the text.
|
int |
hashCode()
Returns a hash code for this object.
|
private void |
readObject(java.io.ObjectInputStream stream)
Provides serialization support.
|
private void |
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.
|
private static final long serialVersionUID
public static final java.awt.Font DEFAULT_FONT
public static final java.awt.Paint DEFAULT_PAINT
private java.lang.String text
private java.awt.Font font
private transient java.awt.Paint paint
private float baselineOffset
protected static final LogContext logger
public TextFragment(java.lang.String text)
text
- the text (null
not permitted).public TextFragment(java.lang.String text, java.awt.Font font)
text
- the text (null
not permitted).font
- the font (null
not permitted).public TextFragment(java.lang.String text, java.awt.Font font, java.awt.Paint paint)
text
- the text (null
not permitted).font
- the font (null
not permitted).paint
- the text color (null
not permitted).public TextFragment(java.lang.String text, java.awt.Font font, java.awt.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 java.lang.String getText()
null
).public java.awt.Font getFont()
null
).public java.awt.Paint getPaint()
null
).public float getBaselineOffset()
public void draw(java.awt.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(java.awt.Graphics2D g2)
g2
- the graphics device.public float calculateBaselineOffset(java.awt.Graphics2D g2, TextAnchor anchor)
g2
- the graphics device.anchor
- the anchor.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to test against (null
permitted).public int hashCode()
hashCode
in class java.lang.Object
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
stream
- the output stream.java.io.IOException
- if there is an I/O error.private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
stream
- the input stream.java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.