X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fparticipant%2FPanZoomRotateHandler.java;h=6ca4f786247b9e4cc82db6892ad150e0db685a41;hb=3598f987e691cb4f35ab8f283d4dfd760bcdd410;hp=eeab18069717aaa250ffe5ffb5d0e06320b47871;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/PanZoomRotateHandler.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/PanZoomRotateHandler.java index eeab18069..6ca4f7862 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/PanZoomRotateHandler.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/participant/PanZoomRotateHandler.java @@ -13,7 +13,6 @@ package org.simantics.g2d.participant; import static org.simantics.g2d.canvas.Hints.KEY_CANVAS_TRANSFORM; -import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; @@ -185,18 +184,22 @@ public class PanZoomRotateHandler extends AbstractCanvasParticipant { super.removedFromContext(ctx); } + protected Class getNavigationNodeClass() { + return NavigationNode.class; + } + @SGInit public void initSG(G2DParentNode parent) { // Replace old NAVIGATION_NODE with a new one INode oldnav = NodeUtil.getRootNode(parent).getNode(SceneGraphConstants.NAVIGATION_NODE_NAME); if(oldnav != null) { - node = oldnav.appendParent(SceneGraphConstants.NAVIGATION_NODE_NAME, NavigationNode.class); + node = oldnav.appendParent(SceneGraphConstants.NAVIGATION_NODE_NAME, getNavigationNodeClass()); // FIXME : oldnav seems to be the same node as parent (most of the cases). // Deleting it will cause plenty of code to fail, since they refer to the node directly. // The bug was not shown, since deleting() a Node did not actually wipe its structures (until now). // oldnav.delete(); } else { - node = parent.addNode(SceneGraphConstants.NAVIGATION_NODE_NAME, NavigationNode.class); + node = parent.addNode(SceneGraphConstants.NAVIGATION_NODE_NAME, getNavigationNodeClass()); } node.setLookupId(SceneGraphConstants.NAVIGATION_NODE_NAME); node.setZIndex(0); @@ -369,9 +372,8 @@ public class PanZoomRotateHandler extends AbstractCanvasParticipant { if (d==null) return false; Set selections = selection.getAllSelections(); - Shape bounds = ElementUtils.getElementBoundsOnDiagram(selections); - if (bounds == null) return false; - Rectangle2D diagramRect = bounds.getBounds2D(); + Rectangle2D diagramRect = ElementUtils.getSurroundingElementBoundsOnDiagram(selections); + if (diagramRect == null) return false; if (diagramRect.getWidth() <= 0 && diagramRect.getHeight() <= 0) return false;