All Packages Class Hierarchy This Package Previous Next Index
Class jp.kyasu.graphics.TextBuffer
java.lang.Object
|
+----jp.kyasu.graphics.TextBuffer
- public class TextBuffer
- extends Object
- implements Serializable
The 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.
- Version:
- 16 Dec 1998
- Author:
- Kazuki YASUMATSU
- See Also:
- Text, RichText
-
TextBuffer()
- Constructs an empty text buffer.
-
TextBuffer(int)
- Constructs an empty text buffer with the specified initial capacity.
-
TextBuffer(int, TextStyle)
- Constructs an empty text buffer with the specified initial capacity
and text style.
-
TextBuffer(Reader)
- Constructs a text buffer so that it represents the same string
contents as the reader argument.
-
TextBuffer(Reader, TextStyle)
- Constructs a text buffer so that it represents the same string
contents as the reader argument, with the specified text style.
-
TextBuffer(String)
- Constructs a text buffer so that it represents the same
sequence of characters as the string argument.
-
TextBuffer(String, TextStyle)
- Constructs a text buffer so that it represents the same
sequence of characters as the string argument, with the
specified text style.
-
TextBuffer(Text)
- Constructs a text buffer so that it represents the same contents
as the text argument.
-
TextBuffer(TextStyle)
- Constructs an empty text buffer with the specified text style.
-
append(boolean)
- Appends the text representation of the boolean argument to this
text buffer.
-
append(char)
- Appends the text representation of the char argument to this
text buffer.
-
append(char[])
- Appends the text representation of the
char
array
argument to this text buffer.
-
append(char[], int, int)
- Appends the text representation of a subarray of the
char
array argument to this text buffer.
-
append(double)
- Appends the text representation of the double argument to this
text buffer.
-
append(float)
- Appends the text representation of the float argument to this
text buffer.
-
append(int)
- Appends the text representation of the int argument to this
text buffer.
-
append(long)
- Appends the text representation of the long argument to this
text buffer.
-
append(Object)
- Appends the text representation of the object argument to
this text buffer.
-
append(Reader)
- Appends the text representation of the string contents of the
reader argument to this text buffer.
-
append(String)
- Appends the text representation of the string argument to
this text buffer.
-
append(Text)
- Appends the text argument to this text buffer.
-
append(TextAttachment)
- Appends the text representation of the text attachment argument to
this text buffer.
-
append(Visualizable)
- Appends the text representation of the visual object argument to
this text buffer.
-
getAttachmentAt(int)
- Returns the text attachment at a specified index in this text buffer.
-
getChar(int)
- Returns the character at a specified index in this text buffer.
-
getCurrentParagraphStyle()
- Returns the current paragraph style of this text buffer.
-
getCurrentTextStyle()
- Returns the current text style of this text buffer.
-
isEmpty()
- Checks if this text buffer is currently empty.
-
length()
- Returns the current length of this text buffer.
-
modifyParagraphStyle(ParagraphStyleModifier)
- Modifies the current paragraph style of this text buffer by the
specified paragraph style modifier.
-
modifyTextStyle(TextStyleModifier)
- Modifies the current text style of this text buffer by the specified
text style modifier.
-
setColor(Color)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font color.
-
setFontBold()
- Modifies the current text style of this text buffer by replicating
the current text style with the bold font style.
-
setFontBoldItalic()
- Modifies the current text style of this text buffer by replicating
the current text style with the bold and italic font style.
-
setFontItalic()
- Modifies the current text style of this text buffer by replicating
the current text style with the italic font style.
-
setFontName(String)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font name.
-
setFontPlain()
- Modifies the current text style of this text buffer by replicating
the current text style with the plain font style.
-
setFontSize(int)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font size.
-
setFontStyle(int)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font style.
-
setParagraphStyle(ParagraphStyle)
- Sets the current paragraph style of this text buffer to be the
specified paragraph style.
-
setTextStyle(TextStyle)
- Sets the current text style of this text buffer to be the specified
text style.
-
setUnderline(boolean)
- Modifies the current text style of this text buffer by replicating
the current text style with the underline.
-
toRichText(RichTextStyle)
- Converts to a rich text representing the data in this text buffer.
-
toString()
- Converts to a string representing the data in this text buffer.
-
toSystemString()
- Converts to a system string representing the data in this text buffer.
-
toSystemString(String)
- Converts to a system string representing the data in this text buffer,
with the specified separator string.
-
toText()
- Converts to a text representing the data in this text buffer.
-
writeTo(Writer)
- Writes to a system string representation of the text buffer to the
specified writer.
-
writeTo(Writer, String)
- Writes to a system string representation of the text buffer to the
specified writer, with the specified separator string.
TextBuffer
public TextBuffer()
- Constructs an empty text buffer.
TextBuffer
public TextBuffer(int initialCapacity)
- Constructs an empty text buffer with the specified initial capacity.
- Parameters:
- initialCapacity - the initial capacity.
TextBuffer
public TextBuffer(TextStyle style)
- Constructs an empty text buffer with the specified text style.
- Parameters:
- style - the text style.
TextBuffer
public TextBuffer(int initialCapacity,
TextStyle style)
- Constructs an empty text buffer with the specified initial capacity
and text style.
- Parameters:
- initialCapacity - the initial capacity.
- style - the text style.
TextBuffer
public TextBuffer(String str)
- Constructs a text buffer so that it represents the same
sequence of characters as the string argument.
- Parameters:
- str - the string.
TextBuffer
public TextBuffer(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.
- Parameters:
- str - the string.
- style - the text style.
TextBuffer
public TextBuffer(Reader reader) throws IOException
- Constructs a text buffer so that it represents the same string
contents as the reader argument.
- Parameters:
- reader - the reader to read from.
- Throws: IOException
- If an I/O error occurs.
TextBuffer
public TextBuffer(Reader reader,
TextStyle style) throws IOException
- Constructs a text buffer so that it represents the same string
contents as the reader argument, with the specified text style.
- Parameters:
- reader - the reader to read from.
- style - the text style.
- Throws: IOException
- If an I/O error occurs.
- See Also:
- copySystemToJavaReadWriter
TextBuffer
public TextBuffer(Text t)
- Constructs a text buffer so that it represents the same contents
as the text argument.
- Parameters:
- t - the text.
length
public int length()
- Returns the current length of this text buffer.
isEmpty
public boolean isEmpty()
- Checks if this text buffer is currently empty.
getChar
public char getChar(int index)
- Returns the character at a specified index in this text buffer.
- Parameters:
- index - the index of the desired character.
- Returns:
- the character at the specified index.
getAttachmentAt
public TextAttachment getAttachmentAt(int index)
- Returns the text attachment at a specified index in this text buffer.
- Parameters:
- index - the index of the desired text attachment.
- Returns:
- the text attachment at the specified index, or
null
if the text attachment does not exist at the specified index.
getCurrentTextStyle
public TextStyle getCurrentTextStyle()
- Returns the current text style of this text buffer.
setTextStyle
public TextBuffer setTextStyle(TextStyle style)
- Sets the current text style of this text buffer to be the specified
text style.
- Parameters:
- style - the text style.
- Returns:
- this text buffer.
modifyTextStyle
public TextBuffer modifyTextStyle(TextStyleModifier modifier)
- Modifies the current text style of this text buffer by the specified
text style modifier.
- Parameters:
- modifier - the text style modifier.
- Returns:
- this text buffer.
getCurrentParagraphStyle
public ParagraphStyle getCurrentParagraphStyle()
- Returns the current paragraph style of this text buffer.
setParagraphStyle
public TextBuffer setParagraphStyle(ParagraphStyle style)
- Sets the current paragraph style of this text buffer to be the
specified paragraph style.
- Parameters:
- style - the paragraph style.
- Returns:
- this text buffer.
modifyParagraphStyle
public TextBuffer modifyParagraphStyle(ParagraphStyleModifier modifier)
- Modifies the current paragraph style of this text buffer by the
specified paragraph style modifier.
- Parameters:
- modifier - the paragraph style modifier.
- Returns:
- this text buffer.
setFontName
public TextBuffer setFontName(String name)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font name.
- Parameters:
- name - the font name for the new text style.
- Returns:
- this text buffer.
- See Also:
- modifyTextStyle
setFontStyle
public TextBuffer setFontStyle(int style)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font style.
- Parameters:
- style - the font style for the new text style.
- Returns:
- this text buffer.
- See Also:
- modifyTextStyle
setFontSize
public TextBuffer setFontSize(int size)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font size.
- Parameters:
- size - the font size for the new text style.
- Returns:
- this text buffer.
- See Also:
- modifyTextStyle
setColor
public TextBuffer setColor(Color color)
- Modifies the current text style of this text buffer by replicating
the current text style with the new font color.
- Parameters:
- color - the font color for the new text style.
- Returns:
- this text buffer.
- See Also:
- modifyTextStyle
setUnderline
public TextBuffer setUnderline(boolean underline)
- Modifies the current text style of this text buffer by replicating
the current text style with the underline.
- Parameters:
- underline - the new text style is underlined.
- Returns:
- this text buffer.
- See Also:
- modifyTextStyle
setFontPlain
public TextBuffer setFontPlain()
- Modifies the current text style of this text buffer by replicating
the current text style with the plain font style.
- Returns:
- this text buffer.
- See Also:
- setFontStyle
setFontBold
public TextBuffer setFontBold()
- Modifies the current text style of this text buffer by replicating
the current text style with the bold font style.
- Returns:
- this text buffer.
- See Also:
- setFontStyle
setFontItalic
public TextBuffer setFontItalic()
- Modifies the current text style of this text buffer by replicating
the current text style with the italic font style.
- Returns:
- this text buffer.
- See Also:
- setFontStyle
setFontBoldItalic
public TextBuffer setFontBoldItalic()
- Modifies the current text style of this text buffer by replicating
the current text style with the bold and italic font style.
- Returns:
- this text buffer.
- See Also:
- setFontStyle
append
public TextBuffer append(Object obj)
- Appends the text representation of the object argument to
this text buffer. The argument is converted to a text with the
current text style.
- Parameters:
- obj - an object.
- See Also:
- append
append
public TextBuffer append(Reader reader) throws IOException
- Appends the text representation of the string contents of the
reader argument to this text buffer. The argument is converted to
a text with the current text style.
- Parameters:
- reader - a reader.
- Throws: IOException
- If an I/O error occurs.
- See Also:
- copySystemToJavaReadWriter
append
public TextBuffer append(String str)
- Appends the text representation of the string argument to
this text buffer. The argument is converted to a text with the
current text style.
- Parameters:
- str - a string.
- See Also:
- append
append
public TextBuffer append(char str[])
- Appends the text representation of the
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.
- Parameters:
- str - the characters to be appended.
- Returns:
- this text buffer.
append
public TextBuffer append(char str[],
int offset,
int len)
- Appends the text representation of a subarray of the
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
.
- Parameters:
- str - the characters to be appended.
- offset - the index of the first character to append.
- len - the number of characters to append.
- Returns:
- this text buffer.
append
public TextBuffer append(Text t)
- Appends the text argument to this text buffer. The current text
style becomes the last style of the text argument.
- Parameters:
- t - a text.
append
public TextBuffer append(TextAttachment ta)
- Appends the text representation of the text attachment argument to
this text buffer. The argument is converted to a text with the
text attachment.
- Parameters:
- ta - a text attachment.
- See Also:
- append
append
public TextBuffer append(Visualizable v)
- Appends the text representation of the visual object argument to
this text buffer. The argument is converted to a text with a
text attachment that wraps the visual object.
- Parameters:
- v - a visual object.
- See Also:
- append
append
public TextBuffer append(boolean b)
- Appends the text representation of the boolean argument to this
text buffer. The argument is converted to a text with the current
text style.
- Parameters:
- b - a boolean.
- See Also:
- append
append
public TextBuffer append(char c)
- Appends the text representation of the char argument to this
text buffer. The argument is converted to a text with the current
text style.
- Parameters:
- c - a char.
- See Also:
- append
append
public TextBuffer append(int i)
- Appends the text representation of the int argument to this
text buffer. The argument is converted to a text with the current
text style.
- Parameters:
- i - an int.
- See Also:
- append
append
public TextBuffer append(long l)
- Appends the text representation of the long argument to this
text buffer. The argument is converted to a text with the current
text style.
- Parameters:
- l - a long.
- See Also:
- append
append
public TextBuffer append(float f)
- Appends the text representation of the float argument to this
text buffer. The argument is converted to a text with the current
text style.
- Parameters:
- f - a float.
- See Also:
- append
append
public TextBuffer append(double d)
- Appends the text representation of the double argument to this
text buffer. The argument is converted to a text with the current
text style.
- Parameters:
- d - a double.
- See Also:
- append
toString
public String toString()
- Converts to a string representing the data in this text buffer.
- Returns:
- a string representation of the text buffer.
- Overrides:
- toString in class Object
toSystemString
public String toSystemString()
- Converts to a system string representing the data in this text buffer.
- Returns:
- a system string representation of the text buffer.
- See Also:
- getSystemString
toSystemString
public String toSystemString(String separator)
- Converts to a system string representing the data in this text buffer,
with the specified separator string.
- Parameters:
- separator - the separator string for the platform.
- Returns:
- a string representation of the text buffer.
- See Also:
- getSystemString
toText
public Text toText()
- Converts to a text representing the data in this text buffer.
Subsequent changes to the text buffer do not affect the contents
of the returned
Text
.
- Returns:
- a text representation of the text buffer.
toRichText
public RichText toRichText(RichTextStyle richTextStyle)
- Converts to a rich text representing the data in this text buffer.
- Parameters:
- richTextStyle - the style for a new rich text.
- Returns:
- a rich text representation of the text buffer.
writeTo
public void writeTo(Writer writer) throws IOException
- Writes to a system string representation of the text buffer to the
specified writer.
- Parameters:
- writer - the writer to write to.
- Throws: IOException
- If an I/O error occurs.
writeTo
public void writeTo(Writer writer,
String separator) throws IOException
- Writes to a system string representation of the text buffer to the
specified writer, with the specified separator string.
- Parameters:
- writer - the writer to write to.
- separator - the separator string for the platform.
- Throws: IOException
- If an I/O error occurs.
- See Also:
- copyJavaToSystemReadWriter
All Packages Class Hierarchy This Package Previous Next Index