Package org.apache.batik.gvt.event
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AffineTransform
The base AffineTransform for InputEvent-to-GraphicsNodeEvent coordinates as determined by setBaseTransform().protected GraphicsNode
The current GraphicsNode targeted by an key events.protected boolean
protected List
These are used to queue events while a rendering event is in progress.protected int
protected EventListenerList
The global listener list.protected GraphicsNode
The lastest node which has been targeted by an event.protected GraphicsNode
The root GraphicsNode as determined by setRootNode(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.void
Adds the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.void
Adds the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.void
dispatchEvent
(EventObject evt) Dispatches the specified AWT event.protected void
dispatchKeyEvent
(KeyEvent evt) Dispatches the specified AWT key event.protected void
Dispatches the specified AWT mouse event.protected void
Dispatches the specified AWT mouse wheel event.Returns the base transform applied to MouseEvent coordinates prior to dispatch.protected int
Returns 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.protected static boolean
isMetaDown
(int modifiers) Returns whether the meta key is down according to the given modifiers bitfield.protected boolean
Returns true if the input event e is a node decrement event, false otherwise.protected boolean
Returns true if the input event e is a node increment event, false otherwise.void
keyPressed
(KeyEvent evt) Dispatches the specified AWT key event down to the GVT tree.void
keyReleased
(KeyEvent evt) Dispatches the specified AWT key event down to the GVT tree.void
Dispatches the specified AWT key event down to the GVT tree.void
mouseClicked
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
mouseDragged
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
mouseEntered
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
mouseExited
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
mouseMoved
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
mousePressed
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
mouseReleased
(MouseEvent evt) Dispatches the specified AWT mouse event down to the GVT tree.void
Dispatches the specified AWT mouse wheel event down to the GVT tree.void
Dispatches a graphics node key event to by firing the 'global' listeners attached to this event dispatcher.protected void
Processes the specified event by firing the 'global' listeners attached to this event dispatcher.protected void
Processes the specified event by firing the 'global' listeners attached to this event dispatcher.void
Removes the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.void
Removes the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.void
Removes the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.void
Sets the base transform applied to MouseEvent coordinates prior to dispatch.void
setEventDispatchEnabled
(boolean b) void
setEventQueueMaxSize
(int n) void
Associates all InputEvents of typee.getID()
with "decrementing" of the currently selected GraphicsNode.void
Associates all InputEvents of typee.getID()
with "incrementing" of the currently selected GraphicsNode.void
setRootNode
(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
-
-
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:
setRootNode
in interfaceEventDispatcher
- Parameters:
root
- the root node
-
getRootNode
Returns the root node for MouseEvent dispatch containment searches and field selections.- Specified by:
getRootNode
in interfaceEventDispatcher
-
setBaseTransform
Sets the base transform applied to MouseEvent coordinates prior to dispatch.- Specified by:
setBaseTransform
in interfaceEventDispatcher
- Parameters:
t
- the affine transform
-
getBaseTransform
Returns the base transform applied to MouseEvent coordinates prior to dispatch.- Specified by:
getBaseTransform
in interfaceEventDispatcher
-
mousePressed
Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.- Specified by:
mousePressed
in 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:
mouseReleased
in 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:
mouseEntered
in 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:
mouseExited
in 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:
mouseClicked
in 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:
mouseMoved
in 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:
mouseDragged
in 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:
mouseWheelMoved
in 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:
keyPressed
in 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:
keyReleased
in 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:
keyTyped
in interfaceKeyListener
- Parameters:
evt
- the key event to propagate
-
addGraphicsNodeMouseListener
Adds the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.- Specified by:
addGraphicsNodeMouseListener
in interfaceEventDispatcher
- Parameters:
l
- the listener to add
-
removeGraphicsNodeMouseListener
Removes the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.- Specified by:
removeGraphicsNodeMouseListener
in interfaceEventDispatcher
- Parameters:
l
- the listener to remove
-
addGraphicsNodeMouseWheelListener
Adds the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.- Specified by:
addGraphicsNodeMouseWheelListener
in interfaceEventDispatcher
- Parameters:
l
- the listener to add
-
removeGraphicsNodeMouseWheelListener
Removes the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.- Specified by:
removeGraphicsNodeMouseWheelListener
in interfaceEventDispatcher
- Parameters:
l
- the listener to remove
-
addGraphicsNodeKeyListener
Adds the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.- Specified by:
addGraphicsNodeKeyListener
in interfaceEventDispatcher
- Parameters:
l
- the listener to add
-
removeGraphicsNodeKeyListener
Removes the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.- Specified by:
removeGraphicsNodeKeyListener
in 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:
getListeners
in 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:
dispatchEvent
in 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
-
setNodeIncrementEvent
Associates all InputEvents of typee.getID()
with "incrementing" of the currently selected GraphicsNode.- Specified by:
setNodeIncrementEvent
in 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:
setNodeDecrementEvent
in 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.
-