Added checkbox to change visibility of annotation to GUI
-Checkbox is used to toggle the text displayed beside boats -Race Clock is now scaled using the scale factor #story [23]
This commit is contained in:
@@ -39,6 +39,8 @@ public class RaceController extends Controller{
|
||||
@FXML
|
||||
CheckBox showFPS;
|
||||
|
||||
@FXML
|
||||
public CheckBox showAnno;
|
||||
|
||||
@FXML
|
||||
Label timer;
|
||||
@@ -152,6 +154,13 @@ public class RaceController extends Controller{
|
||||
}
|
||||
});
|
||||
|
||||
showAnno.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
public void changed(ObservableValue<? extends Boolean> ov,
|
||||
Boolean old_val, Boolean new_val) {
|
||||
raceMap.toggleAnno();
|
||||
}
|
||||
});
|
||||
|
||||
new Thread((race)).start();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public abstract class Race implements Runnable {
|
||||
System.out.println("====================");
|
||||
for (int i = 0; i < startingBoats.size(); i++) {
|
||||
if (startingBoats.get(i) != null) {
|
||||
System.out.println(i + 1 + ". " + startingBoats.get(i).toString() + ", Speed: "
|
||||
System.out.println(i + 1 + ". " + startingBoats.get(i).getName() + ", Speed: "
|
||||
+ Math.round(startingBoats.get(i).getVelocity() * 1.94384) + "kn");
|
||||
startingBoats.get(i).setCurrentLeg(legs.get(0));
|
||||
}
|
||||
@@ -117,6 +117,7 @@ public abstract class Race implements Runnable {
|
||||
long timeLoopEnded;
|
||||
|
||||
while (currentTime <= startTime) {
|
||||
if (controller != null) controller.updateMap(startingBoats);
|
||||
timeLeft = startTime - currentTime;
|
||||
currentTimeInSeconds = timeLeft / 1000;
|
||||
minutes = currentTimeInSeconds / 60;
|
||||
@@ -146,7 +147,7 @@ public abstract class Race implements Runnable {
|
||||
long remainingSeconds;
|
||||
long hours;
|
||||
|
||||
currentTimeInSeconds = totalTimeElapsed / 1000;
|
||||
currentTimeInSeconds = (totalTimeElapsed / 1000) * scaleFactor;
|
||||
minutes = currentTimeInSeconds / 60;
|
||||
remainingSeconds = currentTimeInSeconds % 60;
|
||||
hours = minutes / 60;
|
||||
@@ -186,7 +187,7 @@ 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;
|
||||
@@ -198,7 +199,7 @@ public abstract class Race implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (controller != null) controller.updateMap(startingBoats);
|
||||
//if (controller != null) controller.updateMap(startingBoats);
|
||||
if (timerEnabled)
|
||||
updateTime(calcTimer());
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package seng302.Model;
|
||||
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import seng302.Constants;
|
||||
import seng302.Controllers.RaceController;
|
||||
import seng302.GPSCoordinate;
|
||||
import seng302.GraphCoordinate;
|
||||
import seng302.RaceMap;
|
||||
@@ -25,6 +27,8 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
private GraphicsContext gc;
|
||||
private RaceMap map;
|
||||
private BoatInRace[] boats;
|
||||
private RaceController controller;
|
||||
private boolean raceAnno = true;
|
||||
|
||||
/**
|
||||
* Sets the boats that are to be displayed in this race.
|
||||
@@ -191,7 +195,8 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
if (boat != null) {
|
||||
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
|
||||
displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour());
|
||||
displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
|
||||
if (raceAnno){
|
||||
displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,6 +218,14 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
displayPoint(graphCoordinate, colour);
|
||||
}
|
||||
|
||||
public void toggleAnno(){
|
||||
if (raceAnno){
|
||||
raceAnno = false;
|
||||
} else {
|
||||
raceAnno = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Canvas to resizable.
|
||||
*
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||
<children>
|
||||
<CheckBox fx:id="showFPS" mnemonicParsing="false" selected="true" text="Show FPS" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
<CheckBox fx:id="showAnno" mnemonicParsing="false" selected="true" text="Show Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="25.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
|
||||
Reference in New Issue
Block a user