Package snap.text

Class TextRun

java.lang.Object
snap.text.TextRun
All Implemented Interfaces:
CharSequence, Cloneable, CharSequenceX

public class TextRun extends Object implements CharSequenceX, Cloneable
This is class represents a range of characters in a TextLine that share the same style.
  • Field Details

    • _textLine

      protected TextLine _textLine
    • _startCharIndex

      protected int _startCharIndex
    • _length

      protected int _length
    • _style

      protected TextStyle _style
    • _index

      protected int _index
    • _width

      protected double _width
  • Constructor Details

    • TextRun

      public TextRun(TextLine aTextLine)
      Constructor.
  • Method Details

    • getLine

      public TextLine getLine()
      Returns the TextLine that contains this TextRun.
    • getStartCharIndex

      public int getStartCharIndex()
      Returns the start char index for this run.
    • getEndCharIndex

      public int getEndCharIndex()
      Returns the end char index for this run.
    • getStyle

      public TextStyle getStyle()
      Returns the run style.
    • setStyle

      protected void setStyle(TextStyle aStyle)
      Sets the run style.
    • getIndex

      public int getIndex()
      Returns the run index.
    • length

      public int length()
      Returns the length in characters for this run.
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int anIndex)
      CharSequence method returning character at given index.
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int aStart, int anEnd)
      CharSequence method return character sequence for range.
      Specified by:
      subSequence in interface CharSequence
    • getString

      public String getString()
      Returns the string for this run.
    • getWidth

      public double getWidth()
      Returns the width of run.
    • getWidth

      public double getWidth(int anIndex)
      Returns the width of run from given index.
    • addLength

      protected void addLength(int aLength)
      Adds length to grow this run (negative value reduces it).
    • getFont

      public Font getFont()
      Returns the font for this run.
    • getColor

      public Color getColor()
      Returns the color for this run.
    • getFormat

      public TextFormat getFormat()
      Returns the format for this run.
    • getBorder

      public Border getBorder()
      Returns the border for this run.
    • isUnderlined

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

      public int getUnderlineStyle()
      Returns the underline style of this run.
    • getScripting

      public int getScripting()
      Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none).
    • getCharSpacing

      public float getCharSpacing()
      Returns the char spacing.
    • getCharAdvance

      public double getCharAdvance(char aChar)
      Returns the char advance for a given character.
    • getAscent

      public double getAscent()
      Returns the max distance above the baseline for this run font.
    • getDescent

      public double getDescent()
      Returns the max distance below the baseline that this font goes.
    • getLeading

      public double getLeading()
      Returns the default distance between lines for this font.
    • getLineAdvance

      public double getLineAdvance()
      Returns the line advance.
    • getNext

      public TextRun getNext()
      Returns the next run, if available.
    • equals

      public boolean equals(Object anObj)
      Returns whether this run is equal to the given object.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Standard hashCode implementation.
      Overrides:
      hashCode in class Object
    • clone

      public TextRun clone()
      Returns a basic clone of this object.
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Returns a string representation of this run.
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object