All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jp.kyasu.graphics.TextScanner

java.lang.Object
   |
   +----jp.kyasu.graphics.TextScanner

public class TextScanner
extends Object
The TextScanner class scans text to lay out text, to draw text, and to compute the position of text.

Version:
24 Jun 1998
Author:
Kazuki YASUMATSU

Variable Index

 o ATTACHMENT
The stop condition constant that shows the character encountered is an attachment mark.
 o baseline
The baseline of a line.
 o CHAR_NOT_IN_FONT
The stop condition constant that shows the character encountered is not defined in the current font.
 o CROSSED_X
The stop condition constant that shows the scanning runs across the the right edge.
 o destX
The current x position.
 o END_OF_RUN
The stop condition constant that shows the scanning runs to the end.
 o JAVA_BREAK_STOPS
The stop conditions for the first 256 characters.
 o JAVA_STOPS
The stop conditions for the first 256 characters.
 o lastCondition
The last stop condition scanned.
 o lastIndex
The last index scanned.
 o leftMargin
The left margin for scanning.
 o LINE_BREAK
The stop condition constant that shows the character encountered is a line break.
 o LINE_SEPARATOR
The stop condition constant that shows the character encountered is a line separator.
 o lineBegin
The beginning index of a line (inclusive).
 o lineEnd
The ending index of a line (exclusive).
 o lineHeight
The height of a line.
 o LIST_STOPS
The stop conditions for the first 256 characters.
 o NO_STOPS
The stop conditions for the first 256 characters.
 o rightMargin
The right margin (edge) for scanning.
 o runEnd
The ending index in the text for scanning (exclusive).
 o SIMPLE_STOPS
The stop conditions for the first 256 characters.
 o TAB
The stop condition constant that shows the character encountered is a tab character.

Constructor Index

 o TextScanner(RichText, int, Locale)
Constructs a text scanner with the rich text to be scanned, the line wrapping style, and the locale of the text.
 o TextScanner(Text, RichTextStyle, int, Locale)
Constructs a text scanner with the text to be scanned, the rich text style, the line wrapping style, and the locale of the text.

Method Index

 o charWidth(char)
Returns the advance width of the specified character in the text.
 o charWidth(int)
Returns the advance width of the specified character in the text.
 o charWidthAt(int, int, int, TextLineInfo, ParagraphStyle)
Returns the advance width of a character in the specified index of the text with the specified scanning context.
 o doLayoutLine(int, int, int, int, int, int, ParagraphStyle, int[], TextLineInfo)
Breaks text into a line.
 o doLayoutLine(int, int, int, int, int, int, ParagraphStyle, TextLineInfo)
Breaks text into a line.
 o doLayoutLine(int, int, int, int, ParagraphStyle, TextLineInfo)
Breaks text into a line.
 o doLayoutLine(int, int, int, ParagraphStyle, TextLineInfo)
Breaks text into a line.
 o drawLine(Graphics, Point, TextLineInfo, ParagraphStyle)
Draws a line.
 o drawLineFromTo(Graphics, Point, int, int, int, int, int, int, int)
Draws a line from the beginning index to the ending index of text.
 o drawLineFromTo(Graphics, Point, int, int, int, int, int, int, int, int[])
Draws a line from the beginning index to the ending index of text.
 o drawLineFromTo(Graphics, Point, int, int, int, int, int, int, ParagraphStyle)
Draws a line from the beginning index to the ending index of text.
 o drawLineFromTo(Graphics, Point, int, int, int, TextLineInfo, ParagraphStyle)
Draws a line from the beginning index to the ending index of text.
 o drawLineTo(Graphics, Point, int, int, int, int, int, ParagraphStyle)
Draws a line to the specified ending index of text.
 o drawLineTo(Graphics, Point, int, TextLineInfo, ParagraphStyle)
Draws a line to the specified ending index of text.
 o linePositionAt(int, TextLineInfo, ParagraphStyle)
Computes the positin of the character in the text.
 o linePositionAt(Point, int, int, int, int, int)
Computes the positin of the character in the text.
 o linePositionAt(Point, int, int, int, int, int, int[])
Computes the positin of the character in the text.
 o linePositionAt(Point, TextLineInfo, ParagraphStyle)
Computes the positin of the character in the text.
 o setNotInFontChar(char)
Sets the character displayed instead of a character that is not defined in the current font.

Variables

 o destX
 public int destX
