added copy constructor to RaceMapSettings and use it in EmbeddedMapAndWIndChartEntryPoint to update settings partially

This commit is contained in:
Axel Uhl committed 2015-07-17 01:51:08 +02:00
1 parent a422ad8036
commit 41a76b0108
3 files changed
+25 -5

No files matched your search

@@ -1,10 +1,11 @@
package com.sap.sailing.gwt.ui.client.shared.racemap;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.sap.sse.common.Util;
public class RaceMapHelpLinesSettings {
/**
@@ -28,8 +29,9 @@ public class RaceMapHelpLinesSettings {
visibleHelpLines.add(HelpLineTypes.BOATTAILS);
}
public RaceMapHelpLinesSettings(Collection<HelpLineTypes> visibleHelpLines) {
this.visibleHelpLines = new HashSet<HelpLineTypes>(visibleHelpLines);
public RaceMapHelpLinesSettings(Iterable<HelpLineTypes> visibleHelpLines) {
this.visibleHelpLines = new HashSet<>();
Util.addAll(visibleHelpLines, this.visibleHelpLines);
}
public boolean isVisible(HelpLineTypes helpLineType) {
@@ -47,6 +47,23 @@ public class RaceMapSettings extends AbstractSettings {
this.helpLinesSettings = new RaceMapHelpLinesSettings();
}
/**
* "Copy constructor" that produces a new settings object that equals the one passed as argument
*/
public RaceMapSettings(RaceMapSettings settings) {
this.buoyZoneRadiusInMeters = settings.buoyZoneRadiusInMeters;
this.helpLinesSettings = new RaceMapHelpLinesSettings(settings.getHelpLinesSettings().getVisibleHelpLineTypes());
this.maneuverTypesToShow = settings.maneuverTypesToShow;
this.showDouglasPeuckerPoints = settings.showDouglasPeuckerPoints;
this.showOnlySelectedCompetitors = settings.showOnlySelectedCompetitors;
this.showSelectedCompetitorsInfo = settings.showSelectedCompetitorsInfo;
this.showSimulationOverlay = settings.showSimulationOverlay;
this.showWindStreamletOverlay = settings.showWindStreamletOverlay;
this.tailLengthInMilliseconds = settings.tailLengthInMilliseconds;
this.windUp = settings.windUp;
this.zoomSettings = new RaceMapZoomSettings(settings.zoomSettings.getTypesToConsiderOnZoom(), settings.zoomSettings.isZoomToSelectedCompetitors());
}
/**
* @return 0 if the tails are not visible {@link #getTailLengthInMilliseconds()} otherwise
*/
@@ -66,7 +66,7 @@ public class EmbeddedMapAndWindChartEntryPoint extends AbstractSailingEntryPoint
@Override
protected void doOnModuleLoad() {
GWT.debugger(); // TODO remove again
GWT.debugger(); // TODO remove
super.doOnModuleLoad();
// read mandatory parameters
regattaLikeName = Window.Location.getParameter(PARAM_REGATTA_LIKE_NAME);
@@ -168,12 +168,13 @@ public class EmbeddedMapAndWindChartEntryPoint extends AbstractSailingEntryPoint
map.setControls(ControlPosition.RIGHT_BOTTOM, backToLivePlayButton);
}
};
final RaceMapSettings mapSettings = raceMap.getSettings();
final RaceMapSettings mapSettings = new RaceMapSettings(raceMap.getSettings());
mapSettings.setZoomSettings(new RaceMapZoomSettings(Arrays.asList(ZoomTypes.BUOYS), /* zoom to selection */ false));
Set<HelpLineTypes> helpLineTypes = new HashSet<>();
Util.addAll(mapSettings.getHelpLinesSettings().getVisibleHelpLineTypes(), helpLineTypes);
helpLineTypes.add(HelpLineTypes.COURSEGEOMETRY);
mapSettings.setHelpLinesSettings(new RaceMapHelpLinesSettings(helpLineTypes));
mapSettings.setWindUp(true);
raceMap.updateSettings(mapSettings);
raceMap.onRaceSelectionChange(raceList);
final WindChart windChart;