1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50:
51:
55: public abstract class DragGestureRecognizer implements Serializable
56: {
57:
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:
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: }