org.jfree.text
Class TextFragment

java.lang.Object
  extended byorg.jfree.text.TextFragment

public class TextFragment
extends java.lang.Object

A text item, with an associated font, that fits on a single line (see TextLine).

Author:
David Gilbert

Field Summary
static java.awt.Font DEFAULT_FONT
          The default font.
 
Constructor Summary
TextFragment(java.lang.String text)
          Creates a new text fragment.
TextFragment(java.lang.String text, java.awt.Font font)
          Creates a new text fragment.
 
Method Summary
 float calculateBaselineOffset(java.awt.Graphics2D g2, TextAnchor anchor)
          Calculates the vertical offset between the baseline and the specified text anchor.
 java.awt.Dimension 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.
 java.awt.Font getFont()
          Returns the font.
 java.lang.String getText()
          Returns the text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static final java.awt.Font DEFAULT_FONT
The default font.

Constructor Detail

TextFragment

public TextFragment(java.lang.String text)
Creates a new text fragment.

Parameters:
text - the text.

TextFragment

public TextFragment(java.lang.String text,
                    java.awt.Font font)
Creates a new text fragment.

Parameters:
text - the text.
font - the font.
Method Detail

getText

public java.lang.String getText()
Returns the text.

Returns:
the text.

getFont

public java.awt.Font getFont()
Returns the font.

Returns:
the font.

calculateDimensions

public java.awt.Dimension calculateDimensions(java.awt.Graphics2D g2)
Calculates the dimensions of the text fragment.

Parameters:
g2 - the graphics device.
Returns:
the width and height.

draw

public void draw(java.awt.Graphics2D g2,
                 float anchorX,
                 float anchorY,
                 TextAnchor anchor,
                 float rotateX,
                 float rotateY,
                 double angle)
Draws the text fragment.

Parameters:
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.

calculateBaselineOffset

public float calculateBaselineOffset(java.awt.Graphics2D g2,
                                     TextAnchor anchor)
Calculates the vertical offset between the baseline and the specified text anchor.

Parameters:
g2 - the graphics device.
anchor - the anchor.
Returns:
the offset.