Package com.inductiveautomation.rm.text
Class RMXString
java.lang.Object
com.inductiveautomation.rm.base.RMListenerList
com.inductiveautomation.rm.base.RMObject
com.inductiveautomation.rm.text.RMXString
- All Implemented Interfaces:
- Archivable,- RMPropertyChanger,- RMTypes,- RMTextTypes,- CharSequence,- Cloneable
An RMXString is like a String that lets you apply attributes, like fonts and colors, to character ranges. These
 character ranges with common attributes are represented internally as the inner class Run.
 
You might use it like this:
RMXString xstring = new RMXString("Hello World", RMColor.red); xstring.addAttribute(RMFont.getFont("Arail Bold", 12), 0, 5); xstring.addAttribute(RMFont.getFont("Arial BoldItalic", 12), 6, xstring.length());
Advanced applications, that need to dissect or render strings, might iterate over the runs like this:
 
    for(int i=0; i<xstring.getRunCount(); i++) {
      RMXString.Run run = xstring.getRun(i);
      graphics.setFont(run.getFont().awt());
      graphics.setColor(run.getColor().awt());
      graphics.drawString(xstring.substring(run.start(), run.end()));
      }
 
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionclassA property change event for addChars/removeChars.static classThe Outline inner class represents the attributes of outlined text: strokeWidth and fillColor.classA property change event for RMXStringRun.Style change.Nested classes/interfaces inherited from interface com.inductiveautomation.rm.text.RMTextTypesRMTextTypes.TabTypeNested classes/interfaces inherited from interface com.inductiveautomation.rm.base.RMTypesRMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
- 
Field SummaryFields inherited from interface com.inductiveautomation.rm.text.RMTextTypesTEXT_CHAR_SPACING, TEXT_COLOR, TEXT_EMBEDDED_SHAPE, TEXT_FONT, TEXT_FORMAT, TEXT_OUTLINE, TEXT_PARAGRAPH, TEXT_SCRIPTING, TEXT_UNDERLINE
- 
Constructor SummaryConstructorsConstructorDescriptionCreates an empty RMXString.RMXString(CharSequence theChars) Creates an RMXString initialized with the given String and no attributes.RMXString(CharSequence theChars, RMTextStyle aStyle) Creates an RMXString initialized with the given String with all characters set to the given style.RMXString(CharSequence theChars, Object... theAttrs) Creates an RMXString initialized with the given String with all characters set to the given attributes.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddChars(CharSequence theChars) Appends the given String to the end of this XString.voidaddChars(CharSequence theChars, int anIndex) Adds chars at index.voidaddChars(CharSequence theChars, RMTextStyle aStyle, int anIndex) Appends the given string to this XString, with the given attributes, at the given index.voidaddChars(CharSequence theChars, Object... theAttrs) Appends the given chars with the given attribute(s).voidaddChars(CharSequence theChars, Map theAttrs) Appends the given string to the end of this XString, with the given attributes.voidaddChars(CharSequence theChars, Map theAttrs, int anIndex) Appends the given string to this XString, with the given attributes, at the given index.voidAdds an XString to this string at given index.charcharAt(int anIndex) Returns the char at given index.clone()Returns a clone of this x string.booleanStandard Object equals implementation.protected voidfirePropertyChange(PropertyChangeEvent anEvent, String aName, Object oldVal, Object newVal, int anIndex) Override so RMXStringRun can reach this and to reset representable string and version.fromXML(RXArchiver anArchiver, RXElement anElement) XML unarchival.Returns the horizontal alignment of the first paragraph of the xstring.getDefaultAttribute(String aKey) Returns the default for a given key.Returns the default color for this string.Returns the default font for this string.Returns the default format for this string.Returns the default paragraph for this string.getFontAt(int anIndex) Returns the current font at the given character index.getParagraphAt(int anIndex) Returns the current paragraph at the given character index.Returns a version of this string that substitutes alternate fonts for any characters that cannot be displayed in their associated fonts (simply returns the receiver if all characters are valid).getRun()Returns the XString head run.getRun(int anIndex) Returns the specific Run at the given index in this XString.final RMXStringRungetRunAt(int anIndex) Returns the XString run that contains or ends at given index.getRunAt(int anIndex, boolean isInclusive) Returns the XString run that contains or ends (if given option is true) at given index.intReturns the number of runs in this XString.Returns the last run in this XString (convenience).getStyleAt(int anIndex) Returns the text style for the run at the given character index.getStyleAt(int anIndex, boolean isInclusive) Returns the text style for the run at the given character index.getText()Returns the simple String represented by this RMXString.booleanOverride to return false if FirePropertyChangeEnabled is off.intReturns the index within this string of the first occurrence of the given substring.intReturns the index within this string of first occurrence of given substring, starting at given index.intlength()The length.voidremoveChars(int aStart, int anEnd) Removes characters in given range.voidreplaceChars(CharSequence theChars, int aStart, int anEnd) Replaces chars in given range, with given String.voidreplaceChars(CharSequence theChars, RMTextStyle aStyle, int aStart, int anEnd) Replaces chars in given range, with given String, using the given attributes.voidreplaceString(RMXString xString, int aStart, int anEnd) Replaces the chars in given range, with given XString.rpgClone(ReportOwner anRptOwner, Object userInfo, RMShape aShape, boolean doCopy) Creates a clone of the receiver, with substitution performed on @-sign delineated keys.voidsetAlignX(RMTypes.AlignX anAlignX) Sets the horizontal alignment of the xstring.voidsetAttribute(Object anAttr) Applies the given attribute to whole xstring, assuming it's a basic attr types (font, color, etc.).voidsetAttribute(Object anAttr, int aStart, int anEnd) Applies the given attribute to the given character range, assuming it's a basic attr type (font, color, etc.).voidsetAttribute(String aKey, Object anAttr) Adds a given attribute of given type to the whole string.voidsetAttribute(String aKey, Object aValue, int aStart, int anEnd) Sets a given attribute to a given value for a given range.voidsetDateFormat(RMDateFormat dateFormat) voidsetDateFormat(String dateFormatString) voidsetFirePropertyChangeEnabled(boolean aValue) Sets whether string fires property change events.voidvoidsetNumberFormat(RMNumberFormat numberFormat) voidsetNumberFormat(String numberFormatString) voidsetParagraph(RMParagraph ps, int start, int end) Sets the paragraph for the given character index range.voidsetStyle(RMTextStyle aStyle, int aStart, int anEnd) Sets the text style for given range.voidSets the simple String represented by this RMXString.voidsetUnderlined(boolean aFlag) Sets the xstring to be underlined.subSequence(int aStart, int anEnd) Returns a subsequence.substring(int aStart) Returns an XString for given char range.substring(int aStart, int anEnd) Returns an XString for given char range.toString()Standard toString implementation.toXML(RXArchiver anArchiver) XML archival.Methods inherited from class com.inductiveautomation.rm.base.RMObjectaddPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChangeMethods inherited from class com.inductiveautomation.rm.base.RMListenerListaddListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, removeListenerMethods inherited from class java.lang.Objectfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequencechars, codePoints, isEmpty
- 
Constructor Details- 
RMXStringpublic RMXString()Creates an empty RMXString.
- 
RMXStringCreates an RMXString initialized with the given String and no attributes.
- 
RMXStringCreates an RMXString initialized with the given String with all characters set to the given style.
- 
RMXStringCreates an RMXString initialized with the given String with all characters set to the given attributes.
 
