All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jp.kyasu.graphics.RichText

java.lang.Object
   |
   +----jp.kyasu.graphics.RichText

public class RichText
extends Object
implements Cloneable, Serializable
The RichText class implements a text with paragraph styles. The principal operations on a RichText are the replace, setTextStyle, modifyTextStyle, setParagraphStyle, modifyParagraphStyle, and print methods:

The RichText object is laid out (composed) into the lines by a TextLayout object. The TextLayout object composes the RichText object into multiple paragraphs that are separated by the line end character (RichTextStyle.getLineEndChar()). Each paragraph has its own paragraph style, if the RichTextStyle.multipleParagraphStylesAllowed() is true. The RichText object in the paragraph is composed into multiple lines that are broken at the layout width.

Version:
15 Jun 1998
Author:
Kazuki YASUMATSU
See Also:
TextStyle, TextStyleModifier, ParagraphStyle, ParagraphStyleModifier, TextChange, TextLayout

Variable Index

 o DEFAULT_PRINT_INSETS
The constant for the default insets of the printing medium (paper).

Constructor Index

 o RichText(RichTextStyle)
Constructs an empty rich text with the specified rich text style.
 o RichText(String, RichTextStyle)
Constructs a rich text with the specified string and rich text style.
 o RichText(Text, RichTextStyle)
Constructs a rich text with the specified text and rich text style.

Method Index

 o clone()
Returns a clone of this rich text.
 o getAttachmentAt(int)
Returns the text attachment at the specified index.
 o getAttachmentCount()
Returns the number of the text attachments in this rich text.
 o getChar(int)
Returns the character at the specified index.
 o getCharacterIterator()
Returns the character iterator for this text.
 o getCharacterIterator(int)
Returns the character iterator for this text, with the specified initial index.
 o getCharacterIterator(int, int, int)
Returns the character iterator for this text, with the specified range and initial index.
 o getParagraphStyleAt(int)
Returns the paragraph style at the specified index.
 o getParagraphStyleCount()
Returns the number of the paragraph styles in this rich text.
 o getParagraphStyleRuns()
Returns the paragraph styles as a run array in this rich text.
 o getParagraphStyles()
Returns all paragraph styles in this rich text.
 o getParagraphStyles(int, int)
Returns the paragraph styles in this rich text.
 o getParagraphStylesPerParagraph(int, int)
Returns the paragraph styles in this rich text per paragraph.
 o getRichTextStyle()
Returns the RichTextStyle object of this rich text.
 o getText()
Returns the Text object in this rich text.
 o getTextStyleAt(int)
Returns the text style at the specified index.
 o getTextStyleConstraint()
Returns the text style constraint of this rich text.
 o getTextStyleCount()
Returns the number of the text styles in this rich text.
 o getTextStyleRuns()
Returns the text styles as a run array in this rich text.
 o getTextStyles()
Returns all text styles in this rich text.
 o getTextStyles(int, int)
Returns the text styles in this rich text.
 o isEmpty()
Tests if this rich text has no characters.
 o length()
Returns the length of this rich text.
 o modifyParagraphStyle(int, int, ParagraphStyleModifier)
 o modifyTextStyle(int, int, TextStyleModifier)
 o nextParagraphBeginIndexOf(int)
Returns the index of the next paragraph begin, starting the search at the specified index.
 o paragraphBeginIndexOf(int)
Returns the index of the paragraph begin, searching backward starting at the specified index.
 o paragraphEndIndexOf(int)
Returns the index of the paragraph end, starting the search at the specified index.
 o paragraphStyles()
Returns an enumeration of the paragraph styles of this text.
 o paragraphStyles(int, int)
Returns an enumeration of the paragraph styles of this text.
 o print(PrintJob)
Prints the rich text to a print device provided from the specified print job.
 o print(PrintJob, Insets, int, String, boolean)
Prints the rich text to a print device provided from the specified print job, with the specified insets, line wrapping, header string, and flag determining to print a page number in footer.
 o print(PrintJob, Insets, int, String, boolean, Font, Color)
