Save This Page
Home » jcommon-1.0.13 » org.jfree.text » [javadoc | source]
org.jfree.text
public class: TextUtilities [javadoc | source]
java.lang.Object
   org.jfree.text.TextUtilities
Some utility methods for working with text.
Field Summary
protected static final  LogContext logger    Access to logging facilities. 
Method from org.jfree.text.TextUtilities Summary:
calculateRotatedStringBounds,   calculateRotatedStringBounds,   createTextBlock,   createTextBlock,   createTextBlock,   drawAlignedString,   drawRotatedString,   drawRotatedString,   drawRotatedString,   drawRotatedString,   getTextBounds,   getUseFontMetricsGetStringBounds,   isUseDrawRotatedStringWorkaround,   setUseDrawRotatedStringWorkaround,   setUseFontMetricsGetStringBounds
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jfree.text.TextUtilities Detail:
 public static Shape calculateRotatedStringBounds(String text,
    Graphics2D g2,
    float x,
    float y,
    TextAnchor textAnchor,
    double angle,
    TextAnchor rotationAnchor) 
    Returns a shape that represents the bounds of the string after the specified rotation has been applied.
 public static Shape calculateRotatedStringBounds(String text,
    Graphics2D g2,
    float textX,
    float textY,
    double angle,
    float rotateX,
    float rotateY) 
    Returns a shape that represents the bounds of the string after the specified rotation has been applied.
 public static TextBlock createTextBlock(String text,
    Font font,
    Paint paint) 
    Creates a TextBlock from a String. Line breaks are added where the String contains '\n' characters.
 public static TextBlock createTextBlock(String text,
    Font font,
    Paint paint,
    float maxWidth,
    TextMeasurer measurer) 
    Creates a new text block from the given string, breaking the text into lines so that the maxWidth value is respected.
 public static TextBlock createTextBlock(String text,
    Font font,
    Paint paint,
    float maxWidth,
    int maxLines,
    TextMeasurer measurer) 
    Creates a new text block from the given string, breaking the text into lines so that the maxWidth value is respected.
 public static Rectangle2D drawAlignedString(String text,
    Graphics2D g2,
    float x,
    float y,
    TextAnchor anchor) 
    Draws a string such that the specified anchor point is aligned to the given (x, y) location.
 public static  void drawRotatedString(String text,
    Graphics2D g2,
    double angle,
    float x,
    float y) 
    A utility method for drawing rotated text.

    A common rotation is -Math.PI/2 which draws text 'vertically' (with the top of the characters on the left).

 public static  void drawRotatedString(String text,
    Graphics2D g2,
    float textX,
    float textY,
    double angle,
    float rotateX,
    float rotateY) 
    A utility method for drawing rotated text.

    A common rotation is -Math.PI/2 which draws text 'vertically' (with the top of the characters on the left).

 public static  void drawRotatedString(String text,
    Graphics2D g2,
    float x,
    float y,
    TextAnchor textAnchor,
    double angle,
    TextAnchor rotationAnchor) 
    Draws a string that is aligned by one anchor point and rotated about another anchor point.
 public static  void drawRotatedString(String text,
    Graphics2D g2,
    float x,
    float y,
    TextAnchor textAnchor,
    double angle,
    float rotationX,
    float rotationY) 
    Draws a string that is aligned by one anchor point and rotated about another anchor point.
 public static Rectangle2D getTextBounds(String text,
    Graphics2D g2,
    FontMetrics fm) 
    Returns the bounds for the specified text.
 public static boolean getUseFontMetricsGetStringBounds() 
    Returns the flag that controls whether the FontMetrics.getStringBounds() method is used or not. If you are having trouble with label alignment or positioning, try changing the value of this flag.
 public static boolean isUseDrawRotatedStringWorkaround() 
 public static  void setUseDrawRotatedStringWorkaround(boolean use) 
    Sets the flag that controls whether or not a workaround is used for drawing rotated strings. The related bug is on Sun's bug parade (id 4312117) and the workaround involves using a TextLayout instance to draw the text instead of calling the drawString() method in the Graphics2D class.
 public static  void setUseFontMetricsGetStringBounds(boolean use) 
    Sets the flag that controls whether the FontMetrics.getStringBounds() method is used or not. If you are having trouble with label alignment or positioning, try changing the value of this flag.