From e8b96542ea305825ae4dbf7c35f11275689ef564 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Wed, 10 Jun 2020 13:51:55 +0300 Subject: [PATCH] Propagate ignoreNulls parameter recursively in bounds calculation Change-Id: Iea4cc6b2da17967944d0f67fc8da362c579d70a6 --- .../src/org/simantics/scenegraph/g2d/G2DParentNode.java | 3 ++- .../src/org/simantics/scenegraph/g2d/nodes/LinkNode.java | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java index af8c5630d..a752e9253 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java @@ -349,11 +349,12 @@ public class G2DParentNode extends ParentNode 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 { diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/LinkNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/LinkNode.java index 50d50ecd2..aa570d6aa 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/LinkNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/LinkNode.java @@ -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; -- 2.43.2