edu.umd.cs.piccolo
Class PInputManager

java.lang.Object
  extended by edu.umd.cs.piccolo.event.PBasicInputEventHandler
      extended by edu.umd.cs.piccolo.PInputManager
All Implemented Interfaces:
PInputEventListener, PRoot.InputSource, EventListener

public class PInputManager
extends PBasicInputEventHandler
implements PRoot.InputSource

PInputManager is responsible for dispatching PInputEvents to node's event listeners. Events are dispatched from PRoot's processInputs method.

Version:
1.0
Author:
Jesse Grosjean
See Also:
PInputEvent, PRoot

Constructor Summary
PInputManager()
          Creates a PInputManager and sets positions (last, current) to the origin (0,0).
 
Method Summary
protected  void checkForMouseEnteredAndExited(PInputEvent event)
          Fires events whenever the mouse moves from PNode to PNode.
 Point2D getCurrentCanvasPosition()
          Returns the position of the current canvas event.
 PInputEventListener getKeyboardFocus()
          Return the node that currently has the keyboard focus.
 Point2D getLastCanvasPosition()
          Returns the position on the Canvas of the last event.
 PPickPath getMouseFocus()
          Return the current Pick Path under the mouse focus.
 PPickPath getMouseOver()
          Return the node the the mouse is currently over.
 void keyPressed(PInputEvent event)
          Will get called whenever a key has been pressed down.
 void keyReleased(PInputEvent event)
          Will get called whenever a key has been released.
 void keyTyped(PInputEvent event)
          Will be called at the end of a full keystroke (down then up).
 void mouseClicked(PInputEvent event)
          Will be called at the end of a full click (mouse pressed followed by mouse released).
 void mouseDragged(PInputEvent event)
          Will be called when a drag is occurring.
 void mouseEntered(PInputEvent event)
          Will be invoked when the mouse enters a specified region.
 void mouseExited(PInputEvent event)
          Will be invoked when the mouse leaves a specified region.
 void mouseMoved(PInputEvent event)
          Will be called when the mouse is moved.
 void mousePressed(PInputEvent event)
          Will be called when a mouse button is pressed down.
 void mouseReleased(PInputEvent event)
          Will be called when any mouse button is released.
 void mouseWheelRotated(PInputEvent event)
          This method is invoked when the mouse wheel is rotated.
 void mouseWheelRotatedByBlock(PInputEvent event)
          This method is invoked when the mouse wheel is rotated by a block.
 void processEventFromCamera(InputEvent event, int type, PCamera camera)
          Flags the given event as needing to be processed.
 void processInput()
          Causes the system to process any pending Input Events.
 void setKeyboardFocus(PInputEventListener eventHandler)
          Set the node that should receive key events.
 void setMouseFocus(PPickPath path)
          Sets the current Pick Path under the mouse focus.
 void setMouseOver(PPickPath path)
          Records the path which is directly below the mouse.
 
Methods inherited from class edu.umd.cs.piccolo.event.PBasicInputEventHandler
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, paramString, processEvent, setEventFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PInputManager

public PInputManager()
Creates a PInputManager and sets positions (last, current) to the origin (0,0).

Method Detail

getKeyboardFocus

public PInputEventListener getKeyboardFocus()
Return the node that currently has the keyboard focus. This node receives the key events.

Returns:
the current keyboard focus

setKeyboardFocus

public void setKeyboardFocus(PInputEventListener eventHandler)
Set the node that should receive key events.

Parameters:
eventHandler - sets the keyboard event focus, may be null

getMouseFocus

public PPickPath getMouseFocus()
Return the current Pick Path under the mouse focus. This will return the path that received the current mouse pressed event, or null if the mouse is not pressed. The mouse focus gets mouse dragged events even what the mouse is not over the mouse focus.

Returns:
the current Pick Path under the mouse focus

setMouseFocus

public void setMouseFocus(PPickPath path)
Sets the current Pick Path under the mouse focus. The mouse focus gets mouse dragged events even when the mouse is not over the mouse focus.

Parameters:
path - the new mouse focus

getMouseOver

public PPickPath getMouseOver()
Return the node the the mouse is currently over.

Returns:
the path over which the mouse currently is

setMouseOver

public void setMouseOver(PPickPath path)
Records the path which is directly below the mouse.

Parameters:
path - path over which the mouse has been moved

getLastCanvasPosition

