JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class JCWordWrap

java.lang.Object
  |
  +--com.klg.jclass.util.swing.JCWordWrap

public class JCWordWrap
extends Object

JCWordWrap provides a static method wrapText, which performs basic word-wrap logic on a String given a line width and new line delimiter.


Constructor Summary
JCWordWrap()
           
 
Method Summary
static String replace(String text, String oldDelimiter, String newDelimiter)
          Returns a String with each occurence of an old delimiter replaced by a new delimiter.
static String wrapText(String text, FontMetrics fm, int width, String delimiter, boolean isLeftAligned)
          Returns a word-wrapped String given a line width and delimiter, such as a newline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCWordWrap

public JCWordWrap()
Method Detail

wrapText

public static String wrapText(String text,
                              FontMetrics fm,
                              int width,
                              String delimiter,
                              boolean isLeftAligned)
Returns a word-wrapped String given a line width and delimiter, such as a newline. Word-wrap logic breaks lines by spaces and provides no hyphenation logic. The original String is returned if the number of characters is less than 10. Note that the word delimiter is always a space.

Parameters:
text - The original text to wrap
fm - The font metrics used to decide whether text fits on a line
width - The width of the line
delimiter - The delimiter to use for line wrapping.
isLeftAligned - No longer used
Returns:
The newly created word-wrapped String

replace

public static String replace(String text,
                             String oldDelimiter,
                             String newDelimiter)
Returns a String with each occurence of an old delimiter replaced by a new delimiter.

Parameters:
text - The text in which the replacement happens
oldDelimiter - The delimiter text to be replaced
newDelimiter - The new text to replace the old
Returns:
A string in which the replacement has happened. If there are no occurrences of the old delimiter in the text, the passed in String is returned.

Copyright © 2004 Quest Software Inc..
All rights reserved.