]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Propagate ignoreNulls parameter recursively in bounds calculation 03/4303/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 10 Jun 2020 10:51:55 +0000 (13:51 +0300)
committerJussi Koskela <jussi.koskela@semantum.fi>
Wed, 10 Jun 2020 10:51:55 +0000 (13:51 +0300)
Change-Id: Iea4cc6b2da17967944d0f67fc8da362c579d70a6

bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/LinkNode.java

index af8c5630dc84c88c46c350b07c540ee9926e9ae6..a752e9253eedf1149b1d6860fe8e2586ffdaf539 100644 (file)
@@ -349,11 +349,12 @@ 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(!GeometryUtils.isUndefinedRectangle(b)) {
+                    b = node.localToParent(b);
                     if(bounds == null) {
                         bounds = b.getFrame();
                     } else {
index 50d50ecd2f3fe48e2d8b9f894149c7585880bd13..aa570d6aa21144d3ea4dfd6eb9f2dd7d255de93e 100644 (file)
@@ -131,6 +131,11 @@ public class LinkNode extends StateMaskNode {
 
     @Override
     public Rectangle2D getBoundsInLocal() {
+        return getBoundsInLocal(false);
+    }
+    
+    @Override
+    public Rectangle2D getBoundsInLocal(boolean ignoreNulls) {
         // Safety against cyclic cases.
         if (hasFlags(IN_GET_BOUNDS))
             return new Rectangle2D.Double();
@@ -141,7 +146,7 @@ public class LinkNode extends StateMaskNode {
 
         setFlags(IN_GET_BOUNDS);
         try {
-            Rectangle2D bounds = n.getBoundsInLocal();
+            Rectangle2D bounds = n.getBoundsInLocal(ignoreNulls);
             if (transform != null && !transform.isIdentity())
                 bounds = transform.createTransformedShape(bounds).getBounds2D();
             return bounds;