From 67060876802b31ca74ddf847c12dde65513ccc91 Mon Sep 17 00:00:00 2001 From: lehtonen Date: Thu, 10 Feb 2011 18:49:46 +0000 Subject: [PATCH] * Added ElementHints.KEY_HIDDEN for stating that an element should be considered hidden and no it should not: ** show up in any diagram/element measurements ** be involved in picking or any other interaction ** be rendered * Changed InternalSize.getBounds specification to allow implementations to differentiate between cases where an element has no area (is infinitesimally small) and that an element does not exist visually (has no bounds). This also helps in the implementation of proper diagram element measurements when parts of the diagram are hidden. fixes #2091 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@19757 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../connections/SysdynConnectionClass.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/SysdynConnectionClass.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/SysdynConnectionClass.java index a98c5c04..e391f7e9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/SysdynConnectionClass.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/SysdynConnectionClass.java @@ -252,11 +252,6 @@ public class SysdynConnectionClass { @Override public Rectangle2D getBounds(IElement e, Rectangle2D size) { - - if (size == null) - size = new Rectangle2D.Double(); - size.setFrame(0, 0, 0, 0); - ConnectionEntity ce = e.getHint(ElementHints.KEY_CONNECTION_ENTITY); if (ce == null) return size; @@ -266,24 +261,36 @@ public class SysdynConnectionClass { parts = ce.getSegments(parts); if (parts.isEmpty()) return size; + parts = ce.getBranchPoints(parts); Rectangle2D temp = null; for (IElement part : parts) { + if (ElementUtils.isHidden(part)) + continue; + // Using on-diagram coordinates because neither connections nor // edges have a non-identity transform which means that // coordinates are always absolute. Therefore branch point // bounds also need to be calculated in absolute coordinates. - ElementUtils.getElementBoundsOnDiagram(part, size); + Rectangle2D bounds = ElementUtils.getElementBoundsOnDiagram(part, size); + if (bounds == null) + continue; + // System.out.println("InternalSize BOUNDS: " + size + " for part " + part + " " + part.getElementClass()); if (temp == null) { temp = new Rectangle2D.Double(); - temp.setRect(size); + temp.setRect(bounds); } else - Rectangle2D.union(temp, size, temp); + Rectangle2D.union(temp, bounds, temp); //System.out.println("InternalSize Combined BOUNDS: " + temp); } - size.setRect(temp); + if (temp != null) { + if (size == null) + size = temp; + else + size.setRect(temp); + } // Don't leave dangling references behind. parts.clear(); -- 2.47.1