public class RMXString
extends java.lang.Object
implements java.lang.Cloneable
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.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHAR_SPACING_KEY |
static java.lang.String |
COLOR_KEY |
static java.lang.String |
EMBEDDED_SHAPE_KEY |
static java.lang.String |
FONT_KEY |
static java.lang.String |
FORMAT_KEY |
static java.lang.String |
OUTLINE_KEY |
static java.lang.String |
PARAGRAPH_KEY |
static java.lang.String |
SCRIPTING_KEY |
static java.lang.String |
UNDERLINE_KEY |
static java.lang.String |
VALUE_KEY |
Constructor and Description |
---|
RMXString()
Creates an empty RMXString.
|
RMXString(java.lang.String aString)
Creates an RMXString initialized with the given String and no attributes.
|
RMXString(java.lang.String aString,
java.util.Map attrs)
Creates an RMXString initialized with the given String with all characters set to the given attributes.
|
RMXString(java.lang.String aString,
java.lang.Object... attributes)
Creates an RMXString initialized with the given String with all characters set to the given
attribute (should be a common attribute type like RMFont, RMColor, RMFormat, etc.).
|
Modifier and Type | Method and Description |
---|---|
RMXString |
add(RMXString xString)
Appends the given XString to the end of this String.
|
RMXString |
add(RMXString xString,
int anIndex)
Appends the given XString to this XString, at the given index.
|
RMXString |
add(java.lang.String aString)
Appends the given String to the end of this XString.
|
RMXString |
add(java.lang.String aString,
int anIndex)
Appends the given String to this XString, at the given index.
|
RMXString |
add(java.lang.String aString,
java.util.Map attrs)
Appends the given string to the end of this XString, with the given attributes.
|
RMXString |
add(java.lang.String aString,
java.util.Map attrs,
int anIndex)
Appends the given String to this XString, with the given attributes, at the given index.
|
void |
addAttribute(java.lang.Object attr)
Applies the given attribute to whole xstring, assuming it's a basic attr types (font, color, etc.).
|
void |
addAttribute(java.lang.Object attr,
int start,
int end)
Applies the given attribute to the given character range, assuming it's a basic attr type (font, color, etc.).
|
void |
addAttribute(java.lang.String aKey,
java.lang.Object object)
Adds a given attribute of given type to the whole string.
|
void |
addAttribute(java.lang.String aKey,
java.lang.Object attr,
int start,
int end)
Adds a given attribute of given type to the given range of the string.
|
void |
addAttribute(java.lang.String aKey,
java.lang.Object anAttr,
int start,
int end,
boolean ifAbsent)
Adds a given attribute of given type to the given range of the string, only if specified type is missing.
|
void |
addAttributes(java.util.Map attrs,
int start,
int end)
Adds the attributes in the given map to the specified character range.
|
void |
addAttributes(java.util.Map attrs,
int start,
int end,
boolean ifAbsent)
Adds the attributes in the given map to the specified character range.
|
void |
addListener(java.util.EventListener aListener)
Add listener.
|
void |
alignCenter()
Aligns the xstring center.
|
void |
alignLeft()
Aligns the xstring left.
|
void |
alignRight()
Aligns the xstring right.
|
RMXString |
blend(RMXString aString,
float fraction)
Returns a blended version of the receiver and the given string (0 is receiver, 1 is given string).
|
char |
charAt(int anIndex)
Returns the character at the given index.
|
RMXString |
clone()
Returns a clone of this x string.
|
void |
coalesceNewlines()
Replaces any occurrence of consecutive newlines with a single newline.
|
void |
delete(int start,
int end)
Deletes the chars in the given range.
|
void |
didChange()
Notifies string that something significant changed.
|
boolean |
equals(java.lang.Object anObj)
Standard Object equals implementation.
|
void |
firePropertyChange(java.lang.String aProperty,
java.lang.Object oldValue,
java.lang.Object newValue,
int anIndex)
Fires an indexed property change.
|
java.lang.Object |
fromXML(com.reportmill.archiver.RXArchiver anArchiver,
com.reportmill.archiver.RXElement anElement,
java.lang.Object anOwner)
XML unarchival.
|
byte |
getAlign()
Returns the horizontal alignment of the first paragraph of the xstring.
|
java.lang.Object |
getAttributeAt(java.lang.String aKey,
int anIndex)
Returns the value for the given attribute key at the given character index.
|
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.
|
RMColor |
getColorAtIndex(int anIndex)
Returns the current color at the given character index.
|
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.
|
<T extends java.util.EventListener> |
getListener(java.lang.Class<T> aClass,
int anIndex)
Returns the individual listener of a given class at given index (from all listeners of given class).
|
int |
getListenerCount(java.lang.Class aClass)
Returns the number of listeners of a given class.
|
RMParagraph |
getParagraphAtIndex(int index)
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).
|
com.reportmill.text.RMXStringRun |
getRun(int anIndex)
Returns the specific Run at the given index in this XString.
|
com.reportmill.text.RMXStringRun |
getRunAt(int anIndex)
Returns the XString run at the given index.
|
com.reportmill.text.RMXStringRun |
getRunAtExactly(int anIndex)
Returns an XString run for the given character index, potentially splitting an existing run to ensure
that new run starts at the given index.
|
int |
getRunCount()
Returns the number of runs in this XString.
|
int |
getRunIndexAt(int anIndex)
Returns the XString run index for the given character index.
|
int |
getRunIndexAtExactly(int anIndex)
Returns an XString segment index for the given character index, potentially splitting an existing run to ensure
that new run starts at the given index.
|
com.reportmill.text.RMXStringRun |
getRunLast()
Returns the last run in this XString (convenience).
|
java.lang.String |
getString()
Returns the simple String represented by this RMXString.
|
int |
getVersion()
Returns the version of this xstring.
|
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 start)
Returns the index within this string of first occurrence of given substring, starting at given index.
|
int |
length()
Returns the number of characters associated with this RMXString.
|
void |
removeAttribute(java.lang.String aKey,
int start,
int end)
Removes any attribute of the specified type from the specified range of the string.
|
void |
removeListener(java.util.EventListener aListener)
Remove listener.
|
RMXString |
replace(int start,
int end,
RMXString xString)
Replaces the chars in given range, with given XString.
|
RMXString |
replace(int start,
int end,
java.lang.String aString)
Replaces chars in given range, with given String.
|
RMXString |
replace(int start,
int end,
java.lang.String aString,
java.util.Map attrs)
Replaces chars in given range, with given String, using the given attributes.
|
RMXString |
rpgClone(com.reportmill.base.ReportMill aReportMill,
java.lang.Object userInfo,
RMShape aShape)
Creates a clone of the receiver, with substitution performed on @-sign delineated keys.
|
void |
scaleFonts(float aScale)
Sets a value to that should be multiplied times all font sizes in this string.
|
java.util.Vector |
separate(java.lang.String aSeparator)
Returns a List of XString substrings of this XString that are separated by the given separator String.
|
void |
setAlign(int align)
Sets the horizontal alignment of the xstring.
|
void |
setOutlined(boolean flag)
Sets the xstring to be outlined.
|
void |
setParagraph(RMParagraph ps,
int start)
Sets the paragraph at the given character index.
|
void |
setParagraph(RMParagraph ps,
int start,
int end)
Sets the paragraph for the given character index range.
|
RMXString |
setString(java.lang.String aString)
Sets the simple String represented by this RMXString.
|
void |
setUnderlined(boolean flag)
Sets the xstring to be underlined.
|
RMXString |
substring(int index)
Returns the substring from the given index to end of XString.
|
RMXString |
substring(int start,
int end)
Returns the substring from the given start index to the given end index.
|
java.lang.String |
toString()
Returns the String associated with this XString.
|
java.lang.String |
toStringXML()
Returns an XML style string representation of the attributes and string runs in this XString.
|
com.reportmill.archiver.RXElement |
toXML(com.reportmill.archiver.RXArchiver anArchiver,
java.lang.Object anOwner)
XML archival.
|
public static final java.lang.String FONT_KEY
public static final java.lang.String COLOR_KEY
public static final java.lang.String FORMAT_KEY
public static final java.lang.String UNDERLINE_KEY
public static final java.lang.String OUTLINE_KEY
public static final java.lang.String PARAGRAPH_KEY
public static final java.lang.String SCRIPTING_KEY
public static final java.lang.String CHAR_SPACING_KEY
public static final java.lang.String EMBEDDED_SHAPE_KEY
public static final java.lang.String VALUE_KEY
public RMXString()
public RMXString(java.lang.String aString)
public RMXString(java.lang.String aString, java.util.Map attrs)
public RMXString(java.lang.String aString, java.lang.Object... attributes)
public java.lang.String getString()
public RMXString setString(java.lang.String aString)
public int length()
public int indexOf(java.lang.String aString)
public int indexOf(java.lang.String aString, int start)
public char charAt(int anIndex)
public int getRunCount()
public com.reportmill.text.RMXStringRun getRun(int anIndex)
public com.reportmill.text.RMXStringRun getRunLast()
public com.reportmill.text.RMXStringRun getRunAt(int anIndex)
public int getRunIndexAt(int anIndex)
public com.reportmill.text.RMXStringRun getRunAtExactly(int anIndex)
public int getRunIndexAtExactly(int anIndex)
public java.util.Map getAttributes(int anIndex)
public java.lang.Object getAttributeAt(java.lang.String aKey, int anIndex)
public java.util.Map getAttributesAt(int anIndex)
public void addAttributes(java.util.Map attrs, int start, int end)
public void addAttributes(java.util.Map attrs, int start, int end, boolean ifAbsent)
public void addAttribute(java.lang.String aKey, java.lang.Object object)
public void addAttribute(java.lang.String aKey, java.lang.Object attr, int start, int end)
public void addAttribute(java.lang.String aKey, java.lang.Object anAttr, int start, int end, boolean ifAbsent)
public void removeAttribute(java.lang.String aKey, int start, int end)
public RMFont getFontAtIndex(int anIndex)
public RMColor getColorAtIndex(int anIndex)
public RMFormat getFormatAtIndex(int anIndex)
public RMParagraph getParagraphAtIndex(int index)
public void setParagraph(RMParagraph ps, int start)
public void setParagraph(RMParagraph ps, int start, int end)
public void addAttribute(java.lang.Object attr)
public void addAttribute(java.lang.Object attr, int start, int end)
public void scaleFonts(float aScale)
public RMXString add(java.lang.String aString)
public RMXString add(java.lang.String aString, int anIndex)
public RMXString add(RMXString xString, int anIndex)
public RMXString add(java.lang.String aString, java.util.Map attrs)
public RMXString add(java.lang.String aString, java.util.Map attrs, int anIndex)
public RMXString replace(int start, int end, java.lang.String aString)
public RMXString replace(int start, int end, java.lang.String aString, java.util.Map attrs)
public RMXString replace(int start, int end, RMXString xString)
public void delete(int start, int end)
public RMXString substring(int index)
public RMXString substring(int start, int end)
public java.util.Vector separate(java.lang.String aSeparator)
public void coalesceNewlines()
public void didChange()
public int getListenerCount(java.lang.Class aClass)
public <T extends java.util.EventListener> T getListener(java.lang.Class<T> aClass, int anIndex)
public void addListener(java.util.EventListener aListener)
public void removeListener(java.util.EventListener aListener)
public void firePropertyChange(java.lang.String aProperty, java.lang.Object oldValue, java.lang.Object newValue, int anIndex)
public void setUnderlined(boolean flag)
public void setOutlined(boolean flag)
public byte getAlign()
public void setAlign(int align)
public void alignLeft()
public void alignRight()
public void alignCenter()
public int getVersion()
public RMFont getDefaultFont()
public RMColor getDefaultColor()
public RMParagraph getDefaultParagraph()
public RMFormat getDefaultFormat()
public RMXString getRepresentableString()
public boolean equals(java.lang.Object anObj)
equals
in class java.lang.Object
public RMXString clone()
clone
in class java.lang.Object
public RMXString rpgClone(com.reportmill.base.ReportMill aReportMill, java.lang.Object userInfo, RMShape aShape)
public RMXString blend(RMXString aString, float fraction)
public com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver, java.lang.Object anOwner)
public java.lang.Object fromXML(com.reportmill.archiver.RXArchiver anArchiver, com.reportmill.archiver.RXElement anElement, java.lang.Object anOwner)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringXML()