|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.display.AttributedText
public class AttributedText
AttributedText contains text that should be rendered with
different attributes. The data encapsulated by this object can be viewed
as pairs of values:
The method getCount() returns the number of the attribute/text pairs
this AttributedText object contains. getAttribute(int)
and getText(int) provide access to the attribute and the text, respectively.
The following sample code shows how to render "Attributed text" on the display.
Note: This class is not thread safe.
AttributedText attrText = new AttributedText(); Font boldFont = Font.getFont(face, Font.STYLE_BOLD, Font.SIZE_MEDIUM); attrText.addText(boldFont, "Attributed "); Font italicFont = Font.getFont(face, Font.STYLE_ITALIC, Font.SIZE_MEDIUM); attrText.addText(italicFont, "text"); ScrollLabel label; label.draw(attrText, true);
parseEnriched(String, Font),
ScrollLabel.draw(AttributedText, boolean)| Nested Class Summary | |
|---|---|
static class |
AttributedText.Attribute
Attribute encapsulates the font attribute associated with the
the text in an attribute/text pair. |
| Constructor Summary | |
|---|---|
AttributedText()
Constructs an instance of AttributedText. |
|
| Method Summary | |
|---|---|
void |
addText(AttributedText text)
Appends the contents of another AttributedText object. |
void |
addText(Font font,
String text)
Adds the text that should be rendered using the font specified. |
void |
clear()
Clears all the attributed text data in this AttributedText object. |
AttributedText.Attribute |
getAttribute(int index)
Gets the attribute for the index specified. |
int |
getCount()
Returns the number of attribute\text pairs that this AttributedText object
contains. |
String |
getText(int index)
Gets the text for the index specified. |
String |
getUnattributedText()
Returns a string representation of this object. |
void |
insertText(int index,
AttributedText text)
Inserts the contents of another AttributedText object at the
specified index. |
void |
insertText(int index,
Font font,
String text)
Inserts text at the specified index. |
static Object |
parseEnriched(String s,
Font font)
Parses enriched text and returns the string or a new AttributedText, as appropriate. |
String |
toString()
Returns a string representation of this object. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AttributedText()
AttributedText.
| Method Detail |
|---|
public void addText(Font font,
String text)
null.
font - a Font to be used for rendering the text.text - the String text to which the attribute will be added.getUnattributedText(),
addText(AttributedText)public void addText(AttributedText text)
AttributedText object. This
does nothing if the text is null.
text - append the contents of this AttributedText objectgetUnattributedText(),
addText(Font, String)
public void insertText(int index,
AttributedText text)
AttributedText object at the
specified index. All text at an index greater than or equal to the
specified index is shifted to the next spot.
The index must be in the range 0–count, inclusive.
index - insert the text heretext - the attributed text to insert
IndexOutOfBoundsException - if the index is not valid.getCount(),
insertText(int, Font, String)
public void insertText(int index,
Font font,
String text)
The index must be in the range 0–count, inclusive.
index - insert the text herefont - the fonttext - the text to insert
IndexOutOfBoundsException - if the index is not valid.getCount(),
insertText(int, AttributedText)public void clear()
AttributedText object.
public int getCount()
AttributedText object
contains.
public AttributedText.Attribute getAttribute(int index)
index - index of the attribute.
AttributedText.Attribute object at the index specified;
or null if the index is invalid.public String getText(int index)
index - attribute index.
null if the index
is invalid.public String getUnattributedText()
addText(Font, String)public String toString()
getUnattributedText(). Note that this
behavior may change in the future.
toString in class Object
public static Object parseEnriched(String s,
Font font)
AttributedText, as appropriate. If the string does not contain
correct enriched text then this will just return the given string
object.
If a null font is given, then the
default will be used.
This currently supports bold with the <b></b> tags and italic with the <i></i> tags. Note that these are not necessarily supported by all fonts. In these cases, the plain version of the font may be used.
s - parse this stringfont - the font, null for the default
String or AttributedText object after parsing
the specified enriched text string.Font.getFont(int, int, int),
Font.getFont(String, int, int),
Font,
RFC 1896 - The text/enriched MIME Content-type
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||