0N/A/*
2362N/A * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.awt.dnd;
0N/A
0N/Aimport java.awt.Point;
0N/A
0N/Aimport java.util.EventObject;
0N/A
0N/A/**
0N/A * This class is the base class for
0N/A * <code>DragSourceDragEvent</code> and
0N/A * <code>DragSourceDropEvent</code>.
0N/A * <p>
0N/A * <code>DragSourceEvent</code>s are generated whenever the drag enters, moves
0N/A * over, or exits a drop site, when the drop action changes, and when the drag
0N/A * ends. The location for the generated <code>DragSourceEvent</code> specifies
0N/A * the mouse cursor location in screen coordinates at the moment this event
0N/A * occured.
0N/A * <p>
0N/A * In a multi-screen environment without a virtual device, the cursor location is
0N/A * specified in the coordinate system of the <i>initiator</i>
0N/A * <code>GraphicsConfiguration</code>. The <i>initiator</i>
0N/A * <code>GraphicsConfiguration</code> is the <code>GraphicsConfiguration</code>
0N/A * of the <code>Component</code> on which the drag gesture for the current drag
0N/A * operation was recognized. If the cursor location is outside the bounds of
0N/A * the initiator <code>GraphicsConfiguration</code>, the reported coordinates are
0N/A * clipped to fit within the bounds of that <code>GraphicsConfiguration</code>.
0N/A * <p>
0N/A * In a multi-screen environment with a virtual device, the location is specified
0N/A * in the corresponding virtual coordinate system. If the cursor location is
0N/A * outside the bounds of the virtual device the reported coordinates are
0N/A * clipped to fit within the bounds of the virtual device.
0N/A *
0N/A * @since 1.2
0N/A */
0N/A
0N/Apublic class DragSourceEvent extends EventObject {
0N/A
0N/A private static final long serialVersionUID = -763287114604032641L;
0N/A
0N/A /**
0N/A * The <code>boolean</code> indicating whether the cursor location
0N/A * is specified for this event.
0N/A *
0N/A * @serial
0N/A */
0N/A private final boolean locationSpecified;
0N/A
0N/A /**
0N/A * The horizontal coordinate for the cursor location at the moment this
0N/A * event occured if the cursor location is specified for this event;
0N/A * otherwise zero.
0N/A *
0N/A * @serial
0N/A */
0N/A private final int x;
0N/A
0N/A /**
0N/A * The vertical coordinate for the cursor location at the moment this event
0N/A * occured if the cursor location is specified for this event;
0N/A * otherwise zero.
0N/A *
0N/A * @serial
0N/A */
0N/A private final int y;
0N/A
0N/A /**
0N/A * Construct a <code>DragSourceEvent</code>
0N/A * given a specified <code>DragSourceContext</code>.
0N/A * The coordinates for this <code>DragSourceEvent</code>
0N/A * are not specified, so <code>getLocation</code> will return
0N/A * <code>null</code> for this event.
0N/A *
0N/A * @param dsc the <code>DragSourceContext</code>
0N/A *
0N/A * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
0N/A *
0N/A * @see #getLocation
0N/A */
0N/A
0N/A public DragSourceEvent(DragSourceContext dsc) {
0N/A super(dsc);
0N/A locationSpecified = false;
0N/A this.x = 0;
0N/A this.y = 0;
0N/A }
0N/A
0N/A /**
0N/A * Construct a <code>DragSourceEvent</code> given a specified
0N/A * <code>DragSourceContext</code>, and coordinates of the cursor
0N/A * location.
0N/A *
0N/A * @param dsc the <code>DragSourceContext</code>
0N/A * @param x the horizontal coordinate for the cursor location
0N/A * @param y the vertical coordinate for the cursor location
0N/A *
0N/A * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
0N/A *
0N/A * @since 1.4
0N/A */
0N/A public DragSourceEvent(DragSourceContext dsc, int x, int y) {
0N/A super(dsc);
0N/A locationSpecified = true;
0N/A this.x = x;
0N/A this.y = y;
0N/A }
0N/A
0N/A /**
0N/A * This method returns the <code>DragSourceContext</code> that
0N/A * originated the event.
0N/A * <P>
0N/A * @return the <code>DragSourceContext</code> that originated the event
0N/A */
0N/A
0N/A public DragSourceContext getDragSourceContext() {
0N/A return (DragSourceContext)getSource();
0N/A }
0N/A
0N/A /**
0N/A * This method returns a <code>Point</code> indicating the cursor
0N/A * location in screen coordinates at the moment this event occured, or
0N/A * <code>null</code> if the cursor location is not specified for this
0N/A * event.
0N/A *
0N/A * @return the <code>Point</code> indicating the cursor location
0N/A * or <code>null</code> if the cursor location is not specified
0N/A * @since 1.4
0N/A */
0N/A public Point getLocation() {
0N/A if (locationSpecified) {
0N/A return new Point(x, y);
0N/A } else {
0N/A return null;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This method returns the horizontal coordinate of the cursor location in
0N/A * screen coordinates at the moment this event occured, or zero if the
0N/A * cursor location is not specified for this event.
0N/A *
0N/A * @return an integer indicating the horizontal coordinate of the cursor
0N/A * location or zero if the cursor location is not specified
0N/A * @since 1.4
0N/A */
0N/A public int getX() {
0N/A return x;
0N/A }
0N/A
0N/A /**
0N/A * This method returns the vertical coordinate of the cursor location in
0N/A * screen coordinates at the moment this event occured, or zero if the
0N/A * cursor location is not specified for this event.
0N/A *
0N/A * @return an integer indicating the vertical coordinate of the cursor
0N/A * location or zero if the cursor location is not specified
0N/A * @since 1.4
0N/A */
0N/A public int getY() {
0N/A return y;
0N/A }
0N/A}