boats now calculate the time since last mark
-the raceclock is passed around so that the time can be tracked -time from start to mark 1 is wrong #story[878]
This commit is contained in:
@@ -10,6 +10,9 @@ import seng302.Mock.StreamedCourse;
|
||||
import seng302.RaceDataSource;
|
||||
import seng302.RaceMap;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -28,10 +31,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
private boolean annoAbbrev = true;
|
||||
private boolean annoSpeed = true;
|
||||
private boolean annoPath = true;
|
||||
private boolean annoTimeSinceLastMark = true;
|
||||
private List<Color> colours;
|
||||
private final List<Marker> markers;
|
||||
private final RaceDataSource raceData;
|
||||
|
||||
private RaceClock raceClock;
|
||||
|
||||
public ResizableRaceCanvas(RaceDataSource raceData) {
|
||||
super();
|
||||
|
||||
@@ -160,7 +166,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
* @param speed speed of the boat
|
||||
* @param coordinate coordinate the text appears
|
||||
*/
|
||||
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate) {
|
||||
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate, ZonedDateTime timeSinceLastMark) {
|
||||
String text = "";
|
||||
//Check name toggle value
|
||||
if (annoName){
|
||||
@@ -174,6 +180,11 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
if (annoSpeed){
|
||||
text += String.format("%.2fkn", speed);
|
||||
}
|
||||
//Check time since last mark toggle value
|
||||
if(annoTimeSinceLastMark){
|
||||
Duration timeSince = Duration.between(timeSinceLastMark, raceClock.getTime());
|
||||
text += String.format("%d", timeSince.getSeconds());
|
||||
}
|
||||
//String text = String.format("%s, %2$.2fkn", name, speed);
|
||||
long xCoord = coordinate.getX() + 20;
|
||||
long yCoord = coordinate.getY();
|
||||
@@ -293,7 +304,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
}
|
||||
|
||||
if (raceAnno)
|
||||
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
|
||||
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getTimeSinceLastMark());
|
||||
//TODO this needs to be fixed.
|
||||
drawTrack(boat, colours.get(currentColour));
|
||||
currentColour = (currentColour + 1) % colours.size();
|
||||
@@ -330,4 +341,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
));
|
||||
}
|
||||
|
||||
public void setRaceClock(RaceClock raceClock) {
|
||||
this.raceClock = raceClock;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user