Package snap.text
Class TextToken
java.lang.Object
snap.text.TextToken
- All Implemented Interfaces:
Cloneable
,ParseToken
This class represents a 'word' in a TextLine.
-
Nested Class Summary
Nested classes/interfaces inherited from interface snap.parse.ParseToken
ParseToken.Builder
-
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.int
Returns the end char index of token in text.int
Returns the end char index of token in line.getFont()
Returns the token font.double
Returns the height.int
getIndex()
Returns the index of token in line.int
Returns the length of token.int
Returns the line index.double
getMaxX()
Returns the token max x.getName()
Returns the token name.getNext()
Returns the next token, if available.Returns the regex pattern that defines this token.Returns the previous token, if available.int
Returns the last split index.int
Returns the start char index of token in text.int
Returns the start char index of token in line.Returns the string.Returns the token color.Returns the TextLine.double
Returns the max X in text block.double
Returns the max Y in text block.double
Returns the y position for this token in text block.Returns the TextStyle for token.double
getTextX()
Returns the token X coord in text block.double
getTextY()
Returns token Y coord in text block.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 this run has a hyphen at the end.boolean
Returns whether token can be split.void
setHyphenated
(boolean aFlag) Sets whether this run has a hyphen at the end.void
Sets the token name.void
setPattern
(String aPattern) Sets the regex pattern that defines this token.void
setTextColor
(Color aColor) Sets token color.toString()
Standard toString implementation.Standard toStringProps implementation.
-
Field Details
-
_name
-
_pattern
-
_textLine
-
_index
protected int _index -
_x
protected double _x -
_split
protected boolean _split -
_justifyShiftX
protected double _justifyShiftX
-
-
Constructor Details
-
Method Details
-
getName
Returns the token name.- Specified by:
getName
in interfaceParseToken
-
setName
Sets the token name. -
getPattern
Returns the regex pattern that defines this token.- Specified by:
getPattern
in interfaceParseToken
-
setPattern
Sets the regex pattern that defines this token. -
getTextLine
Returns the TextLine. -
getLineIndex
public int getLineIndex()Returns the line index.- Specified by:
getLineIndex
in interfaceParseToken
-
getStartCharIndexInLine
public int getStartCharIndexInLine()Returns the start char index of token in line.- Specified by:
getStartCharIndexInLine
in interfaceParseToken
-
getEndCharIndexInLine
public int getEndCharIndexInLine()Returns the end char index of token in line.- Specified by:
getEndCharIndexInLine
in interfaceParseToken
-
getStartCharIndex
public int getStartCharIndex()Returns the start char index of token in text.- Specified by:
getStartCharIndex
in interfaceParseToken
-
getEndCharIndex
public int getEndCharIndex()Returns the end char index of token in text.- Specified by:
getEndCharIndex
in interfaceParseToken
-
getLength
public int getLength()Returns the length of token. -
getIndex
public int getIndex()Returns the index of token in line. -
getTextStyle
Returns the TextStyle for token. -
getFont
Returns the token font. -
getTextColor
Returns the token color. -
setTextColor
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
Returns the next token, if available. -
getPrevious
Returns the previous token, if available. -
getString
Returns the string.- Specified by:
getString
in interfaceParseToken
-
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.
-