/**
 * 
 */
package org.mwc.cmap.plotViewer.actions;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.mwc.cmap.core.CorePlugin;
import org.mwc.cmap.core.operations.DebriefActionWrapper;
import org.mwc.cmap.plotViewer.editors.chart.*;
import org.mwc.cmap.plotViewer.editors.chart.SWTChart.PlotMouseDragger;

import MWC.GUI.*;
import MWC.GUI.Tools.Action;
import MWC.GenericData.*;

/**
 * @author ian.mayo
 */
public class ZoomIn extends CoreDragAction
{

	public static class ZoomInMode extends SWTChart.PlotMouseDragger
	{
		Point _startPoint;

		SWTCanvas _myCanvas;

		private PlainChart _myChart;

		public void doMouseDrag(final Point pt, final int JITTER, final Layers theLayers, SWTCanvas theCanvas)
		{
			// just do a check that we have our start point (it may have been cleared at the end of the move operation)
			if (_startPoint != null)
			{
				int deltaX = _startPoint.x - pt.x;
				int deltaY = _startPoint.y - pt.y;
				if (Math.abs(deltaX) < JITTER && Math.abs(deltaY) < JITTER)
					return;
				Tracker _dragTracker = new Tracker((Composite) _myCanvas.getCanvas(), SWT.RESIZE);
				Rectangle rect = new Rectangle(_startPoint.x, _startPoint.y, deltaX, deltaY);
				_dragTracker.setRectangles(new Rectangle[] { rect });
				boolean dragResult = _dragTracker.open();
				if (dragResult)
				{
					Rectangle[] rects = _dragTracker.getRectangles();
					Rectangle res = rects[0];
					// get world area
					java.awt.Point tl = new java.awt.Point(res.x, res.y);
					java.awt.Point br = new java.awt.Point(res.x + res.width, res.y + res.height);
					WorldLocation locA = new WorldLocation(_myCanvas.getProjection().toWorld(tl));
					WorldLocation locB = new WorldLocation(_myCanvas.getProjection().toWorld(br));
					WorldArea area = new WorldArea(locA, locB);

					WorldArea oldArea = _myCanvas.getProjection().getDataArea();
					Action theAction = 	new MWC.GUI.Tools.Chart.ZoomIn.ZoomInAction(_myChart, oldArea, area);
					
					// and wrap it
					DebriefActionWrapper daw = new DebriefActionWrapper(theAction, null);
					
					// and add it to the clipboard
					CorePlugin.run(daw);

					_dragTracker = null;
					_startPoint = null;
					_myChart = null;
					_myCanvas = null;
				}
			}
		}

		public void doMouseUp(Point point, int keyState)
		{
			_startPoint = null;
		}

		public void mouseDown(Point point, SWTCanvas canvas, PlainChart theChart)
		{
			_startPoint = point;
			_myCanvas = canvas;
			_myChart = theChart;
		}

	}

	public PlotMouseDragger getDragMode()
	{
		// TODO Auto-generated method stub
		return new ZoomInMode();
	}
}
@@ -738,17 +738,21 @@
 eLayers,
- 
+%0A%09%09%09%09
 SWTCanva
@@ -844,16 +844,22 @@
  cleared
+%0A%09%09%09//
  at the 
@@ -1000,84 +1000,8 @@
 .y;%0A
-%09%09%09%09if (Math.abs(deltaX) %3C JITTER && Math.abs(deltaY) %3C JITTER)%0A%09%09%09%09%09return;
 %0A%09%09%09
@@ -1548,16 +1548,78 @@
 eight);%0A
+%0A%09%09%09%09%09if (res.width %3E JITTER %7C%7C res.height %3E JITTER)%0A%09%09%09%09%09%7B%0A%0A%09
 %09%09%09%09%09Wor
@@ -1690,24 +1690,25 @@
 World(tl));%0A
+%09
 %09%09%09%09%09WorldLo
@@ -1780,24 +1780,25 @@
 (br));%0A%09%09%09%09%09
+%09
 WorldArea ar
@@ -1826,24 +1826,25 @@
 cA, locB);%0A%0A
+%09
 %09%09%09%09%09WorldAr
@@ -1893,24 +1893,25 @@
 DataArea();%0A
+%09
 %09%09%09%09%09Action 
@@ -1922,17 +1922,16 @@
 ction = 
-%09
 new MWC.
@@ -1975,17 +1975,25 @@
 myChart,
- 
+%0A%09%09%09%09%09%09%09%09
 oldArea,
@@ -2000,25 +2000,21 @@
  area);%0A
-%09
+%0A
 %09%09%09%09
-%0A%09%09%09
 %09%09// and
@@ -2022,16 +2022,17 @@
 wrap it%0A
+%09
 %09%09%09%09%09Deb
@@ -2102,14 +2102,10 @@
 l);%0A
-%09%09%09%09%09
 %0A
+%09
 %09%09%09%09
@@ -2141,16 +2141,17 @@
 rd%0A%09%09%09%09%09
+%09
 CorePlug
@@ -2160,24 +2160,32 @@
 .run(daw);%0A%0A
+%09%09%09%09%09%7D%0A%0A
 %09%09%09%09%09_dragTr

Improve how we handle not zooming on double-click