public class RichText
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
RichText class implements a text with paragraph styles.
The principal operations on a RichText are the
replace, setTextStyle,
modifyTextStyle, setParagraphStyle,
modifyParagraphStyle, and print methods:
replace method replaces the specified range of the
rich text with the specified replacement text and returns the
TextChange object.
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.
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.
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.
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.
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.
| 修飾子とタイプ | フィールドと説明 |
|---|---|
static java.awt.Insets |
DEFAULT_PRINT_INSETS
The constant for the default insets of the printing medium (paper).
|
protected RunArray |
paragraphStyles
The paragraph styles.
|
protected RichTextStyle |
rtStyle
The style of the rich text.
|
protected Text |
text
The text of the rich text.
|
protected TextStyleModifier |
textStyleConstraint
The text style constraint.
|
| 修飾子 | コンストラクタと説明 |
|---|---|
protected |
RichText(RichText richText)
Constructs a rich text that has the same contents as the specified
rich text.
|
|
RichText(RichTextStyle rtStyle)
Constructs an empty rich text with the specified rich text style.
|
|
RichText(java.lang.String string,
RichTextStyle rtStyle)
Constructs a rich text with the specified string and rich text style.
|
|
RichText(Text text,
RichTextStyle rtStyle)
Constructs a rich text with the specified text and rich text style.
|
protected |
RichText(Text text,
RichTextStyle rtStyle,
RunArray paragraphStyles)
Constructs a rich text with the specified text, rich text style,
and paragraph styles.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
java.lang.Object |
clone()
Returns a clone of this rich text.
|
TextAttachment |
getAttachmentAt(int textIndex)
Returns the text attachment at the specified index.
|
int |
getAttachmentCount()
Returns the number of the text attachments in this rich text.
|
char |
getChar(int textIndex)
Returns the character at the specified index.
|
java.text.CharacterIterator |
getCharacterIterator()
Returns the character iterator for this text.
|
java.text.CharacterIterator |
getCharacterIterator(int pos)
Returns the character iterator for this text, with the specified
initial index.
|
java.text.CharacterIterator |
getCharacterIterator(int begin,
int end,
int pos)
Returns the character iterator for this text, with the specified
range and initial index.
|
ParagraphStyle |
getParagraphStyleAt(int textIndex)
Returns the paragraph style at the specified index.
|
int |
getParagraphStyleCount()
Returns the number of the paragraph styles in this rich text.
|
RunArray |
getParagraphStyleRuns()
Returns the paragraph styles as a run array in this rich text.
|
ParagraphStyle[] |
getParagraphStyles()
Returns all paragraph styles in this rich text.
|
ParagraphStyle[] |
getParagraphStyles(int begin,
int end)
Returns the paragraph styles in this rich text.
|
ParagraphStyle[] |
getParagraphStylesPerParagraph(int begin,
int end)
Returns the paragraph styles in this rich text per paragraph.
|
RichTextStyle |
getRichTextStyle()
Returns the
RichTextStyle object of this rich text. |
Text |
getText()
Returns the
Text object in this rich text. |
TextStyle |
getTextStyleAt(int textIndex)
Returns the text style at the specified index.
|
TextStyleModifier |
getTextStyleConstraint()
Returns the text style constraint of this rich text.
|
int |
getTextStyleCount()
Returns the number of the text styles in this rich text.
|
RunArray |
getTextStyleRuns()
Returns the text styles as a run array in this rich text.
|
TextStyle[] |
getTextStyles()
Returns all text styles in this rich text.
|
TextStyle[] |
getTextStyles(int begin,
int end)
Returns the text styles in this rich text.
|
boolean |
isEmpty()
Tests if this rich text has no characters.
|
int |
length()
Returns the length of this rich text.
|
TextChange |
modifyParagraphStyle(int begin,
int end,
ParagraphStyleModifier modifier) |
TextChange |
modifyTextStyle(int begin,
int end,
TextStyleModifier modifier) |
int |
nextParagraphBeginIndexOf(int fromIndex)
Returns the index of the next paragraph begin, starting the search
at the specified index.
|
int |
paragraphBeginIndexOf(int fromIndex)
Returns the index of the paragraph begin, searching backward starting
at the specified index.
|
int |
paragraphEndIndexOf(int fromIndex)
Returns the index of the paragraph end, starting the search at
the specified index.
|
java.util.Enumeration |
paragraphStyles()
Returns an enumeration of the paragraph styles of this text.
|
java.util.Enumeration |
paragraphStyles(int begin,
int end)
Returns an enumeration of the paragraph styles of this text.
|
void |
print(java.awt.PrintJob job)
Prints the rich text to a print device provided from the specified
print job.
|
void |
print(java.awt.PrintJob job,
java.awt.Insets insets,
int lineWrap,
java.lang.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.
|
void |
print(java.awt.PrintJob job,
java.awt.Insets insets,
int lineWrap,
java.lang.String header,
boolean printPageNum,
java.awt.Font headerFooterFont,
java.awt.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.
|
void |
print(java.awt.PrintJob job,
java.lang.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.
|
TextChange |
replace(int begin,
int end,
RichText rep)
Replaces the specified range of this rich text with the specified
replacement rich text object.
|
TextChange |
replace(int begin,
int end,
Text rep)
Replaces the specified range of this rich text with the specified
replacement text object.
|
TextChange |
setBaseTextStyle(TextStyle textStyle)
Sets the base text style of this rich text to be the specified
text style.
|
TextChange |
setParagraphStyle(int begin,
int end,
ParagraphStyle pStyle) |
TextChange |
setParagraphStyles(int begin,
int end,
ParagraphStyle[] pStyles) |
TextChange |
setTextStyle(int begin,
int end,
TextStyle textStyle) |
void |
setTextStyleConstraint(TextStyleModifier constraint)
Sets the text style constraint of this rich text to be the specified
text style modifier.
|
TextChange |
setTextStyles(int begin,
int end,
RunArray textStyles) |
RichText |
subtext(int begin,
int end)
Returns a new rich text that is a subtext of this rich text.
|
java.util.Enumeration |
textStyles()
Returns an enumeration of the text styles of this text.
|
java.util.Enumeration |
textStyles(int begin,
int end)
Returns an enumeration of the text styles of this text.
|
protected Text text
protected RichTextStyle rtStyle
protected RunArray paragraphStyles
protected transient TextStyleModifier textStyleConstraint
public static final java.awt.Insets DEFAULT_PRINT_INSETS
public RichText(RichTextStyle rtStyle)
rtStyle - the rich text style.public RichText(java.lang.String string,
RichTextStyle rtStyle)
string - the initial string.rtStyle - the rich text style.public RichText(Text text, RichTextStyle rtStyle)
text - the initial text.rtStyle - the rich text style.protected RichText(RichText richText)
richText - the rich text.protected RichText(Text text, RichTextStyle rtStyle, RunArray paragraphStyles)
text - the text.rtStyle - the rich text style.paragraphStyles - the paragraph style.public final Text getText()
Text object in this rich text.
An application should not modify the returned text.public final RichTextStyle getRichTextStyle()
RichTextStyle object of this rich text.public final boolean isEmpty()
true if this text has no characters;
false otherwise.Text.isEmpty()public final int length()
Text.length()public final char getChar(int textIndex)
index - an index into this rich text.Text.getChar(int)public final java.text.CharacterIterator getCharacterIterator()
public final java.text.CharacterIterator getCharacterIterator(int pos)
pos - initial iterator position.public final java.text.CharacterIterator getCharacterIterator(int begin,
int end,
int pos)
begin - index of the first character.end - index of the character following the last character.pos - initial iterator position.public final java.util.Enumeration textStyles()
public final java.util.Enumeration textStyles(int begin,
int end)
begin - the beginning index to get styles, inclusive.end - the ending index to get styles, exclusive.public final RunArray getTextStyleRuns()
Text.getTextStyleRuns()public final TextStyle getTextStyleAt(int textIndex)
index - an index into this rich text.jp.kyasu.graphics.Text#getTextStyleAt()public final int getTextStyleCount()
Text.getTextStyleCount()public final TextStyle[] getTextStyles()
Text.getTextStyles()public final TextStyle[] getTextStyles(int begin, int end)
begin - the beginning index to get text styles, inclusive.end - the ending index to get text styles, exclusive.Text.getTextStyles(int, int)public final TextAttachment getAttachmentAt(int textIndex)
index - an index into this rich text.null otherwise.Text.getAttachmentAt(int)public final int getAttachmentCount()
public final java.util.Enumeration paragraphStyles()
public final java.util.Enumeration paragraphStyles(int begin,
int end)
begin - the beginning index to get styles, inclusive.end - the ending index to get styles, exclusive.public final RunArray getParagraphStyleRuns()
public final ParagraphStyle getParagraphStyleAt(int textIndex)
index - an index into this rich text.public final int getParagraphStyleCount()
public final ParagraphStyle[] getParagraphStyles()
public final ParagraphStyle[] getParagraphStyles(int begin, int end)
begin - the beginning index of the text to get paragraph styles,
inclusive.end - the ending index of the text to get paragraph styles,
exclusive.public final ParagraphStyle[] getParagraphStylesPerParagraph(int begin, int end)
begin - the beginning index of the text to get paragraph styles,
inclusive.end - the ending index of the text to get paragraph styles,
exclusive.public RichText subtext(int begin, int end)
begin - the beginning index, inclusive.end - the ending index, exclusive.public final int paragraphBeginIndexOf(int fromIndex)
fromIndex - the index to start the search from.public final int paragraphEndIndexOf(int fromIndex)
fromIndex - the index to start the search from.public final int nextParagraphBeginIndexOf(int fromIndex)
fromIndex - the index to start the search from.-1
if the paragraph is last one.public TextChange setBaseTextStyle(TextStyle textStyle)
textStyle - the text style.TextChange object that provides an
information of changes in this rich text made by this method.public TextStyleModifier getTextStyleConstraint()
setTextStyleConstraint(jp.kyasu.graphics.TextStyleModifier)public void setTextStyleConstraint(TextStyleModifier constraint)
constraint - the text style modifier.getTextStyleConstraint()public java.lang.Object clone()
clone クラス内 java.lang.Objectpublic TextChange replace(int begin, int end, Text rep)
begin - the beginning text position to replace, inclusive.end - the ending text position to replace, exclusive.rep - a replacement Text object.TextChange object that provides an
information of changes in this rich text made by this method.public TextChange replace(int begin, int end, RichText rep)
begin - the beginning text position to replace, inclusive.end - the ending text position to replace, exclusive.rep - a replacement RichText object.TextChange object that provides an
information of changes in this rich text made by this method.public TextChange setTextStyle(int begin, int end, TextStyle textStyle)
public TextChange setTextStyles(int begin, int end, RunArray textStyles)
public TextChange modifyTextStyle(int begin, int end, TextStyleModifier modifier)
public TextChange setParagraphStyle(int begin, int end, ParagraphStyle pStyle)
public TextChange setParagraphStyles(int begin, int end, ParagraphStyle[] pStyles)
public TextChange modifyParagraphStyle(int begin, int end, ParagraphStyleModifier modifier)
public void print(java.awt.PrintJob job)
job - the print job.public void print(java.awt.PrintJob job,
java.lang.String header,
boolean printPageNum)
job - the print job.header - the header string.printPageNum - if true, prints a page number in footer.public void print(java.awt.PrintJob job,
java.awt.Insets insets,
int lineWrap,
java.lang.String header,
boolean printPageNum)
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.public void print(java.awt.PrintJob job,
java.awt.Insets insets,
int lineWrap,
java.lang.String header,
boolean printPageNum,
java.awt.Font headerFooterFont,
java.awt.Color foreground)
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.