## org.apache.batik.gvt.event
Class AbstractAWTEventDispatcher

    java.lang.Object
      org.apache.batik.gvt.event.AbstractAWTEventDispatcher

All Implemented Interfaces:
  java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, EventDispatcher

Direct Known Subclasses:
  AWTEventDispatcher

    public abstract class AbstractAWTEventDispatcher

extends java.lang.Object
implements EventDispatcher, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.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.

This class is made abstract so that concrete versions can be made for different JDK versions.

Field Summary
`protected java.awt.geom.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 java.util.List` `eventQueue` These are used to queue events while a rendering event is in progress.
`protected int` `eventQueueMaxSize`
`protected javax.swing.event.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 Summary
`AbstractAWTEventDispatcher()` Constructs a new event dispatcher.

Method Summary
`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(java.util.EventObject evt)` Dispatches the specified AWT event.
`protected abstract void` `dispatchKeyEvent(java.awt.event.KeyEvent evt)` Dispatches the specified AWT key event.
`protected void` `dispatchMouseEvent(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event.
`java.awt.geom.AffineTransform` `getBaseTransform()` Returns the base transform applied to MouseEvent coordinates prior to dispatch.
`protected abstract int` `getButton(java.awt.event.MouseEvent evt)` Returns the button whose state changed for the given event.
`protected int` `getCurrentLockState()` Returns a bitmask representing the state of the key locks.
`java.util.EventListener[]` `getListeners(java.lang.Class listenerType)` Returns an array of listeners that were added to this event dispatcher and of the specified type.
`protected abstract int` `getModifiers(java.awt.event.InputEvent evt)` Returns the modifiers mask for this event.
`GraphicsNode` `getRootNode()` Returns the root node for MouseEvent dispatch containment searches and field selections.
`protected boolean` `isNodeDecrementEvent(java.awt.event.InputEvent e)` Returns true if the input event e is a node decrement event, false otherwise.
`protected boolean` `isNodeIncrementEvent(java.awt.event.InputEvent e)` Returns true if the input event e is a node increment event, false otherwise.
`void` `keyPressed(java.awt.event.KeyEvent evt)` Dispatches the specified AWT key event down to the GVT tree.
`void` `keyReleased(java.awt.event.KeyEvent evt)` Dispatches the specified AWT key event down to the GVT tree.
`void` `keyTyped(java.awt.event.KeyEvent evt)` Dispatches the specified AWT key event down to the GVT tree.
`void` `mouseClicked(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event down to the GVT tree.
`void` `mouseDragged(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event down to the GVT tree.
`void` `mouseEntered(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event down to the GVT tree.
`void` `mouseExited(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event down to the GVT tree.
`void` `mouseMoved(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event down to the GVT tree.
`void` `mousePressed(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse event down to the GVT tree.
`void` `mouseReleased(java.awt.event.MouseEvent evt)` Dispatches the specified AWT mouse 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.
`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(java.awt.geom.AffineTransform t)` Sets the base transform applied to MouseEvent coordinates prior to dispatch.
`void` `setEventDispatchEnabled(boolean b)`
`void` `setEventQueueMaxSize(int n)`
`void` `setNodeDecrementEvent(java.awt.event.InputEvent e)` Associates all InputEvents of type `e.getID()` with "decrementing" of the currently selected GraphicsNode.
`void` `setNodeIncrementEvent(java.awt.event.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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### root

    protected GraphicsNode root

  The root GraphicsNode as determined by setRootNode().

### baseTransform

    protected java.awt.geom.AffineTransform baseTransform

  The base AffineTransform for InputEvent-to-GraphicsNodeEvent coordinates as determined by setBaseTransform().

### glisteners

    protected javax.swing.event.EventListenerList glisteners

  The global listener list.

### lastHit

    protected GraphicsNode lastHit

  The lastest node which has been targeted by an event.

### currentKeyEventTarget

    protected GraphicsNode currentKeyEventTarget

  The current GraphicsNode targeted by an key events.

### eventQueue

    protected java.util.List eventQueue

  These are used to queue events while a rendering event is in progress.

### eventDispatchEnabled

    protected boolean eventDispatchEnabled

### eventQueueMaxSize

    protected int eventQueueMaxSize

Constructor Detail

### AbstractAWTEventDispatcher

    public AbstractAWTEventDispatcher()

  Constructs a new event dispatcher.

Method Detail

### setRootNode

    public void setRootNode(GraphicsNode root)

  Sets the root node for MouseEvent dispatch containment searches and field selections.

  Specified by:
    `setRootNode` in interface `EventDispatcher`
  Parameters:
    `root` - the root node

### getRootNode

    public GraphicsNode getRootNode()

  Returns the root node for MouseEvent dispatch containment searches and field selections.

  Specified by:
    `getRootNode` in interface `EventDispatcher`

### setBaseTransform

    public void setBaseTransform(java.awt.geom.AffineTransform t)

  Sets the base transform applied to MouseEvent coordinates prior to dispatch.

  Specified by:
    `setBaseTransform` in interface `EventDispatcher`
  Parameters:
    `t` - the affine transform

### getBaseTransform

    public java.awt.geom.AffineTransform getBaseTransform()

  Returns the base transform applied to MouseEvent coordinates prior to dispatch.

  Specified by:
    `getBaseTransform` in interface `EventDispatcher`

### mousePressed

    public void mousePressed(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mousePressed` in interface `java.awt.event.MouseListener`
  Parameters:
    `evt` - the mouse event to propagate

### mouseReleased

    public void mouseReleased(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mouseReleased` in interface `java.awt.event.MouseListener`
  Parameters:
    `evt` - the mouse event to propagate

### mouseEntered

    public void mouseEntered(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mouseEntered` in interface `java.awt.event.MouseListener`
  Parameters:
    `evt` - the mouse event to propagate

### mouseExited

    public void mouseExited(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mouseExited` in interface `java.awt.event.MouseListener`
  Parameters:
    `evt` - the mouse event to propagate

### mouseClicked

    public void mouseClicked(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mouseClicked` in interface `java.awt.event.MouseListener`
  Parameters:
    `evt` - the mouse event to propagate

### mouseMoved

    public void mouseMoved(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mouseMoved` in interface `java.awt.event.MouseMotionListener`
  Parameters:
    `evt` - the mouse event to propagate

### mouseDragged

    public void mouseDragged(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event down to the GVT tree. The mouse event is mutated to a GraphicsNodeMouseEvent.

  Specified by:
    `mouseDragged` in interface `java.awt.event.MouseMotionListener`
  Parameters:
    `evt` - the mouse event to propagate

### keyPressed

    public void keyPressed(java.awt.event.KeyEvent evt)

  Dispatches the specified AWT key event down to the GVT tree. The mouse event is mutated to a GraphicsNodeKeyEvent.

  Specified by:
    `keyPressed` in interface `java.awt.event.KeyListener`
  Parameters:
    `evt` - the key event to propagate

### keyReleased

    public void keyReleased(java.awt.event.KeyEvent evt)

  Dispatches the specified AWT key event down to the GVT tree. The mouse event is mutated to a GraphicsNodeKeyEvent.

  Specified by:
    `keyReleased` in interface `java.awt.event.KeyListener`
  Parameters:
    `evt` - the key event to propagate

### keyTyped

    public void keyTyped(java.awt.event.KeyEvent evt)

  Dispatches the specified AWT key event down to the GVT tree. The mouse event is mutated to a GraphicsNodeKeyEvent.

  Specified by:
    `keyTyped` in interface `java.awt.event.KeyListener`
  Parameters:
    `evt` - the key event to propagate

### addGraphicsNodeMouseListener

    public void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l)

  Adds the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.

  Specified by:
    `addGraphicsNodeMouseListener` in interface `EventDispatcher`
  Parameters:
    `l` - the listener to add

### removeGraphicsNodeMouseListener

    public void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l)

  Removes the specified 'global' GraphicsNodeMouseListener which is notified of all MouseEvents dispatched.

  Specified by:
    `removeGraphicsNodeMouseListener` in interface `EventDispatcher`
  Parameters:
    `l` - the listener to remove

### addGraphicsNodeMouseWheelListener

    public void addGraphicsNodeMouseWheelListener(GraphicsNodeMouseWheelListener l)

  Adds the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.

  Specified by:
    `addGraphicsNodeMouseWheelListener` in interface `EventDispatcher`
  Parameters:
    `l` - the listener to add

### removeGraphicsNodeMouseWheelListener

    public void removeGraphicsNodeMouseWheelListener(GraphicsNodeMouseWheelListener l)

  Removes the specified 'global' GraphicsNodeMouseWheelListener which is notified of all MouseWheelEvents dispatched.

  Specified by:
    `removeGraphicsNodeMouseWheelListener` in interface `EventDispatcher`
  Parameters:
    `l` - the listener to remove

### addGraphicsNodeKeyListener

    public void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l)

  Adds the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.

  Specified by:
    `addGraphicsNodeKeyListener` in interface `EventDispatcher`
  Parameters:
    `l` - the listener to add

### removeGraphicsNodeKeyListener

    public void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l)

  Removes the specified 'global' GraphicsNodeKeyListener which is notified of all KeyEvents dispatched.

  Specified by:
    `removeGraphicsNodeKeyListener` in interface `EventDispatcher`
  Parameters:
    `l` - the listener to remove

### getListeners

    public java.util.EventListener[] getListeners(java.lang.Class listenerType)

  Returns an array of listeners that were added to this event dispatcher and of the specified type.

  Specified by:
    `getListeners` in interface `EventDispatcher`
  Parameters:
    `listenerType` - the type of the listeners to return

### setEventDispatchEnabled

    public void setEventDispatchEnabled(boolean b)

### setEventQueueMaxSize

    public void setEventQueueMaxSize(int n)

### dispatchEvent

    public void dispatchEvent(java.util.EventObject evt)

  Dispatches the specified AWT event.

  Specified by:
    `dispatchEvent` in interface `EventDispatcher`
  Parameters:
    `evt` - the event to dispatch

### getCurrentLockState

    protected int getCurrentLockState()

  Returns a bitmask representing the state of the key locks.

### dispatchKeyEvent

    protected abstract void dispatchKeyEvent(java.awt.event.KeyEvent evt)

  Dispatches the specified AWT key event. Abstract because KeyEvent.getKeyLocation() is available only in JDKs >= 1.4.

  Parameters:
    `evt` - the key event to dispatch

### getModifiers

    protected abstract int getModifiers(java.awt.event.InputEvent evt)

  Returns the modifiers mask for this event. Overridden in the descendent class to use `InputEvent.getModifiers()` in JRE 1.3 or `InputEvent.getModifiersEx()` in JREs >= 1.4.

### getButton

    protected abstract int getButton(java.awt.event.MouseEvent evt)

  Returns the button whose state changed for the given event. Overridden in the descendant class to use `InputEvent.getModifiers()` in JRE 1.3 or `MouseEvent.getButton()` in JREs >= 1.4.

### dispatchMouseEvent

    protected void dispatchMouseEvent(java.awt.event.MouseEvent evt)

  Dispatches the specified AWT mouse event.

  Parameters:
    `evt` - the mouse event to dispatch

### processMouseEvent

    protected void processMouseEvent(GraphicsNodeMouseEvent evt)

  Processes the specified event by firing the 'global' listeners attached to this event dispatcher.

  Parameters:
    `evt` - the event to process

### processKeyEvent

    public void processKeyEvent(GraphicsNodeKeyEvent evt)

  Dispatches a graphics node key event to by firing the 'global' listeners attached to this event dispatcher.

  Parameters:
    `evt` - the evt to dispatch

### setNodeIncrementEvent

    public void setNodeIncrementEvent(java.awt.event.InputEvent e)

  Associates all InputEvents of type `e.getID()` with "incrementing" of the currently selected GraphicsNode.

  Specified by:
    `setNodeIncrementEvent` in interface `EventDispatcher`

### setNodeDecrementEvent

    public void setNodeDecrementEvent(java.awt.event.InputEvent e)

  Associates all InputEvents of type `e.getID()` with "decrementing" of the currently selected GraphicsNode. The notion of "currently selected" GraphicsNode is used for dispatching KeyEvents.

  Specified by:
    `setNodeDecrementEvent` in interface `EventDispatcher`

### isNodeIncrementEvent

    protected boolean isNodeIncrementEvent(java.awt.event.InputEvent e)

  Returns true if the input event e is a node increment event, false otherwise.

  Parameters:
    `e` - the input event

### isNodeDecrementEvent

    protected boolean isNodeDecrementEvent(java.awt.event.InputEvent e)

  Returns true if the input event e is a node decrement event, false otherwise.

Copyright © 2008 Apache Software Foundation. All Rights Reserved.