< prev index next >
src/java.desktop/share/classes/java/awt/dnd/DragGestureRecognizer.java
Print this page
*** 38,82 ****
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
! * The <code>DragGestureRecognizer</code> is an
* abstract base class for the specification
* of a platform-dependent listener that can be associated with a particular
! * <code>Component</code> in order to
* identify platform-dependent drag initiating gestures.
* <p>
! * The appropriate <code>DragGestureRecognizer</code>
* subclass instance is obtained from the
* {@link DragSource} associated with
! * a particular <code>Component</code>, or from the <code>Toolkit</code> object via its
* {@link java.awt.Toolkit#createDragGestureRecognizer createDragGestureRecognizer()}
* method.
* <p>
! * Once the <code>DragGestureRecognizer</code>
! * is associated with a particular <code>Component</code>
* it will register the appropriate listener interfaces on that
! * <code>Component</code>
! * in order to track the input events delivered to the <code>Component</code>.
* <p>
! * Once the <code>DragGestureRecognizer</code> identifies a sequence of events
! * on the <code>Component</code> as a drag initiating gesture, it will notify
! * its unicast <code>DragGestureListener</code> by
* invoking its
* {@link java.awt.dnd.DragGestureListener#dragGestureRecognized gestureRecognized()}
* method.
* <P>
! * When a concrete <code>DragGestureRecognizer</code>
* instance detects a drag initiating
! * gesture on the <code>Component</code> it is associated with,
* it fires a {@link DragGestureEvent} to
! * the <code>DragGestureListener</code> registered on
! * its unicast event source for <code>DragGestureListener</code>
! * events. This <code>DragGestureListener</code> is responsible
* for causing the associated
! * <code>DragSource</code> to start the Drag and Drop operation (if
* appropriate).
*
* @author Laurence P. G. Cable
* @see java.awt.dnd.DragGestureListener
* @see java.awt.dnd.DragGestureEvent
--- 38,82 ----
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
! * The {@code DragGestureRecognizer} is an
* abstract base class for the specification
* of a platform-dependent listener that can be associated with a particular
! * {@code Component} in order to
* identify platform-dependent drag initiating gestures.
* <p>
! * The appropriate {@code DragGestureRecognizer}
* subclass instance is obtained from the
* {@link DragSource} associated with
! * a particular {@code Component}, or from the {@code Toolkit} object via its
* {@link java.awt.Toolkit#createDragGestureRecognizer createDragGestureRecognizer()}
* method.
* <p>
! * Once the {@code DragGestureRecognizer}
! * is associated with a particular {@code Component}
* it will register the appropriate listener interfaces on that
! * {@code Component}
! * in order to track the input events delivered to the {@code Component}.
* <p>
! * Once the {@code DragGestureRecognizer} identifies a sequence of events
! * on the {@code Component} as a drag initiating gesture, it will notify
! * its unicast {@code DragGestureListener} by
* invoking its
* {@link java.awt.dnd.DragGestureListener#dragGestureRecognized gestureRecognized()}
* method.
* <P>
! * When a concrete {@code DragGestureRecognizer}
* instance detects a drag initiating
! * gesture on the {@code Component} it is associated with,
* it fires a {@link DragGestureEvent} to
! * the {@code DragGestureListener} registered on
! * its unicast event source for {@code DragGestureListener}
! * events. This {@code DragGestureListener} is responsible
* for causing the associated
! * {@code DragSource} to start the Drag and Drop operation (if
* appropriate).
*
* @author Laurence P. G. Cable
* @see java.awt.dnd.DragGestureListener
* @see java.awt.dnd.DragGestureEvent
*** 86,125 ****
public abstract class DragGestureRecognizer implements Serializable {
private static final long serialVersionUID = 8996673345831063337L;
/**
! * Construct a new <code>DragGestureRecognizer</code>
! * given the <code>DragSource</code> to be used
! * in this Drag and Drop operation, the <code>Component</code>
! * this <code>DragGestureRecognizer</code> should "observe"
* for drag initiating gestures, the action(s) supported
* for this Drag and Drop operation, and the
! * <code>DragGestureListener</code> to notify
* once a drag initiating gesture has been detected.
*
! * @param ds the <code>DragSource</code> this
! * <code>DragGestureRecognizer</code>
* will use to process the Drag and Drop operation
*
! * @param c the <code>Component</code>
! * this <code>DragGestureRecognizer</code>
* should "observe" the event stream to,
* in order to detect a drag initiating gesture.
! * If this value is <code>null</code>, the
! * <code>DragGestureRecognizer</code>
! * is not associated with any <code>Component</code>.
*
* @param sa the set (logical OR) of the
! * <code>DnDConstants</code>
* that this Drag and Drop operation will support
*
! * @param dgl the <code>DragGestureRecognizer</code>
* to notify when a drag gesture is detected
*
* @throws IllegalArgumentException
! * if ds is <code>null</code>.
*/
protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl) {
super();
--- 86,125 ----
public abstract class DragGestureRecognizer implements Serializable {
private static final long serialVersionUID = 8996673345831063337L;
/**
! * Construct a new {@code DragGestureRecognizer}
! * given the {@code DragSource} to be used
! * in this Drag and Drop operation, the {@code Component}
! * this {@code DragGestureRecognizer} should "observe"
* for drag initiating gestures, the action(s) supported
* for this Drag and Drop operation, and the
! * {@code DragGestureListener} to notify
* once a drag initiating gesture has been detected.
*
! * @param ds the {@code DragSource} this
! * {@code DragGestureRecognizer}
* will use to process the Drag and Drop operation
*
! * @param c the {@code Component}
! * this {@code DragGestureRecognizer}
* should "observe" the event stream to,
* in order to detect a drag initiating gesture.
! * If this value is {@code null}, the
! * {@code DragGestureRecognizer}
! * is not associated with any {@code Component}.
*
* @param sa the set (logical OR) of the
! * {@code DnDConstants}
* that this Drag and Drop operation will support
*
! * @param dgl the {@code DragGestureRecognizer}
* to notify when a drag gesture is detected
*
* @throws IllegalArgumentException
! * if ds is {@code null}.
*/
protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl) {
super();
*** 135,213 ****
// cant happen ...
}
}
/**
! * Construct a new <code>DragGestureRecognizer</code>
! * given the <code>DragSource</code> to be used in this
* Drag and Drop
! * operation, the <code>Component</code> this
! * <code>DragGestureRecognizer</code> should "observe"
* for drag initiating gestures, and the action(s)
* supported for this Drag and Drop operation.
*
! * @param ds the <code>DragSource</code> this
! * <code>DragGestureRecognizer</code> will use to
* process the Drag and Drop operation
*
! * @param c the <code>Component</code> this
! * <code>DragGestureRecognizer</code> should "observe" the event
* stream to, in order to detect a drag initiating gesture.
! * If this value is <code>null</code>, the
! * <code>DragGestureRecognizer</code>
! * is not associated with any <code>Component</code>.
*
! * @param sa the set (logical OR) of the <code>DnDConstants</code>
* that this Drag and Drop operation will support
*
* @throws IllegalArgumentException
! * if ds is <code>null</code>.
*/
protected DragGestureRecognizer(DragSource ds, Component c, int sa) {
this(ds, c, sa, null);
}
/**
! * Construct a new <code>DragGestureRecognizer</code>
! * given the <code>DragSource</code> to be used
* in this Drag and Drop operation, and
! * the <code>Component</code> this
! * <code>DragGestureRecognizer</code>
* should "observe" for drag initiating gestures.
*
! * @param ds the <code>DragSource</code> this
! * <code>DragGestureRecognizer</code>
* will use to process the Drag and Drop operation
*
! * @param c the <code>Component</code>
! * this <code>DragGestureRecognizer</code>
* should "observe" the event stream to,
* in order to detect a drag initiating gesture.
! * If this value is <code>null</code>,
! * the <code>DragGestureRecognizer</code>
! * is not associated with any <code>Component</code>.
*
* @throws IllegalArgumentException
! * if ds is <code>null</code>.
*/
protected DragGestureRecognizer(DragSource ds, Component c) {
this(ds, c, DnDConstants.ACTION_NONE);
}
/**
! * Construct a new <code>DragGestureRecognizer</code>
! * given the <code>DragSource</code> to be used in this
* Drag and Drop operation.
*
! * @param ds the <code>DragSource</code> this
! * <code>DragGestureRecognizer</code> will
* use to process the Drag and Drop operation
*
* @throws IllegalArgumentException
! * if ds is <code>null</code>.
*/
protected DragGestureRecognizer(DragSource ds) {
this(ds, null);
}
--- 135,213 ----
// cant happen ...
}
}
/**
! * Construct a new {@code DragGestureRecognizer}
! * given the {@code DragSource} to be used in this
* Drag and Drop
! * operation, the {@code Component} this
! * {@code DragGestureRecognizer} should "observe"
* for drag initiating gestures, and the action(s)
* supported for this Drag and Drop operation.
*
! * @param ds the {@code DragSource} this
! * {@code DragGestureRecognizer} will use to
* process the Drag and Drop operation
*
! * @param c the {@code Component} this
! * {@code DragGestureRecognizer} should "observe" the event
* stream to, in order to detect a drag initiating gesture.
! * If this value is {@code null}, the
! * {@code DragGestureRecognizer}
! * is not associated with any {@code Component}.
*
! * @param sa the set (logical OR) of the {@code DnDConstants}
* that this Drag and Drop operation will support
*
* @throws IllegalArgumentException
! * if ds is {@code null}.
*/
protected DragGestureRecognizer(DragSource ds, Component c, int sa) {
this(ds, c, sa, null);
}
/**
! * Construct a new {@code DragGestureRecognizer}
! * given the {@code DragSource} to be used
* in this Drag and Drop operation, and
! * the {@code Component} this
! * {@code DragGestureRecognizer}
* should "observe" for drag initiating gestures.
*
! * @param ds the {@code DragSource} this
! * {@code DragGestureRecognizer}
* will use to process the Drag and Drop operation
*
! * @param c the {@code Component}
! * this {@code DragGestureRecognizer}
* should "observe" the event stream to,
* in order to detect a drag initiating gesture.
! * If this value is {@code null},
! * the {@code DragGestureRecognizer}
! * is not associated with any {@code Component}.
*
* @throws IllegalArgumentException
! * if ds is {@code null}.
*/
protected DragGestureRecognizer(DragSource ds, Component c) {
this(ds, c, DnDConstants.ACTION_NONE);
}
/**
! * Construct a new {@code DragGestureRecognizer}
! * given the {@code DragSource} to be used in this
* Drag and Drop operation.
*
! * @param ds the {@code DragSource} this
! * {@code DragGestureRecognizer} will
* use to process the Drag and Drop operation
*
* @throws IllegalArgumentException
! * if ds is {@code null}.
*/
protected DragGestureRecognizer(DragSource ds) {
this(ds, null);
}
*** 227,250 ****
*/
protected abstract void unregisterListeners();
/**
! * This method returns the <code>DragSource</code>
! * this <code>DragGestureRecognizer</code>
* will use in order to process the Drag and Drop
* operation.
*
* @return the DragSource
*/
public DragSource getDragSource() { return dragSource; }
/**
! * This method returns the <code>Component</code>
* that is to be "observed" by the
! * <code>DragGestureRecognizer</code>
* for drag initiating gestures.
*
* @return The Component this DragGestureRecognizer
* is associated with
*/
--- 227,250 ----
*/
protected abstract void unregisterListeners();
/**
! * This method returns the {@code DragSource}
! * this {@code DragGestureRecognizer}
* will use in order to process the Drag and Drop
* operation.
*
* @return the DragSource
*/
public DragSource getDragSource() { return dragSource; }
/**
! * This method returns the {@code Component}
* that is to be "observed" by the
! * {@code DragGestureRecognizer}
* for drag initiating gestures.
*
* @return The Component this DragGestureRecognizer
* is associated with
*/
*** 255,265 ****
* set the Component that the DragGestureRecognizer is associated with
*
* registerListeners() and unregisterListeners() are called as a side
* effect as appropriate.
*
! * @param c The <code>Component</code> or <code>null</code>
*/
public synchronized void setComponent(Component c) {
if (component != null && dragGestureListener != null)
unregisterListeners();
--- 255,265 ----
* set the Component that the DragGestureRecognizer is associated with
*
* registerListeners() and unregisterListeners() are called as a side
* effect as appropriate.
*
! * @param c The {@code Component} or {@code null}
*/
public synchronized void setComponent(Component c) {
if (component != null && dragGestureListener != null)
unregisterListeners();
*** 307,323 ****
*/
public void resetRecognizer() { events.clear(); }
/**
! * Register a new <code>DragGestureListener</code>.
*
! * @param dgl the <code>DragGestureListener</code> to register
! * with this <code>DragGestureRecognizer</code>.
*
* @throws java.util.TooManyListenersException if a
! * <code>DragGestureListener</code> has already been added.
*/
public synchronized void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException {
if (dragGestureListener != null)
throw new TooManyListenersException();
--- 307,323 ----
*/
public void resetRecognizer() { events.clear(); }
/**
! * Register a new {@code DragGestureListener}.
*
! * @param dgl the {@code DragGestureListener} to register
! * with this {@code DragGestureRecognizer}.
*
* @throws java.util.TooManyListenersException if a
! * {@code DragGestureListener} has already been added.
*/
public synchronized void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException {
if (dragGestureListener != null)
throw new TooManyListenersException();
*** 329,343 ****
}
/**
* unregister the current DragGestureListener
*
! * @param dgl the <code>DragGestureListener</code> to unregister
! * from this <code>DragGestureRecognizer</code>
*
* @throws IllegalArgumentException if
! * dgl is not (equal to) the currently registered <code>DragGestureListener</code>.
*/
public synchronized void removeDragGestureListener(DragGestureListener dgl) {
if (dragGestureListener == null || !dragGestureListener.equals(dgl))
throw new IllegalArgumentException();
--- 329,343 ----
}
/**
* unregister the current DragGestureListener
*
! * @param dgl the {@code DragGestureListener} to unregister
! * from this {@code DragGestureRecognizer}
*
* @throws IllegalArgumentException if
! * dgl is not (equal to) the currently registered {@code DragGestureListener}.
*/
public synchronized void removeDragGestureListener(DragGestureListener dgl) {
if (dragGestureListener == null || !dragGestureListener.equals(dgl))
throw new IllegalArgumentException();
*** 368,416 ****
/**
* Listeners registered on the Component by this Recognizer shall record
* all Events that are recognized as part of the series of Events that go
* to comprise a Drag and Drop initiating gesture via this API.
* <P>
! * This method is used by a <code>DragGestureRecognizer</code>
! * implementation to add an <code>InputEvent</code>
* subclass (that it believes is one in a series
* of events that comprise a Drag and Drop operation)
* to the array of events that this
! * <code>DragGestureRecognizer</code> maintains internally.
*
! * @param awtie the <code>InputEvent</code>
! * to add to this <code>DragGestureRecognizer</code>'s
! * internal array of events. Note that <code>null</code>
* is not a valid value, and will be ignored.
*/
protected synchronized void appendEvent(InputEvent awtie) {
events.add(awtie);
}
/**
! * Serializes this <code>DragGestureRecognizer</code>. This method first
* performs default serialization. Then, this object's
! * <code>DragGestureListener</code> is written out if and only if it can be
! * serialized. If not, <code>null</code> is written instead.
*
* @serialData The default serializable fields, in alphabetical order,
! * followed by either a <code>DragGestureListener</code>, or
! * <code>null</code>.
* @since 1.4
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
s.writeObject(SerializationTester.test(dragGestureListener)
? dragGestureListener : null);
}
/**
! * Deserializes this <code>DragGestureRecognizer</code>. This method first
! * performs default deserialization for all non-<code>transient</code>
! * fields. This object's <code>DragGestureListener</code> is then
* deserialized as well by using the next object in the stream.
*
* @since 1.4
*/
@SuppressWarnings("unchecked")
--- 368,416 ----
/**
* Listeners registered on the Component by this Recognizer shall record
* all Events that are recognized as part of the series of Events that go
* to comprise a Drag and Drop initiating gesture via this API.
* <P>
! * This method is used by a {@code DragGestureRecognizer}
! * implementation to add an {@code InputEvent}
* subclass (that it believes is one in a series
* of events that comprise a Drag and Drop operation)
* to the array of events that this
! * {@code DragGestureRecognizer} maintains internally.
*
! * @param awtie the {@code InputEvent}
! * to add to this {@code DragGestureRecognizer}'s
! * internal array of events. Note that {@code null}
* is not a valid value, and will be ignored.
*/
protected synchronized void appendEvent(InputEvent awtie) {
events.add(awtie);
}
/**
! * Serializes this {@code DragGestureRecognizer}. This method first
* performs default serialization. Then, this object's
! * {@code DragGestureListener} is written out if and only if it can be
! * serialized. If not, {@code null} is written instead.
*
* @serialData The default serializable fields, in alphabetical order,
! * followed by either a {@code DragGestureListener}, or
! * {@code null}.
* @since 1.4
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
s.writeObject(SerializationTester.test(dragGestureListener)
? dragGestureListener : null);
}
/**
! * Deserializes this {@code DragGestureRecognizer}. This method first
! * performs default deserialization for all non-{@code transient}
! * fields. This object's {@code DragGestureListener} is then
* deserialized as well by using the next object in the stream.
*
* @since 1.4
*/
@SuppressWarnings("unchecked")
*** 435,478 ****
/*
* fields
*/
/**
! * The <code>DragSource</code>
* associated with this
! * <code>DragGestureRecognizer</code>.
*
* @serial
*/
protected DragSource dragSource;
/**
! * The <code>Component</code>
! * associated with this <code>DragGestureRecognizer</code>.
*
* @serial
*/
protected Component component;
/**
! * The <code>DragGestureListener</code>
! * associated with this <code>DragGestureRecognizer</code>.
*/
protected transient DragGestureListener dragGestureListener;
/**
! * An <code>int</code> representing
* the type(s) of action(s) used
* in this Drag and Drop operation.
*
* @serial
*/
protected int sourceActions;
/**
* The list of events (in order) that
! * the <code>DragGestureRecognizer</code>
* "recognized" as a "gesture" that triggers a drag.
*
* @serial
*/
protected ArrayList<InputEvent> events = new ArrayList<InputEvent>(1);
--- 435,478 ----
/*
* fields
*/
/**
! * The {@code DragSource}
* associated with this
! * {@code DragGestureRecognizer}.
*
* @serial
*/
protected DragSource dragSource;
/**
! * The {@code Component}
! * associated with this {@code DragGestureRecognizer}.
*
* @serial
*/
protected Component component;
/**
! * The {@code DragGestureListener}
! * associated with this {@code DragGestureRecognizer}.
*/
protected transient DragGestureListener dragGestureListener;
/**
! * An {@code int} representing
* the type(s) of action(s) used
* in this Drag and Drop operation.
*
* @serial
*/
protected int sourceActions;
/**
* The list of events (in order) that
! * the {@code DragGestureRecognizer}
* "recognized" as a "gesture" that triggers a drag.
*
* @serial
*/
protected ArrayList<InputEvent> events = new ArrayList<InputEvent>(1);
< prev index next >