- 
- 
Method Details- 
getTextReturns the simple String represented by this RMXString.
- 
lengthpublic int length()The length.- Specified by:
- lengthin interface- CharSequence
 
- 
charAtpublic char charAt(int anIndex) Returns the char at given index.- Specified by:
- charAtin interface- CharSequence
 
- 
subSequenceReturns a subsequence.- Specified by:
- subSequencein interface- CharSequence
 
- 
setTextSets the simple String represented by this RMXString.
- 
indexOfReturns the index within this string of the first occurrence of the given substring.
- 
indexOfReturns the index within this string of first occurrence of given substring, starting at given index.
- 
addCharsAppends the given String to the end of this XString.
- 
addCharsAppends the given chars with the given attribute(s).
- 
addCharsAppends the given string to the end of this XString, with the given attributes.
- 
addCharsAdds chars at index.
- 
addCharsAppends the given string to this XString, with the given attributes, at the given index.
- 
addCharsAppends the given string to this XString, with the given attributes, at the given index.
- 
removeCharspublic void removeChars(int aStart, int anEnd) Removes characters in given range.
- 
replaceCharsReplaces chars in given range, with given String.
- 
replaceCharsReplaces chars in given range, with given String, using the given attributes.
- 
addStringAdds an XString to this string at given index.
- 
replaceStringReplaces the chars in given range, with given XString.
- 
getRunReturns the XString head run.
- 
getRunCountpublic int getRunCount()Returns the number of runs in this XString.
- 
getRunReturns the specific Run at the given index in this XString.
- 
getRunLastReturns the last run in this XString (convenience).
- 
getRunAtReturns the XString run that contains or ends at given index.
- 
getRunAtReturns the XString run that contains or ends (if given option is true) at given index.
- 
getNumberFormat
- 
setNumberFormat
- 
setNumberFormat
- 
getDateFormat
- 
setDateFormat
- 
setDateFormat
- 
setFormat
- 
getStyleAtReturns the text style for the run at the given character index.
- 
getStyleAtReturns the text style for the run at the given character index.
- 
setStyleSets the text style for given range.
- 
setAttributeApplies the given attribute to whole xstring, assuming it's a basic attr types (font, color, etc.).
- 
setAttributeApplies the given attribute to the given character range, assuming it's a basic attr type (font, color, etc.).
- 
setAttributeAdds a given attribute of given type to the whole string.
- 
setAttributeSets a given attribute to a given value for a given range.
- 
getFontAtReturns the current font at the given character index.
- 
getParagraphAtReturns the current paragraph at the given character index.
- 
setParagraphSets the paragraph for the given character index range.
- 
setUnderlinedpublic void setUnderlined(boolean aFlag) Sets the xstring to be underlined.
- 
getAlignXReturns the horizontal alignment of the first paragraph of the xstring.
- 
setAlignXSets the horizontal alignment of the xstring.
- 
getDefaultFontReturns the default font for this string.
- 
getDefaultColorReturns the default color for this string.
- 
getDefaultParagraphReturns the default paragraph for this string.
- 
getDefaultFormatReturns the default format for this string.
- 
getDefaultAttributeReturns the default for a given key.
- 
getRepresentableStringReturns a version of this string that substitutes alternate fonts for any characters that cannot be displayed in their associated fonts (simply returns the receiver if all characters are valid).
- 
substringReturns an XString for given char range.
- 
substringReturns an XString for given char range.
- 
rpgCloneCreates a clone of the receiver, with substitution performed on @-sign delineated keys.
- 
firePropertyChangeprotected void firePropertyChange(PropertyChangeEvent anEvent, String aName, Object oldVal, Object newVal, int anIndex) Override so RMXStringRun can reach this and to reset representable string and version.- Overrides:
- firePropertyChangein class- RMObject
 
- 
setFirePropertyChangeEnabledpublic void setFirePropertyChangeEnabled(boolean aValue) Sets whether string fires property change events.
- 
hasListenerspublic boolean hasListeners()Override to return false if FirePropertyChangeEnabled is off.- Overrides:
- hasListenersin class- RMListenerList
 
- 
toXMLXML archival.- Specified by:
- toXMLin interface- Archivable
 
- 
fromXMLXML unarchival.- Specified by:
- fromXMLin interface- Archivable
 
- 
equalsStandard Object equals implementation.
- 
cloneReturns a clone of this x string.- Overrides:
- clonein class- RMListenerList
 
- 
toStringStandard toString implementation.- Specified by:
- toStringin interface- CharSequence
- Overrides:
- toStringin class- RMObject
 
 
-