Package snap.text

Class TextToken

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

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

    • _name

      protected String _name
    • _pattern

      protected String _pattern
    • _textLine

      protected TextLine _textLine
    • _index

      protected int _index
    • _x

      protected double _x
    • _split

      protected boolean _split
    • _justifyShiftX

      protected double _justifyShiftX
  • Constructor Details

    • TextToken

      public TextToken(TextLine aTextLine, int startCharIndexInLine, int endCharIndexInLine, TextStyle aTextStyle)
      Constructor.
  • Method Details

    • getName

      public String getName()
      Returns the token name.
      Specified by:
      getName in interface ParseToken
    • setName

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

      public String getPattern()
      Returns the regex pattern that defines this token.
      Specified by:
      getPattern in interface ParseToken
    • setPattern

      public void setPattern(String aPattern)
      Sets the regex pattern that defines this token.
    • getTextLine

      public TextLine getTextLine()
      Returns the TextLine.
    • getLineIndex

      public int getLineIndex()
      Returns the line index.
      Specified by:
      getLineIndex in interface ParseToken
    • getStartCharIndexInLine

      public int getStartCharIndexInLine()
      Returns the start char index of token in line.
      Specified by:
      getStartCharIndexInLine in interface ParseToken
    • getEndCharIndexInLine

      public int getEndCharIndexInLine()
      Returns the end char index of token in line.
      Specified by:
      getEndCharIndexInLine in interface ParseToken
    • getStartCharIndex

      public int getStartCharIndex()
      Returns the start char index of token in text.
      Specified by:
      getStartCharIndex in interface ParseToken
    • getEndCharIndex

      public int getEndCharIndex()
      Returns the end char index of token in text.
      Specified by:
      getEndCharIndex in interface ParseToken
    • getLength

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

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

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

      public Font getFont()
      Returns the token font.
    • getTextColor

      public Color getTextColor()
      Returns the token color.
    • setTextColor

      public void setTextColor(Color aColor)
      Sets token color.
    • isHyphenated

      public boolean isHyphenated()
      Returns whether this run has a hyphen at the end.
    • setHyphenated

      public void setHyphenated(boolean aFlag)
      Sets whether this run has a hyphen at the end.
    • getX

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

      public double getWidth()
      Returns the width.
    • getMaxX

      public double getMaxX()
      Returns the token max x.
    • getHeight

      public double getHeight()
      Returns the height.
    • getTextX

      public double getTextX()
      Returns the token X coord in text block.
    • getTextY

      public double getTextY()
      Returns token Y coord in text block.
    • getTextStringY

      public double getTextStringY()
      Returns the y position for this token in text block.
    • getTextMaxX

      public double getTextMaxX()
      Returns the max X in text block.
    • getTextMaxY

      public double getTextMaxY()
      Returns the max Y in text block.
    • 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.
      Specified by:
      getString in interface ParseToken
    • 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.