Faster bounds calculation for zoom to selection and navigate to target 30/2330/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 18 Oct 2018 10:45:45 +0000 (13:45 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 18 Oct 2018 10:45:45 +0000 (13:45 +0300)
gitlab #151

Change-Id: If72f62ea8c5ce4789bc8331eb598668091158ab6

bundles/org.simantics.g2d/src/org/simantics/g2d/participant/PanZoomRotateHandler.java
bundles/org.simantics.modeling/src/org/simantics/modeling/actions/NavigateToTarget.java

index 371ecbf1586bb22910410a728ddf8325deb4bbb9..6ca4f786247b9e4cc82db6892ad150e0db685a41 100644 (file)
@@ -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;
@@ -373,9 +372,8 @@ public class PanZoomRotateHandler extends AbstractCanvasParticipant {
             if (d==null) return false;
 
             Set<IElement> 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;
 
index 7805a46887ed88c0777268be2a570800d147ee00..c35852d2a9db2a5803836aaa2f508e67e0eabc35 100644 (file)
@@ -11,7 +11,6 @@
  *******************************************************************************/
 package org.simantics.modeling.actions;
 
-import java.awt.Shape;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.util.ArrayList;
@@ -398,8 +397,8 @@ public class NavigateToTarget extends Operation {
         if (controlBounds == null || controlBounds.isEmpty())
             return false;
 
-        final Shape shp = ElementUtils.getElementBoundsOnDiagram(selection);
-        if (shp == null)
+        Rectangle2D diagramRect = ElementUtils.getSurroundingElementBoundsOnDiagram(selection);
+        if (diagramRect == null)
             return false;
 
         ThreadUtils.asyncExec(canvas.getThreadAccess(), new Runnable() {
@@ -408,8 +407,6 @@ public class NavigateToTarget extends Operation {
                 if (canvas.isDisposed())
                     return;
 
-                Rectangle2D diagramRect = shp.getBounds2D();
-
                 // Make sure that even empty bounds can be zoomed into.
                 org.simantics.scenegraph.utils.GeometryUtils.expandRectangle(diagramRect, 1);