package org.mwc.cmap.xyplot.wizards;

import java.text.DecimalFormat;

import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
import org.mwc.cmap.core.ui_support.wizards.SimplePageListWizard;
import org.mwc.cmap.core.wizards.EnterStringPage;

import Debrief.Tools.FilterOperations.ShowTimeVariablePlot3.CalculationWizard;
import Debrief.Tools.Tote.toteCalculation;
import Debrief.Tools.Tote.Calculations.dopplerCalc;
import MWC.GUI.Editable;
import MWC.GenericData.WatchableList;

public class DopplerPlotWizard implements CalculationWizard
{

	public int open(toteCalculation pCalc,WatchableList primary, Editable[] subjects)
	{
		dopplerCalc calc = (dopplerCalc) pCalc;
		
		// create the wizard to color/name this
		final SimplePageListWizard wizard = new SimplePageListWizard();

		final String imagePath = "images/UnderwaterPropagation.png";
		final String taskTitle = "Generate Doppler Plot";
		
		DecimalFormat fFormat= new DecimalFormat("0.0000");
		DecimalFormat cFormat= new DecimalFormat("0.0");
		

		final EnterStringPage getf0 = new EnterStringPage(null, " " + fFormat.format(calc.getFNought()) + " ",
				taskTitle, "Please enter a f-Nought (Hz) for [" + primary + "]",
				"(e.g. 150)",
				imagePath, null, false);
		final EnterStringPage getSoundSpeed = new EnterStringPage(null, " " +  cFormat.format(calc.getSpeedOfSound()) + " ",
				taskTitle, "Please enter the Speed of Sound in Water (kts)",
				"(e.g. 2000)",
				imagePath, null, false);
		wizard.addWizard(getf0);
		wizard.addWizard(getSoundSpeed);
		final WizardDialog dialog = new WizardDialog(Display.getCurrent()
				.getActiveShell(), wizard);
		dialog.create();
		dialog.setBlockOnOpen(true);
		dialog.open();
		// did it work?
		if (dialog.getReturnCode() == WizardDialog.OK)
		{
			calc.setFNought(Double.parseDouble(getf0.getString()));
			calc.setSpeedOfSound(Double.parseDouble(getSoundSpeed.getString()));
		}
		
		// ok, return the dialog ok/cancel value
		return dialog.getReturnCode();
	}
}

@@ -441,16 +441,51 @@
 erCalc;%0A
+import MWC.Algorithms.Conversions;%0A
 import M
@@ -1371,32 +1371,52 @@
  cFormat.format(
+Conversions.Kts2Mps(
 calc.getSpeedOfS
@@ -1422,16 +1422,17 @@
 Sound())
+)
  + %22 %22,%0A
@@ -1493,11 +1493,13 @@
 er (
-kts
+m/sec
 )%22,%0A
@@ -1929,16 +1929,36 @@
 OfSound(
+Conversions.Mps2Kts(
 Double.p
@@ -1991,24 +1991,25 @@
 etString()))
+)
 ;%0A%09%09%7D%0A%09%09%0A%09%09/

allow the user to specify doppler calc in m/sec