org.jfree.text
Class TextUtilities

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

public abstract class TextUtilities
extends java.lang.Object

Some utility methods for working with text.


Field Summary
protected static LogContext logger
          Access to logging facilities.
 
Constructor Summary
TextUtilities()
           
 
Method Summary
static TextBlock createTextBlock(java.lang.String text, java.awt.Font font, java.awt.Paint paint, float maxWidth, int maxLines, TextMeasurer measurer)
          Creates a new text block from the given string.
static TextBlock createTextBlock(java.lang.String text, java.awt.Font font, java.awt.Paint paint, float maxWidth, TextMeasurer measurer)
          Creates a new text block from the given string.
static java.awt.geom.Rectangle2D getTextBounds(java.lang.String text, java.awt.Graphics2D g2, java.awt.FontMetrics fm)
          Returns the bounds for the specified text.
static boolean getUseFontMetricsGetStringBounds()
          Returns the flag that controls whether the FontMetrics.getStringBounds() method is used or not.
static void setUseFontMetricsGetStringBounds(boolean use)
          Sets the flag that controls whether the FontMetrics.getStringBounds() method is used or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final LogContext logger
Access to logging facilities.

Constructor Detail

TextUtilities

public TextUtilities()
Method Detail

createTextBlock

public static TextBlock createTextBlock(java.lang.String text,
                                        java.awt.Font font,
                                        java.awt.Paint paint,
                                        float maxWidth,
                                        TextMeasurer measurer)
Creates a new text block from the given string.

Parameters:
text - the text.
font - the font.
paint - the paint.
maxWidth - the maximum width for each line.
measurer - the text measurer.
Returns:
A text block.

createTextBlock

public static TextBlock createTextBlock(java.lang.String text,
                                        java.awt.Font font,
                                        java.awt.Paint paint,
                                        float maxWidth,
                                        int maxLines,
                                        TextMeasurer measurer)
Creates a new text block from the given string.

Parameters:
text - the text.
font - the font.
paint - the paint.
maxWidth - the maximum width for each line.
maxLines - the maximum number of lines.
measurer - the text measurer.
Returns:
A text block.

getTextBounds

public static java.awt.geom.Rectangle2D getTextBounds(java.lang.String text,
                                                      java.awt.Graphics2D g2,
                                                      java.awt.FontMetrics fm)
Returns the bounds for the specified text.

Parameters:
text - the text (null permitted).
g2 - the graphics context (not null).
fm - the font metrics (not null).
Returns:
The text bounds (possibly null).

getUseFontMetricsGetStringBounds

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.

Returns:
A boolean.

setUseFontMetricsGetStringBounds

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.

Parameters:
use - the flag.