The current x position.

 o lastIndex
 public int lastIndex
The last index scanned.

 o leftMargin
 public int leftMargin
The left margin for scanning.

 o rightMargin
 public int rightMargin
The right margin (edge) for scanning.

 o runEnd
 public int runEnd
The ending index in the text for scanning (exclusive).

 o lineBegin
 public int lineBegin
The beginning index of a line (inclusive).

 o lineEnd
 public int lineEnd
The ending index of a line (exclusive).

 o lineHeight
 public int lineHeight
The height of a line.

 o baseline
 public int baseline
The baseline of a line.

 o lastCondition
 public int lastCondition
The last stop condition scanned.

 o END_OF_RUN
 public static final int END_OF_RUN
The stop condition constant that shows the scanning runs to the end.

 o CROSSED_X
 public static final int CROSSED_X
The stop condition constant that shows the scanning runs across the the right edge.

 o TAB
 public static final int TAB
The stop condition constant that shows the character encountered is a tab character.

 o LINE_SEPARATOR
 public static final int LINE_SEPARATOR
The stop condition constant that shows the character encountered is a line separator.

See Also:
LINE_SEPARATOR_CHAR
 o LINE_BREAK
 public static final int LINE_BREAK
The stop condition constant that shows the character encountered is a line break.

See Also:
LINE_BREAK_CHAR
 o CHAR_NOT_IN_FONT
 public static final int CHAR_NOT_IN_FONT
The stop condition constant that shows the character encountered is not defined in the current font.

 o ATTACHMENT
 public static final int ATTACHMENT
The stop condition constant that shows the character encountered is an attachment mark.

See Also:
ATTACHMENT_CHAR
 o NO_STOPS
 public static final int NO_STOPS[]
The stop conditions for the first 256 characters. This constant is used for scanning as is.

 o SIMPLE_STOPS
 public static final int SIMPLE_STOPS[]
The stop conditions for the first 256 characters. This constant is used for ignoring the ANSI control characters.

 o JAVA_STOPS
 public static final int JAVA_STOPS[]
The stop conditions for the first 256 characters. This constant is used for scanning the text without line break, i.e., scanning '\f', '\n' (Text.LINE_SEPARATOR_CHAR) as LINE_SEPARATOR.

See Also:
LINE_SEPARATOR_CHAR, isJavaLineSeparator
 o JAVA_BREAK_STOPS
 public static final int JAVA_BREAK_STOPS[]
The stop conditions for the first 256 characters. This constant is used for scanning the text with line break, i.e., scanning '\f', '\n' (Text.LINE_SEPARATOR_CHAR) as LINE_SEPARATOR, and '\r' (Text.LINE_BREAK_CHAR) as LINE_BREAK.

See Also:
LINE_SEPARATOR_CHAR, LINE_BREAK_CHAR, isJavaLineSeparatorWithBreak
 o LIST_STOPS
 public static final int LIST_STOPS[]
The stop conditions for the first 256 characters. This constant is used for scanning list items.

See Also:
LIST_SEPARATOR_CHAR, isListSeparator

Constructors

 o TextScanner
 public TextScanner(RichText richText,
                    int lineWrap,
                    Locale locale)
Constructs a text scanner with the rich text to be scanned, the line wrapping style, and the locale of the text.

Parameters:
richText - the rich text style.
lineWrap - the line wrapping style.
locale - the locale of the text.
 o TextScanner
 public TextScanner(Text text,
                    RichTextStyle richTextStyle,
                    int lineWrap,
                    Locale locale)
Constructs a text scanner with the text to be scanned, the rich text style, the line wrapping style, and the locale of the text.

Parameters:
text - the text to be scanned.
richTextStyle - the rich text style.
lineWrap - the line wrapping style.
locale - the locale of the text.

Methods

 o doLayoutLine
 public int doLayoutLine(int beginIndex,
                         int compositionWidth,
                         int lineTop,
                         ParagraphStyle pStyle,
                         TextLineInfo lineInfo)
Breaks text into a line.

Parameters:
beginIndex - the beginning index of text to scan.
compositionWidth - the composition width of a line.
lineTop - the top position of a line.
pStyle - the paragraph style of a line.
lineInfo - the line information into which the scanning results are stored.
Returns:
the next line top position, or -1 if no more layout needed.
 o doLayoutLine
 public int doLayoutLine(int beginIndex,
                         int startX,
                         int compositionWidth,
                         int lineTop,
                         ParagraphStyle pStyle,
                         TextLineInfo lineInfo)
