Package edu.umd.cs.piccolo.event
Class PDragEventHandler
java.lang.Object
edu.umd.cs.piccolo.event.PBasicInputEventHandler
edu.umd.cs.piccolo.event.PDragSequenceEventHandler
edu.umd.cs.piccolo.event.PDragEventHandler
- All Implemented Interfaces:
PInputEventListener,EventListener
PDragEventHandler is a simple event handler for dragging a node on the
canvas.
- Version:
- 1.0
- Author:
- Jesse Grosjean
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a drag event handler which defaults to not moving the node to the front on drag. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddrag(PInputEvent event) Moves the dragged node in proportion to the drag distance.protected voidendDrag(PInputEvent event) Clears the current drag node.protected PNodeReturns the node that is currently being dragged, or null if none.booleanReturns whether this drag event handler has been informed to move nodes to the front of all other on drag.protected voidsetDraggedNode(PNode draggedNode) Set's the node that is currently being dragged.voidsetMoveToFrontOnPress(boolean moveToFrontOnPress) Informs this drag event handler whether it should move nodes to the front when they are dragged.protected booleanReturns whether the given event should be start a drag interaction.protected voidstartDrag(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, stopDragActivityMethods 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
-
Constructor Details
-
PDragEventHandler
public PDragEventHandler()Constructs a drag event handler which defaults to not moving the node to the front on drag.
-
-
Method Details
-
getDraggedNode
Returns the node that is currently being dragged, or null if none.- Returns:
- node being dragged or null
-
setDraggedNode
Set's the node that is currently being dragged.- Parameters:
draggedNode- node to be flagged as this handler's current drag node
-
shouldStartDragInteraction
Returns whether the given event should be start a drag interaction.- Overrides:
shouldStartDragInteractionin classPDragSequenceEventHandler- Parameters:
event- the event being tested- Returns:
- true if event is a valid start drag event
-
startDrag
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:
startDragin classPDragSequenceEventHandler- Parameters:
event- The Event responsible for the start of the drag
-
drag
Moves the dragged node in proportion to the drag distance.- Overrides:
dragin classPDragSequenceEventHandler- Parameters:
event- event representing the drag
-
endDrag
Clears the current drag node.- Overrides:
endDragin classPDragSequenceEventHandler- 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
-