KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > event > EventDispatcher


1 /*
2
3    Copyright 2000-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.gvt.event;
19
20 import java.awt.event.InputEvent JavaDoc;
21 import java.awt.geom.AffineTransform JavaDoc;
22 import java.util.EventListener JavaDoc;
23 import java.util.EventObject JavaDoc;
24
25 import org.apache.batik.gvt.GraphicsNode;
26
27 /**
28  * Interface for receiving and dispatching events down to a GVT tree.
29  *
30  * <p>Mouse events are dispatched to their "containing" node (the
31  * GraphicsNode corresponding to the mouse event coordinate). Searches
32  * for containment are performed from the EventDispatcher's "root"
33  * node.</p>
34  *
35  * @author <a HREF="mailto:bill.haneman@ireland.sun.com">Bill Haneman</a>
36  * @author <a HREF="mailto:tkormann@ilog.fr">Thierry Kormann</a>
37  * @version $Id: EventDispatcher.java,v 1.9 2005/03/27 08:58:34 cam Exp $ */

38 public interface EventDispatcher {
39
40     /**
41      * Sets the root node for MouseEvent dispatch containment searches
42      * and field selections.
43      * @param root the root node
44      */

45     void setRootNode(GraphicsNode root);
46
47     /**
48      * Returns the root node for MouseEvent dispatch containment
49      * searches and field selections.
50      */

51     GraphicsNode getRootNode();
52
53     /**
54      * Sets the base transform applied to MouseEvent coordinates prior
55      * to dispatch.
56      * @param t the affine transform
57      */

58     void setBaseTransform(AffineTransform JavaDoc t);
59
60     /**
61      * Returns the base transform applied to MouseEvent coordinates prior
62      * to dispatch.
63      */

64     AffineTransform JavaDoc getBaseTransform();
65
66     /**
67      * Dispatched the specified event object.
68      *
69      * <p>Converts the EventObject to a corresponding GraphicsNodeEvent
70      * and dispatch it to the appropriate GraphicsNode(s). If the
71      * event is a MouseEvent the dispatch is performed to each
72      * GraphicsNode which contains the MouseEvent coordinate, until
73      * the event is consumed. If the event is a KeyEvent, it is
74      * dispatched to the currently selected GraphicsNode.</p>
75      *
76      * @param e the event to dispatch
77      */

78     void dispatchEvent(EventObject JavaDoc e);
79
80     //
81
// Global GVT listeners support
82
//
83

84     /**
85      * Adds the specified 'global' GraphicsNodeMouseListener which is
86      * notified of all MouseEvents dispatched.
87      * @param l the listener to add
88      */

89     void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
90     /**
91      * Removes the specified 'global' GraphicsNodeMouseListener which is
92      * notified of all MouseEvents dispatched.
93      * @param l the listener to remove
94      */

95     void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
96
97     /**
98      * Adds the specified 'global' GraphicsNodeKeyListener which is
99      * notified of all KeyEvents dispatched.
100      * @param l the listener to add
101      */

102     void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
103
104     /**
105      * Removes the specified 'global' GraphicsNodeKeyListener which is
106      * notified of all KeyEvents dispatched.
107      * @param l the listener to remove
108      */

109     void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
110
111     /**
112      * Returns an array of listeners that were added to this event
113      * dispatcher and of the specified type.
114      * @param listenerType the type of the listeners to return
115      */

116     EventListener JavaDoc [] getListeners(Class JavaDoc listenerType);
117
118     /**
119      * Associates all InputEvents of type <tt>e.getID()</tt>
120      * with "incrementing" of the currently selected GraphicsNode.
121      */

122     void setNodeIncrementEvent(InputEvent JavaDoc e);
123
124     /**
125      * Associates all InputEvents of type <tt>e.getID()</tt>
126      * with "decrementing" of the currently selected GraphicsNode.
127      * The notion of "currently selected" GraphicsNode is used
128      * for dispatching KeyEvents.
129      */

130     void setNodeDecrementEvent(InputEvent JavaDoc e);
131
132 }
133
134
Popular Tags