source: trunk/gcc/libjava/java/awt/dnd/DragGestureRecognizer.java

Last change on this file was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.8 KB
Line 
1/* DragGestureRecognizer.java --
2 Copyright (C) 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.awt.dnd;
40
41import java.awt.Component;
42import java.awt.Point;
43import java.awt.event.InputEvent;
44import java.io.IOException;
45import java.io.ObjectInputStream;
46import java.io.ObjectOutputStream;
47import java.io.Serializable;
48import java.util.ArrayList;
49import java.util.TooManyListenersException;
50
51/**
52 * STUBBED
53 * @since 1.2
54 */
55public abstract class DragGestureRecognizer implements Serializable
56{
57 /**
58 * Compatible with JDK 1.2+.
59 */
60 private static final long serialVersionUID = 8996673345831063337L;
61
62 protected DragSource dragSource;
63 protected Component component;
64 protected transient DragGestureListener dragGestureListener;
65 protected int sourceActions;
66 protected ArrayList events = new ArrayList();
67
68 protected DragGestureRecognizer(DragSource ds, Component c, int sa,
69 DragGestureListener dgl)
70 {
71 if (ds == null)
72 throw new IllegalArgumentException();
73 dragSource = ds;
74 component = c;
75 sourceActions = sa;
76 dragGestureListener = dgl;
77 }
78
79 protected DragGestureRecognizer(DragSource ds, Component c, int sa)
80 {
81 this(ds, c, sa, null);
82 }
83
84 protected DragGestureRecognizer(DragSource ds, Component c)
85 {
86 this(ds, c, 0, null);
87 }
88
89 protected DragGestureRecognizer(DragSource ds)
90 {
91 this(ds, null, 0, null);
92 }
93
94 protected abstract void registerListeners();
95
96 protected abstract void unregisterListeners();
97
98 public DragSource getDragSource()
99 {
100 return dragSource;
101 }
102
103 public Component getComponent()
104 {
105 return component;
106 }
107
108 public void setComponent(Component c)
109 {
110 component = c;
111 }
112
113 public int getSourceActions()
114 {
115 return sourceActions;
116 }
117
118 public void setSourceActions(int sa)
119 {
120 sourceActions = sa;
121 }
122
123 public InputEvent getTriggerEvent()
124 {
125 return events.size() > 0 ? (InputEvent) events.get(0) : null;
126 }
127
128 public void resetRecognizer()
129 {
130 throw new Error("not implemented");
131 }
132
133 /**
134 * Register a new DragGestureListener.
135 *
136 * @exception TooManyListenersException If a DragGestureListener has already
137 * been added.
138 */
139 public void addDragGestureListener(DragGestureListener dgl)
140 throws TooManyListenersException
141 {
142 if (dragGestureListener != null)
143 throw new TooManyListenersException();
144 dragGestureListener = dgl;
145 }
146
147 public void removeDragGestureListener(DragGestureListener dgl)
148 {
149 if (dragGestureListener != dgl)
150 throw new IllegalArgumentException();
151 dragGestureListener = null;
152 }
153
154 protected void fireDragGestureRecognized(int dragAction, Point p)
155 {
156 throw new Error("not implemented");
157 }
158
159 protected void appendEvent(InputEvent e)
160 {
161 if (e == null)
162 return;
163 events.add(e);
164 }
165
166 private void readObject(ObjectInputStream s)
167 throws ClassNotFoundException, IOException
168 {
169 s.defaultReadObject();
170 dragGestureListener = (DragGestureListener) s.readObject();
171 }
172
173 private void writeObject(ObjectOutputStream s) throws IOException
174 {
175 s.defaultWriteObject();
176 s.writeObject(dragGestureListener instanceof Serializable
177 ? dragGestureListener : null);
178 }
179} // class DragGestureRecognizer
Note: See TracBrowser for help on using the repository browser.