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
replace
method replaces the specified range of the
rich text with the specified replacement text and returns the
TextChange
object.
- The
setTextStyle
method sets the text style in the
specified range of the rich text to be the specified text style
and returns the TextChange
object.
- The
modifyTextStyle
method modifies the text style in
the specified range of the rich text by using the specified
TextStyleModifier
object and returns the
TextChange
object.
- The
setParagraphStyle
method sets the paragraph style
at the specified range of the rich text to be the specified
paragraph style and returns the TextChange
object.
- The
modifyParagraphStyle
method modifies the paragraph
style at the specified range of the rich text by using the
specified ParagraphStyleModifier
object and returns the
TextChange
object.
- The
print
method prints the rich text to a print
device provided from the specified PrintJob
object.
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
-
DEFAULT_PRINT_INSETS
- The constant for the default insets of the printing medium (paper).
-
RichText(RichTextStyle)
- Constructs an empty rich text with the specified rich text style.
-
RichText(String, RichTextStyle)
- Constructs a rich text with the specified string and rich text style.
-
RichText(Text, RichTextStyle)
- Constructs a rich text with the specified text and rich text style.
-
clone()
- Returns a clone of this rich text.
-
getAttachmentAt(int)
- Returns the text attachment at the specified index.
-
getAttachmentCount()
- Returns the number of the text attachments in this rich text.
-
getChar(int)
- Returns the character at the specified index.
-
getCharacterIterator()
- Returns the character iterator for this text.
-
getCharacterIterator(int)
- Returns the character iterator for this text, with the specified
initial index.
-
getCharacterIterator(int, int, int)
- Returns the character iterator for this text, with the specified
range and initial index.
-
getParagraphStyleAt(int)
- Returns the paragraph style at the specified index.
-
getParagraphStyleCount()
- Returns the number of the paragraph styles in this rich text.
-
getParagraphStyleRuns()
- Returns the paragraph styles as a run array in this rich text.
-
getParagraphStyles()
- Returns all paragraph styles in this rich text.
-
getParagraphStyles(int, int)
- Returns the paragraph styles in this rich text.
-
getParagraphStylesPerParagraph(int, int)
- Returns the paragraph styles in this rich text per paragraph.
-
getRichTextStyle()
- Returns the
RichTextStyle
object of this rich text.
-
getText()
- Returns the
Text
object in this rich text.
-
getTextStyleAt(int)
- Returns the text style at the specified index.
-
getTextStyleConstraint()
- Returns the text style constraint of this rich text.
-
getTextStyleCount()
- Returns the number of the text styles in this rich text.
-
getTextStyleRuns()
- Returns the text styles as a run array in this rich text.
-
getTextStyles()
- Returns all text styles in this rich text.
-
getTextStyles(int, int)
- Returns the text styles in this rich text.
-
isEmpty()
- Tests if this rich text has no characters.
-
length()
- Returns the length of this rich text.
-
modifyParagraphStyle(int, int, ParagraphStyleModifier)
-
-
modifyTextStyle(int, int, TextStyleModifier)
-
-
nextParagraphBeginIndexOf(int)
- Returns the index of the next paragraph begin, starting the search
at the specified index.
-
paragraphBeginIndexOf(int)
- Returns the index of the paragraph begin, searching backward starting
at the specified index.
-
paragraphEndIndexOf(int)
- Returns the index of the paragraph end, starting the search at
the specified index.
-
paragraphStyles()
- Returns an enumeration of the paragraph styles of this text.
-
paragraphStyles(int, int)
- Returns an enumeration of the paragraph styles of this text.
-
print(PrintJob)
- Prints the rich text to a print device provided from the specified
print job.
-
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.
-
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.
-
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.
-
replace(int, int, RichText)
- Replaces the specified range of this rich text with the specified
replacement rich text object.
-
replace(int, int, Text)
- Replaces the specified range of this rich text with the specified
replacement text object.
-
setBaseTextStyle(TextStyle)
- Sets the base text style of this rich text to be the specified
text style.
-
setParagraphStyle(int, int, ParagraphStyle)
-
-
setParagraphStyles(int, int, ParagraphStyle[])
-
-
setTextStyle(int, int, TextStyle)
-
-
setTextStyleConstraint(TextStyleModifier)
- Sets the text style constraint of this rich text to be the specified
text style modifier.
-
setTextStyles(int, int, RunArray)
-
-
subtext(int, int)
- Returns a new rich text that is a subtext of this rich text.
-
textStyles()
- Returns an enumeration of the text styles of this text.
-
textStyles(int, int)
- Returns an enumeration of the text styles of this text.
DEFAULT_PRINT_INSETS
public static final Insets DEFAULT_PRINT_INSETS
- The constant for the default insets of the printing medium (paper).
RichText
public RichText(RichTextStyle rtStyle)
- Constructs an empty rich text with the specified rich text style.
- Parameters:
- rtStyle - the rich text style.
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.
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.
getText
public final Text getText()
- Returns the
Text
object in this rich text.
An application should not modify the returned text.
getRichTextStyle
public final RichTextStyle getRichTextStyle()
- Returns the
RichTextStyle
object of this rich text.
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
length
public final int length()
- Returns the length of this rich text.
- See Also:
- length
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
getCharacterIterator
public final CharacterIterator getCharacterIterator()
- Returns the character iterator for this text.
- Returns:
- the character iterator for this text.
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.
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.
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.
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.
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
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
getTextStyleCount
public final int getTextStyleCount()
- Returns the number of the text styles in this rich text.
- See Also:
- getTextStyleCount
getTextStyles
public final TextStyle[] getTextStyles()
- Returns all text styles in this rich text.
- See Also:
- getTextStyles
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
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
getAttachmentCount
public final int getAttachmentCount()
- Returns the number of the text attachments in this rich text.
- See Also:
- getAttachmentCount
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.
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.
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.
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.
getParagraphStyleCount
public final int getParagraphStyleCount()
- Returns the number of the paragraph styles in this rich text.
getParagraphStyles
public final ParagraphStyle[] getParagraphStyles()
- Returns all paragraph styles in this rich text.
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.
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.
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.
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.
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.
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.
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.
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
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
clone
public Object clone()
- Returns a clone of this rich text.
- Overrides:
- clone in class Object
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.
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.
setTextStyle
public TextChange setTextStyle(int begin,
int end,
TextStyle textStyle)
setTextStyles
public TextChange setTextStyles(int begin,
int end,
RunArray textStyles)
modifyTextStyle
public TextChange modifyTextStyle(int begin,
int end,
TextStyleModifier modifier)
setParagraphStyle
public TextChange setParagraphStyle(int begin,
int end,
ParagraphStyle pStyle)
setParagraphStyles
public TextChange setParagraphStyles(int begin,
int end,
ParagraphStyle pStyles[])
modifyParagraphStyle
public TextChange modifyParagraphStyle(int begin,
int end,
ParagraphStyleModifier modifier)
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.
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.
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.
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