Package docking.widgets.fieldpanel.field
Class AttributedString
java.lang.Object
docking.widgets.fieldpanel.field.AttributedString
- Direct Known Subclasses:
CompositeAttributedString
An object that wraps a string and provides data that describes how to render
that string.
This class was created as a place to house attributes of rendering that are not described by Java's Font object, like underlining.
-
Constructor Summary
ConstructorDescriptionAttributedString
(String text, Color textColor, FontMetrics fontMetrics) Creates an attributed string with the given text, color and metrics with no other attributes, like highlighting or underlining.AttributedString
(String text, Color textColor, FontMetrics fontMetrics, boolean underline, Color underlineColor) Creates an attributed string with the given text, color and metrics with other attributes, like highlighting and underlining.AttributedString
(Icon icon, String text, Color textColor, FontMetrics fontMetrics, boolean underline, Color underlineColor) Creates an attributed string with the given text, color, icon and metrics with other attributes, like highlighting and underlining. -
Method Summary
Modifier and TypeMethodDescriptionderiveAttributedString
(String newText) int
getCharPosition
(int x) getColor
(int charIndex) getFontMetrics
(int charIndex) int
int
getIcon()
int
getText()
int
length()
void
paint
(JComponent c, Graphics g, int x, int y) replaceAll
(char[] targets, char repacement) substring
(int start) substring
(int start, int end) toString()
-
Constructor Details
-
AttributedString
Creates an attributed string with the given text, color and metrics with no other attributes, like highlighting or underlining.- Parameters:
text
- The text that this class describes.textColor
- The color to paint the text.fontMetrics
- The font metrics used to draw the text.
-
AttributedString
public AttributedString(String text, Color textColor, FontMetrics fontMetrics, boolean underline, Color underlineColor) Creates an attributed string with the given text, color and metrics with other attributes, like highlighting and underlining.- Parameters:
text
- The text that this class describes.textColor
- The color to paint the text.fontMetrics
- The font metrics used to draw the text.underline
- True iftext
should be underlined.underlineColor
- the color to use for underlining.
-
AttributedString
public AttributedString(Icon icon, String text, Color textColor, FontMetrics fontMetrics, boolean underline, Color underlineColor) Creates an attributed string with the given text, color, icon and metrics with other attributes, like highlighting and underlining.- Parameters:
icon
- icon image to be displayed to the left of the texttext
- The text that this class describes.textColor
- The color to paint the text.fontMetrics
- The font metrics used to draw the text.underline
- True iftext
should be underlined.underlineColor
- the color to use for underlining.
-
-
Method Details
-
getText
-
getIcon
-
length
public int length() -
getStringWidth
public int getStringWidth() -
getHeightAbove
public int getHeightAbove() -
getHeightBelow
public int getHeightBelow() -
getCharPosition
public int getCharPosition(int x) -
getFontMetrics
-
getColor
-
substring
-
substring
-
replaceAll
-
toString
-
paint
-
deriveAttributedString
-