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
    • _textStyle

      protected TextStyle _textStyle
    • _index

      protected int _index
    • _x

      protected double _x
    • _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.
    • getTextStyle

      public TextStyle getTextStyle()
      Returns the run text style.
    • setTextStyle

      protected void setTextStyle(TextStyle textStyle)
      Sets the run text 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.
    • getX

      public double getX()
      Returns the x location of run.
    • getWidth

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

      public double getTrailingWhitespaceWidth()
      Returns the width of the trailing whitespace.
    • getMaxX

      public double getMaxX()
      Returns the max x location of run.
    • getWidthForStartCharIndex

      public double getWidthForStartCharIndex(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.
    • getScripting

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

      public double getCharSpacing()
      Returns the char spacing.
    • 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.
    • getNext

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

      public TextRun getPrevious()
      Returns the previous 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
    • copyForRange

      public TextRun copyForRange(int aStart, int aEnd)
      Returns a copy of this line for given char range.
    • 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