Mouse Wheel Zooming added to XYGraph
Change-Id: I82e728fe0046e38038751a22980db6c28ba52b98
Signed-off-by: DavidLopez <david.lopez@cea.fr>
diff --git a/bundles/core/tools/org.eclipse.papyrus.moka.modeling.utils/META-INF/MANIFEST.MF b/bundles/core/tools/org.eclipse.papyrus.moka.modeling.utils/META-INF/MANIFEST.MF
index ed39fe5..a945cf0 100644
--- a/bundles/core/tools/org.eclipse.papyrus.moka.modeling.utils/META-INF/MANIFEST.MF
+++ b/bundles/core/tools/org.eclipse.papyrus.moka.modeling.utils/META-INF/MANIFEST.MF
@@ -4,6 +4,8 @@
Bundle-SymbolicName: org.eclipse.papyrus.moka.modeling.utils
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.uml2.uml;bundle-version="5.3.0"
+Require-Bundle: org.eclipse.uml2.uml;bundle-version="5.3.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="3.1.0",
+ org.eclipse.papyrus.uml.extensionpoints;bundle-version="1.3.0"
Bundle-Vendor: Eclipse Modeling Project
Export-Package: org.eclipse.papyrus.moka.modeling.utils
diff --git a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/META-INF/MANIFEST.MF b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/META-INF/MANIFEST.MF
index 45e26cf..c486bef 100644
--- a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/META-INF/MANIFEST.MF
+++ b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/META-INF/MANIFEST.MF
@@ -8,7 +8,7 @@
org.eclipse.papyrus.moka.xygraph.mapping;bundle-version="1.0.100";visibility:=reexport,
org.eclipse.draw2d;bundle-version="[3.10.100,4.0.0)",
org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.nebula.visualization.xygraph;bundle-version="[2.1.0,3.0.0)"
+ org.eclipse.nebula.visualization.xygraph;bundle-version="2.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.moka.xygraph.common,
diff --git a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/src/org/eclipse/papyrus/moka/xygraph/common/ui/XYGraphEditorPart.java b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/src/org/eclipse/papyrus/moka/xygraph/common/ui/XYGraphEditorPart.java
index f99a0f9..fbb23e3 100644
--- a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/src/org/eclipse/papyrus/moka/xygraph/common/ui/XYGraphEditorPart.java
+++ b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.common/src/org/eclipse/papyrus/moka/xygraph/common/ui/XYGraphEditorPart.java
@@ -23,6 +23,7 @@
import org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph;
import org.eclipse.nebula.visualization.xygraph.figures.XYGraph;
import org.eclipse.papyrus.moka.xygraph.mapping.common.XYGraphCoordinator;
+import org.eclipse.papyrus.moka.xygraph.mapping.writing.impl.MouseWheelZoomer;
import org.eclipse.papyrus.moka.xygraph.model.xygraph.XYGraphDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
@@ -80,13 +81,17 @@
Canvas canvas = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(canvas);
- lws.setContents(buildGraphFromModel());
+ lws.setContents(buildGraphFromModel(canvas));
}
- protected ToolbarArmedXYGraph buildGraphFromModel(){
+ protected ToolbarArmedXYGraph buildGraphFromModel(Canvas canvas){
IXYGraph xyGraph = coordinator.buildXYGraph();
+
xyGraph.addPropertyChangeListener(IXYGraph.PROPERTY_CONFIG, this);
xyGraph.addPropertyChangeListener(IXYGraph.PROPERTY_ZOOMTYPE, this);
+
+ canvas.addMouseWheelListener(new MouseWheelZoomer(xyGraph));
+
return new ToolbarArmedXYGraph(xyGraph);
}
diff --git a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/common/XYGraphCoordinator.java b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/common/XYGraphCoordinator.java
index c1c0983..ab4fb3d 100644
--- a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/common/XYGraphCoordinator.java
+++ b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/common/XYGraphCoordinator.java
@@ -193,7 +193,7 @@
//Update the range in the axis?
factory.getAxisUpdateStrategy().updateAxisDescriptor(axis, graphMap);
- System.out.println("Updated axis Range: " + aDesc.getRangeLower() + ", " + aDesc.getRangeUpper());
+ //System.out.println("Updated axis Range: " + aDesc.getRangeLower() + ", " + aDesc.getRangeUpper());
}
public void dispose() {
diff --git a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/util/LightDataProvider.java b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/util/LightDataProvider.java
index 4e1e677..0086d92 100644
--- a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/util/LightDataProvider.java
+++ b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/util/LightDataProvider.java
@@ -166,4 +166,5 @@
public TraceDataBounds getBounds() {
return bounds;
}
+
}
diff --git a/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/writing/impl/MouseWheelZoomer.java b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/writing/impl/MouseWheelZoomer.java
new file mode 100644
index 0000000..773ddf0
--- /dev/null
+++ b/bundles/core/tools/visualization/org.eclipse.papyrus.moka.xygraph.mapping/src/org/eclipse/papyrus/moka/xygraph/mapping/writing/impl/MouseWheelZoomer.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * David LOPEZ BETANCUR (CEA LIST)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.xygraph.mapping.writing.impl;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.nebula.visualization.internal.xygraph.undo.SaveStateCommand;
+import org.eclipse.nebula.visualization.internal.xygraph.undo.ZoomCommand;
+import org.eclipse.nebula.visualization.xygraph.figures.IXYGraph;
+import org.eclipse.nebula.visualization.xygraph.figures.PlotArea;
+import org.eclipse.nebula.visualization.xygraph.figures.ZoomType;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseWheelListener;
+
+public class MouseWheelZoomer implements MouseWheelListener{
+
+ private IXYGraph xygraph;
+
+
+ private static final ZoomType zoomType = ZoomType.ZOOM_IN;
+
+ public MouseWheelZoomer(IXYGraph xygraph) {
+ super();
+ this.xygraph = xygraph;
+ }
+
+ @Override
+ public void mouseScrolled(MouseEvent e) {
+ //Axis.ZOOM_RATIO = 0.1, but it's not public !
+ double factor = 0.1 * Math.signum(e.count);
+
+ PlotArea pa = xygraph.getPlotArea();
+ Rectangle bounds = pa.getBounds();
+
+ pa.zoomInOut(true, true, bounds.width / 2, bounds.height / 2, factor);
+
+ //Add it to the operation story so it can be undone
+ SaveStateCommand command = new ZoomCommand(zoomType.getDescription(), xygraph.getXAxisList(), xygraph.getYAxisList());
+ command.saveState();
+ xygraph.getOperationsManager().addCommand(command);
+ }
+
+}