public Point2D getLastCanvasPosition()
Returns the position on the Canvas of the last event.

Returns:
position of last canvas event

getCurrentCanvasPosition

public Point2D getCurrentCanvasPosition()
Returns the position of the current canvas event.

Returns:
position of current canvas event

keyPressed

public void keyPressed(PInputEvent event)
Will get called whenever a key has been pressed down. Subclasses should override this method to implement their own behavior.

Overrides:
keyPressed in class PBasicInputEventHandler
Parameters:
event - the event representing the keystroke

keyReleased

public void keyReleased(PInputEvent event)
Will get called whenever a key has been released. Subclasses should override this method to implement their own behavior.

Overrides:
keyReleased in class PBasicInputEventHandler
Parameters:
event - the event representing the keystroke

keyTyped

public void keyTyped(PInputEvent event)
Will be called at the end of a full keystroke (down then up). Subclasses should override this method to implement their own behavior.

Overrides:
keyTyped in class PBasicInputEventHandler
Parameters:
event - object which can be queried for the event's details

mouseClicked

public void mouseClicked(PInputEvent event)
Will be called at the end of a full click (mouse pressed followed by mouse released). Subclasses should override this method to implement their own behavior.

Overrides:
mouseClicked in class PBasicInputEventHandler
Parameters:
event - object which can be queried for the event's details

mouseWheelRotated

public void mouseWheelRotated(PInputEvent event)
This method is invoked when the mouse wheel is rotated. Subclasses should override this method to implement their own behavior.

Overrides:
mouseWheelRotated in class PBasicInputEventHandler
Parameters:
event - an object that can be queries to discover the event's details

mouseWheelRotatedByBlock

public void mouseWheelRotatedByBlock(PInputEvent event)
This method is invoked when the mouse wheel is rotated by a block. Subclasses should override this method to implement their own behavior.

Overrides:
mouseWheelRotatedByBlock in class PBasicInputEventHandler
Parameters:
event - an object that can be queries to discover the event's details

mouseDragged

public void mouseDragged(PInputEvent event)
Will be called when a drag is occurring. This is system dependent. Subclasses should override this method to implement their own behavior.

Overrides:
mouseDragged in class PBasicInputEventHandler
Parameters:
event - object which can be queried for the event's details

mouseEntered

public void mouseEntered(PInputEvent event)
Will be invoked when the mouse enters a specified region. Subclasses should override this method to implement their own behavior.

Overrides:
mouseEntered in class PBasicInputEventHandler
Parameters:
event - object which can be queried for the event's details

mouseExited

public void mouseExited(PInputEvent event)
Will be invoked when the mouse leaves a specified region. Subclasses should override this method to implement their own behavior.

Overrides:
mouseExited in class PBasicInputEventHandler
Parameters:
event - object which can be queried for the event's details

mouseMoved

public void mouseMoved(PInputEvent event)
Will be called when the mouse is moved. Subclasses should override this method to implement their own behavior.

Overrides:
mouseMoved in class PBasicInputEventHandler
Parameters:
event - object which can be queried for event details

mousePressed

public void mousePressed(PInputEvent event)
Will be called when a mouse button is pressed down. Should two buttons be pressed simultaneously, it will dispatch two of these in an unspecified order. Subclasses should override this method to implement their own behavior.

Overrides:
mousePressed in class PBasicInputEventHandler
Parameters:
event - object which can be queried for the event's details

mouseReleased

public void mouseReleased(PInputEvent event)
Will be called when any mouse button is released. Should two or more buttons be released simultaneously, this method will be called multiple times. Subclasses should override this method to implement their own behavior.

Overrides:
mouseReleased in class PBasicInputEventHandler
Parameters:
event - object which can be queried for event details

checkForMouseEnteredAndExited

protected void checkForMouseEnteredAndExited(PInputEvent event)
Fires events whenever the mouse moves from PNode to PNode.

Parameters:
event - to check to see if the top node has changed.

processInput

public void processInput()
Causes the system to process any pending Input Events.

Specified by:
processInput in interface PRoot.InputSource

processEventFromCamera

public void processEventFromCamera(InputEvent event,
                                   int type,
                                   PCamera camera)
Flags the given event as needing to be processed.

Parameters:
event - the event to be processed
type - type of event to be processed
camera - camera from which the event was dispatched


Copyright © 1995-2011 Piccolo2D. All Rights Reserved.