本文整理汇总了Java中org.piccolo2d.util.PPickPath类的典型用法代码示例。如果您正苦于以下问题:Java PPickPath类的具体用法?Java PPickPath怎么用?Java PPickPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PPickPath类属于org.piccolo2d.util包,在下文中一共展示了PPickPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullPick
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Return true if this node or any pickable descendants are picked. If a
* pick occurs the pickPath is modified so that this node is always returned
* as the picked node, event if it was a descendant node that initially
* reported the pick.
*
* @param pickPath the pick path to add the nodes to if they are picked
* @return true if this node or one of its descendants was picked
*/
public boolean fullPick(final PPickPath pickPath) {
if (super.fullPick(pickPath)) {
PNode picked = pickPath.getPickedNode();
// this code won't work with internal cameras, because it doesn't
// pop the cameras view transform.
while (picked != this) {
pickPath.popTransform(picked.getTransformReference(false));
pickPath.popNode(picked);
picked = pickPath.getPickedNode();
}
return true;
}
return false;
}
示例2: testHiddenNodesAreNotPickable
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
public void testHiddenNodesAreNotPickable() {
final PCanvas canvas = new PCanvas();
canvas.setBounds(0, 0, 400, 400);
canvas.setPreferredSize(new Dimension(400, 400));
final PNode node1 = new PNode();
node1.setBounds(0, 0, 100, 100);
node1.setPaint(Color.RED);
canvas.getLayer().addChild(node1);
final PNode node2 = (PNode) node1.clone();
node2.setPaint(Color.BLUE);
final PLayer layer2 = new PLayer();
layer2.addChild(node2);
layer2.setVisible(false);
canvas.getCamera().addLayer(layer2);
final PPickPath path = canvas.getCamera().pick(5, 5, 5);
assertSame(node1, path.getPickedNode());
}
示例3: testPick
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
public void testPick() {
final PCanvas canvas = new PCanvas();
final PCamera camera = canvas.getCamera();
final PLayer layer = canvas.getLayer();
camera.setBounds(0, 0, 100, 100);
final PNode a = PPath.createRectangle(0, 0, 100, 100);
final PNode b = PPath.createRectangle(0, 0, 100, 100);
final PNode c = PPath.createRectangle(0, 0, 100, 100);
layer.addChild(a);
layer.addChild(b);
layer.addChild(c);
final PPickPath pickPath = camera.pick(50, 50, 2);
assertTrue(pickPath.getPickedNode() == c);
assertTrue(pickPath.nextPickedNode() == b);
assertTrue(pickPath.nextPickedNode() == a);
assertTrue(pickPath.nextPickedNode() == camera);
assertTrue(pickPath.nextPickedNode() == null);
assertTrue(pickPath.nextPickedNode() == null);
}
示例4: testPickPackWorksInSimpleCases
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
public void testPickPackWorksInSimpleCases() {
final PLayer layer = new PLayer();
camera.addChild(layer);
final PNode node1 = new PNode();
node1.setBounds(0, 0, 10, 10);
layer.addChild(node1);
final PNode node2 = new PNode();
node2.setBounds(0, 0, 10, 10);
node2.setOffset(10, 10);
layer.addChild(node2);
final PPickPath path1 = camera.pick(5, 5, 1);
assertEquals(node1, path1.getPickedNode());
final PPickPath path2 = camera.pick(15, 15, 1);
assertEquals(node2, path2.getPickedNode());
}
示例5: mouseExited
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
public void mouseExited(final PInputEvent aEvent) {
final PPickPath focus = aEvent.getInputManager().getMouseFocus();
if (cursorPushed && isNewFocus(focus)) {
aEvent.popCursor();
cursorPushed = false;
}
}
示例6: mouseExited
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* When mouse leaves, pop cursor from stack.
*
* @param aEvent the mouse exited event
*/
public void mouseExited(final PInputEvent aEvent) {
if (cursorPushed) {
final PPickPath focus = aEvent.getInputManager().getMouseFocus();
if (focus == null || focus.getPickedNode() != PBoundsHandle.this) {
aEvent.popCursor();
cursorPushed = false;
}
}
}
示例7: fullPick
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Try to pick this node and all of its descendants if they are visible in
* the clipping region.
*
* @param pickPath the pick path to add the node to if its picked
* @return true if this node or one of its descendants was picked.
*/
public boolean fullPick(final PPickPath pickPath) {
if (getPickable() && fullIntersects(pickPath.getPickBounds())) {
pickPath.pushNode(this);
pickPath.pushTransform(getTransformReference(false));
if (pick(pickPath)) {
return true;
}
if (getChildrenPickable() && getPathReference().intersects(pickPath.getPickBounds())) {
final int count = getChildrenCount();
for (int i = count - 1; i >= 0; i--) {
final PNode each = getChild(i);
if (each.fullPick(pickPath)) {
return true;
}
}
}
if (pickAfterChildren(pickPath)) {
return true;
}
pickPath.popTransform(getTransformReference(false));
pickPath.popNode(this);
}
return false;
}
示例8: getActiveScale
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Detect the current scale. Made protected to enable custom
* re-implementations.
*
* @return the current scale
*/
protected float getActiveScale() {
if (PPickPath.CURRENT_PICK_PATH != null) {
return (float) PPickPath.CURRENT_PICK_PATH.getScale();
}
return 1.0f;
}
示例9: detectOcclusions
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Traverse the pick path determining which parent nodes are occluded by
* their children nodes. Note that this is only detecting a subset of
* occlusions (parent, child), others such as overlapping siblings or
* cousins are not detected.
*
* @param node node from which to detect occlusions
* @param pickPath Pick Path to traverse
*/
public void detectOcclusions(final PNode node, final PPickPath pickPath) {
if (!node.fullIntersects(pickPath.getPickBounds())) {
return;
}
pickPath.pushTransform(node.getTransformReference(false));
final int count = node.getChildrenCount();
for (int i = count - 1; i >= 0; i--) {
final PNode each = node.getChild(i);
if (node.getOccluded()) {
// if n has been occluded by a previous descendant then
// this child must also be occluded
each.setOccluded(true);
}
else {
// see if child each occludes n
detectOcclusions(each, pickPath);
}
}
if (nodeOccludesParents(node, pickPath)) {
final PNode parent = node.getParent();
while (parent != null && !parent.getOccluded()) {
parent.setOccluded(true);
}
}
pickPath.popTransform(node.getTransformReference(false));
}
示例10: getPickedNode
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Returns picked node on pickPath if pickPath is not null, or null.
*
* @param pickPath from which to extract picked node
*
* @return the picked node or null if pickPath is null
*/
private PNode getPickedNode(final PPickPath pickPath) {
if (pickPath == null) {
return null;
}
else {
return pickPath.getPickedNode();
}
}
示例11: pick
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Generate and return a PPickPath for the point x,y specified in the local
* coord system of this camera. Picking is done with a rectangle, halo
* specifies how large that rectangle will be.
*
* @param x the x coordinate of the pick path given in local coordinates
* @param y the y coordinate of the pick path given in local coordinates
* @param halo the distance from the x,y coordinate that is considered for
* inclusion in the pick path
*
* @return the picked path
*/
public PPickPath pick(final double x, final double y, final double halo) {
final PBounds b = new PBounds(new Point2D.Double(x, y), -halo, -halo);
final PPickPath result = new PPickPath(this, b);
fullPick(result);
// make sure this camera is pushed.
if (result.getNodeStackReference().size() == 0) {
result.pushNode(this);
result.pushTransform(getTransformReference(false));
}
return result;
}
示例12: pickAfterChildren
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* <p>
* After the direct children of this camera have been given a chance to be
* picked all of the layers in the list of layers viewed by this camera are
* given a chance to be picked.
* </p>
*
* @return true if any of the layers in the list of layers viewed by this
* camera were picked
*/
protected boolean pickAfterChildren(final PPickPath pickPath) {
if (intersects(pickPath.getPickBounds())) {
pickPath.pushTransform(viewTransform);
if (pickCameraView(pickPath)) {
return true;
}
pickPath.popTransform(viewTransform);
return true;
}
return false;
}
示例13: pickCameraView
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Try to pick all of the layers in the list of layers viewed by this
* camera. This method is called after the view transform has been applied
* to the specified pick path.
*
* @param pickPath pick path
* @return true if any of the layers in the list of layers viewed by this
* camera were picked
*/
protected boolean pickCameraView(final PPickPath pickPath) {
final int size = layers.size();
for (int i = size - 1; i >= 0; i--) {
final PLayer each = (PLayer) layers.get(i);
if (each.fullPick(pickPath)) {
return true;
}
}
return false;
}
示例14: fullPick
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
/**
* Try to pick this node and all of its descendants. Most subclasses should
* not need to override this method. Instead they should override
* <code>pick</code> or <code>pickAfterChildren</code>.
*
* @param pickPath the pick path to add the node to if its picked
* @return true if this node or one of its descendants was picked.
*/
public boolean fullPick(final PPickPath pickPath) {
if (getVisible() && (getPickable() || getChildrenPickable()) && fullIntersects(pickPath.getPickBounds())) {
pickPath.pushNode(this);
pickPath.pushTransform(transform);
final boolean thisPickable = getPickable() && pickPath.acceptsNode(this);
if (thisPickable && pick(pickPath)) {
return true;
}
if (getChildrenPickable()) {
final int count = getChildrenCount();
for (int i = count - 1; i >= 0; i--) {
final PNode each = (PNode) children.get(i);
if (each.fullPick(pickPath)) {
return true;
}
}
}
if (thisPickable && pickAfterChildren(pickPath)) {
return true;
}
pickPath.popTransform(transform);
pickPath.popNode(this);
}
return false;
}
示例15: testfullPickReturnsTrueWhenOverlapsWithChildNode
import org.piccolo2d.util.PPickPath; //导入依赖的package包/类
public void testfullPickReturnsTrueWhenOverlapsWithChildNode() {
final PCanvas canvas = new PCanvas();
node.setBounds(0, 0, 10, 10);
final PNode child = new PNode();
child.setBounds(20, 0, 10, 10);
node.addChild(child);
final PPickPath pickPath = new PPickPath(canvas.getCamera(), new PBounds(20, 0, 10, 10));
canvas.getLayer().addChild(node);
assertTrue(node.fullPick(pickPath));
}