public class RMXString extends RMXStringCore implements RMTextTypes
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 disect or render strings, might iterate over the runs like this:
for(int i=0; i
Modifier and Type | Class and Description |
---|---|
static class |
RMXString.Outline
The Outline inner class represents the attributes of outlined text: strokeWidth and fillColor.
|
RMXStringCore.AttrsChange, RMXStringCore.CharsChange, RMXStringCore.StringChange
RMTextTypes.Attribute, RMTextTypes.TabType
RMTypes.AlignX, RMTypes.AlignY
Modifier and Type | Field and Description |
---|---|
static RMTextTypes.Attribute |
COLOR_KEY |
static RMTextTypes.Attribute |
FONT_KEY |
Constructor and Description |
---|
RMXString()
Creates an empty RMXString.
|
RMXString(java.lang.CharSequence theChars)
Creates an RMXString initialized with the given String and no attributes.
|
RMXString(java.lang.CharSequence theChars,
java.util.Map theAttrs)
Creates an RMXString initialized with the given String with all characters set to the given attributes.
|
RMXString(java.lang.CharSequence theChars,
java.lang.Object... theAttrs)
Creates an RMXString initialized with the given String with all characters set to the given attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributes(java.util.Map<RMTextTypes.Attribute,java.lang.Object> theAttrs)
Adds the attributes in the given map to this whole string.
|
void |
addAttributes(java.util.Map<RMTextTypes.Attribute,java.lang.Object> theAttrs,
int aStart,
int anEnd)
Adds the attributes in the given map to the specified character range.
|
void |
addChars(java.lang.CharSequence theChars)
Appends the given String to the end of this XString.
|
void |
addChars(java.lang.CharSequence theChars,
java.util.Map theAttrs)
Appends the given string to the end of this XString, with the given attributes.
|
void |
addChars(java.lang.CharSequence theChars,
java.lang.Object... theAttrs)
Appends the given chars with the given attribute(s).
|
void |
addString(RMXString xString)
Appends the given XString to the end of this string.
|
RMXString |
fromXML(com.reportmill.archiver.RXArchiver anArchiver,
com.reportmill.archiver.RXElement anElement,
java.lang.Object anOwner)
XML unarchival.
|
RMTypes.AlignX |
getAlignmentX()
Returns the horizontal alignment of the first paragraph of the xstring.
|
java.util.Map |
getAttributes(int anIndex)
Returns the attributes Map for the run at the given index.
|
java.util.Map |
getAttributesAt(int anIndex)
Returns the attributes Map for the run at the given character index.
|
java.util.Map |
getAttributesAt(int anIndex,
boolean isInclusive)
Returns the attributes Map for the run at the given character index.
|
RMColor |
getColorAtIndex(int anIndex)
Returns the current color at the given character index.
|
java.lang.Object |
getDefaultAttribute(RMTextTypes.Attribute anAttribute)
Returns the default for a given key.
|
RMColor |
getDefaultColor()
Returns the default color for this string.
|
RMFont |
getDefaultFont()
Returns the default font for this string.
|
RMFormat |
getDefaultFormat()
Returns the default format for this string.
|
RMParagraph |
getDefaultParagraph()
Returns the default paragraph for this string.
|
RMFont |
getFontAtIndex(int anIndex)
Returns the current font at the given character index.
|
RMFormat |
getFormatAtIndex(int anIndex)
Returns the current format at the given character index.
|
RMParagraph |
getParagraphAtIndex(int anIndex)
Returns the current paragraph at the given character index.
|
RMXString |
getRepresentableString()
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).
|
java.lang.String |
getText()
Returns the simple String represented by this RMXString.
|
int |
indexOf(java.lang.String aString)
Returns the index within this string of the first occurrence of the given substring.
|
int |
indexOf(java.lang.String aString,
int aStart)
Returns the index within this string of first occurrence of given substring, starting at given index.
|
void |
replaceChars(java.lang.CharSequence theChars,
int aStart,
int anEnd)
Replaces chars in given range, with given String.
|
void |
replaceChars(java.lang.CharSequence theChars,
java.util.Map theAttrs,
int aStart,
int anEnd)
Replaces chars in given range, with given String, using the given attributes.
|
void |
replaceString(RMXString xString,
int aStart,
int anEnd)
Replaces the chars in given range, with given XString.
|
RMXString |
rpgClone(ReportMill aReportMill,
java.lang.Object userInfo,
RMShape aShape,
boolean doCopy)
Creates a clone of the receiver, with substitution performed on @-sign delineated keys.
|
void |
setAlign(RMTypes.AlignX anAlignmentX)
Deprecated.
|
void |
setAlignmentX(RMTypes.AlignX anAlignmentX)
Sets the horizontal alignment of the xstring.
|
void |
setAttribute(java.lang.Object anAttr)
Applies the given attribute to whole xstring, assuming it's a basic attr types (font, color, etc.).
|
void |
setAttribute(java.lang.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.).
|
void |
setAttribute(RMTextTypes.Attribute aKey,
java.lang.Object anAttr)
Adds a given attribute of given type to the whole string.
|
void |
setParagraph(RMParagraph ps,
int start,
int end)
Sets the paragraph for the given character index range.
|
void |
setText(java.lang.String aString)
Sets the simple String represented by this RMXString.
|
void |
setUnderlined(boolean aFlag)
Sets the xstring to be underlined.
|
com.reportmill.archiver.RXElement |
toXML(com.reportmill.archiver.RXArchiver anArchiver,
java.lang.Object anOwner)
XML archival.
|
addChars, addChars, addString, clone, equals, getRun, getRun, getRunAt, getRunAt, getRunCount, getRunLast, hasListeners, isFirePropertyChangeEnabled, removeChars, removeString, setAttribute, setFirePropertyChangeEnabled, substring, substring
charAt, length, setCharAt, subSequence, toString, toStringBuffer
addPropertyChangeListener, animUpdate, removePropertyChangeListener
addListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, removeListener
public static RMTextTypes.Attribute FONT_KEY
public static RMTextTypes.Attribute COLOR_KEY
public RMXString()
public RMXString(java.lang.CharSequence theChars)
public RMXString(java.lang.CharSequence theChars, java.util.Map theAttrs)
public RMXString(java.lang.CharSequence theChars, java.lang.Object... theAttrs)
public java.lang.String getText()
public void setText(java.lang.String aString)
public int indexOf(java.lang.String aString)
public int indexOf(java.lang.String aString, int aStart)
indexOf
in class RMBigStringBuilder
public void addChars(java.lang.CharSequence theChars)
public void addChars(java.lang.CharSequence theChars, java.lang.Object... theAttrs)
public void addChars(java.lang.CharSequence theChars, java.util.Map theAttrs)
public void addString(RMXString xString)
public void replaceChars(java.lang.CharSequence theChars, int aStart, int anEnd)
public void replaceChars(java.lang.CharSequence theChars, java.util.Map theAttrs, int aStart, int anEnd)
public void replaceString(RMXString xString, int aStart, int anEnd)
public java.util.Map getAttributes(int anIndex)
public java.util.Map getAttributesAt(int anIndex)
public java.util.Map getAttributesAt(int anIndex, boolean isInclusive)
public void setAttribute(java.lang.Object anAttr)
public void setAttribute(java.lang.Object anAttr, int aStart, int anEnd)
public void setAttribute(RMTextTypes.Attribute aKey, java.lang.Object anAttr)
public void addAttributes(java.util.Map<RMTextTypes.Attribute,java.lang.Object> theAttrs)
public void addAttributes(java.util.Map<RMTextTypes.Attribute,java.lang.Object> theAttrs, int aStart, int anEnd)
public RMFont getFontAtIndex(int anIndex)
public RMColor getColorAtIndex(int anIndex)
public RMFormat getFormatAtIndex(int anIndex)
public RMParagraph getParagraphAtIndex(int anIndex)
public void setParagraph(RMParagraph ps, int start, int end)
public void setUnderlined(boolean aFlag)
public RMTypes.AlignX getAlignmentX()
public void setAlignmentX(RMTypes.AlignX anAlignmentX)
@Deprecated public void setAlign(RMTypes.AlignX anAlignmentX)
public RMFont getDefaultFont()
public RMColor getDefaultColor()
public RMParagraph getDefaultParagraph()
public RMFormat getDefaultFormat()
public java.lang.Object getDefaultAttribute(RMTextTypes.Attribute anAttribute)
public RMXString getRepresentableString()
public RMXString rpgClone(ReportMill aReportMill, java.lang.Object userInfo, RMShape aShape, boolean doCopy)
public com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver, java.lang.Object anOwner)
public RMXString fromXML(com.reportmill.archiver.RXArchiver anArchiver, com.reportmill.archiver.RXElement anElement, java.lang.Object anOwner)