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 java.awt.dnd;
027
028 import java.awt.Component;
029
030 import java.awt.event.MouseEvent;
031 import java.awt.event.MouseListener;
032 import java.awt.event.MouseMotionListener;
033
034 /**
035 * This abstract subclass of <code>DragGestureRecognizer</code>
036 * defines a <code>DragGestureRecognizer</code>
037 * for mouse-based gestures.
038 *
039 * Each platform implements its own concrete subclass of this class,
040 * available via the Toolkit.createDragGestureRecognizer() method,
041 * to encapsulate
042 * the recognition of the platform dependent mouse gesture(s) that initiate
043 * a Drag and Drop operation.
044 * <p>
045 * Mouse drag gesture recognizers should honor the
046 * drag gesture motion threshold, available through
047 * {@link DragSource#getDragThreshold}.
048 * A drag gesture should be recognized only when the distance
049 * in either the horizontal or vertical direction between
050 * the location of the latest mouse dragged event and the
051 * location of the corresponding mouse button pressed event
052 * is greater than the drag gesture motion threshold.
053 * <p>
054 * Drag gesture recognizers created with
055 * {@link DragSource#createDefaultDragGestureRecognizer}
056 * follow this convention.
057 *
058 * @author Laurence P. G. Cable
059 * @version 1.21
060 *
061 * @see java.awt.dnd.DragGestureListener
062 * @see java.awt.dnd.DragGestureEvent
063 * @see java.awt.dnd.DragSource
064 */
065
066 public abstract class MouseDragGestureRecognizer extends
067 DragGestureRecognizer implements MouseListener,
068 MouseMotionListener {
069
070 private static final long serialVersionUID = 6220099344182281120L;
071
072 /**
073 * Construct a new <code>MouseDragGestureRecognizer</code>
074 * given the <code>DragSource</code> for the
075 * <code>Component</code> c, the <code>Component</code>
076 * to observe, the action(s)
077 * permitted for this drag operation, and
078 * the <code>DragGestureListener</code> to
079 * notify when a drag gesture is detected.
080 * <P>
081 * @param ds The DragSource for the Component c
082 * @param c The Component to observe
083 * @param act The actions permitted for this Drag
084 * @param dgl The DragGestureListener to notify when a gesture is detected
085 *
086 */
087
088 protected MouseDragGestureRecognizer(DragSource ds, Component c,
089 int act, DragGestureListener dgl) {
090 super (ds, c, act, dgl);
091 }
092
093 /**
094 * Construct a new <code>MouseDragGestureRecognizer</code>
095 * given the <code>DragSource</code> for
096 * the <code>Component</code> c,
097 * the <code>Component</code> to observe, and the action(s)
098 * permitted for this drag operation.
099 * <P>
100 * @param ds The DragSource for the Component c
101 * @param c The Component to observe
102 * @param act The actions permitted for this drag
103 */
104
105 protected MouseDragGestureRecognizer(DragSource ds, Component c,
106 int act) {
107 this (ds, c, act, null);
108 }
109
110 /**
111 * Construct a new <code>MouseDragGestureRecognizer</code>
112 * given the <code>DragSource</code> for the
113 * <code>Component</code> c, and the
114 * <code>Component</code> to observe.
115 * <P>
116 * @param ds The DragSource for the Component c
117 * @param c The Component to observe
118 */
119
120 protected MouseDragGestureRecognizer(DragSource ds, Component c) {
121 this (ds, c, DnDConstants.ACTION_NONE);
122 }
123
124 /**
125 * Construct a new <code>MouseDragGestureRecognizer</code>
126 * given the <code>DragSource</code> for the <code>Component</code>.
127 * <P>
128 * @param ds The DragSource for the Component
129 */
130
131 protected MouseDragGestureRecognizer(DragSource ds) {
132 this (ds, null);
133 }
134
135 /**
136 * register this DragGestureRecognizer's Listeners with the Component
137 */
138
139 protected void registerListeners() {
140 component.addMouseListener(this );
141 component.addMouseMotionListener(this );
142 }
143
144 /**
145 * unregister this DragGestureRecognizer's Listeners with the Component
146 *
147 * subclasses must override this method
148 */
149
150 protected void unregisterListeners() {
151 component.removeMouseListener(this );
152 component.removeMouseMotionListener(this );
153 }
154
155 /**
156 * Invoked when the mouse has been clicked on a component.
157 * <P>
158 * @param e the <code>MouseEvent</code>
159 */
160
161 public void mouseClicked(MouseEvent e) {
162 }
163
164 /**
165 * Invoked when a mouse button has been
166 * pressed on a <code>Component</code>.
167 * <P>
168 * @param e the <code>MouseEvent</code>
169 */
170
171 public void mousePressed(MouseEvent e) {
172 }
173
174 /**
175 * Invoked when a mouse button has been released on a component.
176 * <P>
177 * @param e the <code>MouseEvent</code>
178 */
179
180 public void mouseReleased(MouseEvent e) {
181 }
182
183 /**
184 * Invoked when the mouse enters a component.
185 * <P>
186 * @param e the <code>MouseEvent</code>
187 */
188
189 public void mouseEntered(MouseEvent e) {
190 }
191
192 /**
193 * Invoked when the mouse exits a component.
194 * <P>
195 * @param e the <code>MouseEvent</code>
196 */
197
198 public void mouseExited(MouseEvent e) {
199 }
200
201 /**
202 * Invoked when a mouse button is pressed on a component.
203 * <P>
204 * @param e the <code>MouseEvent</code>
205 */
206
207 public void mouseDragged(MouseEvent e) {
208 }
209
210 /**
211 * Invoked when the mouse button has been moved on a component
212 * (with no buttons no down).
213 * <P>
214 * @param e the <code>MouseEvent</code>
215 */
216
217 public void mouseMoved(MouseEvent e) {
218 }
219 }
|