Package snap.text

Class StyledString

java.lang.Object
snap.text.StyledString
All Implemented Interfaces:
Cloneable

public class StyledString extends Object implements Cloneable
This class holds a String and TextStyle and provides painting and sizing information.
  • Field Details

    • _fontSizing

      protected boolean _fontSizing
  • Constructor Details

    • StyledString

      public StyledString()
      Constructor.
    • StyledString

      public StyledString(String aString)
      Constructor.
  • Method Details

    • getString

      public String getString()
      Returns the string.
    • setString

      public void setString(String aValue)
      Sets the string.
    • getStyle

      public TextStyle getStyle()
      Returns the TextStyle.
    • setStyle

      public void setStyle(TextStyle aStyle)
      Sets the TextStyle.
    • getFont

      public Font getFont()
      Returns the font.
    • setFont

      public void setFont(Font aFont)
      Sets the font.
    • getTextFill

      public Paint getTextFill()
      Returns the text fill.
    • setTextFill

      public void setTextFill(Paint aPaint)
      Sets the text fill.
    • isUnderlined

      public boolean isUnderlined()
      Returns whether this run is underlined.
    • setUnderlined

      public void setUnderlined(boolean aValue)
      Sets whether this run is underlined.
    • getScripting

      public int getScripting()
      Returns the run's scripting.
    • isFontSizing

      public boolean isFontSizing()
      Returns whether to size to font (looser) instead of glyphs (tighter).
    • setFontSizing

      public void setFontSizing(boolean aValue)
      Sets whether to size to font (looser) instead of glyphs (tighter).
    • length

      public int length()
      Returns the text length.
    • getTextWidth

      public double getTextWidth()
      Returns the width of the string (aka the 'advance').
    • getTextHeight

      public double getTextHeight()
      Returns the height of the current string/font (aka the 'line height').
    • getAscent

      public double getAscent()
      Returns the ascent.
    • getDescent

      public double getDescent()
      Returns the descent.
    • getCharIndexForX

      public int getCharIndexForX(double aX)
      Returns the char index for the X location.
    • paintString

      public void paintString(Painter aPntr, double aX, double aY)
      Paints StringView.
    • paintStringTopLeft

      public void paintStringTopLeft(Painter aPntr, double aX, double aY)
      Paints StringView with upper left XY.
    • clone

      public StyledString clone()
      Returns a copy of this TextRun.
      Overrides:
      clone in class Object