Package snap.text

Class TextToken

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

public class TextToken extends Object implements Cloneable
This class represents a 'word' in a TextLine.
  • Field Details

    • _textLine

      protected TextLine _textLine
    • _index

      protected int _index
    • _x

      protected double _x
    • _split

      protected boolean _split
  • Constructor Details

    • TextToken

      public TextToken(TextLine aTextLine, int startCharIndex, int endCharIndex, TextRun aTextRun)
      Constructor.
  • Method Details

    • getName

      public String getName()
      Returns the token name.
    • setName

      public void setName(String aName)
      Sets the token name.
    • getTextLine

      public TextLine getTextLine()
      Returns the TextLine.
    • getStartCharIndex

      public int getStartCharIndex()
      Returns the start char index of token in line.
    • getEndCharIndex

      public int getEndCharIndex()
      Returns the end char index of token in line.
    • getLength

      public int getLength()
      Returns the length of token.
    • getEndAllCharIndex

      public int getEndAllCharIndex()
      Returns the end char index in line including white space.
    • getIndex

      public int getIndex()
      Returns the index of token in line.
    • getTextRun

      public TextRun getTextRun()
      Returns the TextRun.
    • getTextStyle

      public TextStyle getTextStyle()
      Returns the TextStyle for token.
    • getTextColor

      public Color getTextColor()
      Returns the override TextStyle, if set.
    • setTextColor

      public void setTextColor(Color aColor)
      Sets an override TextStyle, if set.
    • getX

      public double getX()
      Returns the horizontal location of token in line.
    • getWidth

      public double getWidth()
      Returns the width.
    • getWidthForLineRange

      protected double getWidthForLineRange(int startCharIndex, int endCharIndex, boolean trimCharSpacing)
      Returns the width for given char range.
    • getXForCharIndex

      public double getXForCharIndex(int charIndex)
      Returns the X for given char index.
    • getNext

      public TextToken getNext()
      Returns the next token, if available.
    • getPrevious

      public TextToken getPrevious()
      Returns the previous token, if available.
    • getString

      public String getString()
      Returns the string.
    • copyFromCharIndex

      public TextToken copyFromCharIndex(int charIndex)
      Returns a copy from given char index to end.
    • copyToCharIndex

      public TextToken copyToCharIndex(int charIndex)
      Returns a copy of leading chars to given char index.
    • isSplittable

      public boolean isSplittable()
      Returns whether token can be split.
    • getSplittableCharIndex

      public int getSplittableCharIndex()
      Returns the last split index.
    • copyForSplittable

      public TextToken copyForSplittable()
      Returns a copy from given char index on.
    • clone

      public TextToken clone()
      Standard clone implementation.
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object
    • toStringProps

      public String toStringProps()
      Standard toStringProps implementation.
    • createTokensForTextLine

      public static TextToken[] createTokensForTextLine(TextLine aTextLine)
      Returns the tokens.
    • setTokensX

      public static void setTokensX(TextLine aTextLine)
      Sets the X values for tokens in line.