bug5264: added missing update of lastPositions in CompetitorInfoOverlays

This commit is contained in:
Axel Uhl committed 2020-04-30 16:34:53 +02:00
1 parent 373c48c2c4
commit f08cfe1228
2 files changed
+3 -11

No files matched your search

@@ -42,7 +42,6 @@ public class CompetitorInfoOverlay extends CanvasOverlayV3 {
this.infoText = infoText;
canvasWidth = 100;
canvasHeight = 100;
setCanvasSize(canvasWidth, canvasHeight);
canvas.addStyleName("competitorInfo-Canvas");
}
@@ -53,7 +52,6 @@ public class CompetitorInfoOverlay extends CanvasOverlayV3 {
LatLng latLngPosition = coordinateSystem.toLatLng(position);
Context2d ctx = getCanvas().getContext2d();
CssColor grayTransparentColor = CssColor.make("rgba(255,255,255,0.75)");
ctx.setFont("12px bold Verdana sans-serif");
String[] textLines = infoText.split("\n");
TextMetrics measureText = ctx.measureText(findLargestLine(textLines));
@@ -61,10 +59,8 @@ public class CompetitorInfoOverlay extends CanvasOverlayV3 {
infoBoxHeight = defaultInfoBoxHeight + textLines.length * 10;
canvasWidth = (int)largestLineWidth + infoBoxHeight;
setCanvasSize(canvasWidth, canvasHeight);
ctx.save();
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
ctx.setLineWidth(1.0);
ctx.setFillStyle(grayTransparentColor);
if (competitorColor != null) {
@@ -72,12 +68,10 @@ public class CompetitorInfoOverlay extends CanvasOverlayV3 {
} else {
ctx.setStrokeStyle("#888888");
}
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(0,101);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(1.0,1.0);
ctx.lineTo(canvasWidth,1.0);
@@ -88,14 +82,11 @@ public class CompetitorInfoOverlay extends CanvasOverlayV3 {
ctx.closePath();
ctx.fill();
ctx.stroke();
ctx.beginPath();
ctx.setFillStyle("black");
drawText(textLines, ctx);
ctx.stroke();
ctx.restore();
Point objectPositionInPx = mapProjection.fromLatLngToDivPixel(latLngPosition);
setCanvasPosition(objectPositionInPx.getX(), objectPositionInPx.getY() - canvasHeight);
}
@@ -97,11 +97,11 @@ public class CompetitorInfoOverlays implements QuickFlagDataListener {
/**
* Updates {@link #ranks} and {@link speed} and re-draws the corresponding overlay
*/
public void updateFlagData(CompetitorDTO competitorDTO, Integer rank, Double speed) {
public void updateFlagData(CompetitorDTO competitorDTO, Integer rank, Double speedInKnots) {
CompetitorInfoOverlay overlay = competitorInfoOverlays.get(competitorDTO.getIdAsString());
if (overlay != null) {
ranks.put(competitorDTO.getIdAsString(), rank);
lastPositions.put(competitorDTO.getIdAsString(), speed);
lastPositions.put(competitorDTO.getIdAsString(), speedInKnots);
overlay.setInfoText(createInfoText(competitorDTO));
overlay.draw();
}
@@ -125,6 +125,7 @@ public class CompetitorInfoOverlays implements QuickFlagDataListener {
public void updatePosition(CompetitorDTO competitorDTO, GPSFixDTOWithSpeedWindTackAndLegType gpsFixDTO,
long timeForPositionTransitionMillis) {
CompetitorInfoOverlay overlay = competitorInfoOverlays.get(competitorDTO.getIdAsString());
lastPositions.put(competitorDTO.getIdAsString(), gpsFixDTO.speedWithBearing.speedInKnots);
if (overlay != null) {
overlay.setPosition(gpsFixDTO.position, timeForPositionTransitionMillis);
overlay.draw();