Fixed race playback issue, removed obsolete detail from UI.

- Removed race scaling options
- Refactored start screen timer formatting for clarity
- Removed incomplete countdownTimer override in Streamed Race

#story[782]
This commit is contained in:
Connor Taylor-Brown
2017-05-03 22:04:08 +12:00
parent 5a92dd68f5
commit e7008ab6db
4 changed files with 22 additions and 88 deletions
@@ -20,6 +20,8 @@ import seng302.VisualiserInput;
import java.io.IOException;
import java.net.Socket;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
@@ -38,10 +40,8 @@ public class StartController extends Controller implements Observer {
@FXML private TableColumn<Boat, String> boatCodeColumn;
@FXML private Label timeZoneTime;
@FXML private Label timer;
@FXML private int PRERACE_TIME = 15000;
@FXML private int PRERACE_TIME = 10;
@FXML Button oneMinButton;
@FXML Button fiveMinButton;
@FXML Button fifteenMinButton;
private RaceClock raceClock;
@@ -51,20 +51,6 @@ public class StartController extends Controller implements Observer {
private VisualiserInput visualiserInput;
/**
* Begins the race with a scale factor of 15
*/
public void startRace1Min() {
startRace(15);
}
/**
* Begins the race with a scale factor of 3
*/
public void startRace5Min() {
startRace(3);
}
/**
* Begins the race with a scale factor of 1
*/
@@ -73,9 +59,6 @@ public class StartController extends Controller implements Observer {
}
private void startRace(int raceScale){
oneMinButton.setDisable(true);
fiveMinButton.setDisable(true);
fifteenMinButton.setDisable(true);
countdownTimer(raceScale);
}
@@ -118,10 +101,7 @@ public class StartController extends Controller implements Observer {
new AnimationTimer() {
long currentTime = System.currentTimeMillis();
long startTime = currentTime + (PRERACE_TIME/scaleFactor);
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
long hours;
DateFormat timerFormat = new SimpleDateFormat("'Race Clock:' -HH:mm:ss");
@Override
public void handle(long arg0) {
@@ -133,12 +113,7 @@ public class StartController extends Controller implements Observer {
startWrapper.setVisible(false);
} else {
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;
minutes = minutes % 60;
updateTime(String.format("Race Clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
updateTime(timerFormat.format(currentTime));
}
currentTime = System.currentTimeMillis();
@@ -1,21 +1,12 @@
package seng302.Mock;
import javafx.animation.AnimationTimer;
import javafx.collections.FXCollections;
import org.geotools.referencing.GeodeticCalculator;
import seng302.*;
import seng302.Controllers.RaceController;
import seng302.Model.*;
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
import seng302.Networking.Utils.BoatStatusMessage;
import seng302.Networking.Utils.ByteConverter;
import seng302.Networking.Utils.Enums.BoatStatus;
import seng302.Networking.Utils.BoatLocationMessage;
import java.awt.geom.Point2D;
import java.time.Instant;
import java.util.*;
/**
* Created by jjg64 on 21/04/17.
*/
@@ -101,39 +92,4 @@ public class StreamedRace extends Race {
boat.setCurrentPosition(coordinate);
}
@Override
protected void countdownTimer() {
new AnimationTimer() {
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
long hours;
long timeLeft;
@Override
public void handle(long arg0) {
long currentTime = Instant.now().getEpochSecond();
long startTime = visualiserInput.getRaceStatus().getExpectedStartTime();
timeLeft = startTime - currentTime;
System.out.println(timeLeft);
if (timeLeft <= 0 && controller != null) {
updateTime("Race is starting...");
stop();
simulateRace();
} else {
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;
minutes = minutes % 60;
if (controller != null) {
updateTime(String.format("Race clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
}
}
currentTime = System.currentTimeMillis();
}
}.start();
}
}
@@ -12,6 +12,7 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;
/**
* Created by Gondr on 19/04/2017.
@@ -29,6 +30,12 @@ public class RaceClock {
setTime(time);
}
public RaceClock(long utcTime, ZoneId zoneId) {
this.zoneId = zoneId;
this.timeString = new SimpleStringProperty();
this.time = (new Date(utcTime)).toInstant().atZone(zoneId);
}
public static ZonedDateTime getCurrentZonedDateTime(GPSCoordinate gpsCoordinate) {
TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());