Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2018-09-27 16:47:28 +0000
committerLaurent Redor2018-09-27 16:48:24 +0000
commitc793dd0051652f6d5f95cebdd4bb362838d6fa21 (patch)
tree7dbfc4e3318d7443a2a3686cd8dabed5a35cafc9
parentbf5a3032feab51af0fa8f131122e389916db9821 (diff)
downloadorg.eclipse.sirius-c793dd0051652f6d5f95cebdd4bb362838d6fa21.tar.gz
org.eclipse.sirius-c793dd0051652f6d5f95cebdd4bb362838d6fa21.tar.xz
org.eclipse.sirius-c793dd0051652f6d5f95cebdd4bb362838d6fa21.zip
[539569] Fix zoom problem for vertical space insertion tool
Bug: 539569 Change-Id: I8618f3e9e63ebf1dc88026f835ca346b072b9faa Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/SiriusBlankSpacesDragTracker.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/SiriusBlankSpacesDragTracker.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/SiriusBlankSpacesDragTracker.java
index eef1e90e4d..58bf209d42 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/SiriusBlankSpacesDragTracker.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/SiriusBlankSpacesDragTracker.java
@@ -187,6 +187,14 @@ public class SiriusBlankSpacesDragTracker extends SimpleDragTracker {
protected int getCurrentPositionZoomed() {
Point pt = getLocation();
source.getFigure().translateToRelative(pt);
+ if (!(source instanceof SiriusRulerEditPart)) {
+ // When the tool is applied on the diagram, the location must considered the zoom. It is not the case when
+ // the tool is applied on the ruler.
+ double zoom = getZoom();
+ if (zoom != 0) {
+ pt.performScale(zoom);
+ }
+ }
int position = isHorizontal(source) ? pt.x : pt.y;
return position;
}
@@ -199,13 +207,32 @@ public class SiriusBlankSpacesDragTracker extends SimpleDragTracker {
*/
protected int getCurrentPosition() {
int position = getCurrentPositionZoomed();
- ZoomManager zoomManager = (ZoomManager) this.getCurrentViewer().getProperty(ZoomManager.class.toString());
- if (zoomManager != null) {
- position = (int) Math.round(position / zoomManager.getZoom());
+ double zoom = getZoom();
+ if (zoom != 0) {
+ position = (int) Math.round(position / zoom);
}
return position;
}
+ /**
+ * Get the current zoom level. 0 can be returned if the zoom level is not retrieved.
+ *
+ * @return the zoom level
+ */
+ protected double getZoom() {
+ double zoom = 0;
+ ZoomManager zoomManager;
+ if (source instanceof SiriusRulerEditPart) {
+ zoomManager = ((SiriusRulerEditPart) source).getZoomManager();
+ } else {
+ zoomManager = (ZoomManager) this.getCurrentViewer().getProperty(ZoomManager.class.toString());
+ }
+ if (zoomManager != null) {
+ zoom = zoomManager.getZoom();
+ }
+ return zoom;
+ }
+
@Override
protected String getCommandName() {
return Messages.InsertBlankSpace_cmdName;

Back to the top