mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-30 15:57:11 +00:00
Synchronize directional overlays during map rotation
This commit is contained in:
2 files changed
+59
-10
No files matched your search
+45
-10
@@ -231,6 +231,7 @@ public class RaceMap extends AbstractCompositeComponent<RaceMapSettings> impleme
|
||||
* rotated and translated versions of the map, implementing the "wind-up" view.
|
||||
*/
|
||||
private DelegateCoordinateSystem coordinateSystem;
|
||||
private Double synchronizedMapHeading;
|
||||
|
||||
/**
|
||||
* Tells whether the {@link RenderingType#VECTOR} is supported on the current platform / browser.
|
||||
@@ -1013,6 +1014,7 @@ public class RaceMap extends AbstractCompositeComponent<RaceMapSettings> impleme
|
||||
map.addBoundsChangeHandler(new BoundsChangeMapHandler() {
|
||||
@Override
|
||||
public void onEvent(BoundsChangeMapEvent event) {
|
||||
synchronizeCoordinateSystemWithMapHeadingDuringCameraMove();
|
||||
double newZoomLevel = map.getZoom();
|
||||
if (!isAutoZoomInProgress() && (newZoomLevel != currentZoomLevel)) {
|
||||
removeTransitions();
|
||||
@@ -3900,20 +3902,53 @@ public class RaceMap extends AbstractCompositeComponent<RaceMapSettings> impleme
|
||||
return currentMapBounds.getLowerLeft().getDistance(currentMapBounds.getUpperRight()).scale(2);
|
||||
}
|
||||
|
||||
private boolean installActualMapHeading() {
|
||||
final boolean changed;
|
||||
if (vectorRenderingTypeSupported && map != null) {
|
||||
final double mapHeading = map.getHeading();
|
||||
changed = synchronizedMapHeading == null ||
|
||||
Math.abs(synchronizedMapHeading - mapHeading) > 0.000001;
|
||||
if (changed) {
|
||||
coordinateSystem.setCoordinateSystem(new RotatedCoordinateSystem(
|
||||
new DegreeBearingImpl(mapHeading).add(new DegreeBearingImpl(90))));
|
||||
synchronizedMapHeading = mapHeading;
|
||||
}
|
||||
} else {
|
||||
changed = false;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private void redrawMapHeadingIndicators() {
|
||||
combinedWindPanel.redraw();
|
||||
final boolean rotated = coordinateSystem.mapDegreeBearing(0) != 0;
|
||||
trueNorthIndicatorPanel.setVisible(rotated);
|
||||
trueNorthIndicatorButtonButtonGroup.getElement().getStyle().setProperty(
|
||||
"transform", "rotate(" + coordinateSystem.mapDegreeBearing(0) + "deg)");
|
||||
if (rotated) {
|
||||
trueNorthIndicatorPanel.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
private void synchronizeCoordinateSystemWithMapHeadingDuringCameraMove() {
|
||||
final double previousMapHeading = synchronizedMapHeading == null ? map.getHeading() : synchronizedMapHeading;
|
||||
if (installActualMapHeading()) {
|
||||
if (streamletOverlay != null
|
||||
&& settings.isShowWindStreamletOverlay()
|
||||
&& paywallResolver.hasPermission(SecuredDomainType.TrackedRaceActions.VIEWSTREAMLETS,
|
||||
raceMapLifecycle.getRaceDTO())) {
|
||||
streamletOverlay.onMapHeadingChanged(previousMapHeading, map.getHeading());
|
||||
}
|
||||
redrawMapHeadingIndicators();
|
||||
}
|
||||
}
|
||||
|
||||
private void synchronizeCoordinateSystemWithMapHeading() {
|
||||
if (vectorRenderingTypeSupported && map != null) {
|
||||
coordinateSystem.setCoordinateSystem(new RotatedCoordinateSystem(
|
||||
new DegreeBearingImpl(map.getHeading()).add(new DegreeBearingImpl(90))));
|
||||
installActualMapHeading();
|
||||
windSensorOverlays.values().forEach(WindSensorOverlay::draw);
|
||||
courseMarkOverlays.values().forEach(CourseMarkOverlay::draw);
|
||||
combinedWindPanel.redraw();
|
||||
final boolean rotated = coordinateSystem.mapDegreeBearing(0) != 0;
|
||||
trueNorthIndicatorPanel.setVisible(rotated);
|
||||
trueNorthIndicatorButtonButtonGroup.getElement().getStyle().setProperty(
|
||||
"transform", "rotate(" + coordinateSystem.mapDegreeBearing(0) + "deg)");
|
||||
if (rotated) {
|
||||
trueNorthIndicatorPanel.redraw();
|
||||
}
|
||||
redrawMapHeadingIndicators();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
@@ -73,6 +73,7 @@ public class WindStreamletsRaceboardOverlay extends MovingCanvasOverlay implemen
|
||||
private final NumberFormat numberFormatOneDecimal = NumberFormatterFactory.getDecimalFormat(1);
|
||||
private ElementStyleMutationObserver observer;
|
||||
private boolean dragging = false;
|
||||
private Double mapHeadingAtOrientationStart;
|
||||
private boolean isAttached = false, startObserverWhenAttached = false;
|
||||
private boolean timeChangedSinceLastUpdate = true;
|
||||
|
||||
@@ -375,8 +376,21 @@ public class WindStreamletsRaceboardOverlay extends MovingCanvasOverlay implemen
|
||||
swarm.pause(500 / animationIntervalMillis); // pause animation for two seconds
|
||||
}
|
||||
|
||||
public void onMapHeadingChanged(double previousMapHeading, double mapHeading) {
|
||||
if (mapHeadingAtOrientationStart == null) {
|
||||
mapHeadingAtOrientationStart = previousMapHeading;
|
||||
}
|
||||
onDragStart();
|
||||
updateDrawingAngleAndSetCanvasRotation(mapHeadingAtOrientationStart - mapHeading);
|
||||
}
|
||||
|
||||
public void onDragEnd() {
|
||||
dragging = false;
|
||||
if (mapHeadingAtOrientationStart != null) {
|
||||
mapHeadingAtOrientationStart = null;
|
||||
updateDrawingAngleAndSetCanvasRotation(0);
|
||||
swarm.onBoundsChanged(/* zoomChanged */ true, /* swarmPause */ 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void onBoundsChanged(boolean zoomChanged) {
|
||||
|
||||
Reference in new issue
Block a user