All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.eou.toolkit.graphics.FontUtils

java.lang.Object
   |
   +----com.ibm.eou.toolkit.graphics.FontUtils

public class FontUtils
extends Object
This class provides font utility functions.


Variable Index

 o BOTTOM
 o CENTER
 o LEFT
 o RIGHT
 o TOP

Method Index

 o createWrappedStrings(String, int)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string.
 o createWrappedStrings(String, int, FontMetrics, boolean)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string.
 o createWrappedStrings(String, int, FontMetrics, boolean, Locale)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string.
 o createWrappedStrings(String, int, Locale)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string.
 o getLargestFont(Font, int)
Return a font with the same font name and style as the supplied font, but with a size ensuring that strings drawn with the font will just fit in the supplied maximum height.
 o getLargestFont(Font, int, int, String)
Return a font with the same font name and style as the supplied font, but with a size ensuring that the supplied string drawn with the returned font will just fit in a rectangle of the supplied maximum width and height.
 o getLargestFont(Font, int, String)
Return a font with the same font name and style as the supplied font, but with a size ensuring that the supplied string drawn with the returned font will just fit in the supplied maximum width.
 o getWrappedSize(String, double, FontMetrics, boolean)
Return the size of a block of text when word-wrapped.
 o getWrappedSize(String, double, FontMetrics, boolean, Locale)
Return the size of a block of text when word-wrapped.
 o getWrappedSize(String, int, FontMetrics, boolean)
Return the size of a block of text when word-wrapped.
 o getWrappedSize(String, int, FontMetrics, boolean, Locale)
Return the size of a block of text when word-wrapped.
 o indexOfNextLine(String, int, int)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed.
 o indexOfNextLine(String, int, int, FontMetrics, boolean)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed.
 o indexOfNextLine(String, int, int, FontMetrics, boolean, Locale)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed.
 o indexOfNextLine(String, int, int, Locale)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed.
 o renderWrapped(Graphics, Rectangle, String, int, int)
Renders the text string onto the given graphics context, within the specified bounding rectangle, by word-wrapping using the current default locale.
 o renderWrapped(Graphics, Rectangle, String, int, int, Locale)
Renders the text string onto the given graphics context, within the specified bounding rectangle, by word-wrapping using the given locale.

Variables

 o LEFT
 public static final int LEFT
 o RIGHT
 public static final int RIGHT
 o CENTER
 public static final int CENTER
 o TOP
 public static final int TOP
 o BOTTOM
 public static final int BOTTOM

Methods

 o getLargestFont
 public static Font getLargestFont(Font font,
                                   int maximumHeight)
Return a font with the same font name and style as the supplied font, but with a size ensuring that strings drawn with the font will just fit in the supplied maximum height.

 o getLargestFont
 public static Font getLargestFont(Font font,
                                   int maximumWidth,
                                   String text)
Return a font with the same font name and style as the supplied font, but with a size ensuring that the supplied string drawn with the returned font will just fit in the supplied maximum width.

 o getLargestFont
 public static Font getLargestFont(Font font,
                                   int maximumWidth,
                                   int maximumHeight,
                                   String text)
Return a font with the same font name and style as the supplied font, but with a size ensuring that the supplied string drawn with the returned font will just fit in a rectangle of the supplied maximum width and height.

 o indexOfNextLine
 public static int indexOfNextLine(String text,
                                   int startIndex,
                                   int maxChars)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed. The places in the text where a new line can start are determined according to the current default locale. The current line is considered to start at the given startIndex, and will not exceed maxChars long, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text. If the entire remaining text is to form the current line, the return value is the length of the text itself.

 o indexOfNextLine
 public static int indexOfNextLine(String text,
                                   int startIndex,
                                   int maxChars,
                                   Locale locale)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed. The places in the text where a new line can start are determined according to the given locale. The current line is considered to start at the given startIndex, and will not exceed maxChars long, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text. If the entire remaining text is to form the current line, the return value is the length of the text itself.

 o indexOfNextLine
 public static int indexOfNextLine(String text,
                                   int startIndex,
                                   int maxPixels,
                                   FontMetrics fm,
                                   boolean excludeTrailingWhitespace)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed. The places in the text where a new line can start are determined according to the current default locale. The current line is considered to start at the given startIndex, and will not exceed maxPixels when rendered with the given fontmetrics, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text. If excludeTrailingWhitespace is true, all measurements of the pixel length of lines are performed after stripping off trailing whitespace. If the entire remaining text is to form the current line, the return value is the length of the text itself.

 o indexOfNextLine
 public static int indexOfNextLine(String text,
                                   int startIndex,
                                   int maxPixels,
                                   FontMetrics fm,
                                   boolean excludeTrailingWhitespace,
                                   Locale locale)
