mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
Merge branch 'master' of ssh://kielweek.web4sap.com/home/trac/git
This commit is contained in:
commit
c7bc4980b8
4 files changed
+82
-41
No files matched your search
+67
-39
@@ -37,7 +37,7 @@ import com.google.gwt.maps.client.overlay.Polyline;
|
|||||||
import com.google.gwt.maps.client.overlay.PolylineOptions;
|
import com.google.gwt.maps.client.overlay.PolylineOptions;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.sap.sailing.domain.common.ManeuverType;
|
import com.sap.sailing.domain.common.ManeuverType;
|
||||||
@@ -52,6 +52,7 @@ import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
|||||||
import com.sap.sailing.gwt.ui.client.ParallelExecutionCallback;
|
import com.sap.sailing.gwt.ui.client.ParallelExecutionCallback;
|
||||||
import com.sap.sailing.gwt.ui.client.ParallelExecutionHolder;
|
import com.sap.sailing.gwt.ui.client.ParallelExecutionHolder;
|
||||||
import com.sap.sailing.gwt.ui.client.RaceSelectionChangeListener;
|
import com.sap.sailing.gwt.ui.client.RaceSelectionChangeListener;
|
||||||
|
import com.sap.sailing.gwt.ui.client.RequiresDataInitialization;
|
||||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||||
import com.sap.sailing.gwt.ui.client.TimeListener;
|
import com.sap.sailing.gwt.ui.client.TimeListener;
|
||||||
@@ -65,8 +66,8 @@ import com.sap.sailing.gwt.ui.shared.PositionDTO;
|
|||||||
import com.sap.sailing.gwt.ui.shared.components.Component;
|
import com.sap.sailing.gwt.ui.shared.components.Component;
|
||||||
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||||
|
|
||||||
public class RaceMap implements TimeListener, CompetitorSelectionChangeListener, RaceSelectionChangeListener,
|
public class RaceMap extends SimplePanel implements TimeListener, CompetitorSelectionChangeListener, RaceSelectionChangeListener,
|
||||||
Component<RaceMapSettings> {
|
Component<RaceMapSettings>, RequiresDataInitialization {
|
||||||
protected MapWidget map;
|
protected MapWidget map;
|
||||||
|
|
||||||
private final SailingServiceAsync sailingService;
|
private final SailingServiceAsync sailingService;
|
||||||
@@ -161,9 +162,14 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
private final RaceMapSettings settings;
|
private final RaceMapSettings settings;
|
||||||
|
|
||||||
private final StringMessages stringMessages;
|
private final StringMessages stringMessages;
|
||||||
|
|
||||||
|
private boolean dataInitialized;
|
||||||
|
|
||||||
|
private Date lastTimeChangeBeforeInitialization;
|
||||||
|
|
||||||
public RaceMap(SailingServiceAsync sailingService, ErrorReporter errorReporter, Timer timer,
|
public RaceMap(SailingServiceAsync sailingService, ErrorReporter errorReporter, Timer timer,
|
||||||
CompetitorSelectionProvider competitorSelection, StringMessages stringMessages) {
|
CompetitorSelectionProvider competitorSelection, StringMessages stringMessages) {
|
||||||
|
this.setSize("100%", "100%");
|
||||||
this.stringMessages = stringMessages;
|
this.stringMessages = stringMessages;
|
||||||
this.sailingService = sailingService;
|
this.sailingService = sailingService;
|
||||||
this.errorReporter = errorReporter;
|
this.errorReporter = errorReporter;
|
||||||
@@ -179,6 +185,9 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
this.competitorSelection = competitorSelection;
|
this.competitorSelection = competitorSelection;
|
||||||
competitorSelection.addCompetitorSelectionChangeListener(this);
|
competitorSelection.addCompetitorSelectionChangeListener(this);
|
||||||
settings = new RaceMapSettings();
|
settings = new RaceMapSettings();
|
||||||
|
lastTimeChangeBeforeInitialization = null;
|
||||||
|
dataInitialized = false;
|
||||||
|
initializeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calculateDistance(double lat1, double lng1, double lat2, double lng2) {
|
public double calculateDistance(double lat1, double lng1, double lat2, double lng2) {
|
||||||
@@ -195,7 +204,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
return dist;
|
return dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMapsAPI(final Panel parentPanel) {
|
private void loadMapsAPI() {
|
||||||
Maps.loadMapsApi(mapsAPIKey, "2", false, new Runnable() {
|
Maps.loadMapsApi(mapsAPIKey, "2", false, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
map = new MapWidget();
|
map = new MapWidget();
|
||||||
@@ -206,7 +215,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
// Add the map to the HTML host page
|
// Add the map to the HTML host page
|
||||||
map.setScrollWheelZoomEnabled(true);
|
map.setScrollWheelZoomEnabled(true);
|
||||||
map.setContinuousZoom(true);
|
map.setContinuousZoom(true);
|
||||||
parentPanel.add(map);
|
RaceMap.this.add(map);
|
||||||
map.setSize("100%", "100%");
|
map.setSize("100%", "100%");
|
||||||
map.addMapZoomEndHandler(new MapZoomEndHandler() {
|
map.addMapZoomEndHandler(new MapZoomEndHandler() {
|
||||||
@Override
|
@Override
|
||||||
@@ -236,6 +245,14 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
lastMousePosition = event.getLatLng();
|
lastMousePosition = event.getLatLng();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//If there was a time change before the API was loaded, reset the time
|
||||||
|
if (lastTimeChangeBeforeInitialization != null) {
|
||||||
|
timeChanged(lastTimeChangeBeforeInitialization);
|
||||||
|
lastTimeChangeBeforeInitialization = null;
|
||||||
|
}
|
||||||
|
//Data has been initialized
|
||||||
|
RaceMap.this.dataInitialized = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -267,42 +284,43 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
new ParallelExecutionHolder(getBoatsCallback, getMarksCallback) {
|
new ParallelExecutionHolder(getBoatsCallback, getMarksCallback) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
//Do boat specific actions
|
if (map != null) {
|
||||||
Map<CompetitorDTO, List<GPSFixDTO>> boatData = getBoatsCallback.getData();
|
//Do boat specific actions
|
||||||
// process response only if not received out of order
|
Map<CompetitorDTO, List<GPSFixDTO>> boatData = getBoatsCallback.getData();
|
||||||
if (startedProcessingRequestID < requestID) {
|
// process response only if not received out of order
|
||||||
startedProcessingRequestID = requestID;
|
if (startedProcessingRequestID < requestID) {
|
||||||
Date from = new Date(date.getTime() - settings.getTailLengthInMilliseconds());
|
startedProcessingRequestID = requestID;
|
||||||
updateFixes(boatData, fromAndToAndOverlap.getC());
|
Date from = new Date(date.getTime() - settings.getTailLengthInMilliseconds());
|
||||||
showBoatsOnMap(from, date, getCompetitorsToShow());
|
updateFixes(boatData, fromAndToAndOverlap.getC());
|
||||||
if (douglasMarkers != null) {
|
showBoatsOnMap(from, date, getCompetitorsToShow());
|
||||||
removeAllMarkDouglasPeuckerpoints();
|
if (douglasMarkers != null) {
|
||||||
|
removeAllMarkDouglasPeuckerpoints();
|
||||||
|
}
|
||||||
|
if (maneuverMarkers != null) {
|
||||||
|
removeAllManeuverMarkers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (maneuverMarkers != null) {
|
//Do mark specific actions
|
||||||
removeAllManeuverMarkers();
|
List<MarkDTO> markData = getMarksCallback.getData();
|
||||||
|
showMarksOnMap(markData);
|
||||||
|
//Rezoom the map
|
||||||
|
if (!getSettings().getZoomSettings().contains(ZoomTypes.NONE)) { //Auto zoom if setting is not manual
|
||||||
|
zoomMapToNewBounds(getSettings().getZoomSettings().getNewBounds(RaceMap.this));
|
||||||
|
mapFirstZoomDone = true;
|
||||||
|
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange) { //Zoom once to the boats
|
||||||
|
zoomMapToNewBounds(new BoatsBoundsCalculater().calculateNewBounds(RaceMap.this));
|
||||||
|
mapFirstZoomDone = true;
|
||||||
|
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange && !mapFirstZoomDone) { //Zoom once to the buoys
|
||||||
|
zoomMapToNewBounds(new BuoysBoundsCalculater().calculateNewBounds(RaceMap.this));
|
||||||
|
mapFirstZoomDone = true;
|
||||||
|
/* Reset the mapZoomedOrPannedSinceLastRaceSelection: In spite of the fact that the map was just zoomed
|
||||||
|
* to the bounds of the buoys, it was not a zoom or pan triggered by the user. As a consequence the
|
||||||
|
* mapZoomedOrPannedSinceLastRaceSelection option has to reset again.
|
||||||
|
*/
|
||||||
|
mapZoomedOrPannedSinceLastRaceSelectionChange = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
lastTimeChangeBeforeInitialization = date;
|
||||||
//Do mark specific actions
|
|
||||||
List<MarkDTO> markData = getMarksCallback.getData();
|
|
||||||
showMarksOnMap(markData);
|
|
||||||
|
|
||||||
//Rezoom the map
|
|
||||||
if (!getSettings().getZoomSettings().contains(ZoomTypes.NONE)) { //Auto zoom if setting is not manual
|
|
||||||
zoomMapToNewBounds(getSettings().getZoomSettings().getNewBounds(RaceMap.this));
|
|
||||||
mapFirstZoomDone = true;
|
|
||||||
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange) { //Zoom once to the boats
|
|
||||||
zoomMapToNewBounds(new BoatsBoundsCalculater().calculateNewBounds(RaceMap.this));
|
|
||||||
mapFirstZoomDone = true;
|
|
||||||
} else if (!mapZoomedOrPannedSinceLastRaceSelectionChange && !mapFirstZoomDone) { //Zoom once to the buoys
|
|
||||||
zoomMapToNewBounds(new BuoysBoundsCalculater().calculateNewBounds(RaceMap.this));
|
|
||||||
mapFirstZoomDone = true;
|
|
||||||
/*
|
|
||||||
* Reset the mapZoomedOrPannedSinceLastRaceSelection: In spite of the fact that the map was just zoomed
|
|
||||||
* to the bounds of the buoys, it was not a zoom or pan triggered by the user. As a consequence the
|
|
||||||
* mapZoomedOrPannedSinceLastRaceSelection option has to reset again.
|
|
||||||
*/
|
|
||||||
mapZoomedOrPannedSinceLastRaceSelectionChange = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1191,4 +1209,14 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initializeData() {
|
||||||
|
loadMapsAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDataInitialized() {
|
||||||
|
return dataInitialized;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -71,7 +71,7 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
|
|||||||
mapPanel.setSize("100%", "100%");
|
mapPanel.setSize("100%", "100%");
|
||||||
grid.setWidget(2, 1, mapPanel);
|
grid.setWidget(2, 1, mapPanel);
|
||||||
raceMap = new RaceMap(sailingService, errorReporter, timer, competitorSelectionProvider, stringMessages);
|
raceMap = new RaceMap(sailingService, errorReporter, timer, competitorSelectionProvider, stringMessages);
|
||||||
raceMap.loadMapsAPI(mapPanel);
|
mapPanel.add(raceMap);
|
||||||
raceSelectionModel = new RaceSelectionModel();
|
raceSelectionModel = new RaceSelectionModel();
|
||||||
raceListBox = new RacesListBoxPanel(eventRefresher, raceSelectionModel, stringMessages);
|
raceListBox = new RacesListBoxPanel(eventRefresher, raceSelectionModel, stringMessages);
|
||||||
raceSelectionModel.addRaceSelectionChangeListener(this);
|
raceSelectionModel.addRaceSelectionChangeListener(this);
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package com.sap.sailing.gwt.ui.client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used by UI-Components, which require asynchronous data initialization (for example RaceMap, Charts or the Leaderboard)
|
||||||
|
* @author Lennart Hensler (D054527)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface RequiresDataInitialization {
|
||||||
|
|
||||||
|
public void initializeData();
|
||||||
|
public boolean isDataInitialized();
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -141,7 +141,7 @@ public class RaceBoardPanel extends FormPanel implements EventDisplayer, RaceSel
|
|||||||
CollapsableComponentViewer<RaceMapSettings> raceMapViewer = new CollapsableComponentViewer<RaceMapSettings>(
|
CollapsableComponentViewer<RaceMapSettings> raceMapViewer = new CollapsableComponentViewer<RaceMapSettings>(
|
||||||
raceMap, "auto", "500px", stringMessages);
|
raceMap, "auto", "500px", stringMessages);
|
||||||
|
|
||||||
raceMap.loadMapsAPI((Panel) raceMapViewer.getViewerWidget().getContent());
|
((Panel) raceMapViewer.getViewerWidget().getContent()).add(raceMap);
|
||||||
raceMap.onRaceSelectionChange(Collections.singletonList(selectedRaceIdentifier));
|
raceMap.onRaceSelectionChange(Collections.singletonList(selectedRaceIdentifier));
|
||||||
collapsableViewers.add(raceMapViewer);
|
collapsableViewers.add(raceMapViewer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user