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, java.util.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.
 java.awt.geom.Point2D getCurrentCanvasPosition()
          Returns the position of the current canvas event.
 PInputEventListener getKeyboardFocus()
          Return the node that currently has the keyboard focus.
 java.awt.geom.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)
          
 void keyReleased(PInputEvent event)
          
 void keyTyped(PInputEvent event)
          
 void mouseClicked(PInputEvent event)
          
 void mouseDragged(PInputEvent event)
          
 void mouseEntered(PInputEvent event)
          
 void mouseExited(PInputEvent event)
          
 void mouseMoved(PInputEvent event)
          
 void mousePressed(PInputEvent event)
          
 void mouseReleased(PInputEvent event)
          
 void mouseWheelRotated(PInputEvent event)
          
 void mouseWheelRotatedByBlock(PInputEvent event)
          
 void processEventFromCamera(java.awt.event.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 java.awt.geom.Point2D getLastCanvasPosition()
Returns the position on the Canvas of the last event.

Returns:
position of last canvas event

getCurrentCanvasPosition

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

Returns:
position of current canvas event

keyPressed

public void keyPressed(PInputEvent event)

Overrides:
keyPressed in class PBasicInputEventHandler

keyReleased

public void keyReleased(PInputEvent event)

Overrides:
keyReleased in class PBasicInputEventHandler

keyTyped

public void keyTyped(PInputEvent event)

Overrides:
keyTyped in class PBasicInputEventHandler

mouseClicked

public void mouseClicked(PInputEvent event)

Overrides:
mouseClicked in class PBasicInputEventHandler

mouseWheelRotated

public void mouseWheelRotated(PInputEvent event)

Overrides:
mouseWheelRotated in class PBasicInputEventHandler

mouseWheelRotatedByBlock

public void mouseWheelRotatedByBlock(PInputEvent event)

Overrides:
mouseWheelRotatedByBlock in class PBasicInputEventHandler

mouseDragged

public void mouseDragged(PInputEvent event)

Overrides:
mouseDragged in class PBasicInputEventHandler

mouseEntered

public void mouseEntered(PInputEvent event)

Overrides:
mouseEntered in class PBasicInputEventHandler

mouseExited

public void mouseExited(PInputEvent event)

Overrides:
mouseExited in class PBasicInputEventHandler

mouseMoved

public void mouseMoved(PInputEvent event)

Overrides:
mouseMoved in class PBasicInputEventHandler

mousePressed

public void mousePressed(PInputEvent event)

Overrides:
mousePressed in class PBasicInputEventHandler

mouseReleased

public void mouseReleased(PInputEvent event)

Overrides:
mouseReleased in class PBasicInputEventHandler

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(java.awt.event.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-2009 Piccolo2D. All Rights Reserved.