All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jp.kyasu.graphics.TextLayout

java.lang.Object
   |
   +----jp.kyasu.graphics.TextLines
           |
           +----jp.kyasu.graphics.TextLayout

public class TextLayout
extends TextLines
implements Visualizable
The 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.

Version:
21 Nov 1999
Author:
Kazuki YASUMATSU
See Also:
RichText, TextLines

Constructor Index

 o TextLayout(RichText)
Constructs a text layout with the specified rich text.
 o TextLayout(RichText, int)
Constructs a text layout with the specified rich text and line wrapping style.
 o TextLayout(RichText, int, Locale)
Constructs a text layout with the specified rich text, line wrapping style, and locale.
 o TextLayout(RichText, Locale)
Constructs a text layout with the specified rich text and locale.

Method Index

 o charWidthAt(TextPositionInfo)
Returns the advance width of a character in the specified text position.
 o clone()
Returns a clone of this layout.
 o draw(Graphics, Point, TextPositionInfo, TextPositionInfo)
Draws the specified range of this layout to the specified graphics at the specified location.
 o draw(Graphics, Point, TextPositionInfo, TextPositionInfo, Color)
Draws the specified range of this layout to the specified graphics at the specified location, with the specified background color.
 o draw(Graphics, Point, TextPositionInfo, TextPositionInfo, Color, boolean, boolean)
Draws the specified range of this layout to the specified graphics at the specified location, with the specified background color and various flags.
 o draw(Graphics, Point, TextPositionInfo, TextPositionInfo, Color, boolean, boolean, boolean)
Draws the specified range of this layout to the specified graphics at the specified location, with the specified background color and various flags.
 o draw(Graphics, Point, TextPositionInfo, TextPositionInfo, Color, boolean, boolean, boolean, int)
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.
 o echoCharIsSet()
Checks if this layout has a character set for echoing.
 o getEchoChar()
Returns the character to be used for echoing.
 o getLineBeginPositionOver(int)
Returns the text position information at the beginning of the line that is laid over the specified y position.
 o getLineBeginPositionOver(TextPositionInfo, int)
Returns the text position information at the beginning of the line that is laid over the specified y position.
 o getLineBeginPositionUnder(int)
Returns the text position information at the beginning of the line that is laid under the specified y position.
 o getLineBeginPositionUnder(TextPositionInfo, int)
Returns the text position information at the beginning of the line that is laid under the specified y position.
 o getLineWrap()
Returns the line wrapping style.
 o getLocale()
Returns the locale of this layout.
 o getPreferredCharIncrementSize()
Returns the preferred character increment size for the scroll of this layout.
 o getPreferredLineIncrementSize()
Returns the preferred line increment size for the scroll of this layout.
 o getSize()
Returns the size of this layout.
 o getTextPositionAt(int)
Returns the text position information at the specified index of the text.
 o getTextPositionAt(Point)
Returns the text position information at the specified location in the layout.
 o getTextPositionNearby(TextPositionInfo, int)
Returns the text position information nearby the specfied text position information at the specified index of the text.
 o getTextPositionNearby(TextPositionInfo, Point)
Returns the text position information nearby the specfied text position information at the specified location in the layout.
 o getTextPositionNextTo(TextPositionInfo)
Returns the text position information next to the specfied text position information.
 o getTextPositionPrevTo(TextPositionInfo)
Returns the text position information previous to the specfied text position information.
 o invalidate()
Invalidates the layout.
 o isCharWrap()
Checks if the line wrapping is done at the character boundary.
 o isLineHeightConstant()
Tests if the line height is constant.
 o isNoWrap()
Checks if the line wrapping is done at the line separator.
 o isResizable()
Checks if the layout is resizable.
 o isWordWrap()
Checks if the line wrapping is done at the word boundary.
 o modifyParagraphStyle(TextPositionInfo, TextPositionInfo, ParagraphStyleModifier)
