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
-
ATTACHMENT
- The stop condition constant that shows the character encountered
is an attachment mark.
-
baseline
- The baseline of a line.
-
CHAR_NOT_IN_FONT
- The stop condition constant that shows the character encountered
is not defined in the current font.
-
CROSSED_X
- The stop condition constant that shows the scanning runs across the
the right edge.
-
destX
- The current x position.
-
END_OF_RUN
- The stop condition constant that shows the scanning runs to the end.
-
JAVA_BREAK_STOPS
- The stop conditions for the first 256 characters.
-
JAVA_STOPS
- The stop conditions for the first 256 characters.
-
lastCondition
- The last stop condition scanned.
-
lastIndex
- The last index scanned.
-
leftMargin
- The left margin for scanning.
-
LINE_BREAK
- The stop condition constant that shows the character encountered
is a line break.
-
LINE_SEPARATOR
- The stop condition constant that shows the character encountered
is a line separator.
-
lineBegin
- The beginning index of a line (inclusive).
-
lineEnd
- The ending index of a line (exclusive).
-
lineHeight
- The height of a line.
-
LIST_STOPS
- The stop conditions for the first 256 characters.
-
NO_STOPS
- The stop conditions for the first 256 characters.
-
rightMargin
- The right margin (edge) for scanning.
-
runEnd
- The ending index in the text for scanning (exclusive).
-
SIMPLE_STOPS
- The stop conditions for the first 256 characters.
-
TAB
- The stop condition constant that shows the character encountered
is a tab character.
-
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.
-
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.
-
charWidth(char)
- Returns the advance width of the specified character in the text.
-
charWidth(int)
- Returns the advance width of the specified character in the text.
-
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.
-
doLayoutLine(int, int, int, int, int, int, ParagraphStyle, int[], TextLineInfo)
- Breaks text into a line.
-
doLayoutLine(int, int, int, int, int, int, ParagraphStyle, TextLineInfo)
- Breaks text into a line.
-
doLayoutLine(int, int, int, int, ParagraphStyle, TextLineInfo)
- Breaks text into a line.
-
doLayoutLine(int, int, int, ParagraphStyle, TextLineInfo)
- Breaks text into a line.
-
drawLine(Graphics, Point, TextLineInfo, ParagraphStyle)
- Draws a line.
-
drawLineFromTo(Graphics, Point, int, int, int, int, int, int, int)
- Draws a line from the beginning index to the ending index of text.
-
drawLineFromTo(Graphics, Point, int, int, int, int, int, int, int, int[])
- Draws a line from the beginning index to the ending index of text.
-
drawLineFromTo(Graphics, Point, int, int, int, int, int, int, ParagraphStyle)
- Draws a line from the beginning index to the ending index of text.
-
drawLineFromTo(Graphics, Point, int, int, int, TextLineInfo, ParagraphStyle)
- Draws a line from the beginning index to the ending index of text.
-
drawLineTo(Graphics, Point, int, int, int, int, int, ParagraphStyle)
- Draws a line to the specified ending index of text.
-
drawLineTo(Graphics, Point, int, TextLineInfo, ParagraphStyle)
- Draws a line to the specified ending index of text.
-
linePositionAt(int, TextLineInfo, ParagraphStyle)
- Computes the positin of the character in the text.
-
linePositionAt(Point, int, int, int, int, int)
- Computes the positin of the character in the text.
-
linePositionAt(Point, int, int, int, int, int, int[])
- Computes the positin of the character in the text.
-
linePositionAt(Point, TextLineInfo, ParagraphStyle)
- Computes the positin of the character in the text.
-
setNotInFontChar(char)
- Sets the character displayed instead of a character that is not
defined in the current font.
destX
public int destX
- The current x position.
lastIndex
public int lastIndex
- The last index scanned.
leftMargin
public int leftMargin
- The left margin for scanning.
rightMargin
public int rightMargin
- The right margin (edge) for scanning.
runEnd
public int runEnd
- The ending index in the text for scanning (exclusive).
lineBegin
public int lineBegin
- The beginning index of a line (inclusive).
lineEnd
public int lineEnd
- The ending index of a line (exclusive).
lineHeight
public int lineHeight
- The height of a line.
baseline
public int baseline
- The baseline of a line.
lastCondition
public int lastCondition
- The last stop condition scanned.
END_OF_RUN
public static final int END_OF_RUN
- The stop condition constant that shows the scanning runs to the end.
CROSSED_X
public static final int CROSSED_X
- The stop condition constant that shows the scanning runs across the
the right edge.
TAB
public static final int TAB
- The stop condition constant that shows the character encountered
is a tab character.
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
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
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.
ATTACHMENT
public static final int ATTACHMENT
- The stop condition constant that shows the character encountered
is an attachment mark.
- See Also:
- ATTACHMENT_CHAR
NO_STOPS
public static final int NO_STOPS[]
- The stop conditions for the first 256 characters. This constant is
used for scanning as is.
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.
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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
setNotInFontChar
public void setNotInFontChar(char ch)
- Sets the character displayed instead of a character that is not
defined in the current font.
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.
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.
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