Return the index of the start of the next line of text, to enable word-wrapping of text to be performed. The places in the text where a new line can start are determined according to the given locale. The current line is considered to start at the given startIndex, and will not exceed maxPixels when rendered with the given fontmetrics, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text. If excludeTrailingWhitespace is true, all measurements of the pixel length of lines are performed after stripping off trailing whitespace. If the entire remaining text is to form the current line, the return value is the length of the text itself.

 o createWrappedStrings
 public static String[] createWrappedStrings(String text,
                                             int maxChars)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string. The places in the text where a new line can start are determined according to the current default locale. No line will exceed maxChars long, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text.

 o createWrappedStrings
 public static String[] createWrappedStrings(String text,
                                             int maxChars,
                                             Locale locale)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string. The places in the text where a new line can start are determined according to the given locale. No line will exceed maxChars long, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text.

 o createWrappedStrings
 public static String[] createWrappedStrings(String text,
                                             int maxPixels,
                                             FontMetrics fm,
                                             boolean excludeTrailingWhitespace)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string. The places in the text where a new line can start are determined according to the current default locale. No line will exceed maxPixels when rendered with the given fontmetrics, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text. If excludeTrailingWhitespace is true, all measurements of the pixel length of lines are performed after stripping off trailing whitespace, and all such trailing whitespace is omitted from the result strings.

 o createWrappedStrings
 public static String[] createWrappedStrings(String text,
                                             int maxPixels,
                                             FontMetrics fm,
                                             boolean excludeTrailingWhitespace,
                                             Locale locale)
Return an array of strings containing successive lines of text, which are the result of word-wrapping the given text string. The places in the text where a new line can start are determined according to the given locale. No line will exceed maxPixels when rendered with the given fontmetrics, unless that is necessary in order for the line not to be empty. Linebreaks or control characters in the text will force a new line of text. If excludeTrailingWhitespace is true, all measurements of the pixel length of lines are performed after stripping off trailing whitespace, and all such trailing whitespace is omitted from the result strings.

 o renderWrapped
 public static void renderWrapped(Graphics g,
                                  Rectangle bounds,
                                  String text,
                                  int horizontalAlignment,
                                  int verticalAlignment)
Renders the text string onto the given graphics context, within the specified bounding rectangle, by word-wrapping using the current default locale. The horizontalAlignment determines placement of each line: LEFT causes each line to align to the left edge, RIGHT to the right edge, and CENTER causes each line to be centered horizontally between the left and right edges. The verticalAlignment determines placement of the block of text: TOP causes the top of the block to align to the top edge, BOTTOM causes the bottom to align to the bottom edge, and CENTER causes the block to be centered vertically between the top and bottom edges. The text is drawn and word-wrapped using the current font for the graphics, and is drawn in the current graphics color. If the text does not fit within the bounding rectangle, it may be clipped.

 o renderWrapped
 public static void renderWrapped(Graphics g,
                                  Rectangle bounds,
                                  String text,
                                  int horizontalAlignment,
                                  int verticalAlignment,
                                  Locale locale)
Renders the text string onto the given graphics context, within the specified bounding rectangle, by word-wrapping using the given locale. The horizontalAlignment determines placement of each line: LEFT causes each line to align to the left edge, RIGHT to the right edge, and CENTER causes each line to be centered horizontally between the left and right edges. The verticalAlignment determines placement of the block of text: TOP causes the top of the block to align to the top edge, BOTTOM causes the bottom to align to the bottom edge, and CENTER causes the block to be centered vertically between the top and bottom edges. The text is drawn and word-wrapped using the current font for the graphics, and is drawn in the current graphics color. If the text does not fit within the bounding rectangle, it may be clipped.

 o getWrappedSize
 public static Dimension getWrappedSize(String text,
                                        int maxPixels,
                                        FontMetrics fm,
                                        boolean excludeTrailingWhitespace)
Return the size of a block of text when word-wrapped. The height of the block is determined by the number of lines of text required, while the width may be less the maxPixels because none of the lines of text may fill the entire width.

See Also:
createWrappedStrings
 o getWrappedSize
 public static Dimension getWrappedSize(String text,
                                        int maxPixels,
                                        FontMetrics fm,
                                        boolean excludeTrailingWhitespace,
                                        Locale locale)
Return the size of a block of text when word-wrapped. The height of the block is determined by the number of lines of text required, while the width may be less the maxPixels because none of the lines of text may fill the entire width.

See Also:
createWrappedStrings
 o getWrappedSize
 public static Dimension getWrappedSize(String text,
                                        double aspectRatio,
                                        FontMetrics fm,
                                        boolean excludeTrailingWhitespace)
Return the size of a block of text when word-wrapped. The width of the block is computed so that when the text is word-wrapped with that width as the maxPixels, the height of the resulting text block gives approximately the specified aspect ratio. Note that the iterative algorithm used to find this width will produce an aspect ratio slightly larger than that requested, unless an exact match is found. The aspect ratio of a rectangle is given by its width divided by its height.

See Also:
createWrappedStrings
 o getWrappedSize
 public static Dimension getWrappedSize(String text,
                                        double aspectRatio,
                                        FontMetrics fm,
                                        boolean excludeTrailingWhitespace,
                                        Locale locale)
Return the size of a block of text when word-wrapped. The width of the block is computed so that when the text is word-wrapped with that width as the maxPixels, the height of the resulting text block gives approximately the specified aspect ratio. Note that the iterative algorithm used to find this width will produce an aspect ratio slightly larger than that requested, unless an exact match is found. The aspect ratio of a rectangle is given by its width divided by its height.

See Also:
createWrappedStrings

All Packages  Class Hierarchy  This Package  Previous  Next  Index