| java.lang.Object com.ibm.richtext.textformat.MFormatter com.ibm.richtext.textformat.AsyncFormatter
AsyncFormatter | final class AsyncFormatter extends MFormatter implements Runnable(Code) | | This class implements MFormatter. It maintains a table of
LayoutInfo instances which contain layout information
for each line in the text. This class formats lines on demand,
and creates a low-priority thread to format text in the background.
Note that, at times, some text may not have been formatted, especially
if the text is large.
The line table is an array of LayoutInfo objects, which expands as needed to hold
all computed lines in the text. The line table consists of three
regions: a "positive" region, a "gap," and a "negative" region.
In the positive region, character and graphics offsets are positive
integers, computed from the beginning of the text / display. In the
gap, line table entries are null. New lines may be inserted into the gap.
In the negative region, character and graphics offsets are negative;
their absolute values indicate distances from the end of the text / display.
The fLTPosEnd member gives the index in the line table of the
last positive entry. The fLTNegStart gives the index of first
negative entry. If there are no negative entries, fLTNegStart is
equal to fLTSize, the size of the line table.
Changes to the line table occur only in the formatText() method.
This method calls LineLayout.layout() for each line to format.
author: John Raley See Also: MFormatter See Also: LineLayout See Also: LayoutContext See Also: LayoutInfo |
Method Summary | |
public void | checkTimeStamp() | public synchronized void | draw(Graphics g, Rectangle drawArea, Point origin) Display text in drawArea. | public synchronized void | draw(Graphics g, Rectangle drawArea, Point origin, TextOffset selStart, TextOffset selStop, Color highlight) | public synchronized void | drawCaret(Graphics g, TextOffset offset, Point origin, Color strongCaretColor, Color weakCaretColor) Draw the caret(s) associated with the given offset into the given Graphics. | public synchronized TextOffset | findInsertionOffset(TextOffset result, TextOffset prevOffset, short dir) Compute the offset resulting from moving from a previous offset in direction dir.
For arrow keys.
Parameters: result - the offset to modify and return. | public synchronized TextOffset | findNewInsertionOffset(TextOffset result, TextOffset origOffset, TextOffset prevOffset, short dir) Compute the offset resulting from moving from a previous offset, starting at an original offset, in direction dir.
For arrow keys. | public synchronized void | formatToHeight(int reqHeight) Format text to given height. | public synchronized int | formattedHeight() Return the actual pixel length of the text which has been formatted. | public synchronized Rectangle | getBoundingRect(TextOffset offset1, TextOffset offset2, Point origin, boolean tight) Given two offsets in the text, return a rectangle which encloses the lines containing the offsets. | public synchronized void | getBoundingRect(Rectangle r, TextOffset offset1, TextOffset offset2, Point origin, boolean tight) | public synchronized Rectangle | getCaretRect(TextOffset offset, Point origin) Given an offset, return the Rectangle bounding the caret at the offset. | public AttributeMap | getDefaultValues() | public synchronized int | getLineCount() | public synchronized int | lineAtHeight(int height) Return the number of the line at the given graphic height. | public synchronized int | lineBound() Return the number of pixels along the line dimension. | public synchronized int | lineContaining(int charIndex) | public synchronized int | lineContaining(TextOffset offset) | public synchronized int | lineGraphicStart(int lineNumber) | public synchronized boolean | lineIsLeftToRight(int lineNumber) | public synchronized int | lineRangeLimit(int lineNumber) | public synchronized int | lineRangeLow(int lineNumber) | public synchronized int | maxX() Return the horizontal extent of the text, in pixels. | public synchronized int | maxY() Return the vertical extent of the text, in pixels. | public synchronized int | minX() | public synchronized int | minY() | public synchronized TextOffset | pointToTextOffset(TextOffset result, int px, int py, Point origin, TextOffset anchor, boolean infiniteMode) Given a screen location p, return the offset of the character in the text nearest to p. | public void | run() Perform periodic background formatting. | public synchronized void | setLineBound(int lineBound) Specify the lineBound in pixels. | public synchronized void | setWrap(boolean wrap) Specify whether to wrap lines using the line dimension. | public synchronized void | stopBackgroundFormatting() | public Rectangle | updateFormat(int afStart, int afLength, Rectangle viewRect, Point origin) Reformat text after a change.
After the formatter's text changes, call this method to reformat. | public synchronized boolean | wrap() Return true if lines are wrapped using the line dimension. |
AsyncFormatter | AsyncFormatter(MConstText text, AttributeMap defaultValues, int lineBound, boolean wrap, Graphics g)(Code) | | Create an AsyncFormatter.
Parameters: text - the text to format Parameters: lineBound - length to which lines are foramtted Parameters: wrap - true if text should be "line wrapped" (formatted to fit destination area) |
checkTimeStamp | public void checkTimeStamp()(Code) | | |
draw | public synchronized void draw(Graphics g, Rectangle drawArea, Point origin)(Code) | | Display text in drawArea. Does not reformat text.
Parameters: g - the Graphics object in which to draw Parameters: drawArea - the rectangle, in g's coordinate system, in which to draw Parameters: origin - the top-left corner of the text, in g's coordinate system |
drawCaret | public synchronized void drawCaret(Graphics g, TextOffset offset, Point origin, Color strongCaretColor, Color weakCaretColor)(Code) | | Draw the caret(s) associated with the given offset into the given Graphics.
Parameters: g - the Graphics to draw into Parameters: offset - the offset in the text for which the caret is drawn Parameters: origin - the top-left corner of the text, in the display's coordinate system Parameters: strongCaretColor - the color of the strong caret Parameters: weakCaretColor - the color of the weak caret (if any) |
findInsertionOffset | public synchronized TextOffset findInsertionOffset(TextOffset result, TextOffset prevOffset, short dir)(Code) | | Compute the offset resulting from moving from a previous offset in direction dir.
For arrow keys.
Parameters: result - the offset to modify and return. may be null, if so a new offset is allocated, modified, and returned. Parameters: previousOffset - the insertion offset prior to the arrow key press. Parameters: direction - the direction of the arrow key (eUp, eDown, eLeft, or eRight) |
findNewInsertionOffset | public synchronized TextOffset findNewInsertionOffset(TextOffset result, TextOffset origOffset, TextOffset prevOffset, short dir)(Code) | | Compute the offset resulting from moving from a previous offset, starting at an original offset, in direction dir.
For arrow keys. Use this for "smart" up/down keys.
Parameters: result - the offset to modify and return. May be null, if so a new offset is allocated, modified, and returned. Parameters: origOffset - the offset at which an up-down arrow key sequence began. Parameters: prevOffset - the insertion offset prior to the arrow key press Parameters: dir - the direction of the arrow key (eUp, eDown, eLeft, or eRight) |
formatToHeight | public synchronized void formatToHeight(int reqHeight)(Code) | | Format text to given height.
Parameters: height - the height to which text will be formatted. |
formattedHeight | public synchronized int formattedHeight()(Code) | | Return the actual pixel length of the text which has been formatted.
|
getBoundingRect | public synchronized Rectangle getBoundingRect(TextOffset offset1, TextOffset offset2, Point origin, boolean tight)(Code) | | Given two offsets in the text, return a rectangle which encloses the lines containing the offsets.
Offsets do not need to be ordered or nonnegative.
offset1,offset2 offsets into the text Parameters: origin - the top-left corner of the text, in the display's coordinate system |
getCaretRect | public synchronized Rectangle getCaretRect(TextOffset offset, Point origin)(Code) | | Given an offset, return the Rectangle bounding the caret at the offset.
Parameters: offset - an offset into the text Parameters: origin - the top-left corner of the text, in the display's coordinate system a Rectangle bounding the caret. |
getLineCount | public synchronized int getLineCount()(Code) | | |
lineAtHeight | public synchronized int lineAtHeight(int height)(Code) | | Return the number of the line at the given graphic height.
If height is greater than full height, return line count.
|
lineBound | public synchronized int lineBound()(Code) | | Return the number of pixels along the line dimension.
|
lineContaining | public synchronized int lineContaining(int charIndex)(Code) | | |
lineGraphicStart | public synchronized int lineGraphicStart(int lineNumber)(Code) | | |
lineIsLeftToRight | public synchronized boolean lineIsLeftToRight(int lineNumber)(Code) | | |
lineRangeLimit | public synchronized int lineRangeLimit(int lineNumber)(Code) | | |
lineRangeLow | public synchronized int lineRangeLow(int lineNumber)(Code) | | |
maxX | public synchronized int maxX()(Code) | | Return the horizontal extent of the text, in pixels.
This returns an approximation based on the currently formatted text.
|
maxY | public synchronized int maxY()(Code) | | Return the vertical extent of the text, in pixels.
This returns an approximation based on the currently formatted text.
|
minX | public synchronized int minX()(Code) | | |
minY | public synchronized int minY()(Code) | | |
pointToTextOffset | public synchronized TextOffset pointToTextOffset(TextOffset result, int px, int py, Point origin, TextOffset anchor, boolean infiniteMode)(Code) | | Given a screen location p, return the offset of the character in the text nearest to p.
|
run | public void run()(Code) | | Perform periodic background formatting.
|
setLineBound | public synchronized void setLineBound(int lineBound)(Code) | | Specify the lineBound in pixels. If line wrapping is on, lines
will be wrapped to this value.
Parameters: lineBound - the distance, in pixels, used to wrap lines. |
setWrap | public synchronized void setWrap(boolean wrap)(Code) | | Specify whether to wrap lines using the line dimension.
Parameters: wrap - if true lines will be wrapped; otherwise new lines will only bestarted when a newline is encountered. |
stopBackgroundFormatting | public synchronized void stopBackgroundFormatting()(Code) | | |
updateFormat | public Rectangle updateFormat(int afStart, int afLength, Rectangle viewRect, Point origin)(Code) | | Reformat text after a change.
After the formatter's text changes, call this method to reformat. Does
not redraw.
Parameters: afStart - the offset into the text where modification began; ie, thefirst character in the text which is "different" in some way. Does nothave to be nonnegative. Parameters: afLength - the number of new or changed characters in the text. Should neverbe less than 0. Parameters: viewRect - the Rectangle in which the text will be displayed. This is needed forreturning the "damaged" area - the area of the screen in which the text must be redrawn. Parameters: origin - the top-left corner of the text, in the display's coordinate system |
Methods inherited from com.ibm.richtext.textformat.MFormatter | public static MFormatter createFormatter(MConstText text, AttributeMap defaultValues, int lineBound, boolean wrap, Graphics g)(Code)(Java Doc) abstract public void draw(Graphics g, Rectangle drawArea, Point origin, TextOffset selStart, TextOffset selStop, Color highlight)(Code)(Java Doc) abstract public void draw(Graphics g, Rectangle drawArea, Point origin)(Code)(Java Doc) abstract public void drawCaret(Graphics g, TextOffset offset, Point origin, Color strongCaretColor, Color weakCaretColor)(Code)(Java Doc) abstract public TextOffset findInsertionOffset(TextOffset result, TextOffset previousOffset, short direction)(Code)(Java Doc) abstract public TextOffset findNewInsertionOffset(TextOffset result, TextOffset initialOffset, TextOffset previousOffset, short direction)(Code)(Java Doc) abstract public void formatToHeight(int height)(Code)(Java Doc) abstract public int formattedHeight()(Code)(Java Doc) abstract public Rectangle getBoundingRect(TextOffset offset1, TextOffset offset2, Point origin, boolean tight)(Code)(Java Doc) abstract public void getBoundingRect(Rectangle boundingRect, TextOffset offset1, TextOffset offset2, Point origin, boolean tight)(Code)(Java Doc) abstract public Rectangle getCaretRect(TextOffset offset, Point origin)(Code)(Java Doc) abstract public AttributeMap getDefaultValues()(Code)(Java Doc) abstract public int getLineCount()(Code)(Java Doc) abstract public int lineAtHeight(int height)(Code)(Java Doc) abstract public int lineBound()(Code)(Java Doc) abstract public int lineContaining(int index)(Code)(Java Doc) abstract public int lineContaining(TextOffset offset)(Code)(Java Doc) abstract public int lineGraphicStart(int lineNumber)(Code)(Java Doc) abstract public boolean lineIsLeftToRight(int lineNumber)(Code)(Java Doc) abstract public int lineRangeLimit(int lineNumber)(Code)(Java Doc) abstract public int lineRangeLow(int lineNumber)(Code)(Java Doc) abstract public int maxX()(Code)(Java Doc) abstract public int maxY()(Code)(Java Doc) abstract public int minX()(Code)(Java Doc) abstract public int minY()(Code)(Java Doc) abstract public TextOffset pointToTextOffset(TextOffset result, int px, int py, Point origin, TextOffset anchor, boolean infiniteMode)(Code)(Java Doc) abstract public void setLineBound(int lineBound)(Code)(Java Doc) abstract public void setWrap(boolean wrap)(Code)(Java Doc) abstract public void stopBackgroundFormatting()(Code)(Java Doc) abstract public Rectangle updateFormat(int afStart, int afLength, Rectangle viewRect, Point origin)(Code)(Java Doc) abstract public boolean wrap()(Code)(Java Doc)
|
|
|