Modifies the paragraph style in the specified range of the rich text in this layout by using the specified paragraph style modifier.
 o modifyTextStyle(TextPositionInfo, TextPositionInfo, TextStyleModifier)
Modifies the text style in the specified range of the rich text in this layout by using the specified text style modifier.
 o paint(Graphics, Point)
Paints this layout at the specified location.
 o replace(TextPositionInfo, TextPositionInfo, Text)
Replaces the specified range of the rich text in this layout with the specified replacement text object.
 o setEchoChar(char)
Sets the echo character for this layout.
 o setLineHeightConstant(boolean)
Sets the line height is constant.
 o setLineWrap(int)
Sets the line wrapping style.
 o setLocale(Locale)
Sets the locale of this layout to be the specified locale.
 o setParagraphStyle(TextPositionInfo, TextPositionInfo, ParagraphStyle)
Sets the paragraph style in the specified range of the rich text in this layout to be the specified paragraph style.
 o setSize(Dimension)
Resizes the layout to the specified dimension.
 o setTextStyle(TextPositionInfo, TextPositionInfo, TextStyle)
Sets the text style in the specified range of the rich text in this layout to be the specified text style.
 o setWidth(int)
Resizes the layout to the specified width.
 o updateLayout(TextChange)
Updates this layout according to the specified TextChange object.
 o updateLayout(TextChange, TextPositionInfo, TextPositionInfo)
Updates this layout according to the specified TextChange object, with the position hints.
 o validate()
Ensures that a component has a valid layout.

Constructors

 o TextLayout
 public TextLayout(RichText richText)
Constructs a text layout with the specified rich text.

Parameters:
richText - the rich text to be laid out.
 o TextLayout
 public TextLayout(RichText richText,
                   Locale locale)
Constructs a text layout with the specified rich text and locale.

Parameters:
richText - the rich text to be laid out.
locale - the locale for a layout.
 o TextLayout
 public TextLayout(RichText richText,
                   int lineWrap)
Constructs a text layout with the specified rich text and line wrapping style.

Parameters:
richText - the rich text to be laid out.
lineWrap - the line wrapping style.
See Also:
CHAR_WRAP, WORD_WRAP, NO_WRAP
 o TextLayout
 public TextLayout(RichText richText,
                   int lineWrap,
                   Locale locale)
Constructs a text layout with the specified rich text, line wrapping style, and locale.

Parameters:
richText - the rich text to be laid out.
lineWrap - the line wrapping style.
locale - the locale for a layout.
See Also:
CHAR_WRAP, WORD_WRAP, NO_WRAP

Methods

 o getSize
 public Dimension getSize()
Returns the size of this layout.

See Also:
setSize, setWidth, Visualizable
 o setSize
 public void setSize(Dimension d)
Resizes the layout to the specified dimension.

See Also:
getSize, setWidth, Visualizable
 o isResizable
 public boolean isResizable()
Checks if the layout is resizable.

See Also:
Visualizable
 o paint
 public void paint(Graphics g,
                   Point p)
Paints this layout at the specified location.

Parameters:
g - the specified graphics.
p - the location in the graphics to be painted.
See Also:
Visualizable
 o clone
 public Object clone()
Returns a clone of this layout.

Overrides:
clone in class Object
 o getLocale
 public Locale getLocale()
Returns the locale of this layout.

 o setLocale
 public void setLocale(Locale locale)
Sets the locale of this layout to be the specified locale.

 o getEchoChar
 public char getEchoChar()
Returns the character to be used for echoing.

See Also:
setEchoChar, echoCharIsSet, EchoTextScanner, getEchoChar
 o setEchoChar
 public synchronized TextLayoutChange setEchoChar(char c)
Sets the echo character for this layout.

See Also:
getEchoChar, echoCharIsSet, EchoTextScanner, setEchoChar
 o echoCharIsSet
 public boolean echoCharIsSet()
Checks if this layout has a character set for echoing.

