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.ObjectAn 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 AttributedStringderiveAttributedString(java.lang.String newText)java.awt.ColorgetColor(int charIndex)intgetColumnPosition(int width)java.awt.FontMetricsgetFontMetrics(int charIndex)intgetHeightAbove()intgetHeightBelow()javax.swing.IcongetIcon()intgetStringWidth()java.lang.StringgetText()intlength()voidpaint(javax.swing.JComponent c, java.awt.Graphics g, int x, int y)AttributedStringreplaceAll(char[] targets, char repacement)AttributedStringsubstring(int start)AttributedStringsubstring(int start, int end)java.lang.StringtoString()
-
-
-
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 iftextshould 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 iftextshould 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:
toStringin 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)
-
-