Java Doc for LineOffsets.java in  » Scripting » Kawa » gnu » jemacs » swt » 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 » Scripting » Kawa » gnu.jemacs.swt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


gnu.lists.GapVector
   gnu.jemacs.swt.LineOffsets

LineOffsets
public class LineOffsets extends GapVector (Code)
The purpose of this class is to maintain an ordered set of line offsets for an SwtCharBuffer.

With a LineOffsets instance it's possible to map from the number of a line to the text position where it begins, and back, reasonably fast. (O(1) for line number to line offset, O(log(#lines)) for line offset to line number)

LineOffsets extends GapVector with an U32Vector as base, allowing new line offsets to be inserted quickly during normal text typing.

Instances of SwtCharBuffer should hold an instance LineOffsets class and notify it whenever the it's text changes. The notification happens through the methods:

  • textRegionMoved, which should be called when the gap (of SwtCharBuffer) changes (position or size).
  • textInserted.
  • textDeleted.

TODO: decouple this, using a more general event model.. Assume that lineOffset is an instance of LineOffsets, held by swtCharBuffer an instance of SwtCharBuffer.

Then a value of o at index i in lineOffsets.base means that the line with line number n = (i < lOff.gapStart ? i : i + lOff.gapEnd - lOff.gapStart)

starts at text position p = (o < swtCB.gapStart ? o : o + swtCB.gapEnd - swtCB.gapStart)


author:
   Christian Surlykke
author:
   12-07-2004



Field Summary
final public static  intminGapSize
    

Constructor Summary
public  LineOffsets(int initialSize)
    

Method Summary
public  intcountLines(String newText)
    
public  voiddeleteLines(int firstLine, int numberOfLines)
    
public  intindex2offset(int index)
    
public  voidinsertLine(int index, int offSet)
    
public  voidinsertLines(int index, int[] offsets)
    
public  booleanisLineDelimiter(char c)
    
public  intlinesInRange(int startOffset, int endOffset)
    
public  intoffset2index(int offset)
     We seek the line containing a given text offset using a halfing of intervals algorithm.
public  voidtextDeleted(int startOffset, int endOffset)
    
public  voidtextInserted(int startOffset, CharSequence seq)
    
public  voidtextRegionMoved(int regionStart, int regionEnd, int displacement)
    
public  StringtoString()
    

Field Detail
minGapSize
final public static int minGapSize(Code)




Constructor Detail
LineOffsets
public LineOffsets(int initialSize)(Code)




Method Detail
countLines
public int countLines(String newText)(Code)



deleteLines
public void deleteLines(int firstLine, int numberOfLines)(Code)



index2offset
public int index2offset(int index)(Code)



insertLine
public void insertLine(int index, int offSet)(Code)



insertLines
public void insertLines(int index, int[] offsets)(Code)



isLineDelimiter
public boolean isLineDelimiter(char c)(Code)



linesInRange
public int linesInRange(int startOffset, int endOffset)(Code)



offset2index
public int offset2index(int offset)(Code)
We seek the line containing a given text offset using a halfing of intervals algorithm. Therefore the method will use O(log(n)) time, n being the number of lines.
See Also:   org.eclipse.swt.custom.StyledTextContent.getLineAtOffset(int)



textDeleted
public void textDeleted(int startOffset, int endOffset)(Code)



textInserted
public void textInserted(int startOffset, CharSequence seq)(Code)



textRegionMoved
public void textRegionMoved(int regionStart, int regionEnd, int displacement)(Code)



toString
public String toString()(Code)



Fields inherited from gnu.lists.GapVector
public SimpleVector base(Code)(Java Doc)
public int gapEnd(Code)(Java Doc)
public int gapStart(Code)(Java Doc)

Methods inherited from gnu.lists.GapVector
public void add(int index, Object o)(Code)(Java Doc)
protected int addPos(int ipos, Object value)(Code)(Java Doc)
public void consumePosRange(int iposStart, int iposEnd, Consumer out)(Code)(Java Doc)
public int createPos(int index, boolean isAfter)(Code)(Java Doc)
public void fill(Object value)(Code)(Java Doc)
public void fillPosRange(int fromPos, int toPos, Object value)(Code)(Java Doc)
protected void gapReserve(int size)(Code)(Java Doc)
protected void gapReserve(int where, int size)(Code)(Java Doc)
public Object get(int index)(Code)(Java Doc)
public int getNextKind(int ipos)(Code)(Java Doc)
public int getSegment(int where, int len)(Code)(Java Doc)
public boolean hasNext(int ipos)(Code)(Java Doc)
protected boolean isAfterPos(int ipos)(Code)(Java Doc)
protected int nextIndex(int ipos)(Code)(Java Doc)
protected void removePosRange(int ipos0, int ipos1)(Code)(Java Doc)
public Object set(int index, Object value)(Code)(Java Doc)
protected void shiftGap(int newGapStart)(Code)(Java Doc)
public int size()(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.