Breaks text into a line.

Parameters:
beginIndex - the beginning index of text to scan.
startX - the starting x position to scan.
compositionWidth - the composition width of a line.
lineTop - the top position of a line.
pStyle - the paragraph style of a line.
lineInfo - the line information into which the scanning results are stored.
Returns:
the next line top position, or -1 if no more layout needed.
 o doLayoutLine
 public int doLayoutLine(int beginIndex,
                         int startX,
                         int leftMgn,
                         int rightMgn,
                         int tabW,
                         int lineTop,
                         ParagraphStyle pStyle,
                         TextLineInfo lineInfo)
Breaks text into a line.

Parameters:
beginIndex - the beginning index of text to scan.
startX - the starting x position to scan.
leftMgn - the left margin of a line.
rightMgn - the right margin (edge) of a line.
tabW - the tab width used to scan.
lineTop - the top position of a line.
pStyle - the paragraph style of a line.
lineInfo - the line information into which the scanning results are stored.
Returns:
the next line top position, or -1 if no more layout needed.
 o doLayoutLine
 public int doLayoutLine(int beginIndex,
                         int startX,
                         int leftMgn,
                         int rightMgn,
                         int tabW,
                         int lineTop,
                         ParagraphStyle pStyle,
                         int stops[],
                         TextLineInfo lineInfo)
Breaks text into a line.

Parameters:
beginIndex - the beginning index of text to scan.
startX - the starting x position to scan.
leftMgn - the left margin of a line.
rightMgn - the right margin (edge) of a line.
tabW - the tab width used to scan.
lineTop - the top position of a line.
pStyle - the paragraph style of a line.
stops - the stop conditions for scanning.
lineInfo - the line information into which the scanning results are stored.
Returns:
the next line top position, or -1 if no more layout needed.
 o drawLine
 public void drawLine(Graphics g,
                      Point offset,
                      TextLineInfo lineInfo,
                      ParagraphStyle pStyle)
Draws a line.

Parameters:
g - the graphics.
offset - the offset position to draw.
lineInfo - the line information of a line to be drawn.
pStyle - the paragraph style of a line.
 o drawLineTo
 public void drawLineTo(Graphics g,
                        Point offset,
                        int endIndex,
                        TextLineInfo lineInfo,
                        ParagraphStyle pStyle)
Draws a line to the specified ending index of text.

Parameters:
g - the graphics.
offset - the offset position to draw.
endIndex - the ending index of text to draw. (exclusive)
lineInfo - the line information of a line to be drawn.
pStyle - the paragraph style of a line.
 o drawLineTo
 public void drawLineTo(Graphics g,
                        Point offset,
                        int lineBegin,
                        int endIndex,
                        int remainWidth,
                        int lineHeight,
                        int baseline,
                        ParagraphStyle pStyle)
Draws a line to the specified ending index of text.

Parameters:
g - the graphics.
offset - the offset position to draw.
lineBegin - the beginning index of a line. (inclusive)
endIndex - the ending index of text to draw. (exclusive)
remainWidth - the remaining width (space) of a line.
lineHeight - the height of a line.
baseline - the baseline of a line.
pStyle - the paragraph style of a line.
 o drawLineFromTo
 public void drawLineFromTo(Graphics g,
                            Point offset,
                            int startX,
                            int beginIndex,
                            int endIndex,
                            TextLineInfo lineInfo,
                            ParagraphStyle pStyle)
Draws a line from the beginning index to the ending index of text.

Parameters:
g - the graphics.
offset - the offset position to draw.
startX - the starting x position to draw.
beginIndex - the beginning index of text to draw. (inclusive)
endIndex - the ending index of text to draw. (exclusive)
lineInfo - the line information of a line to be drawn.
pStyle - the paragraph style of a line.
 o drawLineFromTo
 public void drawLineFromTo(Graphics g,
                            Point offset,
                            int startX,
                            int beginIndex,
                            int endIndex,
                            int remainWidth,
                            int lineHeight,
                            int baseline,
                            ParagraphStyle pStyle)
Draws a line from the beginning index to the ending index of text.

