added DelegateCoordinateSystem to make a coordinate system changeable; added clear method on FixesAndTails and use when coordinate system changes

This commit is contained in:
Axel Uhl committed 2015-04-09 14:08:10 +02:00
1 parent 70db98d4d2
commit 61bf0fc55c
3 files changed
+77 -6

No files matched your search

@@ -0,0 +1,54 @@
package com.sap.sailing.gwt.ui.client.shared.racemap;
import com.google.gwt.maps.client.base.LatLng;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Position;
/**
* Holds a {@link CoordinateSystem} that can be exchanged, using {@link #setCoordinateSystem}.
*
* @author Axel Uhl (D043530)
*
*/
public class DelegateCoordinateSystem implements CoordinateSystem {
private CoordinateSystem coordinateSystem;
public DelegateCoordinateSystem(CoordinateSystem coordinateSystem) {
super();
this.coordinateSystem = coordinateSystem;
}
public CoordinateSystem getCoordinateSystem() {
return coordinateSystem;
}
public void setCoordinateSystem(CoordinateSystem coordinateSystem) {
this.coordinateSystem = coordinateSystem;
}
@Override
public Position map(Position position) {
return coordinateSystem.map(position);
}
@Override
public Bearing map(Bearing bearing) {
return coordinateSystem.map(bearing);
}
@Override
public double mapDegreeBearing(double trueBearingInDegrees) {
return coordinateSystem.mapDegreeBearing(trueBearingInDegrees);
}
@Override
public LatLng toLatLng(Position position) {
return coordinateSystem.toLatLng(position);
}
@Override
public Position getPosition(LatLng p) {
return coordinateSystem.getPosition(p);
}
}
@@ -507,4 +507,19 @@ public class FixesAndTails {
}
return null;
}
/**
* Clears all tail data, removing them from the map and from this object's internal structures. GPS fixes remain
* cached. Immediately after this call, {@link #getTail(CompetitorDTO)} will return <code>null</code> for all
* competitors. Tails will need to be created (again) using
* {@link #createTailAndUpdateIndices(CompetitorDTO, Date, Date, TailFactory)}.
*/
protected void clearTails() {
for (Polyline tail : tails.values()) {
tail.setMap(null);
}
tails.clear();
firstShownFix.clear();
lastShownFix.clear();
}
}
@@ -142,7 +142,7 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
* embedded in the map. The coordinate systems facilitates the possibility of transformed displays such as
* rotated and translated versions of the map, implementing the "wind-up" view.
*/
private CoordinateSystem coordinateSystem;
private DelegateCoordinateSystem coordinateSystem;
private FlowPanel headerPanel;
private AbsolutePanel panelForLeftHeaderLabels;
@@ -362,8 +362,9 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
this.competitorSelection = competitorSelection;
competitorSelection.addCompetitorSelectionChangeListener(this);
settings = new RaceMapSettings();
coordinateSystem = updateCoordinateSystemFromSettings();
coordinateSystem = new DelegateCoordinateSystem(new IdentityCoordinateSystem());
fixesAndTails = new FixesAndTails(coordinateSystem);
updateCoordinateSystemFromSettings();
lastTimeChangeBeforeInitialization = null;
isMapInitialized = false;
this.showViewStreamlets = showViewStreamlets;
@@ -378,11 +379,12 @@ public class RaceMap extends AbsolutePanel implements TimeListener, CompetitorSe
combinedWindPanel.setVisible(false);
}
private CoordinateSystem updateCoordinateSystemFromSettings() {
coordinateSystem = getSettings().isWindUp()
private void updateCoordinateSystemFromSettings() {
coordinateSystem.setCoordinateSystem(getSettings().isWindUp()
? new RotateAndTranslateCoordinateSystem(/* TODO */ new DegreePosition(-33.957425, 25.679894), /* TODO */ new DegreeBearingImpl(180))
: new IdentityCoordinateSystem();
return coordinateSystem;
: new IdentityCoordinateSystem());
fixesAndTails.clearTails();
redraw();
}
private void loadMapsAPIV3(final boolean showMapControls) {