Esempio n. 1
0
 /**
  * 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();
   }
 }
Esempio n. 2
0
  public void testPick() {
    PCanvas canvas = new PCanvas();
    PCamera camera = canvas.getCamera();
    PLayer layer = canvas.getLayer();

    camera.setBounds(0, 0, 100, 100);

    PNode a = PPath.createRectangle(0, 0, 100, 100);
    PNode b = PPath.createRectangle(0, 0, 100, 100);
    PNode c = PPath.createRectangle(0, 0, 100, 100);

    layer.addChild(a);
    layer.addChild(b);
    layer.addChild(c);

    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);
  }