The trackpoint line is now a line (poly-line) instead of a sequence of circles. A point along the poly-line is added every 250ms.

issue #18
main
fjc40 8 years ago
parent 175fb11178
commit b07c30704a

@ -2,6 +2,7 @@ package visualiser.model;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate;
import network.Messages.Enums.BoatStatusEnum;
@ -11,6 +12,7 @@ import shared.model.Mark;
import shared.model.RaceClock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -171,6 +173,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
graphCoordinateB.getX(),
graphCoordinateB.getY() );
}
/**
@ -523,15 +526,27 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Apply the boat color.
gc.setFill(boat.getColor());
double[] xPoints = new double[boat.getTrack().size()];
double[] yPoints = new double[boat.getTrack().size()];
int index = 0;
//Draw each TrackPoint.
for (TrackPoint point : new ArrayList<>(boat.getTrack())) {
//Convert the GPSCoordinate to a screen coordinate.
GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate());
//Draw a circle for the trackpoint.
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), point.getDiameter(), point.getDiameter());
xPoints[index] = ((double)scaledCoordinate.getX());
yPoints[index] = ((double)scaledCoordinate.getY());
index++;
}
gc.strokePolyline(xPoints, yPoints, xPoints.length);
}
}

@ -34,11 +34,6 @@ public class TrackPoint {
*/
private final double minAlpha;
/**
* The diameter to draw the track point with.
*/
private final double diameter;
/**
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
@ -53,7 +48,6 @@ public class TrackPoint {
this.expiry = expiry;
this.minAlpha = 0.1;
this.diameter = 5d;
}
@ -97,12 +91,4 @@ public class TrackPoint {
return timeAdded;
}
/**
* Returns the diameter to draw the track point with.
* @return The diameter to draw the track point with.
*/
public double getDiameter() {
return diameter;
}
}

@ -1,7 +1,5 @@
package visualiser.model;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.paint.Color;
import network.Messages.Enums.BoatStatusEnum;
import shared.model.Azimuth;
@ -38,7 +36,7 @@ public class VisualiserBoat extends Boat {
/**
* The minimum period of time, in milliseconds, between the creation of each track point.
*/
private static final long trackPointTimeInterval = 5000;
private static final long trackPointTimeInterval = 250;
/**
* The number of track points that should be created before fully diminishing the alpha of a given track point.
@ -55,7 +53,7 @@ public class VisualiserBoat extends Boat {
/**
* Scalar used to scale the boat's wake.
*/
private static final double wakeScale = 5;
private static final double wakeScale = 20;
/**
* If true then this boat has been allocated to the client.

Loading…
Cancel
Save