]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java
Propagate ignoreNulls parameter recursively in bounds calculation
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / G2DParentNode.java
index 231b616e2a0a1a8f09497ce12941a6a562782a4c..a752e9253eedf1149b1d6860fe8e2586ffdaf539 100644 (file)
@@ -122,6 +122,26 @@ public class G2DParentNode extends ParentNode<IG2DNode> implements IG2DNode, Ini
             g2d.setTransform(ot);
     }
 
+    @Override
+    public void refresh() {
+        for (IG2DNode node : getSortedNodes()) {
+            if (node.validate()) {
+                node.refresh();
+            }
+        }
+    }
+
+    @Override
+    public void accept(IG2DNodeVisitor visitor) {
+        visitor.enter(this);
+        for (IG2DNode node : getSortedNodes()) {
+            if (node.validate()) {
+                node.accept(visitor);
+            }
+        }
+        visitor.leave(this);
+    }
+
     /**
      * Return the IDs of the children of this node in ascending Z order. This
      * method will always allocate a new result list and sort it. To get the IDs
@@ -329,14 +349,17 @@ public class G2DParentNode extends ParentNode<IG2DNode> implements IG2DNode, Ini
         Rectangle2D bounds = null;
         while(it.hasNext()) {
             IG2DNode node = it.next();
-            Rectangle2D b = node.getBounds();
+            Rectangle2D b = node.getBoundsInLocal(ignoreNulls);
             if(b == null && !ignoreNulls)
                 return null;
             if(b != null) {
-                if(bounds == null) {
-                    bounds = b.getFrame();
-                } else {
-                    bounds.add(b);
+                if(!GeometryUtils.isUndefinedRectangle(b)) {
+                    b = node.localToParent(b);
+                    if(bounds == null) {
+                        bounds = b.getFrame();
+                    } else {
+                        bounds.add(b);
+                    }
                 }
             }
         }
@@ -591,4 +614,5 @@ public class G2DParentNode extends ParentNode<IG2DNode> implements IG2DNode, Ini
        public void synchronizeTransform(double[] data) {
                this.setTransform(new AffineTransform(data));
        }
+
 }