001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.gvt.event;
020:
021: import java.awt.event.InputEvent;
022: import java.awt.geom.AffineTransform;
023: import java.util.EventListener;
024: import java.util.EventObject;
025:
026: import org.apache.batik.gvt.GraphicsNode;
027:
028: /**
029: * Interface for receiving and dispatching events down to a GVT tree.
030: *
031: * <p>Mouse events are dispatched to their "containing" node (the
032: * GraphicsNode corresponding to the mouse event coordinate). Searches
033: * for containment are performed from the EventDispatcher's "root"
034: * node.</p>
035: *
036: * @author <a href="mailto:bill.haneman@ireland.sun.com">Bill Haneman</a>
037: * @author <a href="mailto:tkormann@ilog.fr">Thierry Kormann</a>
038: * @version $Id: EventDispatcher.java 475477 2006-11-15 22:44:28Z cam $ */
039: public interface EventDispatcher {
040:
041: /**
042: * Sets the root node for MouseEvent dispatch containment searches
043: * and field selections.
044: * @param root the root node
045: */
046: void setRootNode(GraphicsNode root);
047:
048: /**
049: * Returns the root node for MouseEvent dispatch containment
050: * searches and field selections.
051: */
052: GraphicsNode getRootNode();
053:
054: /**
055: * Sets the base transform applied to MouseEvent coordinates prior
056: * to dispatch.
057: * @param t the affine transform
058: */
059: void setBaseTransform(AffineTransform t);
060:
061: /**
062: * Returns the base transform applied to MouseEvent coordinates prior
063: * to dispatch.
064: */
065: AffineTransform getBaseTransform();
066:
067: /**
068: * Dispatched the specified event object.
069: *
070: * <p>Converts the EventObject to a corresponding GraphicsNodeEvent
071: * and dispatch it to the appropriate GraphicsNode(s). If the
072: * event is a MouseEvent the dispatch is performed to each
073: * GraphicsNode which contains the MouseEvent coordinate, until
074: * the event is consumed. If the event is a KeyEvent, it is
075: * dispatched to the currently selected GraphicsNode.</p>
076: *
077: * @param e the event to dispatch
078: */
079: void dispatchEvent(EventObject e);
080:
081: //
082: // Global GVT listeners support
083: //
084:
085: /**
086: * Adds the specified 'global' GraphicsNodeMouseListener which is
087: * notified of all MouseEvents dispatched.
088: * @param l the listener to add
089: */
090: void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
091:
092: /**
093: * Removes the specified 'global' GraphicsNodeMouseListener which is
094: * notified of all MouseEvents dispatched.
095: * @param l the listener to remove
096: */
097: void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
098:
099: /**
100: * Adds the specified 'global' GraphicsNodeMouseWheelListener which is
101: * notified of all MouseWheelEvents dispatched.
102: * @param l the listener to add
103: */
104: void addGraphicsNodeMouseWheelListener(
105: GraphicsNodeMouseWheelListener l);
106:
107: /**
108: * Removes the specified 'global' GraphicsNodeMouseWheelListener which is
109: * notified of all MouseWheelEvents dispatched.
110: * @param l the listener to remove
111: */
112: void removeGraphicsNodeMouseWheelListener(
113: GraphicsNodeMouseWheelListener l);
114:
115: /**
116: * Adds the specified 'global' GraphicsNodeKeyListener which is
117: * notified of all KeyEvents dispatched.
118: * @param l the listener to add
119: */
120: void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
121:
122: /**
123: * Removes the specified 'global' GraphicsNodeKeyListener which is
124: * notified of all KeyEvents dispatched.
125: * @param l the listener to remove
126: */
127: void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
128:
129: /**
130: * Returns an array of listeners that were added to this event
131: * dispatcher and of the specified type.
132: * @param listenerType the type of the listeners to return
133: */
134: EventListener[] getListeners(Class listenerType);
135:
136: /**
137: * Associates all InputEvents of type <tt>e.getID()</tt>
138: * with "incrementing" of the currently selected GraphicsNode.
139: */
140: void setNodeIncrementEvent(InputEvent e);
141:
142: /**
143: * Associates all InputEvents of type <tt>e.getID()</tt>
144: * with "decrementing" of the currently selected GraphicsNode.
145: * The notion of "currently selected" GraphicsNode is used
146: * for dispatching KeyEvents.
147: */
148: void setNodeDecrementEvent(InputEvent e);
149:
150: }
|