edu.umd.cs.piccolo.event
Class PInputEvent

java.lang.Object
  extended byedu.umd.cs.piccolo.event.PInputEvent

public class PInputEvent
extends java.lang.Object

PInputEvent is used to notify PInputEventListeners of keyboard and mouse input. It has methods for normal event properties such as event modifier keys and event canvas location.

In addition is has methods to get the mouse position and delta in a variety of coordinate systems.

Last of all it provides access to the dispatch manager that can be queried to find the current mouse over, mouse focus, and keyboard focus.

Version:
1.0
Author:
Jesse Grosjean

Constructor Summary
PInputEvent(PInputManager inputManager, java.awt.event.InputEvent event)
           
 
Method Summary
 int getButton()
           
 PCamera getCamera()
          Return the bottom most camera that is currently painting.
 PDimension getCanvasDelta()
          Return the delta between the last and current mouse position in PCanvas coordinates.
 java.awt.geom.Point2D getCanvasPosition()
          Return the mouse position in PCanvas coordinates.
 int getClickCount()
           
 PComponent getComponent()
          Get the canvas associated with the top camera.
 PDimension getDelta()
          Return the delta between the last and current mouse positions transformed through the view transform of the bottom camera.
 PDimension getDeltaRelativeTo(PNode nodeOnPath)
          Return the delta between the last and current mouse positions relative to a given node on the pick path.
 PInputManager getInputManager()
          Return the input manager that dispatched this event.
 char getKeyChar()
           
 int getKeyCode()
           
 int getKeyLocation()
           
 int getModifiers()
           
 PPickPath getPath()
          Return the PPickPath associated with this input event.
 PNode getPickedNode()
          Return the bottom node on the current pickpath, that is the picked node furthest from the root node.
 java.awt.geom.Point2D getPosition()
          Return the mouse position transformed through the view transform of the bottom camera.
 java.awt.geom.Point2D getPositionRelativeTo(PNode nodeOnPath)
          Return the mouse position relative to a given node on the pick path.
 PCamera getTopCamera()
          Return the topmost camera this is painting.
 int getWheelRotation()
           
 long getWhen()
           
 boolean isActionKey()
           
 boolean isAltDown()
           
 boolean isControlDown()
           
 boolean isFocusEvent()
           
 boolean isHandled()
          Return true if another event handler has already handled this event.
 boolean isKeyEvent()
           
 boolean isLeftMouseButton()
           
 boolean isMiddleMouseButton()
           
 boolean isMouseEnteredOrMouseExited()
           
 boolean isMouseEvent()
           
 boolean isMouseWheelEvent()
           
 boolean isPopupTrigger()
          Returns whether or not this event is a popup menu trigger event for the platform.
 boolean isRightMouseButton()
           
 boolean isShiftDown()
           
 void popCursor()
           
 void pushCursor(java.awt.Cursor cursor)
           
 void setHandled(boolean handled)
          Set that this event has been handled by an event handler.
 void setPath(PPickPath path)
           
 java.lang.String toString()
          Returns a string representation of this object for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PInputEvent

public PInputEvent(PInputManager inputManager,
                   java.awt.event.InputEvent event)
Method Detail

pushCursor

public void pushCursor(java.awt.Cursor cursor)

popCursor

public void popCursor()

getCamera

public PCamera getCamera()
Return the bottom most camera that is currently painting. If you are using internal cameras this may be different then what is returned by getTopCamera.


getTopCamera

public PCamera getTopCamera()
Return the topmost camera this is painting. This is the camera assocaited with the PCanvas that requested the current repaint.


getComponent

public PComponent getComponent()
Get the canvas associated with the top camera. This is the canvas where the originating swing event came from.


getInputManager

public PInputManager getInputManager()
Return the input manager that dispatched this event. You can use this input manager to find the current mouse focus, mouse over, and key focus nodes. You can also set a new key focus node.


getPath

public PPickPath getPath()
Return the PPickPath associated with this input event.


setPath

public void setPath(PPickPath path)

getPickedNode

public PNode getPickedNode()
Return the bottom node on the current pickpath, that is the picked node furthest from the root node.


getKeyCode

public int getKeyCode()

getKeyChar

public char getKeyChar()

getKeyLocation

public int getKeyLocation()

isActionKey

public boolean isActionKey()

getModifiers

public int getModifiers()

getClickCount

public int getClickCount()

getWhen

public long getWhen()

isAltDown

public boolean isAltDown()

isControlDown

public boolean isControlDown()

isShiftDown

public boolean isShiftDown()

isLeftMouseButton

public boolean isLeftMouseButton()

isMiddleMouseButton

public boolean isMiddleMouseButton()

isRightMouseButton

public boolean isRightMouseButton()

isHandled

public boolean isHandled()
Return true if another event handler has already handled this event. Event handlers should use this as a hint before handling the event themselves and possibly reject events that have already been handled.


setHandled

public void setHandled(boolean handled)
Set that this event has been handled by an event handler. This is a relaxed for of consuming events. The event will continue to get dispatched to event handlers even after it is marked as handled, but other event handlers that might conflict are expected to ignore events that have already been handled.


getButton

public int getButton()

getWheelRotation

public int getWheelRotation()

isKeyEvent

public boolean isKeyEvent()

isMouseEvent

public boolean isMouseEvent()

isMouseWheelEvent

public boolean isMouseWheelEvent()

isFocusEvent

public boolean isFocusEvent()

isMouseEnteredOrMouseExited

public boolean isMouseEnteredOrMouseExited()

isPopupTrigger

public boolean isPopupTrigger()
Returns whether or not this event is a popup menu trigger event for the platform. Must not be called if this event isn't a mouse event.

Note: Popup menus are triggered differently on different systems. Therefore, isPopupTrigger should be checked in both mousePressed and mouseReleased for proper cross-platform functionality.

Returns:
boolean, true if this event triggers a popup menu for this platform
Throws:
java.lang.IllegalStateException - if this event is not a mouse event

getCanvasPosition

public java.awt.geom.Point2D getCanvasPosition()
Return the mouse position in PCanvas coordinates.


getCanvasDelta

public PDimension getCanvasDelta()
Return the delta between the last and current mouse position in PCanvas coordinates.


getPositionRelativeTo

public java.awt.geom.Point2D getPositionRelativeTo(PNode nodeOnPath)
Return the mouse position relative to a given node on the pick path.


getDeltaRelativeTo

public PDimension getDeltaRelativeTo(PNode nodeOnPath)
Return the delta between the last and current mouse positions relative to a given node on the pick path.


getPosition

public java.awt.geom.Point2D getPosition()
Return the mouse position transformed through the view transform of the bottom camera.


getDelta

public PDimension getDelta()
Return the delta between the last and current mouse positions transformed through the view transform of the bottom camera.


toString

public java.lang.String toString()
Returns a string representation of this object for debugging purposes.



Copyright 2004 by University of Maryland, College Park, MD 20742, USA All rights reserved.