|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.ds.fw.types.string.FwStringSplitter
This class is used to split a long string into multiple lines while preserving whole words. It can split lines either by the number of characters per line or by the number of pixels per line.
| Field Summary | |
static int |
CHARACTER
The character mode constant |
java.awt.FontMetrics |
fontMetrics
Current font metrics |
int |
mode
Current mode |
static int |
PIXEL
The pixel mode constant |
int |
width
Current text width |
| Constructor Summary | |
FwStringSplitter()
Default constructor. |
|
| Method Summary | |
java.lang.String |
getString(java.lang.String s)
Returns the splitted string. |
java.util.Vector |
getVector(java.lang.String s)
Splits the text in lines which are returned as a vector. |
void |
setFontMetrics(java.awt.FontMetrics fm)
Sets the font metrics(for pixel mode). |
void |
setMode(int i)
Sets the current splitting mode. |
void |
setWidth(int i)
Sets the text width to be used for splitting. |
static java.lang.String |
splitByCharacter(java.lang.String s,
int w)
Splits text by char width. |
static java.lang.String |
splitByPixel(java.lang.String s,
int w,
java.awt.FontMetrics fm)
Splits text by pixel width. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int CHARACTER
public static final int PIXEL
public int width
public int mode
public java.awt.FontMetrics fontMetrics
| Constructor Detail |
public FwStringSplitter()
| Method Detail |
public static java.lang.String splitByPixel(java.lang.String s,
int w,
java.awt.FontMetrics fm)
s - the string to be splitw - the width in pixelsfm - the font metrics
public static java.lang.String splitByCharacter(java.lang.String s,
int w)
s - the string to be splitw - the width in chars
public void setWidth(int i)
i - pixels or chars count in relation with the splitting modepublic void setMode(int i)
i - 0- chars, 1- pixelspublic void setFontMetrics(java.awt.FontMetrics fm)
fm - the font metrics to be setpublic java.util.Vector getVector(java.lang.String s)
s - text to split
public java.lang.String getString(java.lang.String s)
s - the text to be splitted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||