From: Tuukka Lehtonen Date: Thu, 18 Oct 2018 10:45:45 +0000 (+0300) Subject: Faster bounds calculation for zoom to selection and navigate to target X-Git-Tag: v1.43.0~136^2~322 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=13edeabfa275ed09f6fa1b76923a96a1172fdc22;p=simantics%2Fplatform.git Faster bounds calculation for zoom to selection and navigate to target gitlab #151 Change-Id: If72f62ea8c5ce4789bc8331eb598668091158ab6 --- 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 371ecbf15..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; @@ -373,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; diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/NavigateToTarget.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/NavigateToTarget.java index 7805a4688..c35852d2a 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/NavigateToTarget.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/NavigateToTarget.java @@ -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);