Revision: 622
Author: allain.lalonde
Date: Wed Jul 29 12:09:45 2009
Log: Fixed Issue 113; made fullPick ignore a node and its children if that  
node is invisible.
http://code.google.com/p/piccolo2d/source/detail?r=622

Modified:
  /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PNode.java
  /piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PNodeTest.java

=======================================
--- /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PNode.java      
 
Tue Jul 28 13:58:25 2009
+++ /piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/PNode.java      
 
Wed Jul 29 12:09:45 2009
@@ -2722,7 +2722,7 @@
       * @return true if this node or one of its descendents was picked.
       */
      public boolean fullPick(final PPickPath pickPath) {
-        if ((getPickable() || getChildrenPickable()) &&  
fullIntersects(pickPath.getPickBounds())) {
+        if (getVisible() && (getPickable() || getChildrenPickable()) &&  
fullIntersects(pickPath.getPickBounds())) {
              pickPath.pushNode(this);
              pickPath.pushTransform(transform);

=======================================
---  
/piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PNodeTest.java      
 
Tue Jul 28 12:46:54 2009
+++  
/piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/PNodeTest.java      
 
Wed Jul 29 12:09:45 2009
@@ -29,6 +29,7 @@
  package edu.umd.cs.piccolo;

  import java.awt.Color;
+import java.awt.Dimension;
  import java.awt.Graphics;
  import java.awt.GraphicsEnvironment;
  import java.awt.geom.AffineTransform;
@@ -52,6 +53,7 @@
  import edu.umd.cs.piccolo.activities.PTransformActivity;
  import edu.umd.cs.piccolo.activities.PColorActivity.Target;
  import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
+import edu.umd.cs.piccolo.event.PInputEvent;
  import edu.umd.cs.piccolo.util.PAffineTransform;
  import edu.umd.cs.piccolo.util.PAffineTransformException;
  import edu.umd.cs.piccolo.util.PBounds;
@@ -1290,4 +1292,25 @@
          node.setOccluded(true);
          assertTrue(node.getOccluded());
      }
-}
+
+    public void testHiddenNodesAreNotPickable() {
+        PCanvas canvas = new PCanvas();
+        canvas.setBounds(0, 0, 400, 400);
+        canvas.setPreferredSize(new Dimension(400, 400));
+        PNode node1 = new PNode();
+        node1.setBounds(0, 0, 100, 100);
+        node1.setPaint(Color.RED);
+        canvas.getLayer().addChild(node1);
+
+        PNode node2 = (PNode) node1.clone();
+        node2.setPaint(Color.BLUE);
+
+        PLayer layer2 = new PLayer();
+        layer2.addChild(node2);
+        layer2.setVisible(false);
+        canvas.getCamera().addLayer(layer2);
+
+        PPickPath path = canvas.getCamera().pick(5, 5, 5);
+        assertSame(node1, path.getPickedNode());
+    }
+}

--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to