Merge remote-tracking branch 'origin/simulator_dev'

This commit is contained in:
Christopher Ronnewinkel (D036654)
2013-08-08 13:42:53 +02:00
12 changed files with 107 additions and 34 deletions
@@ -11,6 +11,7 @@ import com.google.gwt.i18n.client.TimeZone;
import com.google.gwt.maps.client.overlay.Overlay;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sailing.gwt.ui.simulator.racemap.FullCanvasOverlay;
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
/**
* Class to draw the legend for the different paths on the map.
@@ -29,6 +30,7 @@ public class PathLegendCanvasOverlay extends FullCanvasOverlay {
private double curSpeed;
private double curBearing;
private char mode;
/**
* Offset where the legend starts
@@ -42,13 +44,19 @@ public class PathLegendCanvasOverlay extends FullCanvasOverlay {
public String textColor = "Black";
public String textFont = "10pt OpenSansRegular";
public PathLegendCanvasOverlay() {
public PathLegendCanvasOverlay(char mode) {
this.mode = mode;
if (this.mode == SailingSimulatorConstants.ModeEvent) {
yOffset = 170;
}
this.setPathOverlays(null);
}
@Override
protected Overlay copy() {
return new PathLegendCanvasOverlay();
return new PathLegendCanvasOverlay(this.mode);
}
@Override
@@ -4,6 +4,9 @@ import java.util.ArrayList;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.canvas.dom.client.Context2d.TextAlign;
import com.google.gwt.core.client.GWT;
import com.google.gwt.maps.client.MapPaneType;
import com.google.gwt.maps.client.MapType;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.event.MapMoveEndHandler;
import com.google.gwt.maps.client.event.PolygonClickHandler;
@@ -12,11 +15,15 @@ import com.google.gwt.maps.client.geom.LatLngBounds;
import com.google.gwt.maps.client.geom.Point;
import com.google.gwt.maps.client.overlay.Overlay;
import com.google.gwt.maps.client.overlay.Polygon;
import com.sap.sailing.gwt.ui.client.shared.racemap.ImageTransformer;
import com.sap.sailing.gwt.ui.simulator.racemap.FullCanvasOverlay;
import com.sap.sailing.gwt.ui.simulator.util.SimulatorResources;
import com.sap.sailing.simulator.util.SailingSimulatorConstants;
public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
private static SimulatorResources resources = GWT.create(SimulatorResources.class);
private SimulatorMap simulatorMap;
private RaceCourseCanvasOverlay raceCourseCanvasOverlay;
private ArrayList<RegattaArea> regAreas;
@@ -24,6 +31,11 @@ public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
private RegattaArea currentRegArea = null;
private double raceBearing = 0.0;
private double diffBearing = 0.0;
private ImageTransformer windRoseBackground;
private ImageTransformer windRoseNeedle;
private int windBackgroundOffset = 20;
private int windNeedleOffset = 30;
public RegattaAreaCanvasOverlay(SimulatorMap simulatorMap) {
super();
@@ -42,6 +54,16 @@ public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
protected void initialize(final MapWidget map) {
super.initialize(map);
windRoseBackground = new ImageTransformer(resources.windRoseBackground());
windRoseNeedle = new ImageTransformer(resources.windRoseNeedle());
this.pane = map.getPane(MapPaneType.MAP_PANE);
getPane().add(windRoseBackground.getCanvas(), getWidgetPosLeft()+windBackgroundOffset, getWidgetPosTop());
getPane().add(windRoseNeedle.getCanvas(), getWidgetPosLeft()+windBackgroundOffset+windNeedleOffset, getWidgetPosTop()+windNeedleOffset);
//System.out.println("wBackgr: "+getPane().getWidgetIndex(windRoseBackground.getCanvas()));
//System.out.println("wNeedle: "+getPane().getWidgetIndex(windRoseNeedle.getCanvas()));
LatLng cPos;
regAreas = new ArrayList<RegattaArea>();
int regIdx;
@@ -174,6 +196,9 @@ public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
protected void redraw(final boolean force) {
super.redraw(force);
getPane().setWidgetPosition(windRoseBackground.getCanvas(), getWidgetPosLeft()+windBackgroundOffset, getWidgetPosTop());
getPane().setWidgetPosition(windRoseNeedle.getCanvas(), getWidgetPosLeft()+windBackgroundOffset+windNeedleOffset, getWidgetPosTop()+windNeedleOffset);
clear();
drawRegattaAreas();
@@ -187,7 +212,10 @@ public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
protected void drawRegattaAreas() {
clear();
windRoseBackground.drawTransformedImage(0.0, 1.0);
windRoseNeedle.drawTransformedImage(raceBearing+180.0, 1.0);
LatLng cPos = LatLng.newInstance(54.4344,10.19659167);
Point centerPoint = getMap().convertLatLngToDivPixel(cPos);
Point borderPoint = getMap().convertLatLngToDivPixel(this.getEdgePoint(cPos, 0.015));
@@ -196,11 +224,14 @@ public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
final Context2d context2d = canvas.getContext2d();
context2d.setLineWidth(3);
context2d.setStrokeStyle("Black");
for(RegattaArea regArea : regAreas) {
centerPoint = getMap().convertLatLngToDivPixel(regArea.centerPos);
borderPoint = getMap().convertLatLngToDivPixel(regArea.edgePos);
drawRegattaAreaBackground(context2d, centerPoint, borderPoint, regArea.color, pxStroke);
MapType normalMap = MapType.getNormalMap();
if (this.getMap().getCurrentMapType() == normalMap) {
for(RegattaArea regArea : regAreas) {
centerPoint = getMap().convertLatLngToDivPixel(regArea.centerPos);
borderPoint = getMap().convertLatLngToDivPixel(regArea.edgePos);
drawRegattaAreaBackground(context2d, centerPoint, borderPoint, regArea.color, pxStroke);
}
}
for(RegattaArea regArea : regAreas) {
@@ -279,8 +310,11 @@ public class RegattaAreaCanvasOverlay extends FullCanvasOverlay {
}
protected void updateRaceCourse(int type, double bearing) {
if (type == 1) {
raceBearing = bearing;
windRoseNeedle.drawTransformedImage(raceBearing+180.0, 1.0);
} else if (type == 2) {
diffBearing = bearing;
}
@@ -476,6 +476,7 @@ public class SimulatorMainPanel extends SimplePanel {
double minValue = (Double) s.getMin();
double maxValue = (Double) s.getMax();
double defaultValue = (Double) s.getDefault();
double stepSize = (Double) s.getResolution();
FlowPanel vp = new FlowPanel();
vp.getElement().setClassName("sliderWrapper");
@@ -489,8 +490,7 @@ public class SimulatorMainPanel extends SimplePanel {
sliderBar.getElement().getStyle().setProperty("width", "216px");
//sliderBar.setStepSize(Math.round((maxValue - minValue) / 10.), false);
sliderBar.setStepSize(((maxValue - minValue) / (s.getSteps()) ), false);
sliderBar.setStepSize(stepSize, false);
sliderBar.setNumTicks(s.getSteps());
sliderBar.setNumTickLabels(1);
@@ -318,7 +318,7 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
// mapw.setUI(SimulatorMapOptions.newInstance());
// mapw.setSize("100%", "650px");
// mapw.setSize("100%", "80%");
mapw.addControl(new LargeMapControl3D(), new ControlPosition(ControlAnchor.TOP_RIGHT, /* offsetX */0, /* offsetY */
30));
mapw.addControl(new MenuMapTypeControl());
@@ -394,7 +394,7 @@ public class SimulatorMap extends AbsolutePanel implements RequiresDataInitializ
// pathCanvasOverlays = new ArrayList<PathCanvasOverlay>();
this.replayPathCanvasOverlays = new ArrayList<PathCanvasOverlay>();
// timeListeners.add(replayPathCanvasOverlay);
this.legendCanvasOverlay = new PathLegendCanvasOverlay();
this.legendCanvasOverlay = new PathLegendCanvasOverlay(this.mode);
Window.addResizeHandler(new ResizeHandler() {
@@ -0,0 +1,14 @@
package com.sap.sailing.gwt.ui.simulator.util;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface SimulatorResources extends ClientBundle {
@Source("com/sap/sailing/gwt/ui/client/images/simulator/Windrose_plain_background.png")
ImageResource windRoseBackground();
@Source("com/sap/sailing/gwt/ui/client/images/simulator/Windrose_needle.png")
ImageResource windRoseNeedle();
}
@@ -18,7 +18,9 @@ public interface WindPatternSetting<SettingsType> extends Named {
public SettingsType getMax();
public SettingsType getDefault();
public SettingsType getResolution();
public SettingsType getDefault();
public int getSteps();
@@ -62,69 +62,69 @@ public class WindPatternDisplayManagerImpl implements WindPatternDisplayManager
private void addBlastParameters(WindPatternDisplay display) {
if (mode == SailingSimulatorConstants.ModeEvent) {
WindPatternSetting<Double> windBearingSetting = new WindPatternSettingSliderBar("windBearing",
"Base Bearing (Degrees)", 0, 360, 0, 36);
"Base Bearing (Degrees)", 0, 360, 5, 0, 36);
display.addSetting(windBearingSetting);
WindPatternSetting<Double> baseWindBearing = new WindPatternSettingSliderBar("baseWindBearing",
"Race Course Diff (Degrees)", -20, 20, 0,10);
"Race Course Diff (Degrees)", -20, 20, 1, 0, 10);
display.addSetting(baseWindBearing);
}
WindPatternSetting<Double> windSpeedSetting = new WindPatternSettingSliderBar("baseWindSpeed",
"Base Speed (kn)", 2, 22, 12,10);
"Base Speed (kn)", 2, 22, 0.5, 12, 10);
display.addSetting(windSpeedSetting);
WindPatternSetting<Double> blastProbability = new WindPatternSettingSliderBar("blastProbability",
"Probability (%)", 0, 50, 25,10);
"Probability (%)", 0, 50, 5, 25, 10);
display.addSetting(blastProbability);
WindPatternSetting<Double> maxBlastSize = new WindPatternSettingSliderBar("maxBlastSize", "Gust Size", 1, 10,
1,10);
1, 1, 10);
display.addSetting(maxBlastSize);
WindPatternSetting<Double> blastWindSpeed = new WindPatternSettingSliderBar("blastWindSpeed",
"Average Speed (%)", 0, 200, 120,10);
"Average Speed (%)", 0, 200, 5, 120, 10);
display.addSetting(blastWindSpeed);
WindPatternSetting<Double> blastWindSpeedVar = new WindPatternSettingSliderBar("blastWindSpeedVar",
"Speed Variance (%)", 1e-4, 100, 10,10);
"Speed Variance (%)", 1e-4, 100, 5, 10, 10);
display.addSetting(blastWindSpeedVar);
}
private void addOscillationParameters(WindPatternDisplay display) {
if (mode == SailingSimulatorConstants.ModeEvent) {
WindPatternSetting<Double> windBearingSetting = new WindPatternSettingSliderBar("windBearing",
"Base Bearing (Degrees)", 0, 360, 0, 36);
"Base Bearing (Degrees)", 0, 360, 5, 0, 36);
display.addSetting(windBearingSetting);
WindPatternSetting<Double> baseWindBearing = new WindPatternSettingSliderBar("baseWindBearing",
"Race Course Diff (Degrees)", -20, 20, 0,10);
"Race Course Diff (Degrees)", -20, 20, 1, 0, 10);
display.addSetting(baseWindBearing);
WindPatternSetting<Double> windSpeedSetting = new WindPatternSettingSliderBar("baseWindSpeed",
"Base Speed (kn)", 2, 22, 12,10);
"Base Speed (kn)", 2, 22, 1, 12, 10);
display.addSetting(windSpeedSetting);
} else {
WindPatternSetting<Double> windSpeedSetting = new WindPatternSettingSliderBar("baseWindSpeed",
"Base Speed (kn)", 2, 22, 12,10);
"Base Speed (kn)", 2, 22, 1, 12, 10);
display.addSetting(windSpeedSetting);
WindPatternSetting<Double> baseWindBearing = new WindPatternSettingSliderBar("baseWindBearing",
"Average Direction (Degrees)", -20, 20, 0,10);
"Average Direction (Degrees)", -20, 20, 1, 0, 10);
display.addSetting(baseWindBearing);
}
WindPatternSetting<Double> leftWindSpeed = new WindPatternSettingSliderBar("leftWindSpeed",
"Speed Left Side (%)", 0, 200, 100,10);
"Speed Left Side (%)", 0, 200, 5, 100, 10);
display.addSetting(leftWindSpeed);
WindPatternSetting<Double> middleWindSpeed = new WindPatternSettingSliderBar("middleWindSpeed",
"Speed Middle (%)", 0, 200, 100,10);
"Speed Middle (%)", 0, 200, 5, 100, 10);
display.addSetting(middleWindSpeed);
WindPatternSetting<Double> rightWindSpeed = new WindPatternSettingSliderBar("rightWindSpeed",
"Speed Right Side (%)", 0, 200, 100,10);
"Speed Right Side (%)", 0, 200, 5, 100, 10);
display.addSetting(rightWindSpeed);
WindPatternSetting<Double> frequency = new WindPatternSettingSliderBar("frequency",
"Frequency (per hr)", 0, 20, 6,10);
"Frequency (per hr)", 0, 20, 0.5, 6, 10);
display.addSetting(frequency);
WindPatternSetting<Double> amplitude = new WindPatternSettingSliderBar("amplitude",
"Amplitude (Degrees)", -30, 30, 0, 10);
"Amplitude (Degrees)", -30, 30, 1, 0, 10);
display.addSetting(amplitude);
WindPatternSetting<Double> curSpeed = new WindPatternSettingSliderBar("curSpeed",
"Current Speed (kn)", 0, 2, 0, 10);
"Current Speed (kn)", 0, 2, 0.1, 0, 10);
display.addSetting(curSpeed);
WindPatternSetting<Double> curBearing = new WindPatternSettingSliderBar("curBearing",
"Current Bearing (Degrees)", 0, 360, 180, 36);
"Current Bearing (Degrees)", 0, 360, 5, 180, 36);
display.addSetting(curBearing);
}
@@ -50,6 +50,12 @@ public class WindPatternSettingListBox implements WindPatternSetting<String>, Is
return null;
}
@Override
public String getResolution() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDefault() {
// TODO Auto-generated method stub
@@ -19,8 +19,9 @@ public class WindPatternSettingSliderBar implements WindPatternSetting<Double>,
private double currentValue;
private double min;
private double max;
private double res; // resolution of slider bar
private double defaultValue;
private int steps;
private int steps; // number of tickmarks
/**
* Required for serialization
@@ -29,11 +30,12 @@ public class WindPatternSettingSliderBar implements WindPatternSetting<Double>,
}
public WindPatternSettingSliderBar(String name, String displayName, double min, double max, double defaultValue, int steps) {
public WindPatternSettingSliderBar(String name, String displayName, double min, double max, double res, double defaultValue, int steps) {
this.name = name;
this.displayName = displayName;
this.min = min;
this.max = max;
this.res = res;
this.defaultValue = defaultValue;
this.currentValue = defaultValue;
this.steps = steps;
@@ -61,6 +63,11 @@ public class WindPatternSettingSliderBar implements WindPatternSetting<Double>,
return max;
}
@Override
public Double getResolution() {
return res;
}
@Override
public Double getDefault() {
return defaultValue;
@@ -235,6 +235,7 @@ public class PathGeneratorOpportunistEuclidian extends PathGeneratorBase {
if (prevDirection == -1) {
if (startLeft) {
allRight = false;
path.add(new TimedPositionWithSpeedImpl(nextTime, plft, lWind));
currentPosition = plft;
if (prevDirection == 2) {
@@ -245,6 +246,7 @@ public class PathGeneratorOpportunistEuclidian extends PathGeneratorBase {
}
prevDirection = 1;
} else {
allLeft = false;
path.add(new TimedPositionWithSpeedImpl(nextTime, prght, rWind));
currentPosition = prght;
if (prevDirection == 1) {