Source Code Cross Referenced for MMouseDragGestureRecognizer.java in  » 6.0-JDK-Platform » solaris » sun » awt » motif » 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 » 6.0 JDK Platform » solaris » sun.awt.motif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.awt.motif;
027:
028:        import java.awt.Toolkit;
029:        import java.awt.Component;
030:
031:        import java.awt.Point;
032:        import java.awt.dnd.DnDConstants;
033:        import java.awt.dnd.DragSource;
034:        import java.awt.dnd.MouseDragGestureRecognizer;
035:        import java.awt.dnd.DragGestureListener;
036:
037:        import java.awt.event.InputEvent;
038:        import java.awt.event.MouseEvent;
039:        import java.awt.event.MouseListener;
040:        import java.awt.event.MouseMotionListener;
041:
042:        import java.lang.reflect.*;
043:
044:        import sun.awt.dnd.SunDragSourceContextPeer;
045:
046:        /**
047:         * <p>
048:         * This subclass of MouseDragGestureRecognizer defines a DragGestureRecognizer
049:         * for Mouse based gestures on OSF/Motif.
050:         * </p>
051:         *
052:         * @author Laurence P. G. Cable
053:         * @version 1.22
054:         *
055:         * @see java.awt.dnd.DragGestureListener
056:         * @see java.awt.dnd.DragGestureEvent
057:         * @see java.awt.dnd.DragSource
058:         */
059:
060:        class MMouseDragGestureRecognizer extends MouseDragGestureRecognizer {
061:
062:            private static final long serialVersionUID = -841711780352520383L;
063:
064:            /*
065:             * constant for number of pixels hysterisis before drag is determined
066:             * to have started
067:             */
068:
069:            protected static int motionThreshold;
070:
071:            protected static final int ButtonMask = InputEvent.BUTTON1_DOWN_MASK
072:                    | InputEvent.BUTTON2_DOWN_MASK
073:                    | InputEvent.BUTTON3_DOWN_MASK;
074:
075:            /**
076:             * construct a new MMouseDragGestureRecognizer
077:             *
078:             * @param ds  The DragSource for the Component c
079:             * @param c   The Component to observe
080:             * @param act The actions permitted for this Drag
081:             * @param dgl The DragGestureRecognizer to notify when a gesture is detected
082:             *
083:             */
084:
085:            protected MMouseDragGestureRecognizer(DragSource ds, Component c,
086:                    int act, DragGestureListener dgl) {
087:                super (ds, c, act, dgl);
088:            }
089:
090:            /**
091:             * construct a new MMouseDragGestureRecognizer
092:             *
093:             * @param ds  The DragSource for the Component c
094:             * @param c   The Component to observe
095:             * @param act The actions permitted for this Drag
096:             */
097:
098:            protected MMouseDragGestureRecognizer(DragSource ds, Component c,
099:                    int act) {
100:                this (ds, c, act, null);
101:            }
102:
103:            /**
104:             * construct a new MMouseDragGestureRecognizer
105:             *
106:             * @param ds  The DragSource for the Component c
107:             * @param c   The Component to observe
108:             */
109:
110:            protected MMouseDragGestureRecognizer(DragSource ds, Component c) {
111:                this (ds, c, DnDConstants.ACTION_NONE);
112:            }
113:
114:            /**
115:             * construct a new MMouseDragGestureRecognizer
116:             *
117:             * @param ds  The DragSource for the Component c
118:             */
119:
120:            protected MMouseDragGestureRecognizer(DragSource ds) {
121:                this (ds, null);
122:            }
123:
124:            /**
125:             * determine the drop action from the event
126:             */
127:
128:            protected int mapDragOperationFromModifiers(MouseEvent e) {
129:                int mods = e.getModifiersEx();
130:                int btns = mods & ButtonMask;
131:
132:                // Do not allow right mouse button drag since Motif DnD does not
133:                // terminate drag operation on right mouse button release.
134:                if (!(btns == InputEvent.BUTTON1_DOWN_MASK || btns == InputEvent.BUTTON2_DOWN_MASK)) {
135:                    return DnDConstants.ACTION_NONE;
136:                }
137:
138:                return SunDragSourceContextPeer.convertModifiersToDropAction(
139:                        mods, getSourceActions());
140:            }
141:
142:            /**
143:             * Invoked when the mouse has been clicked on a component.
144:             */
145:
146:            public void mouseClicked(MouseEvent e) {
147:                // do nothing
148:            }
149:
150:            /**
151:             * Invoked when a mouse button has been pressed on a component.
152:             */
153:
154:            public void mousePressed(MouseEvent e) {
155:                events.clear();
156:
157:                if (mapDragOperationFromModifiers(e) != DnDConstants.ACTION_NONE) {
158:                    try {
159:                        motionThreshold = DragSource.getDragThreshold();
160:                    } catch (Exception exc) {
161:                        motionThreshold = 5;
162:                    }
163:                    appendEvent(e);
164:                }
165:            }
166:
167:            /**
168:             * Invoked when a mouse button has been released on a component.
169:             */
170:
171:            public void mouseReleased(MouseEvent e) {
172:                events.clear();
173:            }
174:
175:            /**
176:             * Invoked when the mouse enters a component.
177:             */
178:
179:            public void mouseEntered(MouseEvent e) {
180:                events.clear();
181:            }
182:
183:            /**
184:             * Invoked when the mouse exits a component.
185:             */
186:
187:            public void mouseExited(MouseEvent e) {
188:                if (!events.isEmpty()) { // gesture pending
189:                    int dragAction = mapDragOperationFromModifiers(e);
190:
191:                    if (dragAction == DnDConstants.ACTION_NONE) {
192:                        events.clear();
193:                    }
194:                }
195:            }
196:
197:            /**
198:             * Invoked when a mouse button is pressed on a component.
199:             */
200:
201:            public void mouseDragged(MouseEvent e) {
202:                if (!events.isEmpty()) { // gesture pending
203:                    int dop = mapDragOperationFromModifiers(e);
204:
205:                    if (dop == DnDConstants.ACTION_NONE) {
206:                        return;
207:                    }
208:
209:                    MouseEvent trigger = (MouseEvent) events.get(0);
210:
211:                    Point origin = trigger.getPoint();
212:                    Point current = e.getPoint();
213:
214:                    int dx = Math.abs(origin.x - current.x);
215:                    int dy = Math.abs(origin.y - current.y);
216:
217:                    if (dx > motionThreshold || dy > motionThreshold) {
218:                        fireDragGestureRecognized(dop,
219:                                ((MouseEvent) getTriggerEvent()).getPoint());
220:                    } else
221:                        appendEvent(e);
222:                }
223:            }
224:
225:            /**
226:             * Invoked when the mouse button has been moved on a component
227:             * (with no buttons no down).
228:             */
229:
230:            public void mouseMoved(MouseEvent e) {
231:                // do nothing
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.