Class TextRun
java.lang.Object
com.inductiveautomation.snap.text.TextRun
- All Implemented Interfaces:
RMTypes
,TextTypes
,CharSequence
,Cloneable
The Run class represents a range of characters in an TextLine that share common attributes.
This class makes a point to treat its attributes map as read-only so they can be shared among multiple runs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
A property change event for addChars/removeChars.Nested classes/interfaces inherited from interface com.inductiveautomation.rm.base.RMTypes
RMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
Nested classes/interfaces inherited from interface com.inductiveautomation.snap.text.TextTypes
TextTypes.TabType
-
Field Summary
Fields inherited from interface com.inductiveautomation.snap.text.TextTypes
TEXT_CHAR_SPACING, TEXT_COLOR, TEXT_FONT, TEXT_FORMAT, TEXT_LINK, TEXT_OUTLINE, TEXT_SCRIPTING, TEXT_UNDERLINE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChars
(CharSequence theChars, int anIndex) Adds characters with style to this line at given index.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.protected void
firePropertyChangeEvent
(String aPropName, Object oldVal, Object newVal, int anIndex) Fires a property change event.double
getCharAdvance
(char aChar) Returns the char advance for a given character.float
Returns the char spacing.getColor()
Returns the color for this run.int
getEnd()
Returns the end character index for this run.getFont()
Returns the font for this run.int
getIndex()
Returns the run index.double
Returns the default distance between lines for this font.getLine()
Returns the line that this run works for.double
Returns the max distance above the baseline for this run font.double
Returns the max distance below the baseline that this font goes.getNext()
Returns the next run.int
Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none).int
getStart()
Returns the start character index for this run.Returns the string for this run.getStyle()
Returns the run style.int
Returns the underline style of this run.static int
getUnderlineStyle
(Map attrs) Returns the underline style of this run.int
hashCode()
Standard hashCode implementation.boolean
Returns whether this run is underlined.int
length()
Returns the length in characters for this run.void
removeChars
(int aStart, int anEnd) Removes characters in given range.protected void
sendPropertyChange
(PropertyChangeEvent anEvent) Sends a property change event.void
Sets the run style.split
(int anIndex) Splits the run at the given index and returns a run containing the remaining characters (and identical attributes).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
-
Constructor Details
-
TextRun
public TextRun()
-
-
Method Details
-
getLine
Returns the line that this run works for. -
getIndex
public int getIndex()Returns the run index. -
getStart
public int getStart()Returns the start character index for this run. -
getEnd
public int getEnd()Returns the end character index for this run. -
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. -
addChars
Adds characters with style to this line at given index. -
removeChars
public void removeChars(int aStart, int anEnd) Removes characters in given range. -
getStyle
Returns the run style. -
setStyle
Sets the run style. -
getFont
Returns the font for this run. -
getColor
Returns the color for this run. -
isUnderlined
public boolean isUnderlined()Returns whether this run is underlined. -
getUnderlineStyle
public int getUnderlineStyle()Returns the underline style of this run. -
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. -
getMaxAscent
public double getMaxAscent()Returns the max distance above the baseline for this run font. -
getMaxDescent
public double getMaxDescent()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. -
split
Splits the run at the given index and returns a run containing the remaining characters (and identical attributes). -
firePropertyChangeEvent
Fires a property change event. -
sendPropertyChange
Sends a property change event. -
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
-