Java Doc for AsyncFormatter.java in  » Internationalization-Localization » icu4j » com » ibm » richtext » textformat » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.richtext.textformat 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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



Field Summary
final static  StringCOPYRIGHT
    

Constructor Summary
 AsyncFormatter(MConstText text, AttributeMap defaultValues, int lineBound, boolean wrap, Graphics g)
     Create an AsyncFormatter.

Method Summary
public  voidcheckTimeStamp()
    
public synchronized  voiddraw(Graphics g, Rectangle drawArea, Point origin)
     Display text in drawArea.
public synchronized  voiddraw(Graphics g, Rectangle drawArea, Point origin, TextOffset selStart, TextOffset selStop, Color highlight)
    
public synchronized  voiddrawCaret(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  TextOffsetfindInsertionOffset(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  TextOffsetfindNewInsertionOffset(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  voidformatToHeight(int reqHeight)
     Format text to given height.
public synchronized  intformattedHeight()
     Return the actual pixel length of the text which has been formatted.
public synchronized  RectanglegetBoundingRect(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  voidgetBoundingRect(Rectangle r, TextOffset offset1, TextOffset offset2, Point origin, boolean tight)
    
public synchronized  RectanglegetCaretRect(TextOffset offset, Point origin)
     Given an offset, return the Rectangle bounding the caret at the offset.
public  AttributeMapgetDefaultValues()
    
public synchronized  intgetLineCount()
    
public synchronized  intlineAtHeight(int height)
     Return the number of the line at the given graphic height.
public synchronized  intlineBound()
     Return the number of pixels along the line dimension.
public synchronized  intlineContaining(int charIndex)
    
public synchronized  intlineContaining(TextOffset offset)
    
public synchronized  intlineGraphicStart(int lineNumber)
    
public synchronized  booleanlineIsLeftToRight(int lineNumber)
    
public synchronized  intlineRangeLimit(int lineNumber)
    
public synchronized  intlineRangeLow(int lineNumber)
    
public synchronized  intmaxX()
     Return the horizontal extent of the text, in pixels.
public synchronized  intmaxY()
     Return the vertical extent of the text, in pixels.
public synchronized  intminX()
    
public synchronized  intminY()
    
public synchronized  TextOffsetpointToTextOffset(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  voidrun()
     Perform periodic background formatting.
public synchronized  voidsetLineBound(int lineBound)
     Specify the lineBound in pixels.
public synchronized  voidsetWrap(boolean wrap)
     Specify whether to wrap lines using the line dimension.
public synchronized  voidstopBackgroundFormatting()
    
public  RectangleupdateFormat(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  booleanwrap()
     Return true if lines are wrapped using the line dimension.

Field Detail
COPYRIGHT
final static String COPYRIGHT(Code)




Constructor Detail
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)




Method Detail
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




draw
public synchronized void draw(Graphics g, Rectangle drawArea, Point origin, TextOffset selStart, TextOffset selStop, Color highlight)(Code)



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



getBoundingRect
public synchronized void getBoundingRect(Rectangle r, TextOffset offset1, TextOffset offset2, Point origin, boolean tight)(Code)



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.



getDefaultValues
public AttributeMap getDefaultValues()(Code)



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)



lineContaining
public synchronized int lineContaining(TextOffset offset)(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



wrap
public synchronized boolean wrap()(Code)
Return true if lines are wrapped using the line dimension.
See Also:   AsyncFormatter.setWrap



Fields inherited from com.ibm.richtext.textformat.MFormatter
final static String COPYRIGHT(Code)(Java Doc)
final public static boolean LOOSE(Code)(Java Doc)
final public static boolean TIGHT(Code)(Java Doc)
final public static short eUpeDowneLefteRight(Code)(Java Doc)

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)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.