Package com.nomagic.text.rich
Class RichTextStringUtils
java.lang.Object
com.nomagic.text.rich.RichTextStringUtils
Utility class to work with rich text.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
closeColor
(String text) Close color tag.static void
closeColor
(StringBuffer text) Close color tag.static void
closeColor
(StringBuilder text) Close color tag.static void
startColor
(StringBuffer text, Color color) Set given color to the given text.static void
startColor
(StringBuilder text, Color color) Set given color to the given text.static String
startColor
(String text, Color color) Set given color to the given text.static String
static String
Trim text up to the given index.static String
Trim text from-to the given index.static void
wrapInColor
(StringBuffer text, Color color) Set given color to the given text.static void
wrapInColor
(StringBuilder text, Color color) Set given color to the given text.static String
wrapInColor
(String text, Color color) Set given color to the given text.
-
Field Details
-
GRAY_COLOR
Gray color -
COLOR_PREFIX
Color tag prefix- See Also:
-
COLOR_POSTFIX
Color tag postfix- See Also:
-
-
Constructor Details
-
RichTextStringUtils
public RichTextStringUtils()
-
-
Method Details
-
closeColor
Close color tag.- Parameters:
text
- text
-
closeColor
Close color tag.- Parameters:
text
- text
-
closeColor
Close color tag.- Parameters:
text
- text
-
startColor
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
startColor
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
startColor
Set given color to the given text.- Parameters:
text
- textcolor
- color- Returns:
- text with given color
-
wrapInColor
Set given color to the given text.- Parameters:
text
- textcolor
- color- Returns:
- text with given color
-
wrapInColor
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
wrapInColor
Set given color to the given text.- Parameters:
text
- textcolor
- color
-
trimText
Trim text up to the given index. Make sure that "color" tag is not cut.- Parameters:
text
- textendIndex
- cut end index- Returns:
- cut text
-
trimText
Trim text from-to the given index. Make sure that "color" tag is not cut.- Parameters:
text
- textstartIndex
- cut start indexendIndex
- cut end index- Returns:
- cut text
-
toString
- Parameters:
color
- color- Returns:
- color representation
-