edu.umd.cs.piccolo.event
Class PDragEventHandler

java.lang.Object
  extended by edu.umd.cs.piccolo.event.PBasicInputEventHandler
      extended by edu.umd.cs.piccolo.event.PDragSequenceEventHandler
          extended by edu.umd.cs.piccolo.event.PDragEventHandler
All Implemented Interfaces:
PInputEventListener, EventListener

public class PDragEventHandler
extends PDragSequenceEventHandler

PDragEventHandler is a simple event handler for dragging a node on the canvas.

Version:
1.0
Author:
Jesse Grosjean

Constructor Summary
PDragEventHandler()
          Constructs a drag event handler which defaults to not moving the node to the front on drag.
 
Method Summary
protected  void drag(PInputEvent event)
          Moves the dragged node in proportion to the drag distance.
protected  void endDrag(PInputEvent event)
          Clears the current drag node.
protected  PNode getDraggedNode()
          Returns the node that is currently being dragged, or null if none.
 boolean getMoveToFrontOnPress()
          Returns whether this drag event handler has been informed to move nodes to the front of all other on drag.
protected  void setDraggedNode(PNode draggedNode)
          Set's the node that is currently being dragged.
 void setMoveToFrontOnPress(boolean moveToFrontOnPress)
          Informs this drag event handler whether it should move nodes to the front when they are dragged.
protected  boolean shouldStartDragInteraction(PInputEvent event)
          Returns whether the given event should be start a drag interaction.
protected  void startDrag(PInputEvent event)
          Starts a drag event and moves the dragged node to the front if this handler has been directed to do so with a call to setMoveToFrontOnDrag.
 
Methods inherited from class edu.umd.cs.piccolo.event.PDragSequenceEventHandler
dragActivityFinalStep, dragActivityFirstStep, dragActivityStep, getDragActivity, getMinDragStartDistance, getMousePressedCanvasPoint, isDragging, mouseDragged, mousePressed, mouseReleased, setIsDragging, setMinDragStartDistance, startDragActivity, stopDragActivity
 
Methods inherited from class edu.umd.cs.piccolo.event.PBasicInputEventHandler
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseWheelRotated, mouseWheelRotatedByBlock, paramString, processEvent, setEventFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDragEventHandler

public PDragEventHandler()
Constructs a drag event handler which defaults to not moving the node to the front on drag.

Method Detail

getDraggedNode

protected PNode getDraggedNode()
Returns the node that is currently being dragged, or null if none.

Returns:
node being dragged or null

setDraggedNode

protected void setDraggedNode(PNode draggedNode)
Set's the node that is currently being dragged.

Parameters:
draggedNode - node to be flagged as this handler's current drag node

shouldStartDragInteraction

protected boolean shouldStartDragInteraction(PInputEvent event)
Returns whether the given event should be start a drag interaction.

Overrides:
shouldStartDragInteraction in class PDragSequenceEventHandler
Parameters:
event - the event being tested
Returns:
true if event is a valid start drag event

startDrag

protected void startDrag(PInputEvent event)
Starts a drag event and moves the dragged node to the front if this handler has been directed to do so with a call to setMoveToFrontOnDrag.

Overrides:
startDrag in class PDragSequenceEventHandler
Parameters:
event - The Event responsible for the start of the drag

drag

protected void drag(PInputEvent event)
Moves the dragged node in proportion to the drag distance.

Overrides:
drag in class PDragSequenceEventHandler
Parameters:
event - event representing the drag

endDrag

protected void endDrag(PInputEvent event)
Clears the current drag node.

Overrides:
endDrag in class PDragSequenceEventHandler
Parameters:
event - Event reponsible for the end of the drag. Usually a "Mouse Up" event.

getMoveToFrontOnPress

public boolean getMoveToFrontOnPress()
Returns whether this drag event handler has been informed to move nodes to the front of all other on drag.

Returns:
true if dragging a node will move it to the front

setMoveToFrontOnPress

public void setMoveToFrontOnPress(boolean moveToFrontOnPress)
Informs this drag event handler whether it should move nodes to the front when they are dragged. Default is false.

Parameters:
moveToFrontOnPress - true if dragging a node should move it to the front


Copyright © 1995-2011 Piccolo2D. All Rights Reserved.