separate default-time-settings from WindFieldGenParamsDTO;

remove deprecated Date methods by referring to epoch-time and gwt.i18n.client.DateTimeFormat;
update default time-step to 15sec;
This commit is contained in:
Christopher Ronnewinkel (D036654)
2013-06-17 16:10:07 +02:00
parent 541a288757
commit 45043d276e
8 changed files with 53 additions and 42 deletions
@@ -42,7 +42,6 @@ public class WindFieldGenParamsDTO implements IsSerializable {
public WindFieldGenParamsDTO() {
setDefaultTimeSettings();
}
public PositionDTO getNorthWest() {
@@ -101,15 +100,10 @@ public class WindFieldGenParamsDTO implements IsSerializable {
this.timeStep = timeStep;
}
@SuppressWarnings("deprecation")
public void setDefaultTimeSettings() {
startTime = new Date();// new Date(0);
startTime.setHours(0);
startTime.setMinutes(0);
startTime.setSeconds(0);
timeStep = new Date(20 * 1000);
endTime = new Date(startTime.getTime() + 10 * 60 * 1000);
public void setDefaultTimeSettings(Date startTime, Date timeStep, Date endTime) {
this.startTime = startTime;
this.timeStep = timeStep;
this.endTime = endTime;
}
public char getMode() {
@@ -61,8 +61,8 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
this.name = name;
}
public PathCanvasOverlay(String name, Timer timer) {
super(timer);
public PathCanvasOverlay(String name, Timer timer, WindFieldGenParamsDTO windParams) {
super(timer, windParams);
this.name = name;
}
@@ -81,15 +81,15 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
this.pathColor = color;
}
public PathCanvasOverlay(String name, Timer timer, long totalTimeMilliseconds) {
super(timer);
public PathCanvasOverlay(String name, Timer timer, WindFieldGenParamsDTO windParams, long totalTimeMilliseconds) {
super(timer, windParams);
this.name = name;
this.totalTimeIsGiven = true;
this.totalTimeMilliseconds = totalTimeMilliseconds;
}
public PathCanvasOverlay(String name, Timer timer, long totalTimeMilliseconds, String color) {
super(timer);
public PathCanvasOverlay(String name, Timer timer, WindFieldGenParamsDTO windParams, long totalTimeMilliseconds, String color) {
super(timer, windParams);
this.name = name;
this.totalTimeIsGiven = true;
this.totalTimeMilliseconds = totalTimeMilliseconds;
@@ -154,8 +154,6 @@ public class PathCanvasOverlay extends WindFieldCanvasOverlay implements Named {
context2d.fillText(cText, cX-(timewidth/2.0), cY-25);
}
WindFieldGenParamsDTO windParams = new WindFieldGenParamsDTO();
int numPoints = windDTOList.size();
if (numPoints < 1) {
return;
@@ -7,6 +7,7 @@ import java.util.logging.Logger;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
import com.sap.sailing.gwt.ui.shared.WindFieldGenParamsDTO;
public class ReplayPathCanvasOverlay extends PathCanvasOverlay {
@@ -14,8 +15,8 @@ public class ReplayPathCanvasOverlay extends PathCanvasOverlay {
private static Logger logger = Logger.getLogger(ReplayPathCanvasOverlay.class.getName());
private List<SimulatorWindDTO> windDTOToDraw;
public ReplayPathCanvasOverlay(final String name, final Timer timer) {
super(name, timer);
public ReplayPathCanvasOverlay(final String name, final Timer timer, WindFieldGenParamsDTO windParams) {
super(name, timer, windParams);
this.displayWindAlongPath = false;
windDTOToDraw = null;
//this.timer.addTimeListener(this);
@@ -21,6 +21,7 @@ import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -110,8 +111,6 @@ public class SimulatorMainPanel extends SimplePanel {
private StringMessages stringMessages;
private SimulatorServiceAsync simulatorSvc;
private ErrorReporter errorReporter;
private int xRes;
private int yRes;
private boolean autoUpdate;
private char mode;
@@ -231,8 +230,6 @@ public class SimulatorMainPanel extends SimplePanel {
this.simulatorSvc = svc;
this.stringMessages = stringMessages;
this.errorReporter = errorReporter;
this.xRes = xRes;
this.yRes = yRes;
this.autoUpdate = autoUpdate;
this.mode = mode;
this.isOmniscient = new CheckBox(this.stringMessages.omniscient(), true);
@@ -272,6 +269,7 @@ public class SimulatorMainPanel extends SimplePanel {
directionSelector = new ListBox();
directionSelector.getElement().getStyle().setProperty("width", "215px");
windParams = new WindFieldGenParamsDTO();
windParams.setMode(mode);
windParams.setShowArrows(showArrows);
@@ -279,9 +277,9 @@ public class SimulatorMainPanel extends SimplePanel {
windParams.setShowLines(showLines);
windParams.setSeedLines(seedLines);
windParams.setShowStreamlets(showStreamlets);
this.setDefaultTimeSettings();
timer = new Timer(PlayModes.Replay, 1000l);
TimeRangeWithZoomProvider timeRangeProvider = new TimeRangeWithZoomModel();
initTimer();
timer.setTime(windParams.getStartTime().getTime());
@@ -297,6 +295,12 @@ public class SimulatorMainPanel extends SimplePanel {
// logoAndTitlePanel.addStyleName("LogoAndTitlePanel");
// this.addNorth(logoAndTitlePanel, 68);
simulatorMap = new SimulatorMap(simulatorSvc, stringMessages, errorReporter, xRes, yRes, timer, timePanel,
windParams, busyIndicator, mode, this);
simulatorMap.setSize("100%", "100%");
this.rightPanel.add(this.simulatorMap);
createOptionsPanelTop();
createOptionsPanel();
@@ -318,6 +322,19 @@ public class SimulatorMainPanel extends SimplePanel {
}
public void setDefaultTimeSettings() {
Date defaultNow = new Date();
DateTimeFormat fmt = DateTimeFormat.getFormat("Z");
NumberFormat df = NumberFormat.getDecimalFormat();
int utcOffSet = (int) df.parse(fmt.format(defaultNow))/100; // default time zone offset versus UTC
long epochTime = (defaultNow.getTime()/86400000)*86400000 - utcOffSet*3600000; // today, midnight in default time zone
Date startTime = new Date(epochTime);
Date timeStep = new Date(15 * 1000);
Date endTime = new Date(startTime.getTime() + 10 * 60 * 1000);
windParams.setDefaultTimeSettings(startTime, timeStep, endTime);
}
public void showTimePanel(boolean visible) {
mainPanel.setWidgetHidden(fullTimePanel, !visible);
mainPanel.forceLayout(); // trigger onResize() on child panels, relevant for map resize & center
@@ -508,11 +525,6 @@ public class SimulatorMainPanel extends SimplePanel {
windDisplayButton.setValue(false);
}
simulatorMap = new SimulatorMap(simulatorSvc, stringMessages, errorReporter, xRes, yRes, timer, timePanel,
windParams, busyIndicator, mode, this);
simulatorMap.setSize("100%", "100%");
this.rightPanel.add(this.simulatorMap);
}
// initialize timer with a default time span based on windParams
@@ -136,7 +136,7 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
WindFieldDTO pathWindDTO = new WindFieldDTO();
pathWindDTO.setMatrix(currentPath.getPoints());
ReplayPathCanvasOverlay replayPathCanvasOverlay = new ReplayPathCanvasOverlay(pathName, timer);
ReplayPathCanvasOverlay replayPathCanvasOverlay = new ReplayPathCanvasOverlay(pathName, timer, windParams);
replayPathCanvasOverlays.add(replayPathCanvasOverlay);
replayPathCanvasOverlay.pathColor = color;
@@ -367,13 +367,13 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
this.mapw.addOverlay(this.raceCourseCanvasOverlay);
if (this.windParams.isShowArrows()) {
this.windFieldCanvasOverlay = new WindFieldCanvasOverlay(this.timer);
this.windFieldCanvasOverlay = new WindFieldCanvasOverlay(this.timer, this.windParams);
}
if (this.windParams.isShowStreamlets()) {
this.windStreamletsCanvasOverlay = new WindStreamletsCanvasOverlay(this.timer, this.xRes, this.yRes);
}
if (this.windParams.isShowGrid()) {
this.windGridCanvasOverlay = new WindGridCanvasOverlay(this.timer, this.xRes, this.yRes);
this.windGridCanvasOverlay = new WindGridCanvasOverlay(this.timer, this.windParams, this.xRes, this.yRes);
}
if (windParams.isShowLines()) {
this.windLineCanvasOverlay = new WindLineCanvasOverlay(this.timer);
@@ -627,12 +627,12 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
}
}
}
private void refreshWindDisplayView(WindPatternDisplay windPatternDisplay, boolean force) {
if (force) {
// removeOverlays();
this.windParams.setDefaultTimeSettings();
this.parent.setDefaultTimeSettings();
this.generateWindField(windPatternDisplay, true);
// timeListeners.clear();
// timeListeners.add(windFieldCanvasOverlay);
@@ -664,7 +664,7 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
}
} else {
this.windParams.setDefaultTimeSettings();
this.parent.setDefaultTimeSettings();
this.generateWindField(windPatternDisplay, true);
}
}
@@ -21,6 +21,7 @@ import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
import com.sap.sailing.gwt.ui.shared.WindFieldGenParamsDTO;
import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
import com.sap.sailing.gwt.ui.simulator.util.ToolTip;
import com.sap.sailing.gwt.ui.simulator.util.WindFieldMapMouseMoveHandler;
@@ -47,14 +48,16 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
protected String arrowHeadColor = "Blue";
protected WindFieldMapMouseMoveHandler mmHandler;
protected double arrowLength = 15;
protected WindFieldGenParamsDTO windParams = null;
private Timer timer;
private static Logger logger = Logger.getLogger(WindFieldCanvasOverlay.class.getName());
public WindFieldCanvasOverlay(final Timer timer) {
public WindFieldCanvasOverlay(final Timer timer, final WindFieldGenParamsDTO windParams) {
super();
this.timer = timer;
this.windParams = windParams;
init();
}
@@ -118,7 +121,7 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
@Override
protected Overlay copy() {
return new WindFieldCanvasOverlay(this.timer);
return new WindFieldCanvasOverlay(this.timer, this.windParams);
}
@Override
@@ -24,6 +24,7 @@ import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.shared.SimulatorWindDTO;
import com.sap.sailing.gwt.ui.shared.WindFieldDTO;
import com.sap.sailing.gwt.ui.shared.WindFieldGenParamsDTO;
import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
import com.sap.sailing.gwt.ui.simulator.util.WindGridColorPalette;
@@ -43,6 +44,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
protected SortedMap<Long, List<SimulatorWindDTO>> timePointWindDTOMap;
protected final Timer timer;
protected WindFieldGenParamsDTO windParams = null;
private int xRes;
private int yRes;
@@ -96,9 +98,10 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
}
public WindGridCanvasOverlay(final Timer timer, final int xRes, final int yRes) {
public WindGridCanvasOverlay(final Timer timer, WindFieldGenParamsDTO windParams, final int xRes, final int yRes) {
super();
this.timer = timer;
this.windParams = windParams;
this.xRes = xRes;
this.yRes = yRes;
init();
@@ -198,7 +201,7 @@ public class WindGridCanvasOverlay extends FullCanvasOverlay implements TimeList
@Override
protected Overlay copy() {
return new WindFieldCanvasOverlay(this.timer);
return new WindFieldCanvasOverlay(this.timer, windParams);
}
@Override
@@ -84,7 +84,7 @@ public class PathGeneratorTreeGrowWind3 extends PathGeneratorBase {
return 0;
} else {
return (p1.hrz < p2.hrz ? -1 : +1);
}
}
}
}
@@ -563,7 +563,7 @@ public class PathGeneratorTreeGrowWind3 extends PathGeneratorBase {
if ((curPath.vrt > 0.0)) {
//logger.info("\ntPath: " + curPath.path + "\n Time: " + (Math.round((curPath.pos.getTimePoint().asMillis()-startTime.asMillis())/1000.0/60.0*10.0)/10.0)+", Height: "+curPath.vrt+" of "+(Math.round(startPos.getDistance(endPos).getMeters()*100.0)/100.0)+", Dist: "+curPath.hrz+"m ~ "+(Math.round(curPath.pos.getPosition().getDistance(endPos).getMeters()*100.0)/100.0)+"m");
int curBin = (int)Math.round(Math.floor( (curPath.hrz + hrzBinSize/2.0) / hrzBinSize ));
if ((Math.abs(curBin) <= 2)) {
if ((Math.abs(curBin) <= 1)) {
reachedEnd = true;
trgPaths.add(curPath); // add path to list of target-paths
}