Package org.jfree.chart.text
Class TextBlock
java.lang.Object
org.jfree.chart.text.TextBlock
- All Implemented Interfaces:
Serializable
A list of
TextLine objects that form a block of text.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a line of text that will be displayed using the specified font.voidAdds aTextLineto the block.calculateBounds(Graphics2D g2, float anchorX, float anchorY, TextBlockAnchor anchor, float rotateX, float rotateY, double angle) Returns the bounds of the text block.Returns the width and height of the text block.voiddraw(Graphics2D g2, float x, float y, TextBlockAnchor anchor) Draws the text block at a specific location.voiddraw(Graphics2D g2, float anchorX, float anchorY, TextBlockAnchor anchor, float rotateX, float rotateY, double angle) Draws the text block, aligning it with the specified anchor point and rotating it about the specified rotation point.booleanTests this object for equality with an arbitrary object.Returns the last line in the block.Returns the alignment of the lines of text within the block.getLines()Returns an unmodifiable list containing the lines for the text block.inthashCode()Returns a hash code for this object.voidsetLineAlignment(HorizontalAlignment alignment) Sets the alignment of the lines of text within the block.
-
Constructor Details
-
TextBlock
public TextBlock()Creates a new empty text block.
-
-
Method Details
-
getLineAlignment
Returns the alignment of the lines of text within the block.- Returns:
- The alignment (never
null).
-
setLineAlignment
Sets the alignment of the lines of text within the block.- Parameters:
alignment- the alignment (nullnot permitted).
-
addLine
Adds a line of text that will be displayed using the specified font.- Parameters:
text- the text.font- the font.paint- the paint.
-
addLine
Adds aTextLineto the block.- Parameters:
line- the line.
-
getLastLine
Returns the last line in the block.- Returns:
- The last line in the block.
-
getLines
Returns an unmodifiable list containing the lines for the text block.- Returns:
- A list of
TextLineobjects.
-
calculateDimensions
Returns the width and height of the text block.- Parameters:
g2- the graphics device.- Returns:
- The width and height.
-
calculateBounds
public Shape calculateBounds(Graphics2D g2, float anchorX, float anchorY, TextBlockAnchor anchor, float rotateX, float rotateY, double angle) Returns the bounds of the text block.- Parameters:
g2- the graphics device (nullnot permitted).anchorX- the x-coordinate for the anchor point.anchorY- the y-coordinate for the anchor point.anchor- the text block anchor (nullnot permitted).rotateX- the x-coordinate for the rotation point.rotateY- the y-coordinate for the rotation point.angle- the rotation angle.- Returns:
- The bounds.
-
draw
Draws the text block at a specific location.- Parameters:
g2- the graphics device.x- the x-coordinate for the anchor point.y- the y-coordinate for the anchor point.anchor- the anchor point.
-
draw
public void draw(Graphics2D g2, float anchorX, float anchorY, TextBlockAnchor anchor, float rotateX, float rotateY, double angle) Draws the text block, aligning it with the specified anchor point and rotating it about the specified rotation point.- 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 block that is aligned to the anchor point.rotateX- the x-coordinate for the rotation point.rotateY- the x-coordinate for the rotation point.angle- the rotation (in radians).
-
equals
Tests this object for equality with an arbitrary object. -
hashCode
Returns a hash code for this object.
-