Package org.apache.batik.bridge
Class BridgeEventSupport.Listener
- java.lang.Object
-
- org.apache.batik.bridge.BridgeEventSupport.Listener
-
- All Implemented Interfaces:
java.util.EventListener
,GraphicsNodeKeyListener
,GraphicsNodeMouseListener
- Direct Known Subclasses:
SVG12BridgeEventSupport.Listener
- Enclosing class:
- BridgeEventSupport
protected static class BridgeEventSupport.Listener extends java.lang.Object implements GraphicsNodeMouseListener, GraphicsNodeKeyListener
A GraphicsNodeMouseListener that dispatch DOM events accordingly.
-
-
Field Summary
Fields Modifier and Type Field Description protected BridgeContext
context
protected boolean
isDown
protected org.w3c.dom.Element
lastTargetElement
protected UserAgent
ua
-
Constructor Summary
Constructors Constructor Description Listener(BridgeContext ctx, UserAgent u)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
dispatchKeyEvent(java.lang.String eventType, GraphicsNodeKeyEvent evt)
Dispatch a DOM 2 Draft Key event.protected void
dispatchMouseEvent(java.lang.String eventType, GraphicsNodeMouseEvent evt, boolean cancelable)
Dispatches a DOM MouseEvent according to the specified parameters.protected void
dispatchMouseEvent(java.lang.String eventType, org.w3c.dom.Element targetElement, org.w3c.dom.Element relatedElement, java.awt.Point clientXY, GraphicsNodeMouseEvent evt, boolean cancelable)
Dispatches a DOM MouseEvent according to the specified parameters.protected org.w3c.dom.Element
getEventTarget(GraphicsNode node, java.awt.geom.Point2D pt)
Returns the element that is the target of the specified event or null if any.protected org.w3c.dom.Element
getRelatedElement(GraphicsNodeMouseEvent evt)
Returns the related element according to the specified event.void
keyPressed(GraphicsNodeKeyEvent evt)
Invoked when a key has been pressed.void
keyReleased(GraphicsNodeKeyEvent evt)
Invoked when a key has been released.void
keyTyped(GraphicsNodeKeyEvent evt)
Invoked when a key has been typed.protected int
mapKeyCode(int keyCode)
The java KeyEvent keyCodes and the DOMKeyEvent keyCodes map except for the VK_ENTER code (which has a different value in DOM and the VK_KANA_LOCK and VK_INPUT_METHOD_ON_OFF which have no DOM equivalent.void
mouseClicked(GraphicsNodeMouseEvent evt)
Invoked when the mouse has been clicked on a graphics node.void
mouseDragged(GraphicsNodeMouseEvent evt)
Invoked when a mouse button is pressed on a graphics node and then dragged.void
mouseEntered(GraphicsNodeMouseEvent evt)
Invoked when the mouse enters a graphics node.void
mouseExited(GraphicsNodeMouseEvent evt)
Invoked when the mouse exits a graphics node.void
mouseMoved(GraphicsNodeMouseEvent evt)
Invoked when the mouse button has been moved on a node.void
mousePressed(GraphicsNodeMouseEvent evt)
Invoked when a mouse button has been pressed on a graphics node.void
mouseReleased(GraphicsNodeMouseEvent evt)
Invoked when a mouse button has been released on a graphics node.
-
-
-
Field Detail
-
context
protected BridgeContext context
-
ua
protected UserAgent ua
-
lastTargetElement
protected org.w3c.dom.Element lastTargetElement
-
isDown
protected boolean isDown
-
-
Constructor Detail
-
Listener
public Listener(BridgeContext ctx, UserAgent u)
-
-
Method Detail
-
keyPressed
public void keyPressed(GraphicsNodeKeyEvent evt)
Invoked when a key has been pressed.- Specified by:
keyPressed
in interfaceGraphicsNodeKeyListener
- Parameters:
evt
- the graphics node key event
-
keyReleased
public void keyReleased(GraphicsNodeKeyEvent evt)
Invoked when a key has been released.- Specified by:
keyReleased
in interfaceGraphicsNodeKeyListener
- Parameters:
evt
- the graphics node key event
-
keyTyped
public void keyTyped(GraphicsNodeKeyEvent evt)
Invoked when a key has been typed.- Specified by:
keyTyped
in interfaceGraphicsNodeKeyListener
- Parameters:
evt
- the graphics node key event
-
dispatchKeyEvent
protected void dispatchKeyEvent(java.lang.String eventType, GraphicsNodeKeyEvent evt)
Dispatch a DOM 2 Draft Key event.
-
mapKeyCode
protected final int mapKeyCode(int keyCode)
The java KeyEvent keyCodes and the DOMKeyEvent keyCodes map except for the VK_ENTER code (which has a different value in DOM and the VK_KANA_LOCK and VK_INPUT_METHOD_ON_OFF which have no DOM equivalent.
-
mouseClicked
public void mouseClicked(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when the mouse has been clicked on a graphics node.- Specified by:
mouseClicked
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
mousePressed
public void mousePressed(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when a mouse button has been pressed on a graphics node.- Specified by:
mousePressed
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
mouseReleased
public void mouseReleased(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when a mouse button has been released on a graphics node.- Specified by:
mouseReleased
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
mouseEntered
public void mouseEntered(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when the mouse enters a graphics node.- Specified by:
mouseEntered
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
mouseExited
public void mouseExited(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when the mouse exits a graphics node.- Specified by:
mouseExited
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
mouseDragged
public void mouseDragged(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when a mouse button is pressed on a graphics node and then dragged.- Specified by:
mouseDragged
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
mouseMoved
public void mouseMoved(GraphicsNodeMouseEvent evt)
Description copied from interface:GraphicsNodeMouseListener
Invoked when the mouse button has been moved on a node.- Specified by:
mouseMoved
in interfaceGraphicsNodeMouseListener
- Parameters:
evt
- the graphics node mouse event
-
dispatchMouseEvent
protected void dispatchMouseEvent(java.lang.String eventType, GraphicsNodeMouseEvent evt, boolean cancelable)
Dispatches a DOM MouseEvent according to the specified parameters.- Parameters:
eventType
- the event typeevt
- the GVT GraphicsNodeMouseEventcancelable
- true means the event is cancelable
-
dispatchMouseEvent
protected void dispatchMouseEvent(java.lang.String eventType, org.w3c.dom.Element targetElement, org.w3c.dom.Element relatedElement, java.awt.Point clientXY, GraphicsNodeMouseEvent evt, boolean cancelable)
Dispatches a DOM MouseEvent according to the specified parameters.- Parameters:
eventType
- the event typetargetElement
- the target of the eventrelatedElement
- the related target if anyclientXY
- the mouse coordinates in the client spaceevt
- the GVT GraphicsNodeMouseEventcancelable
- true means the event is cancelable
-
getRelatedElement
protected org.w3c.dom.Element getRelatedElement(GraphicsNodeMouseEvent evt)
Returns the related element according to the specified event.- Parameters:
evt
- the GVT GraphicsNodeMouseEvent
-
getEventTarget
protected org.w3c.dom.Element getEventTarget(GraphicsNode node, java.awt.geom.Point2D pt)
Returns the element that is the target of the specified event or null if any.- Parameters:
node
- the graphics node that received the eventpt
- the mouse coordinates in the GVT tree space
-
-