mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-26 05:53:50 +00:00
possible fix for crash upon start
This commit is contained in:
1 parent
9a1616a5d7
commit
9b545b10fe
1 file changed
+23
-2
+23
-2
@@ -7,6 +7,8 @@ import com.google.gwt.canvas.dom.client.Context2d;
|
||||
import com.google.gwt.maps.client.MapWidget;
|
||||
import com.google.gwt.maps.client.base.LatLng;
|
||||
import com.google.gwt.maps.client.base.LatLngBounds;
|
||||
import com.google.gwt.maps.client.events.bounds.BoundsChangeMapEvent;
|
||||
import com.google.gwt.maps.client.events.bounds.BoundsChangeMapHandler;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.sap.sailing.gwt.ui.client.shared.racemap.BoundsUtil;
|
||||
import com.sap.sailing.gwt.ui.client.shared.racemap.CoordinateSystem;
|
||||
@@ -58,6 +60,8 @@ public class Swarm implements TimeListener {
|
||||
private Date timePoint;
|
||||
private double cosineOfAverageLatitude;
|
||||
|
||||
private boolean mapLoaded = false;
|
||||
|
||||
public Swarm(FullCanvasOverlay fullcanvas, MapWidget map, com.sap.sse.gwt.client.player.Timer timer,
|
||||
VectorField vectorField, StreamletParameters streamletPars) {
|
||||
this.field = vectorField;
|
||||
@@ -71,12 +75,29 @@ public class Swarm implements TimeListener {
|
||||
diffPx = new Vector(0, 0);
|
||||
}
|
||||
|
||||
public void start(int animationIntervalMillis) {
|
||||
public void start(final int animationIntervalMillis) {
|
||||
fullcanvas.setCanvasSettings();
|
||||
// if map is not yet loaded, wait for it
|
||||
if (map.getBounds() != null) {
|
||||
startWithMap(animationIntervalMillis);
|
||||
} else {
|
||||
map.addBoundsChangeHandler(new BoundsChangeMapHandler() {
|
||||
@Override
|
||||
public void onEvent(BoundsChangeMapEvent event) {
|
||||
if (!mapLoaded) {
|
||||
startWithMap(animationIntervalMillis);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void startWithMap(int animationIntervalMillis) {
|
||||
mapLoaded = true;
|
||||
projection = new Mercator(fullcanvas, map);
|
||||
projection.calibrate();
|
||||
updateBounds();
|
||||
particles = this.createParticles();
|
||||
particles = createParticles();
|
||||
swarmContinue = true;
|
||||
startLoop(animationIntervalMillis);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user