mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 02:43:53 +00:00
extraction of RaceMapPanel settings into settings dialog seems to work OK by now
This commit is contained in:
1 parent
98caf7abc9
commit
e8d5dbcb5f
3 files changed
+24
-13
No files matched your search
+4
-3
@@ -195,6 +195,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
Maps.loadMapsApi(mapsAPIKey, "2", false, new Runnable() {
|
||||
public void run() {
|
||||
map = new MapWidget();
|
||||
imageResources.setMap(map);
|
||||
map.addControl(new LargeMapControl3D());
|
||||
map.addControl(new MenuMapTypeControl());
|
||||
map.addControl(new ScaleControl());
|
||||
@@ -511,13 +512,13 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
// check if anchors match; re-use marker with setImage only if anchors match
|
||||
ImageTransformer transformer = imageResources.getBoatImageTransformer(lastPos,
|
||||
competitorSelection.isSelected(competitorDAO));
|
||||
Point newAnchor = transformer.getAnchor(imageResources.getRealBoatSizeScaleFactor(map));
|
||||
Point newAnchor = transformer.getAnchor(imageResources.getRealBoatSizeScaleFactor());
|
||||
Point oldAnchor = boatMarker.getIcon().getIconAnchor();
|
||||
if (oldAnchor.getX() == newAnchor.getX() && oldAnchor.getY() == newAnchor.getY()) {
|
||||
boatMarker.setLatLng(LatLng.newInstance(lastPos.position.latDeg,
|
||||
lastPos.position.lngDeg));
|
||||
boatMarker.setImage(imageResources.getBoatImageURL(lastPos,
|
||||
displayHighlighted(competitorDAO), map));
|
||||
displayHighlighted(competitorDAO)));
|
||||
} else {
|
||||
// anchors don't match; replace marker
|
||||
map.removeOverlay(boatMarker);
|
||||
@@ -557,7 +558,7 @@ public class RaceMap implements TimeListener, CompetitorSelectionChangeListener,
|
||||
double latDeg = boatFix.position.latDeg;
|
||||
double lngDeg = boatFix.position.lngDeg;
|
||||
MarkerOptions options = MarkerOptions.newInstance();
|
||||
Icon icon = imageResources.getBoatImageIcon(boatFix, highlighted, map);
|
||||
Icon icon = imageResources.getBoatImageIcon(boatFix, highlighted);
|
||||
options.setIcon(icon);
|
||||
options.setTitle(competitorDAO.name);
|
||||
final Marker boatMarker = new Marker(LatLng.newInstance(latDeg, lngDeg), options);
|
||||
|
||||
+18
-8
@@ -59,6 +59,8 @@ public class RaceMapResources {
|
||||
protected Icon buoyIcon;
|
||||
|
||||
protected Map<Pair<ManeuverType, Tack>, Icon> maneuverIconsForTypeAndTargetTack;
|
||||
|
||||
private MapWidget map;
|
||||
|
||||
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
|
||||
@@ -73,6 +75,14 @@ public class RaceMapResources {
|
||||
boatIconHighlightedPortRotator = new ImageTransformer(resources.highlightedBoatIcon_Port());
|
||||
boatIconStarboardRotator = new ImageTransformer(resources.lowlightedBoatIcon_Starboard());
|
||||
boatIconHighlightedStarboardRotator = new ImageTransformer(resources.highlightedBoatIcon_Starboard());
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this when the map API has finished loading. Up to this point, {@link #buoyIcon} and the {@link #maneuverIconsForTypeAndTargetTack}
|
||||
* are not propertly initialized.
|
||||
*/
|
||||
public void setMap(MapWidget map) {
|
||||
this.map = map;
|
||||
buoyIcon = Icon.newInstance(resources.buoyIcon().getSafeUri().asString());
|
||||
buoyIcon.setIconAnchor(Point.newInstance(4, 4));
|
||||
|
||||
@@ -163,16 +173,16 @@ public class RaceMapResources {
|
||||
}
|
||||
}
|
||||
|
||||
public String getBoatImageURL(GPSFixDAO boatFix, boolean highlighted, MapWidget map) {
|
||||
return getBoatImageURL(getBoatImageTransformer(boatFix, highlighted), boatFix, map);
|
||||
public String getBoatImageURL(GPSFixDAO boatFix, boolean highlighted) {
|
||||
return getBoatImageURL(getBoatImageTransformer(boatFix, highlighted), boatFix);
|
||||
}
|
||||
|
||||
public String getBoatImageURL(ImageTransformer boatImageTransformer, GPSFixDAO boatFix, MapWidget map) {
|
||||
double realBoatSizeScaleFactor = getRealBoatSizeScaleFactor(map);
|
||||
public String getBoatImageURL(ImageTransformer boatImageTransformer, GPSFixDAO boatFix) {
|
||||
double realBoatSizeScaleFactor = getRealBoatSizeScaleFactor();
|
||||
return boatImageTransformer.getTransformedImageURL(boatFix.speedWithBearing.bearingInDegrees, realBoatSizeScaleFactor);
|
||||
}
|
||||
|
||||
public double getRealBoatSizeScaleFactor(MapWidget map) {
|
||||
public double getRealBoatSizeScaleFactor() {
|
||||
// the possible zoom level range is 0 to 21 (zoom level 0 would show the whole world)
|
||||
int zoomLevel = map == null ? 1 : map.getZoomLevel();
|
||||
double minScaleFactor = 0.33;
|
||||
@@ -195,10 +205,10 @@ public class RaceMapResources {
|
||||
return realBoatSizeScaleFactor;
|
||||
}
|
||||
|
||||
public Icon getBoatImageIcon(GPSFixDAO boatFix, boolean highlighted, MapWidget map) {
|
||||
public Icon getBoatImageIcon(GPSFixDAO boatFix, boolean highlighted) {
|
||||
ImageTransformer boatImageTransformer = getBoatImageTransformer(boatFix, highlighted);
|
||||
Icon icon = Icon.newInstance(getBoatImageURL(boatImageTransformer, boatFix, map));
|
||||
icon.setIconAnchor(boatImageTransformer.getAnchor(getRealBoatSizeScaleFactor(map)));
|
||||
Icon icon = Icon.newInstance(getBoatImageURL(boatImageTransformer, boatFix));
|
||||
icon.setIconAnchor(boatImageTransformer.getAnchor(getRealBoatSizeScaleFactor()));
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -51,8 +51,8 @@ public class RaceMapSettingsDialogComponent implements SettingsDialogComponent<R
|
||||
vp.add(checkbox);
|
||||
}
|
||||
checkBoxDouglasPeuckerPoints = dialog.createCheckbox(stringMessages.douglasPeuckerPoints());
|
||||
checkBoxDouglasPeuckerPoints.setValue(initialSettings.isShowDouglasPeuckerPoints());
|
||||
vp.add(checkBoxDouglasPeuckerPoints);
|
||||
vp.add(new Label(stringMessages.tailLength()));
|
||||
return vp;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class RaceMapSettingsDialogComponent implements SettingsDialogComponent<R
|
||||
}
|
||||
result.setShowDouglasPeuckerPoints(checkBoxDouglasPeuckerPoints.getValue());
|
||||
result.setShowOnlySelectedCompetitors(showOnlySelectedCompetitors.getValue());
|
||||
result.setTailLengthInMilliseconds(tailLengthBox.getValue() == null ? -1 : tailLengthBox.getValue());
|
||||
result.setTailLengthInMilliseconds(tailLengthBox.getValue() == null ? -1 : tailLengthBox.getValue()*1000l);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user