|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.javatest.tool.StringFitter
public class StringFitter
Constructor Summary | |
---|---|
StringFitter()
Creates default StringFitter. |
|
StringFitter(java.awt.FontMetrics fm)
Creates a StringFitter with specified FontMetrics. |
|
StringFitter(java.awt.FontMetrics fm,
java.lang.String replaceString,
java.lang.String splitString)
Creates a StringFitter with universal replace string, specified split string and FontMetrics. |
|
StringFitter(java.awt.FontMetrics fm,
java.lang.String leftReplaceString,
java.lang.String rightReplaceString,
java.lang.String splitString)
Creates a StringFitter with replace strings for beginning and ending of the truncated string and also with specified split string and FontMetrics. |
|
StringFitter(java.lang.String replaceString,
java.lang.String splitString)
Creates a StringFitter with universal replace string and specified split string. |
|
StringFitter(java.lang.String leftReplaceString,
java.lang.String rightReplaceString,
java.lang.String splitString)
Creates a StringFitter with replace strings for beginning and ending of the truncated string and also with specified split string. |
Method Summary | |
---|---|
static StringFitter |
getDefaultFitter()
get or create and get an instance of default StringFitter with "..." for replace strings and "" for split string |
java.awt.FontMetrics |
getFontMetrics()
get current FontMetrics |
java.lang.String |
getLeftReplaceString()
get current replace string for beginning of truncated string |
java.lang.String |
getMiddleReplaceString()
get current replacing string for middle parts of truncated string |
java.lang.String |
getRightReplaceString()
get current replace string for ending of truncated string |
java.lang.String |
getSplitString()
get current split string |
void |
setFontMetrics(java.awt.Component c)
set FontMetrics through providing Component that will display truncated string |
void |
setFontMetrics(java.awt.FontMetrics fm)
set FontMetrics |
void |
setLeftReplaceString(java.lang.String s)
set replace string for replacing beginning of the truncated string |
void |
setMiddleReplaceString(java.lang.String s)
Set a string for replacing truncated parts in the middle of truncated string ("..." by default) |
void |
setRightReplaceString(java.lang.String s)
set replace string for replacing ending of the truncated string |
void |
setSplitString(java.lang.String s)
set split string |
java.lang.String |
truncateBeginning(java.lang.String s,
java.awt.Component c)
Truncate a String to fit into Component. |
java.lang.String |
truncateBeginning(java.lang.String s,
int width)
Truncate a String to fit into some width. |
java.lang.String |
truncateEnding(java.lang.String s,
java.awt.Component c)
Truncate a String to fit into Component. |
java.lang.String |
truncateEnding(java.lang.String s,
int width)
Truncate a String to fit into some width. |
java.lang.String |
truncateMiddle(java.lang.String s,
java.awt.Component c)
Truncate a String to fit into Component. |
java.lang.String |
truncateMiddle(java.lang.String s,
int width)
Truncate a String to fit into some width. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringFitter()
public StringFitter(java.lang.String replaceString, java.lang.String splitString)
replaceString
- an universal string for replacing truncated parts. It is
used to replace beginning, ending and middle partssplitString
- a string to provide discrete truncation. E.g. if split
string is "/" - string "/some/long/file/path/that/needs/to/be/fit" will
become "/some/long/file/path/..." and not "/some/long/file/path/th..."
after truncateEnding()public StringFitter(java.lang.String leftReplaceString, java.lang.String rightReplaceString, java.lang.String splitString)
leftReplaceString
- a string for replacing truncated parts in the
beginning of the truncated string. If rightReplaceString and
leftReplaceString are equal leftReplaceString is used to replace middle
parts too. A concatenation of two replace strings is used otherwise.rightReplaceString
- a string for replacing truncated parts in the
ending of the truncated string. If rightReplaceString and
leftReplaceString are equal leftReplaceString is used to replace middle
parts too. A concatenation of two replace strings is used otherwise.splitString
- a string to provide discrete truncation. E.g. if split
string is "/" - string "/some/long/file/path/that/needs/to/be/fit" will
become "/some/long/file/path/..." and not "/some/long/file/path/th..."
after truncateEnding()public StringFitter(java.awt.FontMetrics fm)
fm
- FontMetrics to use in this StringFitter. Current system
FontMetrics is used if it is nullpublic StringFitter(java.awt.FontMetrics fm, java.lang.String replaceString, java.lang.String splitString)
fm
- FontMetrics to use in this StringFitter. Current system
FontMetrics is used if it is nullreplaceString
- an universal string for replacing truncated parts. It is
used to replace beginning, ending and middle partssplitString
- a string to provide discrete truncation. E.g. if split
string is "/" - string "/some/long/file/path/that/needs/to/be/fit" will
become "/some/long/file/path/..." and not "/some/long/file/path/th..."
after truncateEnding()public StringFitter(java.awt.FontMetrics fm, java.lang.String leftReplaceString, java.lang.String rightReplaceString, java.lang.String splitString)
fm
- FontMetrics to use in this StringFitter. Current system
FontMetrics is used if it is nullleftReplaceString
- a string for replacing truncated parts in the
beginning of the truncated string. If rightReplaceString and
leftReplaceString are equal leftReplaceString is used to replace middle
parts too. A concatenation of two replace strings is used otherwise.rightReplaceString
- a string for replacing truncated parts in the
ending of the truncated string. If rightReplaceString and
leftReplaceString are equal leftReplaceString is used to replace middle
parts too. A concatenation of two replace strings is used otherwise.splitString
- a string to provide discrete truncation. E.g. if split
string is "/" - string "/some/long/file/path/that/needs/to/be/fit" will
become "/some/long/file/path/..." and not "/some/long/file/path/th..."
after truncateEnding()Method Detail |
---|
public static StringFitter getDefaultFitter()
public java.lang.String getMiddleReplaceString()
public void setMiddleReplaceString(java.lang.String s)
s
- new replace stringpublic java.lang.String getLeftReplaceString()
public java.lang.String getRightReplaceString()
public java.lang.String getSplitString()
public java.awt.FontMetrics getFontMetrics()
public void setLeftReplaceString(java.lang.String s)
s
- new replace stringpublic void setRightReplaceString(java.lang.String s)
s
- new replace stringpublic void setSplitString(java.lang.String s)
s
- a string to provide discrete truncation. E.g. if split
string is "/" - string "/some/long/file/path/that/needs/to/be/fit" will
become "/some/long/file/path/..." and not "/some/long/file/path/th..."
after truncateEnding()public void setFontMetrics(java.awt.FontMetrics fm)
fm
- new FontMetrics used to calculate widths of stringspublic void setFontMetrics(java.awt.Component c)
c
- Component containing FontMetrics used to calculate widths of stringspublic java.lang.String truncateBeginning(java.lang.String s, java.awt.Component c)
s
- a String to truncatec
- Component that will contains String spublic java.lang.String truncateBeginning(java.lang.String s, int width)
s
- a String to truncatewidth
- available space for the stringpublic java.lang.String truncateEnding(java.lang.String s, java.awt.Component c)
s
- a String to truncatec
- Component that will contains String spublic java.lang.String truncateEnding(java.lang.String s, int width)
s
- a String to truncatewidth
- available space for the stringpublic java.lang.String truncateMiddle(java.lang.String s, java.awt.Component c)
s
- a String to truncatec
- Component that will contains String spublic java.lang.String truncateMiddle(java.lang.String s, int width)
s
- a String to truncatewidth
- available space for the string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |