public class TextBuffer
extends java.lang.Object
implements java.io.Serializable
TextBuffer class provides a convenience way to create
Text object and RichText object.
The principal operations on a TextBuffer are the
append, setTextStyle and
setParagraphStyle methods. The append method
is overloaded so as to accept data of any type. Each effectively
converts a given datum to a text and then appends the text to the
text buffer. The setTextStyle and
setParagraphStyle methods set the current text style
and paragraph style of the text buffer respectively. The text style
is used for the converted text. The paragraph style is used when the
data of the text buffer is converted to the rich text representation
by the toRichText method.
| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected TextStyle |
lastStyle
The current text style.
|
protected VArray |
paragraphStyles
The paragraph styles.
|
protected boolean |
shared
The flag indicating whether the buffer is shared.
|
protected Text |
text
The text used for the buffer.
|
| コンストラクタと説明 |
|---|
TextBuffer()
Constructs an empty text buffer.
|
TextBuffer(int initialCapacity)
Constructs an empty text buffer with the specified initial capacity.
|
TextBuffer(int initialCapacity,
TextStyle style)
Constructs an empty text buffer with the specified initial capacity
and text style.
|
TextBuffer(java.io.Reader reader)
Constructs a text buffer so that it represents the same string
contents as the reader argument.
|
TextBuffer(java.io.Reader reader,
TextStyle style)
Constructs a text buffer so that it represents the same string
contents as the reader argument, with the specified text style.
|
TextBuffer(java.lang.String str)
Constructs a text buffer so that it represents the same
sequence of characters as the string argument.
|
TextBuffer(java.lang.String str,
TextStyle style)
Constructs a text buffer so that it represents the same
sequence of characters as the string argument, with the
specified text style.
|
TextBuffer(Text t)
Constructs a text buffer so that it represents the same contents
as the text argument.
|
TextBuffer(TextStyle style)
Constructs an empty text buffer with the specified text style.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
TextBuffer |
append(boolean b)
Appends the text representation of the boolean argument to this
text buffer.
|
TextBuffer |
append(char c)
Appends the text representation of the char argument to this
text buffer.
|
TextBuffer |
append(char[] str)
Appends the text representation of the
char array
argument to this text buffer. |
TextBuffer |
append(char[] str,
int offset,
int len)
Appends the text representation of a subarray of the
char array argument to this text buffer. |
TextBuffer |
append(double d)
Appends the text representation of the double argument to this
text buffer.
|
TextBuffer |
append(float f)
Appends the text representation of the float argument to this
text buffer.
|
TextBuffer |
append(int i)
Appends the text representation of the int argument to this
text buffer.
|
TextBuffer |
append(long l)
Appends the text representation of the long argument to this
text buffer.
|
TextBuffer |
append(java.lang.Object obj)
Appends the text representation of the object argument to
this text buffer.
|
TextBuffer |
append(java.io.Reader reader)
Appends the text representation of the string contents of the
reader argument to this text buffer.
|
TextBuffer |
append(java.lang.String str)
Appends the text representation of the string argument to
this text buffer.
|
TextBuffer |
append(Text t)
Appends the text argument to this text buffer.
|
TextBuffer |
append(TextAttachment ta)
Appends the text representation of the text attachment argument to
this text buffer.
|
TextBuffer |
append(Visualizable v)
Appends the text representation of the visual object argument to
this text buffer.
|
protected void |
copyWhenShared()
Copies the text when this text buffer is shared.
|
TextAttachment |
getAttachmentAt(int index)
Returns the text attachment at a specified index in this text buffer.
|
char |
getChar(int index)
Returns the character at a specified index in this text buffer.
|
ParagraphStyle |
getCurrentParagraphStyle()
Returns the current paragraph style of this text buffer.
|
TextStyle |
getCurrentTextStyle()
Returns the current text style of this text buffer.
|
boolean |
isEmpty()
Checks if this text buffer is currently empty.
|
int |
length()
Returns the current length of this text buffer.
|
TextBuffer |
modifyParagraphStyle(ParagraphStyleModifier modifier)
Modifies the current paragraph style of this text buffer by the
specified paragraph style modifier.
|
TextBuffer |
modifyTextStyle(TextStyleModifier modifier)
Modifies the current text style of this text buffer by the specified
text style modifier.
|
TextBuffer |
setColor(java.awt.Color color)
Modifies the current text style of this text buffer by replicating
the current text style with the new font color.
|
TextBuffer |
setFontBold()
Modifies the current text style of this text buffer by replicating
the current text style with the bold font style.
|
TextBuffer |
setFontBoldItalic()
Modifies the current text style of this text buffer by replicating
the current text style with the bold and italic font style.
|
TextBuffer |
setFontItalic()
Modifies the current text style of this text buffer by replicating
the current text style with the italic font style.
|
TextBuffer |
setFontName(java.lang.String name)
Modifies the current text style of this text buffer by replicating
the current text style with the new font name.
|
TextBuffer |
setFontPlain()
Modifies the current text style of this text buffer by replicating
the current text style with the plain font style.
|
TextBuffer |
setFontSize(int size)
Modifies the current text style of this text buffer by replicating
the current text style with the new font size.
|
TextBuffer |
setFontStyle(int style)
Modifies the current text style of this text buffer by replicating
the current text style with the new font style.
|
TextBuffer |
setParagraphStyle(ParagraphStyle style)
Sets the current paragraph style of this text buffer to be the
specified paragraph style.
|
TextBuffer |
setTextStyle(TextStyle style)
Sets the current text style of this text buffer to be the specified
text style.
|
TextBuffer |
setUnderline(boolean underline)
Modifies the current text style of this text buffer by replicating
the current text style with the underline.
|
RichText |
toRichText(RichTextStyle richTextStyle)
Converts to a rich text representing the data in this text buffer.
|
java.lang.String |
toString()
Converts to a string representing the data in this text buffer.
|
java.lang.String |
toSystemString()
Converts to a system string representing the data in this text buffer.
|
java.lang.String |
toSystemString(java.lang.String separator)
Converts to a system string representing the data in this text buffer,
with the specified separator string.
|
Text |
toText()
Converts to a text representing the data in this text buffer.
|
void |
writeTo(java.io.Writer writer)
Writes to a system string representation of the text buffer to the
specified writer.
|
void |
writeTo(java.io.Writer writer,
java.lang.String separator)
Writes to a system string representation of the text buffer to the
specified writer, with the specified separator string.
|
protected Text text
protected TextStyle lastStyle
protected VArray paragraphStyles
protected boolean shared
public TextBuffer()
public TextBuffer(int initialCapacity)
initialCapacity - the initial capacity.public TextBuffer(TextStyle style)
style - the text style.public TextBuffer(int initialCapacity,
TextStyle style)
initialCapacity - the initial capacity.style - the text style.public TextBuffer(java.lang.String str)
str - the string.public TextBuffer(java.lang.String str,
TextStyle style)
str - the string.style - the text style.public TextBuffer(java.io.Reader reader)
throws java.io.IOException
reader - the reader to read from.java.io.IOException - If an I/O error occurs.public TextBuffer(java.io.Reader reader,
TextStyle style)
throws java.io.IOException
reader - the reader to read from.style - the text style.java.io.IOException - If an I/O error occurs.Text.copySystemToJavaReadWriter(java.io.Reader, java.io.Writer)public TextBuffer(Text t)
t - the text.public int length()
public boolean isEmpty()
public char getChar(int index)
index - the index of the desired character.public TextAttachment getAttachmentAt(int index)
index - the index of the desired text attachment.null
if the text attachment does not exist at the specified index.public TextStyle getCurrentTextStyle()
public TextBuffer setTextStyle(TextStyle style)
style - the text style.public TextBuffer modifyTextStyle(TextStyleModifier modifier)
modifier - the text style modifier.public ParagraphStyle getCurrentParagraphStyle()
public TextBuffer setParagraphStyle(ParagraphStyle style)
style - the paragraph style.public TextBuffer modifyParagraphStyle(ParagraphStyleModifier modifier)
modifier - the paragraph style modifier.public TextBuffer setFontName(java.lang.String name)
name - the font name for the new text style.modifyTextStyle(jp.kyasu.graphics.TextStyleModifier)public TextBuffer setFontStyle(int style)
style - the font style for the new text style.modifyTextStyle(jp.kyasu.graphics.TextStyleModifier)public TextBuffer setFontSize(int size)
size - the font size for the new text style.modifyTextStyle(jp.kyasu.graphics.TextStyleModifier)public TextBuffer setColor(java.awt.Color color)
color - the font color for the new text style.modifyTextStyle(jp.kyasu.graphics.TextStyleModifier)public TextBuffer setUnderline(boolean underline)
underline - the new text style is underlined.modifyTextStyle(jp.kyasu.graphics.TextStyleModifier)public TextBuffer setFontPlain()
setFontStyle(int)public TextBuffer setFontBold()
setFontStyle(int)public TextBuffer setFontItalic()
setFontStyle(int)public TextBuffer setFontBoldItalic()
setFontStyle(int)public TextBuffer append(java.lang.Object obj)
obj - an object.append(java.lang.String)public TextBuffer append(java.io.Reader reader) throws java.io.IOException
reader - a reader.java.io.IOException - If an I/O error occurs.Text.copySystemToJavaReadWriter(java.io.Reader, java.io.Writer)public TextBuffer append(java.lang.String str)
str - a string.append(jp.kyasu.graphics.Text)public TextBuffer append(char[] str)
char array
argument to this text buffer.
The characters of the array argument are appended, in order, to the contents of this text buffer. The length of this text buffer increases by the length of the argument.
str - the characters to be appended.public TextBuffer append(char[] str, int offset, int len)
char array argument to this text buffer.
The characters of the character array str, starting at
index offset, are appended, in order, to the contents
of this text buffer. The length of this text buffer increases
by the value of len.
str - the characters to be appended.offset - the index of the first character to append.len - the number of characters to append.public TextBuffer append(Text t)
t - a text.public TextBuffer append(TextAttachment ta)
ta - a text attachment.append(jp.kyasu.graphics.Text)public TextBuffer append(Visualizable v)
v - a visual object.append(jp.kyasu.graphics.TextAttachment)public TextBuffer append(boolean b)
b - a boolean.append(java.lang.String)public TextBuffer append(char c)
c - a char.append(java.lang.String)public TextBuffer append(int i)
i - an int.append(java.lang.String)public TextBuffer append(long l)
l - a long.append(java.lang.String)public TextBuffer append(float f)
f - a float.append(java.lang.String)public TextBuffer append(double d)
d - a double.append(java.lang.String)public java.lang.String toString()
toString クラス内 java.lang.Objectpublic java.lang.String toSystemString()
Text.getSystemString(java.lang.String, java.lang.String)public java.lang.String toSystemString(java.lang.String separator)
separator - the separator string for the platform.Text.getSystemString(java.lang.String, java.lang.String)public Text toText()
Text.public RichText toRichText(RichTextStyle richTextStyle)
richTextStyle - the style for a new rich text.public void writeTo(java.io.Writer writer)
throws java.io.IOException
writer - the writer to write to.java.io.IOException - If an I/O error occurs.public void writeTo(java.io.Writer writer,
java.lang.String separator)
throws java.io.IOException
writer - the writer to write to.separator - the separator string for the platform.java.io.IOException - If an I/O error occurs.Text.copyJavaToSystemReadWriter(java.io.Reader, java.io.Writer, java.lang.String)protected void copyWhenShared()