Package edu.umd.cs.piccolo.util
Class PPickPath
java.lang.Object
edu.umd.cs.piccolo.util.PPickPath
- All Implemented Interfaces:
PInputEventListener,EventListener
PPickPath represents a ordered list of nodes that have been picked.
The topmost ancestor node is the first node in the list (and should be a
camera), the bottommost child node is at the end of the list. It is this
bottom node that is given first chance to handle events, and that any active
event handlers usually manipulate.
Note that because of layers (which can be picked by multiple camera's) the ordered list of nodes in a pick path do not all share a parent child relationship with the nodes in the list next to them. This means that the normal localToGlobal methods don't work when trying to transform geometry up and down the pick path, instead you should use the pick paths canvasToLocal methods to get the mouse event points into your local coord system.
Note that PInputEvent wraps most of the useful PPickPath methods, so often you can use a PInputEvent directly instead of having to access its pick path.
- Version:
- 1.0
- Author:
- Jesse Grosjean
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsNode(PNode node) Determines if the passed node has been excluded from being a member of the pickpath.canvasToLocal(Dimension2D canvasDimension, PNode nodeOnPath) Convert the given dimension from the canvas coordinates, down through the pick path (and through any camera view transforms applied to the path) to the local coordinates of the given node.canvasToLocal(Point2D canvasPoint, PNode nodeOnPath) Convert the given point from the canvas coordinates, down through the pick path (and through any camera view transforms applied to the path) to the local coordinates of the given node.canvasToLocal(Rectangle2D canvasRectangle, PNode nodeOnPath) Convert the given rectangle from the canvas coordinates, down through the pick path (and through any camera view transforms applied to the path) to the local coordinates of the given node.Get the bottom camera on the pick path.Returns a reference to the node stack.getPathTransformTo(PNode nodeOnPath) Calculates the context at which the given node is being interacted with.Returns the bounds of the entire PickPath taken as a whole.Get the bottom node on the pick path node stack.doublegetScale()Returns the resulting scale of applying the transforms of the entire pick path.Get the top camera on the pick path.Return the next node that will be picked after the current picked node.voidRemoves the topmost node from the node stack.voidpopTransform(PAffineTransform transform) Pops the top most transform from the pick path.voidprocessEvent(PInputEvent event, int eventType) Process Events - Give each node in the pick path, starting at the bottom most one, a chance to handle the event.voidPushes the provided node to the top of the pick path.voidpushTransform(PAffineTransform transform) Adds the transform to the pick path's transform.voidreset()Resets the PickPath to its initial state.
-
Field Details
-
CURRENT_PICK_PATH
Global pick path.
-
-
Constructor Details
-
PPickPath
Creates a pick pack originating from the provided camera and with the given screen pick bounds.- Parameters:
camera- camera from which the pickpath originatesaScreenPickBounds- bounds of pick area
-
-
Method Details
-
getPickBounds
Returns the bounds of the entire PickPath taken as a whole.- Returns:
- bounds of the entire PickPath
-
acceptsNode
Determines if the passed node has been excluded from being a member of the pickpath.- Parameters:
node- node being tested- Returns:
- true if node is acceptable to the path
-
pushNode
Pushes the provided node to the top of the pick path.- Parameters:
node- node to be added to the pick path
-
popNode
Removes the topmost node from the node stack.- Parameters:
node- completely unused in this method, but is passed in so that subclasses may be informed of it.
-
getPickedNode
Get the bottom node on the pick path node stack. That is the last node to be picked.- Returns:
- the bottom node on the pick path
-
nextPickedNode
Return the next node that will be picked after the current picked node. For instance of you have two overlapping children nodes then the topmost child will always be picked first, use this method to find the covered child. Return the camera when no more visual will be picked. Alters the effective node stack in the process!- Returns:
- next node to picked after the picked node
-
reset
public void reset()Resets the PickPath to its initial state. Can be used to obtain the original node stack after using nextPickedNode(). -
getTopCamera
Get the top camera on the pick path. This is the camera that originated the pick action.- Returns:
- the topmost camera of this pick pack
-
getBottomCamera
Get the bottom camera on the pick path. This may be different then the top camera if internal cameras are in use.- Returns:
- the camera closest to the picked node
-
getNodeStackReference
Returns a reference to the node stack. Be Careful!- Returns:
- the node stack
-
getScale
public double getScale()Returns the resulting scale of applying the transforms of the entire pick path. In essence it gives you the scale at which interaction is occurring.- Returns:
- scale at which interaction is occurring.
-
pushTransform
Adds the transform to the pick path's transform. This is used when determining the context of the current interaction.- Parameters:
transform- transform to be added to applied to the pickpath.
-
popTransform
Pops the top most transform from the pick path.- Parameters:
transform- unused in this method
-
getPathTransformTo
Calculates the context at which the given node is being interacted with.- Parameters:
nodeOnPath- a node currently on the pick path. An exception will be thrown if the node cannot be found.- Returns:
- Transform at which the given node is being interacted with.
-
processEvent
Process Events - Give each node in the pick path, starting at the bottom most one, a chance to handle the event.- Specified by:
processEventin interfacePInputEventListener- Parameters:
event- event to be processedeventType- the type of event being processed
-
canvasToLocal
Convert the given point from the canvas coordinates, down through the pick path (and through any camera view transforms applied to the path) to the local coordinates of the given node.- Parameters:
canvasPoint- point to be transformednodeOnPath- node into which the point is to be transformed iteratively through the pick path- Returns:
- transformed canvasPoint in local coordinates of the picked node
-
canvasToLocal
Convert the given dimension from the canvas coordinates, down through the pick path (and through any camera view transforms applied to the path) to the local coordinates of the given node.- Parameters:
canvasDimension- dimension to be transformednodeOnPath- node into which the dimension is to be transformed iteratively through the stack- Returns:
- transformed canvasDimension in local coordinates of the picked node
-
canvasToLocal
Convert the given rectangle from the canvas coordinates, down through the pick path (and through any camera view transforms applied to the path) to the local coordinates of the given node.- Parameters:
canvasRectangle- rectangle to be transformednodeOnPath- node into which the rectangle is to be transformed iteratively through the stack- Returns:
- transformed canvasRectangle in local coordinates of the picked node
-