public class TextLayout extends TextLines implements Visualizable
TextLayout class implements the layout of the
RichText. The text layout 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.| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected char |
echoChar
The echo character for the layout.
|
protected int |
layoutWidth
The layout width.
|
protected boolean |
lineHeightConstant
The line height is constant or not when the
rtStyle.variableLineHeight is false. |
protected int |
lineWrap
The line wrapping style.
|
protected java.util.Locale |
locale
The locale for the layout.
|
protected int |
preferredLayoutWidth
The preferred layout width.
|
baseline, baselines, layoutHeight, lineBegins, lineHeight, lineTops, remainWidths, richText, rtStyle| コンストラクタと説明 |
|---|
TextLayout(RichText richText)
Constructs a text layout with the specified rich text.
|
TextLayout(RichText richText,
int lineWrap)
Constructs a text layout with the specified rich text and line
wrapping style.
|
TextLayout(RichText richText,
int lineWrap,
java.util.Locale locale)
Constructs a text layout with the specified rich text, line
wrapping style, and locale.
|
TextLayout(RichText richText,
java.util.Locale locale)
Constructs a text layout with the specified rich text and locale.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
int |
charWidthAt(TextPositionInfo posInfo)
Returns the advance width of a character in the specified text
position.
|
java.lang.Object |
clone()
Returns a clone of this layout.
|
protected void |
doLayout(int width)
Lays out the rich text with the specified width.
|
void |
draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end)
Draws the specified range of this layout to the specified graphics
at the specified location.
|
void |
draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor)
Draws the specified range of this layout to the specified graphics
at the specified location, with the specified background color.
|
void |
draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor,
boolean bgFromBegin,
boolean bgToEnd)
Draws the specified range of this layout to the specified
graphics at the specified location, with the specified background
color and various flags.
|
void |
draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor,
boolean bgFromBegin,
boolean bgToEnd,
boolean ignoreIndent)
Draws the specified range of this layout to the specified
graphics at the specified location, with the specified background
color and various flags.
|
void |
draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor,
boolean bgFromBegin,
boolean bgToEnd,
boolean ignoreIndent,
int layoutWidth)
Draws the specified range of this layout to the specified
graphics at the specified location, with the specified background
color, various flags and width for drawing.
|
boolean |
echoCharIsSet()
Checks if this layout has a character set for echoing.
|
char |
getEchoChar()
Returns the character to be used for echoing.
|
TextPositionInfo |
getLineBeginPositionOver(int y)
Returns the text position information at the beginning of the line
that is laid over the specified y position.
|
TextPositionInfo |
getLineBeginPositionOver(TextPositionInfo posInfo,
int y)
Returns the text position information at the beginning of the line
that is laid over the specified y position.
|
TextPositionInfo |
getLineBeginPositionUnder(int y)
Returns the text position information at the beginning of the line
that is laid under the specified y position.
|
TextPositionInfo |
getLineBeginPositionUnder(TextPositionInfo posInfo,
int y)
Returns the text position information at the beginning of the line
that is laid under the specified y position.
|
int |
getLineWrap()
Returns the line wrapping style.
|
java.util.Locale |
getLocale()
Returns the locale of this layout.
|
int |
getPreferredCharIncrementSize()
Returns the preferred character increment size for the scroll of
this layout.
|
int |
getPreferredLineIncrementSize()
Returns the preferred line increment size for the scroll of
this layout.
|
protected TextScanner |
getScanner()
Returns the scanner for this layout.
|
protected TextScanner |
getScanner(java.awt.Graphics g)
Returns the scanner for this layout.
|
java.awt.Dimension |
getSize()
Returns the size of this layout.
|
TextPositionInfo |
getTextPositionAt(int textIndex)
Returns the text position information at the specified index of the
text.
|
protected TextPositionInfo |
getTextPositionAt(int textIndex,
int lineIndex)
Returns the text position information from the specfied text index
and line index.
|
TextPositionInfo |
getTextPositionAt(java.awt.Point point)
Returns the text position information at the specified location in the
layout.
|
TextPositionInfo |
getTextPositionNearby(TextPositionInfo posInfo,
int textIndex)
Returns the text position information nearby the specfied text
position information at the specified index of the text.
|
TextPositionInfo |
getTextPositionNearby(TextPositionInfo posInfo,
java.awt.Point point)
Returns the text position information nearby the specfied text
position information at the specified location in the layout.
|
TextPositionInfo |
getTextPositionNextTo(TextPositionInfo posInfo)
Returns the text position information next to the specfied text
position information.
|
TextPositionInfo |
getTextPositionPrevTo(TextPositionInfo posInfo)
Returns the text position information previous to the specfied text
position information.
|
void |
invalidate()
Invalidates the layout.
|
boolean |
isCharWrap()
Checks if the line wrapping is done at the character boundary.
|
boolean |
isLineHeightConstant()
Tests if the line height is constant.
|
boolean |
isNoWrap()
Checks if the line wrapping is done at the line separator.
|
boolean |
isResizable()
Checks if the layout is resizable.
|
boolean |
isWordWrap()
Checks if the line wrapping is done at the word boundary.
|
TextLayoutChange |
modifyParagraphStyle(TextPositionInfo begin,
TextPositionInfo end,
ParagraphStyleModifier modifier)
Modifies the paragraph style in the specified range of the rich text
in this layout by using the specified paragraph style modifier.
|
TextLayoutChange |
modifyTextStyle(TextPositionInfo begin,
TextPositionInfo end,
TextStyleModifier modifier)
Modifies the text style in the specified range of the rich text in
this layout by using the specified text style modifier.
|
void |
paint(java.awt.Graphics g,
java.awt.Point p)
Paints this layout at the specified location.
|
protected void |
redoLayout(int width)
Re-lays out this layout with the specified width.
|
TextLayoutChange |
replace(TextPositionInfo begin,
TextPositionInfo end,
Text replacement)
Replaces the specified range of the rich text in this layout with
the specified replacement text object.
|
TextLayoutChange |
setEchoChar(char c)
Sets the echo character for this layout.
|
void |
setLineHeightConstant(boolean b)
Sets the line height is constant.
|
TextLayoutChange |
setLineWrap(int lineWrap)
Sets the line wrapping style.
|
protected void |
setLineWrapInner(int lineWrap)
Sets the line wrapping style.
|
void |
setLocale(java.util.Locale locale)
Sets the locale of this layout to be the specified locale.
|
TextLayoutChange |
setParagraphStyle(TextPositionInfo begin,
TextPositionInfo end,
ParagraphStyle pStyle)
Sets the paragraph style in the specified range of the rich text
in this layout to be the specified paragraph style.
|
void |
setSize(java.awt.Dimension d)
Resizes the layout to the specified dimension.
|
TextLayoutChange |
setTextStyle(TextPositionInfo begin,
TextPositionInfo end,
TextStyle textStyle)
Sets the text style in the specified range of the rich text in this
layout to be the specified text style.
|
void |
setWidth(int width)
Resizes the layout to the specified width.
|
TextLayoutChange |
updateLayout(TextChange change)
Updates this layout according to the specified
TextChange
object. |
TextLayoutChange |
updateLayout(TextChange change,
TextPositionInfo beginHint,
TextPositionInfo endHint)
Updates this layout according to the specified
TextChange
object, with the position hints. |
void |
validate()
Ensures that a component has a valid layout.
|
append, append, assert, changeRemainWidths, doLayoutForEmpty, duplicateLastLine, getBaselineAt, getIncompleteTextPositionAt, getIncompleteTextPositionNearby, getIncompleteTextPositionNearby, getLineBeginAt, getLineCount, getLineEndAt, getLineIndexNearby, getLineIndexNearby, getLineIndexNearby, getLineSkipAt, getLineTopAt, getRemainWidthAt, getRichText, getRichTextStyle, getText, getTextLineAt, getTextLineInto, getTextPositionAtLineBegin, invalidateLines, isParagraphMark, isParagraphMarkAt, isValid, markLineAt, markLineBegin, printDebugInfo, reComputeRemainWidths, replace, sublines, unmarkLineAt, unmarkLineBegin, validateLinesprotected int lineWrap
protected int layoutWidth
protected int preferredLayoutWidth
protected java.util.Locale locale
protected boolean lineHeightConstant
rtStyle.variableLineHeight is false.protected char echoChar
public TextLayout(RichText richText)
richText - the rich text to be laid out.public TextLayout(RichText richText, java.util.Locale locale)
richText - the rich text to be laid out.locale - the locale for a layout.public TextLayout(RichText richText, int lineWrap)
richText - the rich text to be laid out.lineWrap - the line wrapping style.RichTextStyle.CHAR_WRAP,
RichTextStyle.WORD_WRAP,
RichTextStyle.NO_WRAPpublic TextLayout(RichText richText, int lineWrap, java.util.Locale locale)
richText - the rich text to be laid out.lineWrap - the line wrapping style.locale - the locale for a layout.RichTextStyle.CHAR_WRAP,
RichTextStyle.WORD_WRAP,
RichTextStyle.NO_WRAPpublic java.awt.Dimension getSize()
getSize インタフェース内 VisualizablesetSize(java.awt.Dimension),
setWidth(int),
Visualizablepublic void setSize(java.awt.Dimension d)
setSize インタフェース内 Visualizabled - the visual object dimension.getSize(),
setWidth(int),
Visualizablepublic boolean isResizable()
isResizable インタフェース内 VisualizableVisualizablepublic void paint(java.awt.Graphics g,
java.awt.Point p)
paint インタフェース内 Visualizableg - the specified graphics.p - the location in the graphics to be painted.Visualizablepublic java.lang.Object clone()
clone インタフェース内 Visualizableclone クラス内 java.lang.Objectpublic java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
public char getEchoChar()
public TextLayoutChange setEchoChar(char c)
public boolean echoCharIsSet()
public boolean isLineHeightConstant()
public void setLineHeightConstant(boolean b)
public final int getLineWrap()
public final boolean isCharWrap()
public final boolean isWordWrap()
public final boolean isNoWrap()
public TextLayoutChange setLineWrap(int lineWrap)
protected void setLineWrapInner(int lineWrap)
public int getPreferredLineIncrementSize()
public int getPreferredCharIncrementSize()
public void validate()
TextLines.isValid(),
invalidate()public void invalidate()
TextLines.isValid(),
validate()public void setWidth(int width)
width - the width of the layout.getSize()public int charWidthAt(TextPositionInfo posInfo)
posInfo - the text position for a character to be measured.public TextPositionInfo getTextPositionAt(int textIndex)
textIndex - the index of the text to search for.null,
if this layout does not have a valid layout.public TextPositionInfo getTextPositionAt(java.awt.Point point)
point - the location to search for.null,
if this layout does not have a valid layout.public TextPositionInfo getTextPositionNearby(TextPositionInfo posInfo, int textIndex)
posInfo - the text position information used as the
starting point for searching. If null, the
searching starts from the beginning or ending
of the layout according to the index of the text.textIndex - the index of the text to search for.public TextPositionInfo getTextPositionNearby(TextPositionInfo posInfo, java.awt.Point point)
posInfo - the text position information used as the starting
point for searching. If null, the searching starts
from the top or bottom of the layout according to
the location.point - the location to search for.public TextPositionInfo getTextPositionNextTo(TextPositionInfo posInfo)
posInfo - the specified text position information.public TextPositionInfo getTextPositionPrevTo(TextPositionInfo posInfo)
posInfo - the specified text position information.public TextPositionInfo getLineBeginPositionOver(int y)
y - the y position to search for.null,
if this layout does not have a valid layout.getLineBeginPositionOver(jp.kyasu.graphics.text.TextPositionInfo, int)public TextPositionInfo getLineBeginPositionOver(TextPositionInfo posInfo, int y)
posInfo - the text position information used as the starting
point for searching. If null, the searching starts
from the top or bottom of the layout according to
the location.y - the y position to search for.null,
if this layout does not have a valid layout.public TextPositionInfo getLineBeginPositionUnder(int y)
y - the y position to search for.null,
if this layout does not have a valid layout.getLineBeginPositionUnder(jp.kyasu.graphics.text.TextPositionInfo, int)public TextPositionInfo getLineBeginPositionUnder(TextPositionInfo posInfo, int y)
posInfo - the text position information used as the starting
point for searching. If null, the searching starts
from the top or bottom of the layout according to
the location.y - the y position to search for.null,
if this layout does not have a valid layout.protected TextPositionInfo getTextPositionAt(int textIndex, int lineIndex)
protected void doLayout(int width)
protected void redoLayout(int width)
public void draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end)
g - the graphics.offset - the offset position to drawbegin - the beginning index of this layout to draw,
inclusive.end - the ending index of this layout to draw,
exclusive.public void draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor)
g - the graphics.offset - the offset position to drawbegin - the beginning index of this layout to draw,
inclusive.end - the ending index of this layout to draw,
exclusive.bgColor - the background color.public void draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor,
boolean bgFromBegin,
boolean bgToEnd)
g - the graphics.offset - the offset position to drawbegin - the beginning index of this layout to draw,
inclusive.end - the ending index of this layout to draw,
exclusive.bgColor - the background color.bgFromBegin - if true, fills the background from the beginning
of the line at the begin index.bgToEnd - if true, fills the background to the ending of
the line at the end index.public void draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor,
boolean bgFromBegin,
boolean bgToEnd,
boolean ignoreIndent)
g - the graphics.offset - the offset position to drawbegin - the beginning index of this layout to draw,
inclusive.end - the ending index of this layout to draw,
exclusive.bgColor - the background color.bgFromBegin - if true, fills the background from the beginning
of the line at the begin index.bgToEnd - if true, fills the background to the ending of
the line at the end index.ignoreIndent - if true, fills the background ignoring the margin
indentation.public void draw(java.awt.Graphics g,
java.awt.Point offset,
TextPositionInfo begin,
TextPositionInfo end,
java.awt.Color bgColor,
boolean bgFromBegin,
boolean bgToEnd,
boolean ignoreIndent,
int layoutWidth)
g - the graphics.offset - the offset position to drawbegin - the beginning index of this layout to draw,
inclusive.end - the ending index of this layout to draw,
exclusive.bgColor - the background color.bgFromBegin - if true, fills the background from the beginning
of the line at the begin index.bgToEnd - if true, fills the background to the ending of
the line at the end index.ignoreIndent - if true, fills the background ignoring the margin
indentation.layoutWidth - the width for drawing.public TextLayoutChange replace(TextPositionInfo begin, TextPositionInfo end, Text replacement)
begin - the beginning text position to replace, inclusive.end - the ending text position to replace, exclusive.rep - a replacement Text object.TextLayoutChange object that provides an
information of changes in the layout made by this method.public TextLayoutChange setTextStyle(TextPositionInfo begin, TextPositionInfo end, TextStyle textStyle)
begin - the beginning text position to set, inclusive.end - the ending text position to set, exclusive.textStyle - the text style.TextLayoutChange object that provides an
information of changes in the layout made by this method.public TextLayoutChange modifyTextStyle(TextPositionInfo begin, TextPositionInfo end, TextStyleModifier modifier)
begin - the beginning text position to modify, inclusive.end - the ending text position to modify, exclusive.modifier - the text style modifier.TextLayoutChange object that provides an
information of changes in the layout made by this method.public TextLayoutChange setParagraphStyle(TextPositionInfo begin, TextPositionInfo end, ParagraphStyle pStyle)
begin - the beginning text position to set, inclusive.end - the ending text position to set, exclusive.pStyle - the paragraph style.TextLayoutChange object that provides an
information of changes in the layout made by this method.public TextLayoutChange modifyParagraphStyle(TextPositionInfo begin, TextPositionInfo end, ParagraphStyleModifier modifier)
begin - the beginning text position to modify, inclusive.end - the ending text position to modify, exclusive.modifier - the paragraph style modifier.TextLayoutChange object that provides an
information of changes in the layout made by this method.public TextLayoutChange updateLayout(TextChange change)
TextChange
object.change - the TextChange object.TextLayoutChange object that provides an
information of changes in the layout made by this method.public TextLayoutChange updateLayout(TextChange change, TextPositionInfo beginHint, TextPositionInfo endHint)
TextChange
object, with the position hints.change - the TextChange object.beginHint - the beginning hint text position.endHint - the ending hint text position.TextLayoutChange object that provides an
information of changes in the layout made by this method.protected TextScanner getScanner(java.awt.Graphics g)
protected TextScanner getScanner()