Parameters:
g - the graphics.
offset - the offset position to draw.
startX - the starting x position to draw.
beginIndex - the beginning index of text to draw. (inclusive)
endIndex - the ending index of text to draw. (exclusive)
remainWidth - the remaining width (space) of a line.
lineHeight - the height of a line.
baseline - the baseline of a line.
pStyle - the paragraph style of a line.
 o drawLineFromTo
 public void drawLineFromTo(Graphics g,
                            Point offset,
                            int startX,
                            int beginIndex,
                            int endIndex,
                            int lineHeight,
                            int baseline,
                            int leftMgn,
                            int tabW)
Draws a line from the beginning index to the ending index of text.

Parameters:
g - the graphics.
offset - the offset position to draw.
startX - the starting x position to draw.
beginIndex - the beginning index of text to draw. (inclusive)
endIndex - the ending index of text to draw. (exclusive)
lineHeight - the height of a line.
baseline - the baseline of a line.
leftMgn - the left margin of a line.
tabW - the tab width used to scan.
 o drawLineFromTo
 public void drawLineFromTo(Graphics g,
                            Point offset,
                            int startX,
                            int beginIndex,
                            int endIndex,
                            int lineHeight,
                            int baseline,
                            int leftMgn,
                            int tabW,
                            int stops[])
Draws a line from the beginning index to the ending index of text.

Parameters:
g - the graphics.
offset - the offset position to draw.
startX - the starting x position to draw.
beginIndex - the beginning index of text to draw. (inclusive)
endIndex - the ending index of text to draw. (exclusive)
lineHeight - the height of a line.
baseline - the baseline of a line.
leftMgn - the left margin of a line.
tabW - the tab width used to scan.
stops - the stop conditions for scanning.
 o linePositionAt
 public int[] linePositionAt(int textIndex,
                             TextLineInfo lineInfo,
                             ParagraphStyle pStyle)
Computes the positin of the character in the text.

Parameters:
textIndex - thea
lineInfo - the information of a line where the character is in.
pStyle - the paragraph style of a line.
Returns:
the computed index and x position of the character.
 o linePositionAt
 public int[] linePositionAt(Point point,
                             TextLineInfo lineInfo,
                             ParagraphStyle pStyle)
Computes the positin of the character in the text.

Parameters:
point - the character position in the text.
lineInfo - the information of a line where the character is in.
pStyle - the paragraph style of a line.
Returns:
the computed index and x position of the character.
 o linePositionAt
 public int[] linePositionAt(Point point,
                             int startX,
                             int beginIndex,
                             int endIndex,
                             int leftMgn,
                             int tabW)
Computes the positin of the character in the text.

Parameters:
point - the character position in the text.
startX - the starting x position to scan.
beginIndex - the beginning index of a line where the character is in.
endIndex - the ending index of a line where the character is in.
leftMgn - the left margin of a line.
tabW - the tab width used to scan.
Returns:
the computed index and x position of the character.
 o linePositionAt
 public int[] linePositionAt(Point point,
                             int startX,
                             int beginIndex,
                             int endIndex,
                             int leftMgn,
                             int tabW,
                             int stops[])
Computes the positin of the character in the text.

Parameters:
point - the character position in the text.
startX - the starting x position to scan.
beginIndex - the beginning index of a line where the character is in.
endIndex - the ending index of a line where the character is in.
leftMgn - the left margin of a line.
tabW - the tab width used to scan.
stops - the stop conditions for scanning.
Returns:
the computed index and x position of the character.
 o setNotInFontChar
 public void setNotInFontChar(char ch)
Sets the character displayed instead of a character that is not defined in the current font.

 o charWidth
 public int charWidth(int ch)
Returns the advance width of the specified character in the text.

Parameters:
ch - the character to be measured.
Returns:
the advance width of the specified character.
 o charWidth
 public int charWidth(char ch)
Returns the advance width of the specified character in the text.

Parameters:
ch - the character to be measured.
Returns:
the advance width of the specified character.
 o charWidthAt
 public int charWidthAt(int textIndex,
                        int startX,
                        int layoutWidth,
                        TextLineInfo lineInfo,
                        ParagraphStyle pStyle)
Returns the advance width of a character in the specified index of the text with the specified scanning context.

Parameters:
textIndex - the index of a character to be measured.
startX - the starting x position to scan.
layoutWidth - the composition width.
lineInfo - the information of a line where a character is in.
pStyle - the paragraph style of a line.
Returns:
the advance width of the specified character.

All Packages  Class Hierarchy  This Package  Previous  Next  Index