Merge branch 'master' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into changeStartingPositions2

main
Erika Savell 9 years ago
commit 45fcd22cc5

@ -47,7 +47,7 @@ public class RaceController extends Controller{
CheckBox showFPS;
@FXML
public CheckBox showAnno;
CheckBox showAnno;
@FXML
Label timer;
@ -163,7 +163,9 @@ public class RaceController extends Controller{
ArrayList<Leg> legs = raceXMLReader.getLegs();
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this, scaleFactor);
showFPS.setVisible(true);
new Thread((race)).start();
//listener for fps
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov,
Boolean old_val, Boolean new_val) {
@ -175,14 +177,14 @@ public class RaceController extends Controller{
}
});
//listener for annotation
showAnno.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov,
Boolean old_val, Boolean new_val) {
raceMap.toggleAnno();
raceMap.drawRaceMap();
}
});
new Thread((race)).start();
}
@ -222,10 +224,19 @@ public class RaceController extends Controller{
return boats;
}
/**
* Set the value for the race clock label
* @param time time that the label will be updated to
*/
public void setTimer(String time) {
timer.setText(time);
}
/**
* Set the value for the fps label
* @param fps fps that the label will be updated to
*/
public void setFrames(String fps) { FPS.setText((fps)); }

@ -118,7 +118,7 @@ public abstract class Race implements Runnable {
long timeLoopEnded;
while (currentTime <= startTime) {
if (controller != null) controller.updateMap(startingBoats);
//if (controller != null) controller.updateMap(startingBoats);
timeLeft = startTime - currentTime;
currentTimeInSeconds = timeLeft / 1000;
minutes = currentTimeInSeconds / 60;
@ -164,6 +164,10 @@ public abstract class Race implements Runnable {
Platform.runLater(() -> {controller.setTimer(time);});
}
/**
* Update the calculated fps to the fps label
* @param fps The new calculated fps value
*/
private void updateFPS(int fps) {
Platform.runLater(() -> {controller.setFrames("FPS: " + fps);});
}
@ -188,7 +192,6 @@ public abstract class Race implements Runnable {
/*long timeLoopStarted;
long timeLoopEnded;
int fps = 0;*/
if (controller != null) controller.updateMap(startingBoats);
if (boatsFinished < startingBoats.size()) {
//timeLoopStarted = System.currentTimeMillis();
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
@ -200,7 +203,7 @@ public abstract class Race implements Runnable {
}
}
//if (controller != null) controller.updateMap(startingBoats);
if (controller != null) controller.updateMap(startingBoats);
if (timerEnabled)
updateTime(calcTimer());
}
@ -211,8 +214,6 @@ public abstract class Race implements Runnable {
timeCurrent = System.currentTimeMillis();
}
;
/*fps++;
try {
timeLoopEnded = System.currentTimeMillis();
@ -273,7 +274,6 @@ public abstract class Race implements Runnable {
* Is automatically called by the initialiser function, so that simulateRace() does not return an empty race.
* @see Race#simulateRace()
*/
protected abstract void updatePosition(BoatInRace boat, int millisecondsElapsed);
/**

@ -27,7 +27,6 @@ public class ResizableRaceCanvas extends Canvas {
private GraphicsContext gc;
private RaceMap map;
private BoatInRace[] boats;
private RaceController controller;
private boolean raceAnno = true;
/**
@ -218,6 +217,9 @@ public class ResizableRaceCanvas extends Canvas {
displayPoint(graphCoordinate, colour);
}
/**
* Toggle the raceAnno value
*/
public void toggleAnno(){
if (raceAnno){
raceAnno = false;

Loading…
Cancel
Save