Class AWTEventDispatcher
java.lang.Object
org.apache.batik.gvt.event.AWTEventDispatcher
- All Implemented Interfaces:
KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, EventListener, EventDispatcher
public class AWTEventDispatcher
extends Object
implements EventDispatcher, MouseListener, MouseMotionListener, MouseWheelListener, KeyListener
An EventDispatcher implementation based on AWT events.
Mouse events are dispatched to their "containing" node (the GraphicsNode corresponding to the mouse event coordinate). Searches for containment are performed from the EventDispatcher's "root" node.
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AffineTransformThe base AffineTransform for InputEvent-to-GraphicsNodeEvent coordinates as determined by setBaseTransform().protected GraphicsNodeThe current GraphicsNode targeted by an key events.protected booleanprotected ListThese are used to queue events while a rendering event is in progress.protected intprotected EventListenerListThe global listener list.protected GraphicsNodeThe lastest node which has been targeted by an event.(package private) static final intdefault max size of the event queue.private intprivate intprivate intprivate intprivate intprivate intprotected GraphicsNodeThe root GraphicsNode as determined by setRootNode(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.voidAdds the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.voidAdds the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.private voidvoiddispatchEvent(EventObject evt) Dispatches the specified AWT event.protected voiddispatchKeyEvent(KeyEvent evt) Dispatches the specified AWT key event.protected voidDispatches the specified AWT mouse event.protected voidDispatches the specified AWT mouse wheel event.Returns the base transform applied to MouseEvent coordinates prior to dispatch.protected intReturns a bitmask representing the state of the key locks.getListeners(Class listenerType) Returns an array of listeners that were added to this event dispatcher and of the specified type.Returns the root node for MouseEvent dispatch containment searches and field selections.private voidprotected static booleanisMetaDown(int modifiers) Returns whether the meta key is down according to the given modifiers bitfield.protected booleanReturns true if the input event e is a node decrement event, false otherwise.protected booleanReturns true if the input event e is a node increment event, false otherwise.voidkeyPressed(KeyEvent evt) Dispatches the specified AWT key event down to the GVT tree.voidkeyReleased(KeyEvent evt) Dispatches the specified AWT key event down to the GVT tree.voidDispatches the specified AWT key event down to the GVT tree.voidmouseClicked(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidmouseDragged(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidmouseEntered(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidmouseExited(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidmouseMoved(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidmousePressed(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidmouseReleased(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.voidDispatches the specified AWT mouse wheel event down to the GVT tree.voidDispatches a graphics node key event to by firing the 'global' listeners attached to this event dispatcher.protected voidProcesses the specified event by firing the 'global' listeners attached to this event dispatcher.protected voidProcesses the specified event by firing the 'global' listeners attached to this event dispatcher.voidRemoves the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.voidRemoves the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.voidRemoves the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.voidSets the base transform applied to MouseEvent coordinates prior to dispatch.voidsetEventDispatchEnabled(boolean b) voidsetEventQueueMaxSize(int n) voidAssociates all InputEvents of typee.getID()with "decrementing" of the currently selected GraphicsNode.voidAssociates all InputEvents of typee.getID()with "incrementing" of the currently selected GraphicsNode.voidsetRootNode(GraphicsNode root) Sets the root node for MouseEvent dispatch containment searches and field selections.
-
Field Details
-
root
The root GraphicsNode as determined by setRootNode(). -
baseTransform
The base AffineTransform for InputEvent-to-GraphicsNodeEvent coordinates as determined by setBaseTransform(). -
glisteners
The global listener list. -
lastHit
The lastest node which has been targeted by an event. -
currentKeyEventTarget
The current GraphicsNode targeted by an key events. -
eventQueue
These are used to queue events while a rendering event is in progress. -
eventDispatchEnabled
protected boolean eventDispatchEnabled -
eventQueueMaxSize
protected int eventQueueMaxSize -
MAX_QUEUE_SIZE
static final int MAX_QUEUE_SIZEdefault max size of the event queue.- See Also:
-
nodeIncrementEventID
private int nodeIncrementEventID -
nodeIncrementEventCode
private int nodeIncrementEventCode -
nodeIncrementEventModifiers
private int nodeIncrementEventModifiers -
nodeDecrementEventID
private int nodeDecrementEventID -
nodeDecrementEventCode
private int nodeDecrementEventCode -
nodeDecrementEventModifiers
private int nodeDecrementEventModifiers
-
-
Constructor Details
-
AWTEventDispatcher
public AWTEventDispatcher()Constructs a new event dispatcher.
-
-
Method Details
-
setRootNode
Sets the root node for MouseEvent dispatch containment searches and field selections.- Specified by:
setRootNodein interfaceEventDispatcher- Parameters:
root- the root node
-
getRootNode
Returns the root node for MouseEvent dispatch containment searches and field selections.- Specified by:
getRootNodein interfaceEventDispatcher
-
setBaseTransform
Sets the base transform applied to MouseEvent coordinates prior to dispatch.- Specified by:
setBaseTransformin interfaceEventDispatcher- Parameters:
t- the affine transform
-
getBaseTransform
Returns the base transform applied to MouseEvent coordinates prior to dispatch.- Specified by:
getBaseTransformin interfaceEventDispatcher
-
mousePressed
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
evt- the mouse event to propagate
-
mouseReleased
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
evt- the mouse event to propagate
-
mouseEntered
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
evt- the mouse event to propagate
-
mouseExited
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
evt- the mouse event to propagate
-
mouseClicked
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
evt- the mouse event to propagate
-
mouseMoved
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
evt- the mouse event to propagate
-
mouseDragged
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Parameters:
evt- the mouse event to propagate
-
mouseWheelMoved
Dispatches the specified AWT mouse wheel event down to the GVT tree. The mouse wheel event is mutated to a GraphicsNodeMouseWheelEvent.- Specified by:
mouseWheelMovedin interfaceMouseWheelListener- Parameters:
evt- the mouse event to propagate
-
keyPressed
Dispatches the specified AWT key event down to the GVT tree. The mouse event is mutated to a GraphicsNodeKeyEvent.- Specified by:
keyPressedin interfaceKeyListener- Parameters:
evt- the key event to propagate
-
keyReleased
Dispatches the specified AWT key event down to the GVT tree. The mouse event is mutated to a GraphicsNodeKeyEvent.- Specified by:
keyReleasedin interfaceKeyListener- Parameters:
evt- the key event to propagate
-
keyTyped
Dispatches the specified AWT key event down to the GVT tree. The mouse event is mutated to a GraphicsNodeKeyEvent.- Specified by:
keyTypedin interfaceKeyListener- Parameters:
evt- the key event to propagate
-
addGraphicsNodeMouseListener
Adds the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.- Specified by:
addGraphicsNodeMouseListenerin interfaceEventDispatcher- Parameters:
l- the listener to add
-
removeGraphicsNodeMouseListener
Removes the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.- Specified by:
removeGraphicsNodeMouseListenerin interfaceEventDispatcher- Parameters:
l- the listener to remove
-
addGraphicsNodeMouseWheelListener
Adds the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.- Specified by:
addGraphicsNodeMouseWheelListenerin interfaceEventDispatcher- Parameters:
l- the listener to add
-
removeGraphicsNodeMouseWheelListener
Removes the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.- Specified by:
removeGraphicsNodeMouseWheelListenerin interfaceEventDispatcher- Parameters:
l- the listener to remove
-
addGraphicsNodeKeyListener
Adds the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.- Specified by:
addGraphicsNodeKeyListenerin interfaceEventDispatcher- Parameters:
l- the listener to add
-
removeGraphicsNodeKeyListener
Removes the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.- Specified by:
removeGraphicsNodeKeyListenerin interfaceEventDispatcher- Parameters:
l- the listener to remove
-
getListeners
Returns an array of listeners that were added to this event dispatcher and of the specified type.- Specified by:
getListenersin interfaceEventDispatcher- Parameters:
listenerType- the type of the listeners to return
-
setEventDispatchEnabled
public void setEventDispatchEnabled(boolean b) -
setEventQueueMaxSize
public void setEventQueueMaxSize(int n) -
dispatchEvent
Dispatches the specified AWT event.- Specified by:
dispatchEventin interfaceEventDispatcher- Parameters:
evt- the event to dispatch
-
getCurrentLockState
protected int getCurrentLockState()Returns a bitmask representing the state of the key locks. -
dispatchKeyEvent
Dispatches the specified AWT key event.- Parameters:
evt- the key event to dispatch
-
dispatchMouseEvent
Dispatches the specified AWT mouse event.- Parameters:
evt- the mouse event to dispatch
-
dispatchMouseWheelEvent
Dispatches the specified AWT mouse wheel event.- Parameters:
evt- the mouse wheel event to dispatch
-
processMouseEvent
Processes the specified event by firing the 'global' listeners attached to this event dispatcher.- Parameters:
evt- the event to process
-
processMouseWheelEvent
Processes the specified event by firing the 'global' listeners attached to this event dispatcher.- Parameters:
evt- the event to process
-
processKeyEvent
Dispatches a graphics node key event to by firing the 'global' listeners attached to this event dispatcher.- Parameters:
evt- the evt to dispatch
-
incrementKeyTarget
private void incrementKeyTarget() -
decrementKeyTarget
private void decrementKeyTarget() -
setNodeIncrementEvent
Associates all InputEvents of typee.getID()with "incrementing" of the currently selected GraphicsNode.- Specified by:
setNodeIncrementEventin interfaceEventDispatcher
-
setNodeDecrementEvent
Associates all InputEvents of typee.getID()with "decrementing" of the currently selected GraphicsNode. The notion of "currently selected" GraphicsNode is used for dispatching KeyEvents.- Specified by:
setNodeDecrementEventin interfaceEventDispatcher
-
isNodeIncrementEvent
Returns true if the input event e is a node increment event, false otherwise.- Parameters:
e- the input event
-
isNodeDecrementEvent
Returns true if the input event e is a node decrement event, false otherwise. -
isMetaDown
protected static boolean isMetaDown(int modifiers) Returns whether the meta key is down according to the given modifiers bitfield.
-