public class StringUtils
Type Params | Return Type | Name and description |
---|---|---|
|
public static Graphics2D |
drawSplittedText(List<String> splittedText, FontMetrics fontMetrics, Graphics2D graphics, int startX, int startY) |
|
public static int |
findBreakAfter(String line, int start) Returns the index of the first whitespace character or '-' in line that is at or after start. |
|
public static int |
findBreakBefore(String line, int start) Returns the index of the first whitespace character or '-' in line that is at or before start. |
|
public static List<String> |
splitIntoLines(String str) Returns an array of strings, one for each line in the string. |
|
public static List<String> |
wrap(String str, FontMetrics fm, int maxWidth) Returns an array of strings, one for each line in the string after it has been wrapped to fit lines of maxWidth. |
|
public static void |
wrapLineInto(String line, List<String> list, FontMetrics fm, int maxWidth) Given a line of text and font metrics information, wrap the line and add the new line(s) to list. |
Returns the index of the first whitespace character or '-' in line that is at or after start. Returns -1 if no such character is found.
line
- a stringstart
- where to star lookingReturns the index of the first whitespace character or '-' in line that is at or before start. Returns -1 if no such character is found.
line
- a stringstart
- where to star lookingReturns an array of strings, one for each line in the string. Lines end with any of cr, lf, or cr lf. A line ending at the end of the string will not output a further, empty string.
This code assumes str is not null
.
str
- the string to splitReturns an array of strings, one for each line in the string after it has been wrapped to fit lines of maxWidth. Lines end with any of cr, lf, or cr lf. A line ending at the end of the string will not output a further, empty string.
This code assumes str is not null
.
str
- the string to splitfm
- needed for string width calculationsmaxWidth
- the max line width, in pointsGiven a line of text and font metrics information, wrap the line and add the new line(s) to list.
line
- a line of textlist
- an output list of stringsfm
- font metricsmaxWidth
- maximum width of the line(s)