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.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
getCharAdvance
(char aChar) Returns the char advance for a given character.float
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
Returns the line advance.getNext()
Returns the next 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.getStyle()
Returns the run style.int
Returns the underline style of this run.double
getWidth()
Returns the width of run.double
getWidth
(int anIndex) Returns the width of run from given index.int
hashCode()
Standard hashCode implementation.boolean
Returns whether this run is underlined.int
length()
Returns the length in characters for this run.protected void
Sets the run 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, indexOfNewline, isAfterLineEnd, isLastCharNewline, isLineEnd, isLineEndChar, isWhiteSpace, lastIndexAfterNewline, lastIndexOfNewline, startsWith
-
Field Details
-
_textLine
-
_startCharIndex
protected int _startCharIndex -
_length
protected int _length -
_style
-
_index
protected int _index -
_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. -
getStyle
Returns the run style. -
setStyle
Sets the run 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. -
getWidth
public double getWidth()Returns the width of run. -
getWidth
public double getWidth(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. -
getUnderlineStyle
public int getUnderlineStyle()Returns the underline style of this run. -
getScripting
public int getScripting()Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none). -
getCharSpacing
public float getCharSpacing()Returns the char spacing. -
getCharAdvance
public double getCharAdvance(char aChar) Returns the char advance for a given character. -
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. -
getLineAdvance
public double getLineAdvance()Returns the line advance. -
getNext
Returns the next run, if available. -
equals
Returns whether this run is equal to the given object. -
hashCode
public int hashCode()Standard hashCode implementation. -
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
-