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
,java.lang.CharSequence
,java.lang.Cloneable
public class Text extends TextRect implements TextTypes, java.lang.CharSequence, java.lang.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChars(java.lang.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
addLine(TextLine aLine, int anIndex)
Adds a line at given index.char
charAt(int anIndex)
Returns the char value at the specified index.Text
clone()
Standard clone implementation.protected double
computePrefHeight()
Returns the preferred height.protected double
computePrefWidth()
Compute the preferred width.protected TextLine
createLine()
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.SnapColor
getColor()
Returns the color for this line.java.lang.Object
getDefaultAttribute(java.lang.Object aKey)
Returns the default for a given key.SnapColor
getDefaultColor()
Returns the default color for this string.SnapFont
getDefaultFont()
Returns the default font for this string.SnapFont
getFont()
Returns the font for this line.double
getFontScale()
Returns the font scale of the text layout.TextLine
getLine(int anIndex)
Returns the individual text line in this text.TextLine
getLineAt(int anIndex)
Returns the TextLine at the given char index.int
getLineCount()
Returns the number of lines in this text.TextLine
getLineFor(int anIndex)
Returns the TextLine at the given char index or the last line if at end.TextLine
getLineForY(double aY)
Returns the line for the given y value.TextLine
getLineLast()
Returns the last line.TextLine
getLineLongest()
Returns the longest line.java.util.List<TextLine>
getLines()
Returns the list of lines.double
getPrefHeight()
Returns the preferred height.double
getPrefWidth()
Returns the preferred width.TextRun
getRunAt(int anIndex)
Returns the TextRun that contains the given index.TextRun
getRunFor(int anIndex)
Returns the TextRun that contains the given index or the last line last run if at end.WebFile
getSourceFile()
Returns the source file.WebURL
getSourceURL()
Returns the source URL.java.lang.String
getString()
Returns the string for the text.TextStyle
getStyleAt(int anIndex)
Returns the TextStyle for the run at the given character index.TextToken
getTokenAt(int anIndex)
Returns the token at given index.boolean
getUseFractionalMetrics()
Returns whether to use fractional character metrics.void
invalidate()
Invalidates text.boolean
isMonofont()
Whether this text only allows a single font, color, etc.boolean
isPropertyChangeEnabled()
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.TextLine
removeLine(int anIndex)
Removes the line at given index.int
removeLine(TextLine aLine)
Removes the given line.void
replaceChars(java.lang.CharSequence theChars, TextStyle theStyle, int aStart, int anEnd)
Replaces chars in given range, with given String, using the given attributes.protected void
sendPropertyChange(java.beans.PropertyChangeEvent anEvent)
Implement so package can use protected method.void
setAttribute(java.lang.String aKey, java.lang.Object aValue, int aStart, int anEnd)
Sets a given attribute to a given value for a given range.void
setColor(SnapColor aColor)
Sets the color for this line.void
setFont(SnapFont aFont)
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
setSource(java.lang.Object aSource)
Loads the text from the given source.void
setSourceURL(WebURL aURL)
Sets the source URL.void
setString(java.lang.String aString)
Sets the text to the given string.void
setUseFractionalMetrics(boolean aFlag)
Sets whether to use fractional character metrics.java.lang.CharSequence
subSequence(int aStart, int anEnd)
Returns a new char sequence that is a subsequence of this sequence.java.lang.String
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
-
-
-
-
Method Detail
-
setSource
public void setSource(java.lang.Object aSource)
Loads the text from the given source.
-
getSourceURL
public WebURL getSourceURL()
Returns the source URL.
-
setSourceURL
public void setSourceURL(WebURL aURL)
Sets the source URL.
-
getSourceFile
public WebFile getSourceFile()
Returns the source file.
-
length
public int length()
Returns the number of characters in the text.- Specified by:
length
in interfacejava.lang.CharSequence
-
charAt
public char charAt(int anIndex)
Returns the char value at the specified index.- Specified by:
charAt
in interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int aStart, int anEnd)
Returns a new char sequence that is a subsequence of this sequence.- Specified by:
subSequence
in interfacejava.lang.CharSequence
-
getString
public java.lang.String getString()
Returns the string for the text.
-
setString
public void setString(java.lang.String aString)
Sets the text to the given string.
-
getFont
public SnapFont getFont()
Returns the font for this line.
-
setFont
public void setFont(SnapFont aFont)
Sets the font for this line.
-
getDefaultFont
public SnapFont 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
public SnapColor getColor()
Returns the color for this line.
-
setColor
public void setColor(SnapColor aColor)
Sets the color for this line.
-
getDefaultColor
public SnapColor getDefaultColor()
Returns the default color for this string.
-
getDefaultAttribute
public java.lang.Object getDefaultAttribute(java.lang.Object aKey)
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
public void addChars(java.lang.CharSequence theChars, TextStyle theStyle, int anIndex)
Adds characters with attributes to this text at given index.
-
removeChars
public void removeChars(int aStart, int anEnd)
Removes characters in given range.
-
replaceChars
public void replaceChars(java.lang.CharSequence theChars, TextStyle theStyle, int aStart, int anEnd)
Replaces chars in given range, with given String, using the given attributes.
-
setAttribute
public void setAttribute(java.lang.String aKey, java.lang.Object aValue, int aStart, int anEnd)
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
public TextLine getLine(int anIndex)
Returns the individual text line in this text.
-
getLines
public java.util.List<TextLine> getLines()
Returns the list of lines.
-
createLine
protected TextLine createLine()
Creates a new line for use in this text.
-
addLine
protected TextLine addLine(int anIndex)
Adds a line at given index.
-
addLine
public void addLine(TextLine aLine, int anIndex)
Adds a line at given index.
-
removeLine
public TextLine removeLine(int anIndex)
Removes the line at given index.
-
removeLine
public int removeLine(TextLine aLine)
Removes the given line.
-
updateLines
protected void updateLines(int anIndex)
Updates lines from index.
-
getLineAt
public TextLine getLineAt(int anIndex)
Returns the TextLine at the given char index.
-
getLineFor
public TextLine getLineFor(int anIndex)
Returns the TextLine at the given char index or the last line if at end.
-
getLineLast
public TextLine getLineLast()
Returns the last line.
-
getLineLongest
public TextLine getLineLongest()
Returns the longest line.
-
getTokenAt
public TextToken getTokenAt(int anIndex)
Returns the token at given index.
-
getRunAt
public TextRun getRunAt(int anIndex)
Returns the TextRun that contains the given index.
-
getRunFor
public TextRun getRunFor(int anIndex)
Returns the TextRun that contains the given index or the last line last run if at end.
-
getStyleAt
public TextStyle getStyleAt(int anIndex)
Returns the TextStyle for the run at the given character index.
-
getLineForY
public TextLine getLineForY(double aY)
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
protected void sendPropertyChange(java.beans.PropertyChangeEvent anEvent)
Implement so package can use protected method.- Overrides:
sendPropertyChange
in classRMObject
-
clone
public Text clone()
Standard clone implementation.- Overrides:
clone
in classRMListenerList
-
-