Class AttributedString

java.lang.Object
docking.widgets.fieldpanel.field.AttributedString
Direct Known Subclasses:
CompositeAttributedString

public class AttributedString extends 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 Details

    • AttributedString

      public AttributedString(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.
      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 if text 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 text
      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 if text should be underlined.
      underlineColor - the color to use for underlining.
  • Method Details

    • getText

      public String getText()
    • getIcon

      public Icon getIcon()
    • length

      public int length()
    • getStringWidth

      public int getStringWidth()
    • getHeightAbove

      public int getHeightAbove()
    • getHeightBelow

      public int getHeightBelow()
    • getCharPosition

      public int getCharPosition(int x)
    • getFontMetrics

      public FontMetrics getFontMetrics(int charIndex)
    • getColor

      public 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 String toString()
      Overrides:
      toString in class Object
    • paint

      public void paint(JComponent c, Graphics g, int x, int y)
    • deriveAttributedString

      public AttributedString deriveAttributedString(String newText)