Package docking.widgets.fieldpanel.field
Class AttributedString
- java.lang.Object
-
- docking.widgets.fieldpanel.field.AttributedString
-
- Direct Known Subclasses:
CompositeAttributedString
public class AttributedString extends java.lang.Object
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
Constructors Constructor Description AttributedString(java.lang.String text, java.awt.Color textColor, java.awt.FontMetrics fontMetrics)
Creates an attributed string with the given text, color and metrics with no other attributes, like highlighting or underlining.AttributedString(java.lang.String text, java.awt.Color textColor, java.awt.FontMetrics fontMetrics, boolean underline, java.awt.Color underlineColor)
Creates an attributed string with the given text, color and metrics with other attributes, like highlighting and underlining.AttributedString(javax.swing.Icon icon, java.lang.String text, java.awt.Color textColor, java.awt.FontMetrics fontMetrics, boolean underline, java.awt.Color underlineColor)
Creates an attributed string with the given text, color, icon and metrics with other attributes, like highlighting and underlining.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributedString
deriveAttributedString(java.lang.String newText)
java.awt.Color
getColor(int charIndex)
int
getColumnPosition(int width)
java.awt.FontMetrics
getFontMetrics(int charIndex)
int
getHeightAbove()
int
getHeightBelow()
javax.swing.Icon
getIcon()
int
getStringWidth()
java.lang.String
getText()
int
length()
void
paint(javax.swing.JComponent c, java.awt.Graphics g, int x, int y)
AttributedString
replaceAll(char[] targets, char repacement)
AttributedString
substring(int start)
AttributedString
substring(int start, int end)
java.lang.String
toString()
-
-
-
Constructor Detail
-
AttributedString
public AttributedString(java.lang.String text, java.awt.Color textColor, java.awt.FontMetrics fontMetrics)
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(java.lang.String text, java.awt.Color textColor, java.awt.FontMetrics fontMetrics, boolean underline, java.awt.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(javax.swing.Icon icon, java.lang.String text, java.awt.Color textColor, java.awt.FontMetrics fontMetrics, boolean underline, java.awt.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 Detail
-
getText
public java.lang.String getText()
-
getIcon
public javax.swing.Icon getIcon()
-
length
public int length()
-
getStringWidth
public int getStringWidth()
-
getHeightAbove
public int getHeightAbove()
-
getHeightBelow
public int getHeightBelow()
-
getColumnPosition
public int getColumnPosition(int width)
-
getFontMetrics
public java.awt.FontMetrics getFontMetrics(int charIndex)
-
getColor
public java.awt.Color getColor(int charIndex)
-
substring
public AttributedString substring(int start)
-
substring
public AttributedString substring(int start, int end)
-
replaceAll
public AttributedString replaceAll(char[] targets, char repacement)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
paint
public void paint(javax.swing.JComponent c, java.awt.Graphics g, int x, int y)
-
deriveAttributedString
public AttributedString deriveAttributedString(java.lang.String newText)
-
-