Changed implementation for Anno(annotations)
-drawRaceMap is now called for annotation to update map #story[23]
This commit is contained in:
@@ -44,7 +44,7 @@ public class RaceController extends Controller{
|
|||||||
CheckBox showFPS;
|
CheckBox showFPS;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public CheckBox showAnno;
|
CheckBox showAnno;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
Label timer;
|
Label timer;
|
||||||
@@ -160,7 +160,8 @@ public class RaceController extends Controller{
|
|||||||
ArrayList<Leg> legs = raceXMLReader.getLegs();
|
ArrayList<Leg> legs = raceXMLReader.getLegs();
|
||||||
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this, scaleFactor);
|
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this, scaleFactor);
|
||||||
|
|
||||||
showFPS.setVisible(true);
|
new Thread((race)).start();
|
||||||
|
|
||||||
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
public void changed(ObservableValue<? extends Boolean> ov,
|
public void changed(ObservableValue<? extends Boolean> ov,
|
||||||
Boolean old_val, Boolean new_val) {
|
Boolean old_val, Boolean new_val) {
|
||||||
@@ -176,10 +177,9 @@ public class RaceController extends Controller{
|
|||||||
public void changed(ObservableValue<? extends Boolean> ov,
|
public void changed(ObservableValue<? extends Boolean> ov,
|
||||||
Boolean old_val, Boolean new_val) {
|
Boolean old_val, Boolean new_val) {
|
||||||
raceMap.toggleAnno();
|
raceMap.toggleAnno();
|
||||||
|
raceMap.drawRaceMap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new Thread((race)).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,10 +219,19 @@ public class RaceController extends Controller{
|
|||||||
return boats;
|
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) {
|
public void setTimer(String time) {
|
||||||
timer.setText(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)); }
|
public void setFrames(String fps) { FPS.setText((fps)); }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public abstract class Race implements Runnable {
|
|||||||
long timeLoopEnded;
|
long timeLoopEnded;
|
||||||
|
|
||||||
while (currentTime <= startTime) {
|
while (currentTime <= startTime) {
|
||||||
if (controller != null) controller.updateMap(startingBoats);
|
//if (controller != null) controller.updateMap(startingBoats);
|
||||||
timeLeft = startTime - currentTime;
|
timeLeft = startTime - currentTime;
|
||||||
currentTimeInSeconds = timeLeft / 1000;
|
currentTimeInSeconds = timeLeft / 1000;
|
||||||
minutes = currentTimeInSeconds / 60;
|
minutes = currentTimeInSeconds / 60;
|
||||||
@@ -163,6 +163,10 @@ public abstract class Race implements Runnable {
|
|||||||
Platform.runLater(() -> {controller.setTimer(time);});
|
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) {
|
private void updateFPS(int fps) {
|
||||||
Platform.runLater(() -> {controller.setFrames("FPS: " + fps);});
|
Platform.runLater(() -> {controller.setFrames("FPS: " + fps);});
|
||||||
}
|
}
|
||||||
@@ -187,7 +191,6 @@ public abstract class Race implements Runnable {
|
|||||||
/*long timeLoopStarted;
|
/*long timeLoopStarted;
|
||||||
long timeLoopEnded;
|
long timeLoopEnded;
|
||||||
int fps = 0;*/
|
int fps = 0;*/
|
||||||
if (controller != null) controller.updateMap(startingBoats);
|
|
||||||
if (boatsFinished < startingBoats.size()) {
|
if (boatsFinished < startingBoats.size()) {
|
||||||
//timeLoopStarted = System.currentTimeMillis();
|
//timeLoopStarted = System.currentTimeMillis();
|
||||||
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
|
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)
|
if (timerEnabled)
|
||||||
updateTime(calcTimer());
|
updateTime(calcTimer());
|
||||||
}
|
}
|
||||||
@@ -210,8 +213,6 @@ public abstract class Race implements Runnable {
|
|||||||
timeCurrent = System.currentTimeMillis();
|
timeCurrent = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*fps++;
|
/*fps++;
|
||||||
try {
|
try {
|
||||||
timeLoopEnded = System.currentTimeMillis();
|
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.
|
* Is automatically called by the initialiser function, so that simulateRace() does not return an empty race.
|
||||||
* @see Race#simulateRace()
|
* @see Race#simulateRace()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected abstract void updatePosition(BoatInRace boat, int millisecondsElapsed);
|
protected abstract void updatePosition(BoatInRace boat, int millisecondsElapsed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class ResizableRaceCanvas extends Canvas {
|
|||||||
private GraphicsContext gc;
|
private GraphicsContext gc;
|
||||||
private RaceMap map;
|
private RaceMap map;
|
||||||
private BoatInRace[] boats;
|
private BoatInRace[] boats;
|
||||||
private RaceController controller;
|
|
||||||
private boolean raceAnno = true;
|
private boolean raceAnno = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,6 +217,9 @@ public class ResizableRaceCanvas extends Canvas {
|
|||||||
displayPoint(graphCoordinate, colour);
|
displayPoint(graphCoordinate, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the raceAnno value
|
||||||
|
*/
|
||||||
public void toggleAnno(){
|
public void toggleAnno(){
|
||||||
if (raceAnno){
|
if (raceAnno){
|
||||||
raceAnno = false;
|
raceAnno = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user