]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/actions/NavigateToTarget.java
Faster bounds calculation for zoom to selection and navigate to target
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / actions / NavigateToTarget.java
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);