Source Code Cross Referenced for Mark.java in  » Swing-Library » abeille-forms-designer » org » netbeans » editor » 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 » abeille forms designer » org.netbeans.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *                 Sun Public License Notice
003:         * 
004:         * The contents of this file are subject to the Sun Public License
005:         * Version 1.0 (the "License"). You may not use this file except in
006:         * compliance with the License. A copy of the License is available at
007:         * http://www.sun.com/
008:         * 
009:         * The Original Code is NetBeans. The Initial Developer of the Original
010:         * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
011:         * Microsystems, Inc. All Rights Reserved.
012:         */
013:
014:        package org.netbeans.editor;
015:
016:        import javax.swing.text.Position;
017:
018:        /**
019:         * Marks hold the relative position in the document.
020:         * 
021:         * @author Miloslav Metelka
022:         * @version 1.00
023:         */
024:
025:        /**
026:         * Class defining basic type of mark. This is a mark used most frequently. It's
027:         * instances are inserted into the leaf plane of the tree.
028:         */
029:        public class Mark {
030:
031:            /** Document marks to which this mark belongs. */
032:            private DocOp op;
033:
034:            /** Offset at which the mark is located in the document. */
035:            int offset;
036:
037:            /** Line at which the mark is located in the document. */
038:            int line;
039:
040:            /**
041:             * Bias of the mark. It is either false for
042:             * {@link javax.swing.text.Position.Bias.Forward} or true for
043:             * {@link javax.swing.text.Position.Bias.Backward}
044:             */
045:            boolean backwardBias;
046:
047:            /** The mark is valid if it's inserted in the marks structure */
048:            boolean valid;
049:
050:            /** Construct new mark with forward bias. */
051:            public Mark() {
052:                this (Position.Bias.Forward);
053:            }
054:
055:            public Mark(Position.Bias bias) {
056:                this (bias == Position.Bias.Backward);
057:            }
058:
059:            /**
060:             * Construct new mark.
061:             * 
062:             * @param backwardBias
063:             *            whether the inserts performed right at the position of this
064:             *            mark will go after this mark i.e. this mark will not move
065:             *            forward when inserting right at its position. This flag
066:             *            corresponds to <tt>Position.Bias.Backward</tt>.
067:             */
068:            public Mark(boolean backwardBias) {
069:                this .backwardBias = backwardBias;
070:            }
071:
072:            /** Package private constructor for cover marks */
073:            Mark(int offset, int line, boolean backwardBias) {
074:                this .offset = offset;
075:                this .line = line;
076:                this .backwardBias = backwardBias;
077:            }
078:
079:            /** Get the position of this mark */
080:            public final int getOffset() throws InvalidMarkException {
081:                try {
082:                    DocOp lop = op; // local copy
083:                    synchronized (lop) {
084:                        if (lop == op) {
085:                            return lop.marks.getOffset(this );
086:
087:                        } else {
088:                            throw new InvalidMarkException();
089:                        }
090:                    }
091:                } catch (NullPointerException e) {
092:                    throw new InvalidMarkException(e.toString());
093:                }
094:            }
095:
096:            /** Get the line number of this mark */
097:            public final int getLine() throws InvalidMarkException {
098:                try {
099:                    DocOp lop = op; // local copy
100:                    synchronized (lop) {
101:                        if (lop == op) {
102:                            return lop.marks.getLine(this );
103:
104:                        } else {
105:                            throw new InvalidMarkException();
106:                        }
107:                    }
108:                } catch (NullPointerException e) {
109:                    throw new InvalidMarkException(e.toString());
110:                }
111:            }
112:
113:            /**
114:             * Get the insertAfter flag. Replaced by {@link #getBackwardBias()}
115:             * 
116:             * @deprecated
117:             */
118:            public final boolean getInsertAfter() {
119:                return backwardBias;
120:            }
121:
122:            /**
123:             * @return true if the mark has backward bias or false if it has forward
124:             *         bias.
125:             */
126:            public final boolean getBackwardBias() {
127:                return getInsertAfter();
128:            }
129:
130:            /**
131:             * @return the bias of this mark. It will be either
132:             *         {@link javax.swing.text.Position.Bias.Forward} or
133:             *         {@link javax.swing.text.Position.Bias.Backward}.
134:             */
135:            public final Position.Bias getBias() {
136:                return backwardBias ? Position.Bias.Backward
137:                        : Position.Bias.Forward;
138:            }
139:
140:            final void setOp(DocOp op) {
141:                this .op = op;
142:            }
143:
144:            /**
145:             * Mark will no longer represent a valid place in the document. Although it
146:             * will not be removed from the structure that holds the marks it will be
147:             * done later automatically.
148:             */
149:            public final void dispose() {
150:                try {
151:                    DocOp lop = op;
152:                    synchronized (lop) {
153:                        if (lop == op && valid) {
154:                            lop.marks.dispose(this );
155:
156:                        } else { // invalid mark
157:                            throw new IllegalStateException();
158:                        }
159:                    }
160:                } catch (NullPointerException e) {
161:                    throw new IllegalStateException(e.toString());
162:                }
163:            }
164:
165:            /**
166:             * Remove mark from the structure holding the marks. The mark can be
167:             * inserted again into some document.
168:             */
169:            public final void remove() throws InvalidMarkException {
170:                try {
171:                    DocOp lop = op;
172:                    synchronized (op) {
173:                        if (lop == op && valid) {
174:                            op.marks.remove(this );
175:                            op = null;
176:
177:                        } else { // invalid mark
178:                            throw new InvalidMarkException();
179:                        }
180:                    }
181:                } catch (NullPointerException e) {
182:                    throw new InvalidMarkException(e.toString());
183:                }
184:            }
185:
186:            final void removeDisposed() {
187:                op = null;
188:            }
189:
190:            /**
191:             * Compare this mark to some position.
192:             * 
193:             * @param pos
194:             *            tested position
195:             * @return zero - if the marks have the same position less than zero - if
196:             *         this mark is before the position greater than zero - if this mark
197:             *         is after the position
198:             */
199:            public final int compare(int pos) throws InvalidMarkException {
200:                return getOffset() - pos;
201:            }
202:
203:            /**
204:             * This function is called from removeUpdater when mark occupies the removal
205:             * area. The mark can decide what to do next. If it doesn't redefine this
206:             * method it will be simply moved to the begining of removal area. It is
207:             * valid to add or remove other mark from this method. It is even possible
208:             * (but not very useful) to add the mark to the removal area. However that
209:             * mark will not be notified about current removal.
210:             * 
211:             * @deprecated It will not be supported in the future.
212:             */
213:            protected void removeUpdateAction(int pos, int len) {
214:            }
215:
216:            /**
217:             * @return true if this mark is currently inserted in the document or false
218:             *         otherwise.
219:             */
220:            public final boolean isValid() {
221:                try {
222:                    synchronized (op) {
223:                        return valid;
224:                    }
225:                } catch (NullPointerException e) {
226:                    return false;
227:                }
228:            }
229:
230:            /** Get info about <CODE>Mark</CODE>. */
231:            public String toString() {
232:                return "rawOffset=" + offset // NOI18N
233:                        + ", rawLine=" + line // NOI18N
234:                        + ", backwardBias=" + backwardBias; // NOI18N
235:            }
236:
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.