See Also:
getEchoChar, setEchoChar, EchoTextScanner, echoCharIsSet
 o isLineHeightConstant
 public boolean isLineHeightConstant()
Tests if the line height is constant.

 o setLineHeightConstant
 public void setLineHeightConstant(boolean b)
Sets the line height is constant.

 o getLineWrap
 public final int getLineWrap()
Returns the line wrapping style.

See Also:
CHAR_WRAP, WORD_WRAP, NO_WRAP
 o isCharWrap
 public final boolean isCharWrap()
Checks if the line wrapping is done at the character boundary.

See Also:
getLineWrap, CHAR_WRAP
 o isWordWrap
 public final boolean isWordWrap()
Checks if the line wrapping is done at the word boundary.

See Also:
getLineWrap, WORD_WRAP
 o isNoWrap
 public final boolean isNoWrap()
Checks if the line wrapping is done at the line separator.

See Also:
getLineWrap, NO_WRAP
 o setLineWrap
 public synchronized TextLayoutChange setLineWrap(int lineWrap)
Sets the line wrapping style.

 o getPreferredLineIncrementSize
 public int getPreferredLineIncrementSize()
Returns the preferred line increment size for the scroll of this layout.

See Also:
getPreferredSize
 o getPreferredCharIncrementSize
 public int getPreferredCharIncrementSize()
Returns the preferred character increment size for the scroll of this layout.

See Also:
getPreferredSize
 o validate
 public synchronized void validate()
Ensures that a component has a valid layout.

See Also:
isValid, invalidate
 o invalidate
 public synchronized void invalidate()
Invalidates the layout. The layout is marked as needing to be laid out.

See Also:
isValid, validate
 o setWidth
 public synchronized void setWidth(int width)
Resizes the layout to the specified width. The height of the layout is automatically computed.

Parameters:
width - the width of the layout.
See Also:
getSize
 o charWidthAt
 public int charWidthAt(TextPositionInfo posInfo)
Returns the advance width of a character in the specified text position.

Parameters:
posInfo - the text position for a character to be measured.
Returns:
the advance width of the character in the specified text position.
 o getTextPositionAt
 public synchronized TextPositionInfo getTextPositionAt(int textIndex)
Returns the text position information at the specified index of the text.

Parameters:
textIndex - the index of the text to search for.
Returns:
the text position information; or null, if this layout does not have a valid layout.
 o getTextPositionAt
 public synchronized TextPositionInfo getTextPositionAt(Point point)
Returns the text position information at the specified location in the layout.

Parameters:
point - the location to search for.
Returns:
the text position information; or null, if this layout does not have a valid layout.
 o getTextPositionNearby
 public synchronized TextPositionInfo getTextPositionNearby(TextPositionInfo posInfo,
                                                            int textIndex)
Returns the text position information nearby the specfied text position information at the specified index of the text.

Parameters:
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.
Returns:
the text position information.
 o getTextPositionNearby
 public synchronized TextPositionInfo getTextPositionNearby(TextPositionInfo posInfo,
                                                            Point point)
Returns the text position information nearby the specfied text position information at the specified location in the layout.

Parameters:
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.
Returns:
the text position information.
 o getTextPositionNextTo
 public synchronized TextPositionInfo getTextPositionNextTo(TextPositionInfo posInfo)
Returns the text position information next to the specfied text position information.

Parameters:
posInfo - the specified text position information.
Returns:
the text position information next to the specified text position information.
 o getTextPositionPrevTo
 public synchronized TextPositionInfo getTextPositionPrevTo(TextPositionInfo posInfo)
Returns the text position information previous to the specfied text position information.

Parameters:
posInfo - the specified text position information.
Returns:
the text position information previous to the specified text position information.
 o getLineBeginPositionOver
 public TextPositionInfo getLineBeginPositionOver(int y)
Returns the text position information at the beginning of the line that is laid over the specified y position.