Prints the rich text to a print device provided from the specified print job, with the specified insets, line wrapping, header string, flag determining to print a page number in footer, font for the header/footer, and foreground printing color.
 o print(PrintJob, String, boolean)
Prints the rich text to a print device provided from the specified print job, with the specified header string and flag determining to print a page number in footer.
 o replace(int, int, RichText)
Replaces the specified range of this rich text with the specified replacement rich text object.
 o replace(int, int, Text)
Replaces the specified range of this rich text with the specified replacement text object.
 o setBaseTextStyle(TextStyle)
Sets the base text style of this rich text to be the specified text style.
 o setParagraphStyle(int, int, ParagraphStyle)
 o setParagraphStyles(int, int, ParagraphStyle[])
 o setTextStyle(int, int, TextStyle)
 o setTextStyleConstraint(TextStyleModifier)
Sets the text style constraint of this rich text to be the specified text style modifier.
 o setTextStyles(int, int, RunArray)
 o subtext(int, int)
Returns a new rich text that is a subtext of this rich text.
 o textStyles()
Returns an enumeration of the text styles of this text.
 o textStyles(int, int)
Returns an enumeration of the text styles of this text.

Variables

 o DEFAULT_PRINT_INSETS
 public static final Insets DEFAULT_PRINT_INSETS
The constant for the default insets of the printing medium (paper).

Constructors

 o RichText
 public RichText(RichTextStyle rtStyle)
Constructs an empty rich text with the specified rich text style.

Parameters:
rtStyle - the rich text style.
 o RichText
 public RichText(String string,
                 RichTextStyle rtStyle)
Constructs a rich text with the specified string and rich text style.

Parameters:
string - the initial string.
rtStyle - the rich text style.
 o RichText
 public RichText(Text text,
                 RichTextStyle rtStyle)
Constructs a rich text with the specified text and rich text style.

Parameters:
text - the initial text.
rtStyle - the rich text style.

Methods

 o getText
 public final Text getText()
Returns the Text object in this rich text. An application should not modify the returned text.

 o getRichTextStyle
 public final RichTextStyle getRichTextStyle()
Returns the RichTextStyle object of this rich text.

 o isEmpty
 public final boolean isEmpty()
Tests if this rich text has no characters.

Returns:
true if this text has no characters; false otherwise.
See Also:
isEmpty
 o length
 public final int length()
Returns the length of this rich text.

See Also:
length
 o getChar
 public final char getChar(int textIndex)
Returns the character at the specified index.

Parameters:
index - an index into this rich text.
Returns:
the character at the specified index.
See Also:
getChar
 o getCharacterIterator
 public final CharacterIterator getCharacterIterator()
Returns the character iterator for this text.

Returns:
the character iterator for this text.
 o getCharacterIterator
 public final CharacterIterator getCharacterIterator(int pos)
Returns the character iterator for this text, with the specified initial index.

Parameters:
pos - initial iterator position.
Returns:
the character iterator for this text.
 o getCharacterIterator
 public final CharacterIterator getCharacterIterator(int begin,
                                                     int end,
                                                     int pos)
Returns the character iterator for this text, with the specified range and initial index.

Parameters:
begin - index of the first character.
end - index of the character following the last character.
pos - initial iterator position.
Returns:
the character iterator for this text.
 o textStyles
 public final Enumeration textStyles()
Returns an enumeration of the text styles of this text.

Returns:
an enumeration of the text styles of this text.
 o textStyles
 public final Enumeration textStyles(int begin,
                                     int end)
Returns an enumeration of the text styles of this text.

Parameters:
begin - the beginning index to get styles, inclusive.
end - the ending index to get styles, exclusive.
Returns:
an enumeration of the text styles of this text.
 o getTextStyleRuns
 public final RunArray getTextStyleRuns()
Returns the text styles as a run array in this rich text. An application should not modify the returned run array.

See Also:
getTextStyleRuns
 o getTextStyleAt
 public final TextStyle getTextStyleAt(int textIndex)
