com.ijchart.xychart.util
Class TextUtil

java.lang.Object
  extended by com.ijchart.xychart.util.TextUtil

public abstract class TextUtil
extends java.lang.Object

Title: IJChart

Description: a chart library for the Java(tm) platform.

Nice static helpers for working with Strings

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.

Constructor Summary
TextUtil()
           
 
Method Summary
static java.awt.geom.Rectangle2D getStringBound(java.awt.Font font, java.lang.String str)
           Returns the bounds of the specified array of characters in the specified font.
static java.awt.geom.Rectangle2D getStringBound(java.awt.Graphics g2, java.lang.String str)
           Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be wrapped.
static java.awt.geom.Rectangle2D getStringBound(java.awt.Graphics g2, java.lang.String str, int beginIndex, int endIndex)
           Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be wrapped.
static java.awt.geom.Rectangle2D getStringBoundWithFm(java.awt.Graphics g2, java.lang.String str)
           Returns the bounds of the specified array of characters in the specified Graphics context.
static double getStringHeight(java.awt.Graphics g2, java.lang.String str)
           Returns the height of the specified array of characters in the specified Graphics context.
static java.awt.geom.Rectangle2D getStringNoWrapBounds(java.lang.String text, java.awt.Font font)
           Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be not wrapped.
static double getStringWidth(java.awt.Graphics g2, java.lang.String str)
           Returns the width of the specified array of characters in the specified Graphics context.
static java.awt.geom.Rectangle2D getStringWrapBounds(java.lang.String text, java.awt.Font font)
           Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be wrapped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextUtil

public TextUtil()
Method Detail

getStringBound

public static java.awt.geom.Rectangle2D getStringBound(java.awt.Graphics g2,
                                                       java.lang.String str)
Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be wrapped.

Parameters:
g2 - Graphics The specified Graphics context (null not permitted).
str - String The specified String (null permitted).
Returns:
Rectangle2D A Rectangle2D that is the bounding box of the specified String in the specified.

getStringBound

public static java.awt.geom.Rectangle2D getStringBound(java.awt.Graphics g2,
                                                       java.lang.String str,
                                                       int beginIndex,
                                                       int endIndex)
Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be wrapped.

Parameters:
g2 - Graphics The specified Graphics context (null not permitted).
str - String The specified String (null permitted).
beginIndex - int The offset of the beginning of str
endIndex - int The offset of the ending of str
Returns:
Rectangle2D A Rectangle2D that is the bounding box of the specified String in the specified.

getStringBound

public static java.awt.geom.Rectangle2D getStringBound(java.awt.Font font,
                                                       java.lang.String str)
Returns the bounds of the specified array of characters in the specified font.

Parameters:
font - Font The font.
str - String The specified String.
Returns:
Rectangle2D A Rectangle2D that is the bounding box of the specified String in the specified.

getStringBoundWithFm

public static java.awt.geom.Rectangle2D getStringBoundWithFm(java.awt.Graphics g2,
                                                             java.lang.String str)
Returns the bounds of the specified array of characters in the specified Graphics context.

Parameters:
g2 - Graphics2D The specified Graphics context.
str - String The specified String.
Returns:
Rectangle2D A Rectangle2D that is the bounding box of the specified String in the specified.

getStringWidth

public static double getStringWidth(java.awt.Graphics g2,
                                    java.lang.String str)
Returns the width of the specified array of characters in the specified Graphics context.

Parameters:
g2 - Graphics The specified Graphics context (null not permitted).
str - String The specified String (null permitted).
Returns:
double The string width.

getStringHeight

public static double getStringHeight(java.awt.Graphics g2,
                                     java.lang.String str)
Returns the height of the specified array of characters in the specified Graphics context.

Parameters:
g2 - Graphics The specified Graphics context (null not permitted).
str - String The specified String (null permitted).
Returns:
double The string height.

getStringWrapBounds

public static java.awt.geom.Rectangle2D getStringWrapBounds(java.lang.String text,
                                                            java.awt.Font font)
Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be wrapped.

Parameters:
text - String The specified String (null not permitted).
font - Font The font (null not permitted).
Returns:
Rectangle2D A Rectangle2D that is the bounding box of the specified String in the specified.

getStringNoWrapBounds

public static java.awt.geom.Rectangle2D getStringNoWrapBounds(java.lang.String text,
                                                              java.awt.Font font)
Returns the bounds of the specified array of characters in the specified Graphics context.If the string contains '\n' will be not wrapped.

Parameters:
text - String The specified String (null not permitted).
font - Font The font (null not permitted).
Returns:
Rectangle2D A Rectangle2D that is the bounding box of the specified String in the specified.