Source Code Cross Referenced for MouseTracker.java in  » GIS » udig-1.1 » net » refractions » udig » tools » edit » 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 » GIS » udig 1.1 » net.refractions.udig.tools.edit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.tools.edit;
016:
017:        import java.util.HashSet;
018:        import java.util.LinkedList;
019:        import java.util.Queue;
020:        import java.util.Set;
021:        import java.util.concurrent.ConcurrentLinkedQueue;
022:
023:        import net.refractions.udig.project.ui.render.displayAdapter.MapMouseEvent;
024:        import net.refractions.udig.project.ui.render.displayAdapter.ViewportPane;
025:        import net.refractions.udig.tools.edit.support.Point;
026:
027:        import org.eclipse.swt.SWT;
028:        import org.eclipse.swt.widgets.Display;
029:
030:        /**
031:         * Keeps track of the what mouse events have happened.  Must be in event thread to call this method.
032:         * 
033:         * @author jones
034:         * @since 1.1.0
035:         */
036:        public class MouseTracker {
037:
038:            private static final int MAX_QUEUE_SIZE = 10;
039:            private Point dragStarted;
040:            private Queue<MapMouseEvent> previousEvents = new ConcurrentLinkedQueue<MapMouseEvent>();
041:            private Point currentPoint;
042:            private volatile Set<EventType> updateTriggers = new HashSet<EventType>();
043:            private EditToolHandler handler;
044:
045:            public MouseTracker(EditToolHandler handler2) {
046:                this .handler = handler2;
047:            }
048:
049:            /**
050:             * Called by EditToolhandler to updates the state.
051:             *
052:             * @param e The most recent event
053:             * @param type the type of event
054:             */
055:            protected void updateState(MapMouseEvent e, EventType type) {
056:                checkAccess();
057:                previousEvents.add(e);
058:
059:                if (previousEvents.size() > MAX_QUEUE_SIZE)
060:                    previousEvents.remove();
061:
062:                switch (type) {
063:                case PRESSED:
064:                    break;
065:                case DRAGGED:
066:                    currentPoint = Point.valueOf(e.x, e.y);
067:                    break;
068:                case DOUBLE_CLICK:
069:
070:                    break;
071:                case ENTERED:
072:
073:                    break;
074:                case EXITED:
075:
076:                    break;
077:                case MOVED:
078:                    currentPoint = dragStarted = Point.valueOf(e.x, e.y);
079:                    break;
080:                case RELEASED:
081:                    break;
082:
083:                default:
084:                    break;
085:                }
086:
087:                if (updateTriggers.contains(type)) {
088:                    if (e.source instanceof  ViewportPane) {
089:                        handler.repaint();
090:                    }
091:                }
092:            }
093:
094:            private void checkAccess() {
095:                if (Display.getCurrent() == null)
096:                    SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
097:            }
098:
099:            /**
100:             * @return Returns the point where the drag started or null if not dragging.
101:             */
102:            public Point getDragStarted() {
103:                checkAccess();
104:                return dragStarted;
105:            }
106:
107:            /**
108:             * This is a copy modifying queue will have no effect on original queue
109:             * 
110:             * @return Returns the queue of previous events.
111:             */
112:            public Queue<MapMouseEvent> getPreviousEvents() {
113:                checkAccess();
114:                return new LinkedList<MapMouseEvent>(previousEvents);
115:            }
116:
117:            /**
118:             * @param dragStarted The dragStarted to set.
119:             */
120:            protected void setDragStarted(Point dragStarted) {
121:                checkAccess();
122:                this .dragStarted = dragStarted;
123:            }
124:
125:            /**
126:             * Returns the previous events queue.  This is a thread-safe queue.
127:             * 
128:             * @param previousEvents The previousEvents to set.
129:             */
130:            protected Queue<MapMouseEvent> getModifiablePreviousEvents() {
131:                checkAccess();
132:                return previousEvents;
133:            }
134:
135:            /**
136:             * Returns the current location of the mouse.
137:             * @return
138:             */
139:            public Point getCurrentPoint() {
140:                checkAccess();
141:                return currentPoint;
142:            }
143:
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.