@Environment(value=CLIENT) public class TextHandler extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TextHandler.FormattedString |
(package private) class |
TextHandler.LineBreakingVisitor |
(package private) static class |
TextHandler.LineWrappingCollector |
static interface |
TextHandler.LineWrappingConsumer
A consumer of the line-breaking information.
|
(package private) class |
TextHandler.WidthLimitingVisitor |
static interface |
TextHandler.WidthRetriever
A retriever of character width.
|
| Modifier and Type | Field and Description |
|---|---|
private TextHandler.WidthRetriever |
widthRetriever |
| Constructor and Description |
|---|
TextHandler(TextHandler.WidthRetriever widthRetriever) |
| Modifier and Type | Method and Description |
|---|---|
int |
getTrimmedLength(String text,
int maxWidth,
Style style)
Returns the length of a string when it is trimmed to be at most
maxWidth wide. |
float |
getWidth(String text)
Returns the width of a string.
|
float |
getWidth(Text text)
Returns the width of a text.
|
static int |
moveCursorByWords(String text,
int offset,
int cursor,
boolean consumeSpaceOrBreak) |
String |
trimToWidth(String text,
int maxWidth,
Style style)
Trim a string to be at most
maxWidth wide. |
Text |
trimToWidth(Text text,
int maxWidth)
Trim a text to be at most
maxWidth wide. |
MutableText |
trimToWidth(Text text,
int width,
Style style) |
String |
trimToWidthBackwards(String text,
int maxWidth,
Style style)
Trim a string from right to left to be at most
maxWidth wide. |
List<Text> |
wrapLines(String text,
int maxWidth,
Style style) |
void |
wrapLines(String text,
int maxWidth,
Style style,
boolean retainTrailingWordSplit,
TextHandler.LineWrappingConsumer consumer) |
List<Text> |
wrapLines(Text text,
int maxWidth,
Style style) |
private final TextHandler.WidthRetriever widthRetriever
public TextHandler(TextHandler.WidthRetriever widthRetriever)
public float getWidth(Text text)
public int getTrimmedLength(String text, int maxWidth, Style style)
maxWidth wide.text - the string to trimmaxWidth - the max width of the trimmed stringstyle - the style of the trimmed stringpublic String trimToWidth(String text, int maxWidth, Style style)
maxWidth wide.text - the string to trimmaxWidth - the max width of the trimmed stringstyle - the style of the trimmed stringpublic String trimToWidthBackwards(String text, int maxWidth, Style style)
maxWidth wide.text - the string to trimmaxWidth - the max width of the trimmed stringstyle - the style of the trimmed string@Nullable public Text trimToWidth(Text text, int maxWidth)
maxWidth wide.text - the textmaxWidth - the max width of the trimmed textpublic MutableText trimToWidth(Text text, int width, Style style)
public static int moveCursorByWords(String text, int offset, int cursor, boolean consumeSpaceOrBreak)
public void wrapLines(String text, int maxWidth, Style style, boolean retainTrailingWordSplit, TextHandler.LineWrappingConsumer consumer)