Returns the text style at the specified index.

Parameters:
index - an index into this rich text.
Returns:
the text style at the specified index.
See Also:
getTextStyleAt
 o getTextStyleCount
 public final int getTextStyleCount()
Returns the number of the text styles in this rich text.

See Also:
getTextStyleCount
 o getTextStyles
 public final TextStyle[] getTextStyles()
Returns all text styles in this rich text.

See Also:
getTextStyles
 o getTextStyles
 public final TextStyle[] getTextStyles(int begin,
                                        int end)
Returns the text styles in this rich text.

Parameters:
begin - the beginning index to get text styles, inclusive.
end - the ending index to get text styles, exclusive.
Returns:
the text styles in this rich text.
See Also:
getTextStyles
 o getAttachmentAt
 public final TextAttachment getAttachmentAt(int textIndex)
Returns the text attachment at the specified index.

Parameters:
index - an index into this rich text.
Returns:
the text attachment if this rich text contains the text attachment at the specified index; null otherwise.
See Also:
getAttachmentAt
 o getAttachmentCount
 public final int getAttachmentCount()
Returns the number of the text attachments in this rich text.

See Also:
getAttachmentCount
 o paragraphStyles
 public final Enumeration paragraphStyles()
Returns an enumeration of the paragraph styles of this text.

Returns:
an enumeration of the paragraph styles of this text.
 o paragraphStyles
 public final Enumeration paragraphStyles(int begin,
                                          int end)
Returns an enumeration of the paragraph styles of this text.

Parameters:
begin - the beginning index to get styles, inclusive.
end - the ending index to get styles, exclusive.
Returns:
an enumeration of the paragraph styles of this text.
 o getParagraphStyleRuns
 public final RunArray getParagraphStyleRuns()
Returns the paragraph styles as a run array in this rich text. An application should not modify the returned run array.

 o getParagraphStyleAt
 public final ParagraphStyle getParagraphStyleAt(int textIndex)
Returns the paragraph style at the specified index.

Parameters:
index - an index into this rich text.
Returns:
the paragraph style at the specified index.
 o getParagraphStyleCount
 public final int getParagraphStyleCount()
Returns the number of the paragraph styles in this rich text.

 o getParagraphStyles
 public final ParagraphStyle[] getParagraphStyles()
Returns all paragraph styles in this rich text.

 o getParagraphStyles
 public final ParagraphStyle[] getParagraphStyles(int begin,
                                                  int end)
Returns the paragraph styles in this rich text.

Parameters:
begin - the beginning index of the text to get paragraph styles, inclusive.
end - the ending index of the text to get paragraph styles, exclusive.
 o getParagraphStylesPerParagraph
 public final ParagraphStyle[] getParagraphStylesPerParagraph(int begin,
                                                              int end)
Returns the paragraph styles in this rich text per paragraph.

Parameters:
begin - the beginning index of the text to get paragraph styles, inclusive.
end - the ending index of the text to get paragraph styles, exclusive.
 o subtext
 public RichText subtext(int begin,
                         int end)
Returns a new rich text that is a subtext of this rich text.

Parameters:
begin - the beginning index, inclusive.
end - the ending index, exclusive.
Returns:
the subtext.
 o paragraphBeginIndexOf
 public final int paragraphBeginIndexOf(int fromIndex)
Returns the index of the paragraph begin, searching backward starting at the specified index.

Parameters:
fromIndex - the index to start the search from.
Returns:
the index of the the paragraph begin, inclusive.
 o paragraphEndIndexOf
 public final int paragraphEndIndexOf(int fromIndex)
Returns the index of the paragraph end, starting the search at the specified index.

Parameters:
fromIndex - the index to start the search from.
Returns:
the index of the paragraph end, inclusive.
 o nextParagraphBeginIndexOf
 public final int nextParagraphBeginIndexOf(int fromIndex)
Returns the index of the next paragraph begin, starting the search at the specified index.

