public class AWTEventDispatcher extends Object implements EventDispatcher, MouseListener, MouseMotionListener, MouseWheelListener, KeyListener
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.
| Modifier and Type | Field and Description |
|---|---|
protected AffineTransform |
baseTransform
The base AffineTransform for InputEvent-to-GraphicsNodeEvent
coordinates as determined by setBaseTransform().
|
protected GraphicsNode |
currentKeyEventTarget
The current GraphicsNode targeted by an key events.
|
protected boolean |
eventDispatchEnabled |
protected List |
eventQueue
These are used to queue events while a rendering event
is in progress.
|
protected int |
eventQueueMaxSize |
protected EventListenerList |
glisteners
The global listener list.
|
protected GraphicsNode |
lastHit
The lastest node which has been targeted by an event.
|
protected GraphicsNode |
root
The root GraphicsNode as determined by setRootNode().
|
| Constructor and Description |
|---|
AWTEventDispatcher()
Constructs a new event dispatcher.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addGraphicsNodeKeyListener(GraphicsNodeKeyListener l)
Adds the specified 'global' GraphicsNodeKeyListener which is
notified of all KeyEvents dispatched.
|
void |
addGraphicsNodeMouseListener(GraphicsNodeMouseListener l)
Adds the specified 'global' GraphicsNodeMouseListener which is
notified of all MouseEvents dispatched.
|
void |
addGraphicsNodeMouseWheelListener(GraphicsNodeMouseWheelListener l)
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 |
dispatchMouseEvent(MouseEvent evt)
Dispatches the specified AWT mouse event.
|
protected void |
dispatchMouseWheelEvent(MouseWheelEvent evt)
Dispatches the specified AWT mouse wheel event.
|
AffineTransform |
getBaseTransform()
Returns the base transform applied to MouseEvent coordinates prior
to dispatch.
|
protected int |
getCurrentLockState()
Returns a bitmask representing the state of the key locks.
|
EventListener[] |
getListeners(Class listenerType)
Returns an array of listeners that were added to this event
dispatcher and of the specified type.
|
GraphicsNode |
getRootNode()
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 |
isNodeDecrementEvent(InputEvent e)
Returns true if the input event e is a node decrement event,
false otherwise.
|
protected boolean |
isNodeIncrementEvent(InputEvent e)
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 |
keyTyped(KeyEvent evt)
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 |
mouseWheelMoved(MouseWheelEvent evt)
Dispatches the specified AWT mouse wheel event down to the GVT tree.
|
void |
processKeyEvent(GraphicsNodeKeyEvent evt)
Dispatches a graphics node key event to by firing the 'global'
listeners attached to this event dispatcher.
|
protected void |
processMouseEvent(GraphicsNodeMouseEvent evt)
Processes the specified event by firing the 'global' listeners
attached to this event dispatcher.
|
protected void |
processMouseWheelEvent(GraphicsNodeMouseWheelEvent evt)
Processes the specified event by firing the 'global' listeners
attached to this event dispatcher.
|
void |
removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l)
Removes the specified 'global' GraphicsNodeKeyListener which is
notified of all KeyEvents dispatched.
|
void |
removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l)
Removes the specified 'global' GraphicsNodeMouseListener which is
notified of all MouseEvents dispatched.
|
void |
removeGraphicsNodeMouseWheelListener(GraphicsNodeMouseWheelListener l)
Removes the specified 'global' GraphicsNodeMouseWheelListener which is
notified of all MouseWheelEvents dispatched.
|
void |
setBaseTransform(AffineTransform t)
Sets the base transform applied to MouseEvent coordinates prior
to dispatch.
|
void |
setEventDispatchEnabled(boolean b) |
void |
setEventQueueMaxSize(int n) |
void |
setNodeDecrementEvent(InputEvent e)
Associates all InputEvents of type
e.getID()
with "decrementing" of the currently selected GraphicsNode. |
void |
setNodeIncrementEvent(InputEvent e)
Associates all InputEvents of type
e.getID()
with "incrementing" of the currently selected GraphicsNode. |
void |
setRootNode(GraphicsNode root)
Sets the root node for MouseEvent dispatch containment searches
and field selections.
|
protected GraphicsNode root
protected AffineTransform baseTransform
protected EventListenerList glisteners
protected GraphicsNode lastHit
protected GraphicsNode currentKeyEventTarget
protected List eventQueue
protected boolean eventDispatchEnabled
protected int eventQueueMaxSize
public AWTEventDispatcher()
public void setRootNode(GraphicsNode root)
setRootNode in interface EventDispatcherroot - the root nodepublic GraphicsNode getRootNode()
getRootNode in interface EventDispatcherpublic void setBaseTransform(AffineTransform t)
setBaseTransform in interface EventDispatchert - the affine transformpublic AffineTransform getBaseTransform()
getBaseTransform in interface EventDispatcherpublic void mousePressed(MouseEvent evt)
mousePressed in interface MouseListenerevt - the mouse event to propagatepublic void mouseReleased(MouseEvent evt)
mouseReleased in interface MouseListenerevt - the mouse event to propagatepublic void mouseEntered(MouseEvent evt)
mouseEntered in interface MouseListenerevt - the mouse event to propagatepublic void mouseExited(MouseEvent evt)
mouseExited in interface MouseListenerevt - the mouse event to propagatepublic void mouseClicked(MouseEvent evt)
mouseClicked in interface MouseListenerevt - the mouse event to propagatepublic void mouseMoved(MouseEvent evt)
mouseMoved in interface MouseMotionListenerevt - the mouse event to propagatepublic void mouseDragged(MouseEvent evt)
mouseDragged in interface MouseMotionListenerevt - the mouse event to propagatepublic void mouseWheelMoved(MouseWheelEvent evt)
mouseWheelMoved in interface MouseWheelListenerevt - the mouse event to propagatepublic void keyPressed(KeyEvent evt)
keyPressed in interface KeyListenerevt - the key event to propagatepublic void keyReleased(KeyEvent evt)
keyReleased in interface KeyListenerevt - the key event to propagatepublic void keyTyped(KeyEvent evt)
keyTyped in interface KeyListenerevt - the key event to propagatepublic void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l)
addGraphicsNodeMouseListener in interface EventDispatcherl - the listener to addpublic void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l)
removeGraphicsNodeMouseListener in interface EventDispatcherl - the listener to removepublic void addGraphicsNodeMouseWheelListener(GraphicsNodeMouseWheelListener l)
addGraphicsNodeMouseWheelListener in interface EventDispatcherl - the listener to addpublic void removeGraphicsNodeMouseWheelListener(GraphicsNodeMouseWheelListener l)
removeGraphicsNodeMouseWheelListener in interface EventDispatcherl - the listener to removepublic void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l)
addGraphicsNodeKeyListener in interface EventDispatcherl - the listener to addpublic void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l)
removeGraphicsNodeKeyListener in interface EventDispatcherl - the listener to removepublic EventListener[] getListeners(Class listenerType)
getListeners in interface EventDispatcherlistenerType - the type of the listeners to returnpublic void setEventDispatchEnabled(boolean b)
public void setEventQueueMaxSize(int n)
public void dispatchEvent(EventObject evt)
dispatchEvent in interface EventDispatcherevt - the event to dispatchprotected int getCurrentLockState()
protected void dispatchKeyEvent(KeyEvent evt)
evt - the key event to dispatchprotected void dispatchMouseEvent(MouseEvent evt)
evt - the mouse event to dispatchprotected void dispatchMouseWheelEvent(MouseWheelEvent evt)
evt - the mouse wheel event to dispatchprotected void processMouseEvent(GraphicsNodeMouseEvent evt)
evt - the event to processprotected void processMouseWheelEvent(GraphicsNodeMouseWheelEvent evt)
evt - the event to processpublic void processKeyEvent(GraphicsNodeKeyEvent evt)
evt - the evt to dispatchpublic void setNodeIncrementEvent(InputEvent e)
e.getID()
with "incrementing" of the currently selected GraphicsNode.setNodeIncrementEvent in interface EventDispatcherpublic void setNodeDecrementEvent(InputEvent e)
e.getID()
with "decrementing" of the currently selected GraphicsNode.
The notion of "currently selected" GraphicsNode is used
for dispatching KeyEvents.setNodeDecrementEvent in interface EventDispatcherprotected boolean isNodeIncrementEvent(InputEvent e)
e - the input eventprotected boolean isNodeDecrementEvent(InputEvent e)
protected static boolean isMetaDown(int modifiers)
Copyright © 2000–2021 Apache Software Foundation. All rights reserved.