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

Constructor Index

 o TextBuffer()
Constructs an empty text buffer.
 o TextBuffer(int)
Constructs an empty text buffer with the specified initial capacity.
 o TextBuffer(int, TextStyle)
Constructs an empty text buffer with the specified initial capacity and text style.
 o TextBuffer(Reader)
Constructs a text buffer so that it represents the same string contents as the reader argument.
 o TextBuffer(Reader, TextStyle)
Constructs a text buffer so that it represents the same string contents as the reader argument, with the specified text style.
 o TextBuffer(String)
Constructs a text buffer so that it represents the same sequence of characters as the string argument.
 o 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.
 o TextBuffer(Text)
Constructs a text buffer so that it represents the same contents as the text argument.
 o TextBuffer(TextStyle)
Constructs an empty text buffer with the specified text style.

Method Index

 o append(boolean)
Appends the text representation of the boolean argument to this text buffer.
 o append(char)
Appends the text representation of the char argument to this text buffer.
 o append(char[])
Appends the text representation of the char array argument to this text buffer.
 o append(char[], int, int)
Appends the text representation of a subarray of the char array argument to this text buffer.
 o append(double)
Appends the text representation of the double argument to this text buffer.
 o append(float)
Appends the text representation of the float argument to this text buffer.
 o append(int)
Appends the text representation of the int argument to this text buffer.
 o append(long)
Appends the text representation of the long argument to this text buffer.
 o append(Object)
Appends the text representation of the object argument to this text buffer.
 o append(Reader)
Appends the text representation of the string contents of the reader argument to this text buffer.
 o append(String)
Appends the text representation of the string argument to this text buffer.
 o append(Text)
Appends the text argument to this text buffer.
 o append(TextAttachment)
Appends the text representation of the text attachment argument to this text buffer.
 o append(Visualizable)
Appends the text representation of the visual object argument to this text buffer.
 o getAttachmentAt(int)
Returns the text attachment at a specified index in this text buffer.
 o getChar(int)
Returns the character at a specified index in this text buffer.
 o getCurrentParagraphStyle()
Returns the current paragraph style of this text buffer.
 o getCurrentTextStyle()
Returns the current text style of this text buffer.
 o isEmpty()
Checks if this text buffer is currently empty.
 o length()
Returns the current length of this text buffer.
 o modifyParagraphStyle(ParagraphStyleModifier)
Modifies the current paragraph style of this text buffer by the specified paragraph style modifier.
 o modifyTextStyle(TextStyleModifier)
Modifies the current text style of this text buffer by the specified text style modifier.
 o setColor(Color)
Modifies the current text style of this text buffer by replicating the current text style with the new font color.
 o setFontBold()
Modifies the current text style of this text buffer by replicating the current text style with the bold font style.
 o setFontBoldItalic()
Modifies the current text style of this text buffer by replicating the current text style with the bold and italic font style.
 o setFontItalic()
Modifies the current text style of this text buffer by replicating the current text style with the italic font style.
 o setFontName(String)
Modifies the current text style of this text buffer by replicating the current text style with the new font name.
 o setFontPlain()
Modifies the current text style of this text buffer by replicating the current text style with the plain font style.
 o setFontSize(int)
Modifies the current text style of this text buffer by replicating the current text style with the new font size.
 o setFontStyle(int)
Modifies the current text style of this text buffer by replicating the current text style with the new font style.
 o setParagraphStyle(ParagraphStyle)
Sets the current paragraph style of this text buffer to be the specified paragraph style.
 o setTextStyle(TextStyle)
Sets the current text style of this text buffer to be the specified text style.
 o setUnderline(boolean)
Modifies the current text style of this text buffer by replicating the current text style with the underline.
 o toRichText(RichTextStyle)
Converts to a rich text representing the data in this text buffer.
 o toString()
Converts to a string representing the data in this text buffer.
 o toSystemString()
Converts to a system string representing the data in this text buffer.
 o toSystemString(String)
Converts to a system string representing the data in this text buffer, with the specified separator string.
 o toText()
Converts to a text representing the data in this text buffer.
 o writeTo(Writer)
Writes to a system string representation of the text buffer to the specified writer.
 o writeTo(Writer, String)
Writes to a system string representation of the text buffer to the specified writer, with the specified separator string.

Constructors

 o TextBuffer
 public TextBuffer()
Constructs an empty text buffer.

 o TextBuffer
 public TextBuffer(int initialCapacity)
Constructs an empty text buffer with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity.
 o TextBuffer
 public TextBuffer(TextStyle style)
Constructs an empty text buffer with the specified text style.

Parameters:
style - the text style.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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
 o TextBuffer
 public TextBuffer(Text t)
Constructs a text buffer so that it represents the same contents as the text argument.

Parameters:
t - the text.

Methods

 o length
 public int length()
Returns the current length of this text buffer.

 o isEmpty
 public boolean isEmpty()
Checks if this text buffer is currently empty.

 o 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.
 o 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.
 o getCurrentTextStyle
 public TextStyle getCurrentTextStyle()
Returns the current text style of this text buffer.

 o 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.
 o 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.
 o getCurrentParagraphStyle
 public ParagraphStyle getCurrentParagraphStyle()
Returns the current paragraph style of this text buffer.

 o 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.
 o 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.
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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.
 o 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.
 o 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.
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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.
 o 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.
 o 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.
 o 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