Parameters:
fromIndex - the index to start the search from.
Returns:
the index of the next paragraph end, or -1 if the paragraph is last one.
 o setBaseTextStyle
 public TextChange setBaseTextStyle(TextStyle textStyle)
Sets the base text style of this rich text to be the specified text style.

Parameters:
textStyle - the text style.
Returns:
the TextChange object that provides an information of changes in this rich text made by this method.
 o getTextStyleConstraint
 public TextStyleModifier getTextStyleConstraint()
Returns the text style constraint of this rich text.

Returns:
the text style constraint of this rich text.
See Also:
setTextStyleConstraint
 o setTextStyleConstraint
 public void setTextStyleConstraint(TextStyleModifier constraint)
Sets the text style constraint of this rich text to be the specified text style modifier.

Parameters:
constraint - the text style modifier.
See Also:
getTextStyleConstraint
 o clone
 public Object clone()
Returns a clone of this rich text.

Overrides:
clone in class Object
 o replace
 public TextChange replace(int begin,
                           int end,
                           Text rep)
Replaces the specified range of this rich text with the specified replacement text object.

Parameters:
begin - the beginning text position to replace, inclusive.
end - the ending text position to replace, exclusive.
rep - a replacement Text object.
Returns:
the TextChange object that provides an information of changes in this rich text made by this method.
 o replace
 public TextChange replace(int begin,
                           int end,
                           RichText rep)
Replaces the specified range of this rich text with the specified replacement rich text object.

Parameters:
begin - the beginning text position to replace, inclusive.
end - the ending text position to replace, exclusive.
rep - a replacement RichText object.
Returns:
the TextChange object that provides an information of changes in this rich text made by this method.
 o setTextStyle
 public TextChange setTextStyle(int begin,
                                int end,
                                TextStyle textStyle)
 o setTextStyles
 public TextChange setTextStyles(int begin,
                                 int end,
                                 RunArray textStyles)
 o modifyTextStyle
 public TextChange modifyTextStyle(int begin,
                                   int end,
                                   TextStyleModifier modifier)
 o setParagraphStyle
 public TextChange setParagraphStyle(int begin,
                                     int end,
                                     ParagraphStyle pStyle)
 o setParagraphStyles
 public TextChange setParagraphStyles(int begin,
                                      int end,
                                      ParagraphStyle pStyles[])
 o modifyParagraphStyle
 public TextChange modifyParagraphStyle(int begin,
                                        int end,
                                        ParagraphStyleModifier modifier)
 o print
 public void print(PrintJob job)
Prints the rich text to a print device provided from the specified print job.

Parameters:
job - the print job.
 o print
 public void print(PrintJob job,
                   String header,
                   boolean printPageNum)
Prints the rich text to a print device provided from the specified print job, with the specified header string and flag determining to print a page number in footer.

Parameters:
job - the print job.
header - the header string.
printPageNum - if true, prints a page number in footer.
 o print
 public void print(PrintJob job,
                   Insets insets,
                   int lineWrap,
                   String header,
                   boolean printPageNum)
Prints the rich text to a print device provided from the specified print job, with the specified insets, line wrapping, header string, and flag determining to print a page number in footer.

Parameters:
job - the print job.
insets - the insets of a printing medium (paper).
lineWrap - the line wrapping style.
header - the header string.
printPageNum - if true, prints a page number in footer.
 o print
 public void print(PrintJob job,
                   Insets insets,
                   int lineWrap,
                   String header,
                   boolean printPageNum,
                   Font headerFooterFont,
                   Color foreground)
Prints the rich text to a print device provided from the specified print job, with the specified insets, line wrapping, header string, flag determining to print a page number in footer, font for the header/footer, and foreground printing color.

Parameters:
job - the print job.
insets - the insets of a printing medium (paper).
lineWrap - the line wrapping style.
header - the header string.
printPageNum - if true, prints a page number in footer.
headerFooterFont - the font for the header and footer.
foreground - the foreground printing color.

All Packages  Class Hierarchy  This Package  Previous  Next  Index