Package snap.text
Class TextRun
java.lang.Object
snap.text.TextRun
- All Implemented Interfaces:
CharSequence
,Cloneable
,CharSequenceX
This is class represents a range of characters in a TextLine that share the same style.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addLength
(int aLength) Adds length to grow this run (negative value reduces it).char
charAt
(int anIndex) CharSequence method returning character at given index.clone()
Returns a basic clone of this object.copyForRange
(int aStart, int aEnd) Returns a copy of this line for given char range.boolean
Returns whether this run is equal to the given object.double
Returns the max distance above the baseline for this run font.Returns the border for this run.double
Returns the char spacing.getColor()
Returns the color for this run.double
Returns the max distance below the baseline that this font goes.int
Returns the end char index for this run.getFont()
Returns the font for this run.Returns the format for this run.int
getIndex()
Returns the run index.double
Returns the default distance between lines for this font.getLine()
Returns the TextLine that contains this TextRun.double
getMaxX()
Returns the max x location of run.getNext()
Returns the next run, if available.Returns the previous run, if available.int
Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none).int
Returns the start char index for this run.Returns the string for this run.Returns the run text style.double
Returns the width of the trailing whitespace.double
getWidth()
Returns the width of run.double
getWidthForStartCharIndex
(int anIndex) Returns the width of run from given index.double
getX()
Returns the x location of run.int
hashCode()
Standard hashCode implementation.boolean
Returns whether this run is underlined.int
length()
Returns the length in characters for this run.protected void
setTextStyle
(TextStyle textStyle) Sets the run text style.subSequence
(int aStart, int anEnd) CharSequence method return character sequence for range.toString()
Returns a string representation of this run.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
Methods inherited from interface snap.util.CharSequenceX
getIndentLength, getIndentString, getLastChar, indexAfterNewline, indexAfterNewlineOrEnd, indexOfNewline, isAfterLineEnd, isLastCharNewline, isLineEnd, isLineEndChar, isWhiteSpace, lastIndexAfterNewline, lastIndexOfNewline, startsWith
-
Field Details
-
_textLine
-
_startCharIndex
protected int _startCharIndex -
_length
protected int _length -
_textStyle
-
_index
protected int _index -
_x
protected double _x -
_width
protected double _width
-
-
Constructor Details
-
TextRun
Constructor.
-
-
Method Details
-
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
Returns the run text style. -
setTextStyle
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 interfaceCharSequence
-
charAt
public char charAt(int anIndex) CharSequence method returning character at given index.- Specified by:
charAt
in interfaceCharSequence
-
subSequence
CharSequence method return character sequence for range.- Specified by:
subSequence
in interfaceCharSequence
-
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
Returns the font for this run. -
getColor
Returns the color for this run. -
getFormat
Returns the format for this run. -
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
Returns the next run, if available. -
getPrevious
Returns the previous run, if available. -
equals
Returns whether this run is equal to the given object. -
hashCode
public int hashCode()Standard hashCode implementation. -
copyForRange
Returns a copy of this line for given char range. -
clone
Returns a basic clone of this object. -
toString
Returns a string representation of this run.- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-