Class Text
java.lang.Object
com.inductiveautomation.rm.base.RMListenerList
com.inductiveautomation.rm.base.RMObject
com.inductiveautomation.snap.text.TextRect
com.inductiveautomation.snap.text.Text
- All Implemented Interfaces:
RMPropertyChanger
,RMTypes
,TextTypes
,CharSequence
,Cloneable
This class represents text.
-
Nested Class Summary
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
ConstructorsConstructorDescriptionText()
Creates a new text.Text
(CharSequence theChars) Creates a Text initialized with the given String and no attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChars
(CharSequence theChars, TextStyle theStyle, int anIndex) Adds characters with attributes to this text at given index.protected TextLine
addLine
(int anIndex) Adds a line at given index.void
Adds a line at given index.char
charAt
(int anIndex) Returns the char value at the specified index.clone()
Standard clone implementation.protected double
Returns the preferred height.protected double
Compute the preferred width.protected TextLine
Creates a new line for use in this text.int
getCharIndex
(double anX, double aY) Returns the character index for the given x/y point.getColor()
Returns the color for this line.getDefaultAttribute
(Object aKey) Returns the default for a given key.Returns the default color for this string.Returns the default font for this string.getFont()
Returns the font for this line.double
Returns the font scale of the text layout.getLine
(int anIndex) Returns the individual text line in this text.getLineAt
(int anIndex) Returns the TextLine at the given char index.int
Returns the number of lines in this text.getLineFor
(int anIndex) Returns the TextLine at the given char index or the last line if at end.getLineForY
(double aY) Returns the line for the given y value.Returns the last line.Returns the longest line.getLines()
Returns the list of lines.double
Returns the preferred height.double
Returns the preferred width.getRunAt
(int anIndex) Returns the TextRun that contains the given index.getRunFor
(int anIndex) Returns the TextRun that contains the given index or the last line last run if at end.Returns the source file.Returns the source URL.Returns the string for the text.getStyleAt
(int anIndex) Returns the TextStyle for the run at the given character index.getTokenAt
(int anIndex) Returns the token at given index.boolean
Returns whether to use fractional character metrics.void
Invalidates text.boolean
Whether this text only allows a single font, color, etc.boolean
Returns whether property change is enabled.int
length()
Returns the number of characters in the text.void
removeChars
(int aStart, int anEnd) Removes characters in given range.removeLine
(int anIndex) Removes the line at given index.int
removeLine
(TextLine aLine) Removes the given line.void
replaceChars
(CharSequence theChars, TextStyle theStyle, int aStart, int anEnd) Replaces chars in given range, with given String, using the given attributes.protected void
sendPropertyChange
(PropertyChangeEvent anEvent) Implement so package can use protected method.void
setAttribute
(String aKey, Object aValue, int aStart, int anEnd) Sets a given attribute to a given value for a given range.void
Sets the color for this line.void
Sets the font for this line.void
setFontScale
(double aValue) Sets the font scale of the text layout.void
setMonofont
(boolean aValue) Sets whether this text only allows a single font, color, etc.void
setPropertyChangeEnabled
(boolean aValue) Sets whether property change is enabled.void
Loads the text from the given source.void
setSourceURL
(WebURL aURL) Sets the source URL.void
Sets the text to the given string.void
setUseFractionalMetrics
(boolean aFlag) Sets whether to use fractional character metrics.subSequence
(int aStart, int anEnd) Returns a new char sequence that is a subsequence of this sequence.toString()
Standard toString implementation.protected void
updateLines
(int anIndex) Updates lines from index.Methods inherited from class com.inductiveautomation.snap.text.TextRect
getHeight, getMaxX, getMaxY, getWidth, getX, getY, setHeight, setRect, setSize, setWidth, setX, setY
Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
Text
public Text()Creates a new text. -
Text
Creates a Text initialized with the given String and no attributes.
-
-
Method Details
-
setSource
Loads the text from the given source. -
getSourceURL
Returns the source URL. -
setSourceURL
Sets the source URL. -
getSourceFile
Returns the source file. -
length
public int length()Returns the number of characters in the text.- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int anIndex) Returns the char value at the specified index.- Specified by:
charAt
in interfaceCharSequence
-
subSequence
Returns a new char sequence that is a subsequence of this sequence.- Specified by:
subSequence
in interfaceCharSequence
-
getString
Returns the string for the text. -
setString
Sets the text to the given string. -
getFont
Returns the font for this line. -
setFont
Sets the font for this line. -
getDefaultFont
Returns the default font for this string. -
getFontScale
public double getFontScale()Returns the font scale of the text layout. -
setFontScale
public void setFontScale(double aValue) Sets the font scale of the text layout. -
getUseFractionalMetrics
public boolean getUseFractionalMetrics()Returns whether to use fractional character metrics. -
setUseFractionalMetrics
public void setUseFractionalMetrics(boolean aFlag) Sets whether to use fractional character metrics. -
getColor
Returns the color for this line. -
setColor
Sets the color for this line. -
getDefaultColor
Returns the default color for this string. -
getDefaultAttribute
Returns the default for a given key. -
isMonofont
public boolean isMonofont()Whether this text only allows a single font, color, etc. (defaults to false). -
setMonofont
public void setMonofont(boolean aValue) Sets whether this text only allows a single font, color, etc. -
addChars
Adds characters with attributes to this text at given index. -
removeChars
public void removeChars(int aStart, int anEnd) Removes characters in given range. -
replaceChars
Replaces chars in given range, with given String, using the given attributes. -
setAttribute
Sets a given attribute to a given value for a given range. -
getLineCount
public int getLineCount()Returns the number of lines in this text. -
getLine
Returns the individual text line in this text. -
getLines
Returns the list of lines. -
createLine
Creates a new line for use in this text. -
addLine
Adds a line at given index. -
addLine
Adds a line at given index. -
removeLine
Removes the line at given index. -
removeLine
Removes the given line. -
updateLines
protected void updateLines(int anIndex) Updates lines from index. -
getLineAt
Returns the TextLine at the given char index. -
getLineFor
Returns the TextLine at the given char index or the last line if at end. -
getLineLast
Returns the last line. -
getLineLongest
Returns the longest line. -
getTokenAt
Returns the token at given index. -
getRunAt
Returns the TextRun that contains the given index. -
getRunFor
Returns the TextRun that contains the given index or the last line last run if at end. -
getStyleAt
Returns the TextStyle for the run at the given character index. -
getLineForY
Returns the line for the given y value. -
getCharIndex
public int getCharIndex(double anX, double aY) Returns the character index for the given x/y point. -
invalidate
public void invalidate()Invalidates text. -
getPrefWidth
public double getPrefWidth()Returns the preferred width. -
getPrefHeight
public double getPrefHeight()Returns the preferred height. -
computePrefWidth
protected double computePrefWidth()Compute the preferred width. -
computePrefHeight
protected double computePrefHeight()Returns the preferred height. -
isPropertyChangeEnabled
public boolean isPropertyChangeEnabled()Returns whether property change is enabled. -
setPropertyChangeEnabled
public void setPropertyChangeEnabled(boolean aValue) Sets whether property change is enabled. -
sendPropertyChange
Implement so package can use protected method.- Overrides:
sendPropertyChange
in classRMObject
-
clone
Standard clone implementation.- Overrides:
clone
in classRMListenerList
-
toString
Standard toString implementation.- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classRMObject
-