Parameters:
y - the y position to search for.
Returns:
the text position information; or null, if this layout does not have a valid layout.
See Also:
getLineBeginPositionOver
 o getLineBeginPositionOver
 public synchronized 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.

Parameters:
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.
Returns:
the text position information; or null, if this layout does not have a valid layout.
 o getLineBeginPositionUnder
 public TextPositionInfo getLineBeginPositionUnder(int y)
Returns the text position information at the beginning of the line that is laid under the specified y position. If the specified y position is greater than the height of this layout, returns the text position information at the end of the layout.

Parameters:
y - the y position to search for.
Returns:
the text position information; or null, if this layout does not have a valid layout.
See Also:
getLineBeginPositionUnder
 o getLineBeginPositionUnder
 public synchronized 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. If the specified y position is greater than the height of this layout, returns the text position information at the end of the layout.

Parameters:
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.
Returns:
the text position information; or null, if this layout does not have a valid layout.
 o draw
 public void draw(Graphics g,
                  Point offset,
                  TextPositionInfo begin,
                  TextPositionInfo end)
Draws the specified range of this layout to the specified graphics at the specified location.

Parameters:
g - the graphics.
offset - the offset position to draw
begin - the beginning index of this layout to draw, inclusive.
end - the ending index of this layout to draw, exclusive.
 o draw
 public void draw(Graphics g,
                  Point offset,
                  TextPositionInfo begin,
                  TextPositionInfo end,
                  Color bgColor)
Draws the specified range of this layout to the specified graphics at the specified location, with the specified background color.

Parameters:
g - the graphics.
offset - the offset position to draw
begin - the beginning index of this layout to draw, inclusive.
end - the ending index of this layout to draw, exclusive.
bgColor - the background color.
 o draw
 public void draw(Graphics g,
                  Point offset,
                  TextPositionInfo begin,
                  TextPositionInfo end,
                  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.

Parameters:
g - the graphics.
offset - the offset position to draw
begin - 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.
 o draw
 public void draw(Graphics g,
                  Point offset,
                  TextPositionInfo begin,
                  TextPositionInfo end,
                  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.

Parameters:
g - the graphics.
offset - the offset position to draw
begin - 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.
 o draw
 public void draw(Graphics g,
                  Point offset,
                  TextPositionInfo begin,
                  TextPositionInfo end,
                  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.

Parameters:
g - the graphics.
offset - the offset position to draw
begin - 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.
 o replace
 public 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.

Parameters:
begin - the beginning text position to replace, inclusive.
end - the ending text position to replace, exclusive.
rep - a replacement Text object.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.
 o setTextStyle
 public 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.

Parameters:
begin - the beginning text position to set, inclusive.
end - the ending text position to set, exclusive.
textStyle - the text style.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.
 o modifyTextStyle
 public 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.

Parameters:
begin - the beginning text position to modify, inclusive.
end - the ending text position to modify, exclusive.
modifier - the text style modifier.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.
 o setParagraphStyle
 public 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.

Parameters:
begin - the beginning text position to set, inclusive.
end - the ending text position to set, exclusive.
pStyle - the paragraph style.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.
 o modifyParagraphStyle
 public 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.

Parameters:
begin - the beginning text position to modify, inclusive.
end - the ending text position to modify, exclusive.
modifier - the paragraph style modifier.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.
 o updateLayout
 public TextLayoutChange updateLayout(TextChange change)
Updates this layout according to the specified TextChange object.

Parameters:
change - the TextChange object.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.
 o updateLayout
 public synchronized TextLayoutChange updateLayout(TextChange change,
                                                   TextPositionInfo beginHint,
                                                   TextPositionInfo endHint)
Updates this layout according to the specified TextChange object, with the position hints.

Parameters:
change - the TextChange object.
beginHint - the beginning hint text position.
endHint - the ending hint text position.
Returns:
the TextLayoutChange object that provides an information of changes in the layout made by this method.

All Packages  Class Hierarchy  This Package  Previous  Next  Index