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
-
TextLayout(RichText)
- Constructs a text layout with the specified rich text.
-
TextLayout(RichText, int)
- Constructs a text layout with the specified rich text and line
wrapping style.
-
TextLayout(RichText, int, Locale)
- Constructs a text layout with the specified rich text, line
wrapping style, and locale.
-
TextLayout(RichText, Locale)
- Constructs a text layout with the specified rich text and locale.
-
charWidthAt(TextPositionInfo)
- Returns the advance width of a character in the specified text
position.
-
clone()
- Returns a clone of this layout.
-
draw(Graphics, Point, TextPositionInfo, TextPositionInfo)
- Draws the specified range of this layout to the specified graphics
at the specified location.
-
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.
-
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.
-
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.
-
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.
-
echoCharIsSet()
- Checks if this layout has a character set for echoing.
-
getEchoChar()
- Returns the character to be used for echoing.
-
getLineBeginPositionOver(int)
- Returns the text position information at the beginning of the line
that is laid over the specified y position.
-
getLineBeginPositionOver(TextPositionInfo, int)
- Returns the text position information at the beginning of the line
that is laid over the specified y position.
-
getLineBeginPositionUnder(int)
- Returns the text position information at the beginning of the line
that is laid under the specified y position.
-
getLineBeginPositionUnder(TextPositionInfo, int)
- Returns the text position information at the beginning of the line
that is laid under the specified y position.
-
getLineWrap()
- Returns the line wrapping style.
-
getLocale()
- Returns the locale of this layout.
-
getPreferredCharIncrementSize()
- Returns the preferred character increment size for the scroll of
this layout.
-
getPreferredLineIncrementSize()
- Returns the preferred line increment size for the scroll of
this layout.
-
getSize()
- Returns the size of this layout.
-
getTextPositionAt(int)
- Returns the text position information at the specified index of the
text.
-
getTextPositionAt(Point)
- Returns the text position information at the specified location in the
layout.
-
getTextPositionNearby(TextPositionInfo, int)
- Returns the text position information nearby the specfied text
position information at the specified index of the text.
-
getTextPositionNearby(TextPositionInfo, Point)
- Returns the text position information nearby the specfied text
position information at the specified location in the layout.
-
getTextPositionNextTo(TextPositionInfo)
- Returns the text position information next to the specfied text
position information.
-
getTextPositionPrevTo(TextPositionInfo)
- Returns the text position information previous to the specfied text
position information.
-
invalidate()
- Invalidates the layout.
-
isCharWrap()
- Checks if the line wrapping is done at the character boundary.
-
isLineHeightConstant()
- Tests if the line height is constant.
-
isNoWrap()
- Checks if the line wrapping is done at the line separator.
-
isResizable()
- Checks if the layout is resizable.
-
isWordWrap()
- Checks if the line wrapping is done at the word boundary.
-
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.
-
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.
-
paint(Graphics, Point)
- Paints this layout at the specified location.
-
replace(TextPositionInfo, TextPositionInfo, Text)
- Replaces the specified range of the rich text in this layout with
the specified replacement text object.
-
setEchoChar(char)
- Sets the echo character for this layout.
-
setLineHeightConstant(boolean)
- Sets the line height is constant.
-
setLineWrap(int)
- Sets the line wrapping style.
-
setLocale(Locale)
- Sets the locale of this layout to be the specified locale.
-
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.
-
setSize(Dimension)
- Resizes the layout to the specified dimension.
-
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.
-
setWidth(int)
- Resizes the layout to the specified width.
-
updateLayout(TextChange)
- Updates this layout according to the specified
TextChange
object.
-
updateLayout(TextChange, TextPositionInfo, TextPositionInfo)
- Updates this layout according to the specified
TextChange
object, with the position hints.
-
validate()
- Ensures that a component has a valid layout.
TextLayout
public TextLayout(RichText richText)
- Constructs a text layout with the specified rich text.
- Parameters:
- richText - the rich text to be laid out.
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.
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
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
getSize
public Dimension getSize()
- Returns the size of this layout.
- See Also:
- setSize, setWidth, Visualizable
setSize
public void setSize(Dimension d)
- Resizes the layout to the specified dimension.
- See Also:
- getSize, setWidth, Visualizable
isResizable
public boolean isResizable()
- Checks if the layout is resizable.
- See Also:
- Visualizable
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
clone
public Object clone()
- Returns a clone of this layout.
- Overrides:
- clone in class Object
getLocale
public Locale getLocale()
- Returns the locale of this layout.
setLocale
public void setLocale(Locale locale)
- Sets the locale of this layout to be the specified locale.
getEchoChar
public char getEchoChar()
- Returns the character to be used for echoing.
- See Also:
- setEchoChar, echoCharIsSet, EchoTextScanner, getEchoChar
setEchoChar
public synchronized TextLayoutChange setEchoChar(char c)
- Sets the echo character for this layout.
- See Also:
- getEchoChar, echoCharIsSet, EchoTextScanner, setEchoChar
echoCharIsSet
public boolean echoCharIsSet()
- Checks if this layout has a character set for echoing.
- See Also:
- getEchoChar, setEchoChar, EchoTextScanner, echoCharIsSet
isLineHeightConstant
public boolean isLineHeightConstant()
- Tests if the line height is constant.
setLineHeightConstant
public void setLineHeightConstant(boolean b)
- Sets the line height is constant.
getLineWrap
public final int getLineWrap()
- Returns the line wrapping style.
- See Also:
- CHAR_WRAP, WORD_WRAP, NO_WRAP
isCharWrap
public final boolean isCharWrap()
- Checks if the line wrapping is done at the character boundary.
- See Also:
- getLineWrap, CHAR_WRAP
isWordWrap
public final boolean isWordWrap()
- Checks if the line wrapping is done at the word boundary.
- See Also:
- getLineWrap, WORD_WRAP
isNoWrap
public final boolean isNoWrap()
- Checks if the line wrapping is done at the line separator.
- See Also:
- getLineWrap, NO_WRAP
setLineWrap
public synchronized TextLayoutChange setLineWrap(int lineWrap)
- Sets the line wrapping style.
getPreferredLineIncrementSize
public int getPreferredLineIncrementSize()
- Returns the preferred line increment size for the scroll of
this layout.
- See Also:
- getPreferredSize
getPreferredCharIncrementSize
public int getPreferredCharIncrementSize()
- Returns the preferred character increment size for the scroll of
this layout.
- See Also:
- getPreferredSize
validate
public synchronized void validate()
- Ensures that a component has a valid layout.
- See Also:
- isValid, invalidate
invalidate
public synchronized void invalidate()
- Invalidates the layout. The layout is marked as needing to be laid out.
- See Also:
- isValid, validate
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
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.
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.
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.
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.
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.
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.
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.
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
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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