jdk/src/share/classes/java/awt/dnd/MouseDragGestureRecognizer.java
author yan
Fri, 28 Mar 2014 14:33:53 +0400
changeset 23588 b0269b21e313
parent 5506 202f599c92aa
permissions -rw-r--r--
8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event Reviewed-by: pchelko, serb Contributed-by: Alexander Stepanov <alexander.v.stepanov@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.dnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.MouseEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.event.MouseListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.event.MouseMotionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * This abstract subclass of <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * defines a <code>DragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * for mouse-based gestures.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Each platform implements its own concrete subclass of this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * available via the Toolkit.createDragGestureRecognizer() method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * to encapsulate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the recognition of the platform dependent mouse gesture(s) that initiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * a Drag and Drop operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Mouse drag gesture recognizers should honor the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * drag gesture motion threshold, available through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * {@link DragSource#getDragThreshold}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * A drag gesture should be recognized only when the distance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * in either the horizontal or vertical direction between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * the location of the latest mouse dragged event and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * location of the corresponding mouse button pressed event
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * is greater than the drag gesture motion threshold.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Drag gesture recognizers created with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * {@link DragSource#createDefaultDragGestureRecognizer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * follow this convention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @author Laurence P. G. Cable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @see java.awt.dnd.DragGestureListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see java.awt.dnd.DragGestureEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see java.awt.dnd.DragSource
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
public abstract class MouseDragGestureRecognizer extends DragGestureRecognizer implements MouseListener, MouseMotionListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final long serialVersionUID = 6220099344182281120L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Construct a new <code>MouseDragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * given the <code>DragSource</code> for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * <code>Component</code> c, the <code>Component</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * to observe, the action(s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * permitted for this drag operation, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * the <code>DragGestureListener</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * notify when a drag gesture is detected.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
    77
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param ds  The DragSource for the Component c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param c   The Component to observe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param act The actions permitted for this Drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @param dgl The DragGestureListener to notify when a gesture is detected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    protected MouseDragGestureRecognizer(DragSource ds, Component c, int act, DragGestureListener dgl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        super(ds, c, act, dgl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Construct a new <code>MouseDragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * given the <code>DragSource</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * the <code>Component</code> c,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * the <code>Component</code> to observe, and the action(s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * permitted for this drag operation.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
    95
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param ds  The DragSource for the Component c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param c   The Component to observe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param act The actions permitted for this drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    protected MouseDragGestureRecognizer(DragSource ds, Component c, int act) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this(ds, c, act, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Construct a new <code>MouseDragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * given the <code>DragSource</code> for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <code>Component</code> c, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <code>Component</code> to observe.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   110
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param ds  The DragSource for the Component c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param c   The Component to observe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected MouseDragGestureRecognizer(DragSource ds, Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        this(ds, c, DnDConstants.ACTION_NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Construct a new <code>MouseDragGestureRecognizer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * given the <code>DragSource</code> for the <code>Component</code>.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   122
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param ds  The DragSource for the Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    protected MouseDragGestureRecognizer(DragSource ds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        this(ds, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * register this DragGestureRecognizer's Listeners with the Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    protected void registerListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        component.addMouseListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        component.addMouseMotionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * unregister this DragGestureRecognizer's Listeners with the Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * subclasses must override this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    protected void unregisterListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        component.removeMouseListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        component.removeMouseMotionListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Invoked when the mouse has been clicked on a component.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   153
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public void mouseClicked(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Invoked when a mouse button has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * pressed on a <code>Component</code>.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   162
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public void mousePressed(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Invoked when a mouse button has been released on a component.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   170
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public void mouseReleased(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Invoked when the mouse enters a component.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   178
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public void mouseEntered(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Invoked when the mouse exits a component.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   186
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public void mouseExited(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Invoked when a mouse button is pressed on a component.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   194
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public void mouseDragged(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Invoked when the mouse button has been moved on a component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * (with no buttons no down).
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 5506
diff changeset
   203
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param e the <code>MouseEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public void mouseMoved(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
}