Source Code Cross Referenced for ScreenLineManager.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » textarea » 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 » Swing Library » jEdit » org.gjt.sp.jedit.textarea 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ScreenLineManager.java - Manage screen line counts
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2004 Slava Pestov
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit.textarea;
024:
025:        //{{{ Imports
026:        import org.gjt.sp.jedit.buffer.*;
027:        import org.gjt.sp.jedit.Debug;
028:        import org.gjt.sp.util.Log;
029:
030:        //}}}
031:
032:        /**
033:         * Performs the Mapping between physical lines and screen lines.
034:         * 
035:         * @since jEdit 4.3pre1
036:         * @author Slava Pestov
037:         * @version $Id: ScreenLineManager.java 10273 2007-08-01 21:20:45Z kpouer $
038:         */
039:        class ScreenLineManager {
040:            //{{{ ScreenLineManager constructor
041:            ScreenLineManager(JEditBuffer buffer) {
042:                this .buffer = buffer;
043:                if (!buffer.isLoading())
044:                    reset();
045:            } //}}}
046:
047:            //{{{ isScreenLineCountValid() method
048:            boolean isScreenLineCountValid(int line) {
049:                return (screenLines[line] & SCREEN_LINES_VALID_MASK) != 0;
050:            } //}}}
051:
052:            //{{{ getScreenLineCount() method
053:            /**
054:             * Returns how many screen lines contains the given physical line.
055:             * It can be greater than 1 when using soft wrap
056:             *
057:             * @param line the physical line
058:             * @return the screen line count
059:             */
060:            int getScreenLineCount(int line) {
061:                return screenLines[line] >> SCREEN_LINES_SHIFT;
062:            } //}}}
063:
064:            //{{{ setScreenLineCount() method
065:            /**
066:             * Sets the number of screen lines that the specified physical line
067:             * is split into.
068:             * @param line the line number
069:             * @param count the line count (1 if no wrap)
070:             */
071:            void setScreenLineCount(int line, int count) {
072:                if (count > Short.MAX_VALUE) {
073:                    // limitations...
074:                    count = Short.MAX_VALUE;
075:                }
076:
077:                if (Debug.SCREEN_LINES_DEBUG)
078:                    Log.log(Log.DEBUG, this , new Exception(
079:                            "setScreenLineCount(" + line + ',' + count + ')'));
080:                screenLines[line] = (short) (count << SCREEN_LINES_SHIFT | SCREEN_LINES_VALID_MASK);
081:            } //}}}
082:
083:            //{{{ invalidateScreenLineCounts() method
084:            void invalidateScreenLineCounts() {
085:                int lineCount = buffer.getLineCount();
086:                for (int i = 0; i < lineCount; i++)
087:                    screenLines[i] &= ~SCREEN_LINES_VALID_MASK;
088:            } //}}}
089:
090:            //{{{ reset() method
091:            void reset() {
092:                screenLines = new short[buffer.getLineCount()];
093:            } //}}}
094:
095:            //{{{ contentInserted() method
096:            public void contentInserted(int startLine, int numLines) {
097:                int endLine = startLine + numLines;
098:                screenLines[startLine] &= ~SCREEN_LINES_VALID_MASK;
099:
100:                int lineCount = buffer.getLineCount();
101:
102:                if (numLines > 0) {
103:                    if (screenLines.length <= lineCount) {
104:                        short[] screenLinesN = new short[((lineCount + 1) << 1)];
105:                        System.arraycopy(screenLines, 0, screenLinesN, 0,
106:                                screenLines.length);
107:                        screenLines = screenLinesN;
108:                    }
109:
110:                    System.arraycopy(screenLines, startLine, screenLines,
111:                            endLine, lineCount - endLine);
112:
113:                    for (int i = 0; i < numLines; i++)
114:                        screenLines[startLine + i] = 0;
115:                }
116:            } //}}}
117:
118:            //{{{ contentRemoved() method
119:            public void contentRemoved(int startLine, int numLines) {
120:                int endLine = startLine + numLines;
121:                screenLines[startLine] &= ~SCREEN_LINES_VALID_MASK;
122:
123:                if (numLines > 0 && endLine != screenLines.length) {
124:                    System.arraycopy(screenLines, endLine + 1, screenLines,
125:                            startLine + 1, screenLines.length - endLine - 1);
126:                }
127:            } //}}}
128:
129:            //{{{ Private members
130:            private static final int SCREEN_LINES_SHIFT = 1;
131:            private static final int SCREEN_LINES_VALID_MASK = 1;
132:
133:            private final JEditBuffer buffer;
134:            /** This array contains the line count for each physical line. */
135:            private short[] screenLines;
136:            //}}}
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.