Package org.jfree.chart.text
Class TextLine
- java.lang.Object
-
- org.jfree.chart.text.TextLine
-
- All Implemented Interfaces:
java.io.Serializable
public class TextLine extends java.lang.Object implements java.io.SerializableA sequence ofTextFragmentobjects that together form a line of text. A sequence of text lines is managed by theTextBlockclass.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ListfragmentsStorage for the text fragments that make up the line.private static longserialVersionUIDFor serialization.
-
Constructor Summary
Constructors Constructor Description TextLine()Creates a new empty line.TextLine(java.lang.String text)Creates a new text line using the default font.TextLine(java.lang.String text, java.awt.Font font)Creates a new text line.TextLine(java.lang.String text, java.awt.Font font, java.awt.Paint paint)Creates a new text line.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFragment(TextFragment fragment)Adds a text fragment to the text line.private floatcalculateBaselineOffset(java.awt.Graphics2D g2, TextAnchor anchor)Calculate the offsets required to translate from the specified anchor position to the left baseline position.Size2DcalculateDimensions(java.awt.Graphics2D g2)Calculates the width and height of the text line.voiddraw(java.awt.Graphics2D g2, float anchorX, float anchorY, TextAnchor anchor, float rotateX, float rotateY, double angle)Draws the text line.booleanequals(java.lang.Object obj)Tests this object for equality with an arbitrary object.TextFragmentgetFirstTextFragment()Returns the first text fragment in the line.TextFragmentgetLastTextFragment()Returns the last text fragment in the line.inthashCode()Returns a hash code for this object.voidremoveFragment(TextFragment fragment)Removes a fragment from the line.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
fragments
private java.util.List fragments
Storage for the text fragments that make up the line.
-
-
Constructor Detail
-
TextLine
public TextLine()
Creates a new empty line.
-
TextLine
public TextLine(java.lang.String text)
Creates a new text line using the default font.- Parameters:
text- the text (nullnot permitted).
-
TextLine
public TextLine(java.lang.String text, java.awt.Font font)Creates a new text line.- Parameters:
text- the text (nullnot permitted).font- the text font (nullnot permitted).
-
TextLine
public TextLine(java.lang.String text, java.awt.Font font, java.awt.Paint paint)Creates a new text line.- Parameters:
text- the text (nullnot permitted).font- the text font (nullnot permitted).paint- the text color (nullnot permitted).
-
-
Method Detail
-
addFragment
public void addFragment(TextFragment fragment)
Adds a text fragment to the text line.- Parameters:
fragment- the text fragment (nullnot permitted).
-
removeFragment
public void removeFragment(TextFragment fragment)
Removes a fragment from the line.- Parameters:
fragment- the fragment to remove.
-
draw
public void draw(java.awt.Graphics2D g2, float anchorX, float anchorY, TextAnchor anchor, float rotateX, float rotateY, double angle)Draws the text line.- Parameters:
g2- the graphics device.anchorX- the x-coordinate for the anchor point.anchorY- the y-coordinate for the anchor point.anchor- the point on the text line that is aligned to the anchor point.rotateX- the x-coordinate for the rotation point.rotateY- the y-coordinate for the rotation point.angle- the rotation angle (in radians).
-
calculateDimensions
public Size2D calculateDimensions(java.awt.Graphics2D g2)
Calculates the width and height of the text line.- Parameters:
g2- the graphics device.- Returns:
- The width and height.
-
getFirstTextFragment
public TextFragment getFirstTextFragment()
Returns the first text fragment in the line.- Returns:
- The first text fragment in the line.
-
getLastTextFragment
public TextFragment getLastTextFragment()
Returns the last text fragment in the line.- Returns:
- The last text fragment in the line.
-
calculateBaselineOffset
private float calculateBaselineOffset(java.awt.Graphics2D g2, TextAnchor anchor)Calculate the offsets required to translate from the specified anchor position to the left baseline position.- Parameters:
g2- the graphics device.anchor- the anchor position.- Returns:
- The offsets.
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to test against (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code for this object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code.
-
-