Increased minimum opacity so actual track from start is visible.

- No longer removes points from track
#story[25]
This commit is contained in:
cbt24
2017-04-07 15:18:57 +12:00
parent 375202e7a0
commit 680c6fb991
2 changed files with 4 additions and 5 deletions
+1 -4
View File
@@ -28,7 +28,7 @@ public class BoatInRace extends Boat {
private boolean started = false;
private StringProperty position;
private Queue<TrackPoint> track = new ConcurrentLinkedQueue<TrackPoint>();
private Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
private long nextValidTime = 0;
private final int TRACK_POINT_TIME_INTERVAL = 1000; // every 1 seconds
private final int TRACK_POINT_LIMIT = 10;
@@ -263,9 +263,6 @@ public class BoatInRace extends Boat {
if (added && this.started) {
nextValidTime = System.currentTimeMillis() + TRACK_POINT_TIME_INTERVAL;
track.add(new TrackPoint(coordinate, System.currentTimeMillis(), TRACK_POINT_LIMIT*TRACK_POINT_TIME_INTERVAL));
if (track.size() > TRACK_POINT_LIMIT) {
track.remove();
}
}
return added;
}
+3 -1
View File
@@ -9,11 +9,13 @@ public class TrackPoint {
private GPSCoordinate coordinate;
private long timeAdded;
private long expiry;
private double minAlpha;
public TrackPoint(GPSCoordinate coordinate, long timeAdded, long expiry) {
this.coordinate = coordinate;
this.timeAdded = timeAdded;
this.expiry = expiry;
this.minAlpha = 0.1;
}
public GPSCoordinate getCoordinate() {
@@ -21,6 +23,6 @@ public class TrackPoint {
}
public double getAlpha() {
return Double.max(0,1.0 - (double)(System.currentTimeMillis() - timeAdded)/expiry);
return Double.max(minAlpha,1.0 - (double)(System.currentTimeMillis() - timeAdded)/expiry);
}
}