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 Link icon

    • AttributedString Link icon

      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 Link icon

      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 Link icon

      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 Link icon

    • getText Link icon

      public String getText()
    • getIcon Link icon

      public Icon getIcon()
    • length Link icon

      public int length()
    • getStringWidth Link icon

      public int getStringWidth()
    • getHeightAbove Link icon

      public int getHeightAbove()
    • getHeightBelow Link icon

      public int getHeightBelow()
    • getCharPosition Link icon

      public int getCharPosition(int x)
    • getFontMetrics Link icon

      public FontMetrics getFontMetrics(int charIndex)
    • getColor Link icon

      public Color getColor(int charIndex)
    • substring Link icon

      public AttributedString substring(int start)
    • substring Link icon

      public AttributedString substring(int start, int end)
    • replaceAll Link icon

      public AttributedString replaceAll(char[] targets, char repacement)
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • paint Link icon

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

      public AttributedString deriveAttributedString(String newText)