Source Code Cross Referenced for ExtensionManager.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:         * ExtensionManager.java - Handles 'layers'
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2002, 2003 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:        import java.awt.Graphics2D;
026:        import java.util.*;
027:        import org.gjt.sp.util.Log;
028:
029:        /**
030:         * Manage the extensions for the gutter and the textarea.
031:         *
032:         * @author Slava Pestov
033:         * @version $Id: ExtensionManager.java 7156 2006-10-02 21:33:17Z kpouer $
034:         */
035:        class ExtensionManager {
036:            //{{{ addExtension() method
037:            /**
038:             * Add an extension.
039:             * See {@link Gutter} and {@link TextAreaPainter} to know the layers
040:             *
041:             * @param layer the layer. It could be defined in Gutter or TextAreaPainter
042:             * @param ext the extension to add
043:             */
044:            void addExtension(int layer, TextAreaExtension ext) {
045:                Entry entry = new Entry(layer, ext);
046:
047:                int i = 0;
048:                for (Entry extension : extensions) {
049:                    int _layer = extension.layer;
050:                    if (layer < _layer) {
051:                        extensions.add(i, entry);
052:                        return;
053:                    }
054:                    i++;
055:                }
056:
057:                extensions.add(entry);
058:            } //}}}
059:
060:            //{{{ removeExtension() method
061:            void removeExtension(TextAreaExtension ext) {
062:                Iterator<Entry> iter = extensions.iterator();
063:                while (iter.hasNext()) {
064:                    if (iter.next().ext == ext) {
065:                        iter.remove();
066:                        return;
067:                    }
068:                }
069:            } //}}}
070:
071:            //{{{ getExtensions() method
072:            TextAreaExtension[] getExtensions() {
073:                TextAreaExtension[] retVal = new TextAreaExtension[extensions
074:                        .size()];
075:                Iterator<Entry> iter = extensions.iterator();
076:                int i = 0;
077:                while (iter.hasNext())
078:                    retVal[i++] = iter.next().ext;
079:
080:                return retVal;
081:            } //}}}
082:
083:            //{{{ paintScreenLineRange() method
084:            void paintScreenLineRange(TextArea textArea, Graphics2D gfx,
085:                    int firstLine, int lastLine, int y, int lineHeight) {
086:                try {
087:                    int[] physicalLines = new int[lastLine - firstLine + 1];
088:                    int[] start = new int[physicalLines.length];
089:                    int[] end = new int[physicalLines.length];
090:
091:                    for (int i = 0; i < physicalLines.length; i++) {
092:                        int screenLine = i + firstLine;
093:                        ChunkCache.LineInfo lineInfo = textArea.chunkCache
094:                                .getLineInfo(screenLine);
095:
096:                        if (lineInfo.physicalLine == -1)
097:                            physicalLines[i] = -1;
098:                        else {
099:                            physicalLines[i] = lineInfo.physicalLine;
100:                            start[i] = textArea
101:                                    .getScreenLineStartOffset(screenLine);
102:                            end[i] = textArea
103:                                    .getScreenLineEndOffset(screenLine);
104:                        }
105:                    }
106:
107:                    paintScreenLineRange(gfx, firstLine, lastLine,
108:                            physicalLines, start, end, y, lineHeight);
109:                } catch (Exception e) {
110:                    Log.log(Log.ERROR, this , "Error repainting line"
111:                            + " range {" + firstLine + ',' + lastLine + "}:");
112:                    Log.log(Log.ERROR, this , e);
113:                }
114:            } //}}}
115:
116:            //{{{ getToolTipText() method
117:            String getToolTipText(int x, int y) {
118:                for (int i = 0; i < extensions.size(); i++) {
119:                    TextAreaExtension ext = extensions.get(i).ext;
120:                    String toolTip = ext.getToolTipText(x, y);
121:                    if (toolTip != null)
122:                        return toolTip;
123:                }
124:
125:                return null;
126:            } //}}}
127:
128:            //{{{ Private members
129:            private final List<Entry> extensions = new LinkedList<Entry>();
130:
131:            //{{{ paintScreenLineRange() method
132:            private void paintScreenLineRange(Graphics2D gfx, int firstLine,
133:                    int lastLine, int[] physicalLines, int[] start, int[] end,
134:                    int y, int lineHeight) {
135:                Iterator<Entry> iter = extensions.iterator();
136:                while (iter.hasNext()) {
137:                    TextAreaExtension ext = iter.next().ext;
138:                    try {
139:                        ext.paintScreenLineRange(gfx, firstLine, lastLine,
140:                                physicalLines, start, end, y, lineHeight);
141:                    } catch (Throwable t) {
142:                        Log.log(Log.ERROR, this , t);
143:
144:                        // remove it so editor can continue
145:                        // functioning
146:                        iter.remove();
147:                    }
148:                }
149:            } //}}}
150:
151:            //}}}
152:
153:            //{{{ Entry class
154:            /** This class represents an extension with his layer. */
155:            static class Entry {
156:                int layer;
157:                TextAreaExtension ext;
158:
159:                Entry(int layer, TextAreaExtension ext) {
160:                    this .layer = layer;
161:                    this .ext = ext;
162:                }
163:            } //}}}
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.