Changed implementation for Anno(annotations)

-drawRaceMap is now called for annotation to update map

#story[23]
main
David Wu 9 years ago
parent 879de9869b
commit 33b94cdf5b

@ -44,7 +44,7 @@ public class RaceController extends Controller{
CheckBox showFPS;
@FXML
public CheckBox showAnno;
CheckBox showAnno;
@FXML
Label timer;
@ -160,7 +160,8 @@ 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();
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov,
Boolean old_val, Boolean new_val) {
@ -176,10 +177,9 @@ public class RaceController extends Controller{
public void changed(ObservableValue<? extends Boolean> ov,
Boolean old_val, Boolean new_val) {
raceMap.toggleAnno();
raceMap.drawRaceMap();
}
});
new Thread((race)).start();
}
@ -219,10 +219,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)); }

@ -117,7 +117,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;
@ -163,6 +163,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);});
}
@ -187,7 +191,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;
@ -199,7 +202,7 @@ public abstract class Race implements Runnable {
}
}
//if (controller != null) controller.updateMap(startingBoats);
if (controller != null) controller.updateMap(startingBoats);
if (timerEnabled)
updateTime(calcTimer());
}
@ -210,8 +213,6 @@ public abstract class Race implements Runnable {
timeCurrent = System.currentTimeMillis();
}
;
/*fps++;
try {
timeLoopEnded = System.currentTimeMillis();
@ -272,7 +273,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