Package snap.text
Class TextToken
java.lang.Object
snap.text.TextToken
- All Implemented Interfaces:
Cloneable
This class represents a 'word' in a TextLine.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Standard clone implementation.Returns a copy from given char index on.copyFromCharIndex
(int charIndex) Returns a copy from given char index to end.copyToCharIndex
(int charIndex) Returns a copy of leading chars to given char index.static TextToken[]
createTokensForTextLine
(TextLine aTextLine) Returns the tokens.int
Returns the end char index in line including white space.int
Returns the end char index of token in line.int
getIndex()
Returns the index of token in line.int
Returns the length of token.getName()
Returns the token name.getNext()
Returns the next token, if available.Returns the previous token, if available.int
Returns the last split index.int
Returns the start char index of token in line.Returns the string.Returns the override TextStyle, if set.Returns the TextLine.Returns the TextRun.Returns the TextStyle for token.double
getWidth()
Returns the width.protected double
getWidthForLineRange
(int startCharIndex, int endCharIndex, boolean trimCharSpacing) Returns the width for given char range.double
getX()
Returns the horizontal location of token in line.double
getXForCharIndex
(int charIndex) Returns the X for given char index.boolean
Returns whether token can be split.void
Sets the token name.void
setTextColor
(Color aColor) Sets an override TextStyle, if set.static void
setTokensX
(TextLine aTextLine) Sets the X values for tokens in line.toString()
Standard toString implementation.Standard toStringProps implementation.
-
Field Details
-
_textLine
-
_index
protected int _index -
_x
protected double _x -
_split
protected boolean _split
-
-
Constructor Details
-
TextToken
Constructor.
-
-
Method Details
-
getName
Returns the token name. -
setName
Sets the token name. -
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
Returns the TextRun. -
getTextStyle
Returns the TextStyle for token. -
getTextColor
Returns the override TextStyle, if set. -
setTextColor
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
Returns the next token, if available. -
getPrevious
Returns the previous token, if available. -
getString
Returns the string. -
copyFromCharIndex
Returns a copy from given char index to end. -
copyToCharIndex
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
Returns a copy from given char index on. -
clone
Standard clone implementation. -
toString
Standard toString implementation. -
toStringProps
Standard toStringProps implementation. -
createTokensForTextLine
Returns the tokens. -
setTokensX
Sets the X values for tokens in line.
-