diff --git a/doc/examples/config.json b/doc/examples/config.json
index 8a3f3ac2..80c3b3e4 100644
--- a/doc/examples/config.json
+++ b/doc/examples/config.json
@@ -9,7 +9,7 @@
},
{
"team-name": "Artemis Racing",
- "velocity": 10.3
+ "velocity": 59.3
},
{
"team-name": "Emirates Team New Zealand",
@@ -17,7 +17,7 @@
},
{
"team-name": "Groupama Team France",
- "velocity": 9.9
+ "velocity": 29.9
},
{
"team-name": "Land Rover BAR",
diff --git a/doc/examples/config.xml b/doc/examples/config.xml
index 05c20921..34e008cc 100644
--- a/doc/examples/config.xml
+++ b/doc/examples/config.xml
@@ -3,6 +3,6 @@
AC35
6
- 2.0
+ 1.0
diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java
index 0c8f749d..033598ec 100644
--- a/src/main/java/seng302/controllers/CanvasController.java
+++ b/src/main/java/seng302/controllers/CanvasController.java
@@ -40,23 +40,23 @@ public class CanvasController {
private GraphicsContext gc;
private HashMap timelineInfos;
+ private AnchorPane raceResults;
+
private final double ORIGIN_LAT = 32.320504;
private final double ORIGIN_LON = -64.857063;
- private final double VIEW_CORNER_LAT = 32.280808;
- private final double VIEW_CORNER_LON = -64.858401;
-
@FXML
private AnchorPane contentAnchorPane;
- @FXML
- private RaceResultController raceResultController;
+ private void loadRaceResultView() {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/FinishView.fxml"));
+ loader.setController(new RaceResultController(race));
- private void setContentPane(String jfxUrl) {
try {
contentAnchorPane.getChildren().removeAll();
contentAnchorPane.getChildren().clear();
- contentAnchorPane.getChildren().addAll((Pane) FXMLLoader.load(getClass().getResource(jfxUrl)));
+ contentAnchorPane.getChildren().addAll((Pane) loader.load());
+
} catch (javafx.fxml.LoadException e) {
System.err.println(e.getCause());
} catch (IOException e) {
@@ -87,37 +87,23 @@ public class CanvasController {
// starts the timer and reads events from each boat's time line
timer.start();
- int i = 0;
Double maxDuration = 0.0;
+ Timeline maxTimeline = null;
for (TimelineInfo timelineInfo : timelineInfos.values()) {
Timeline timeline = timelineInfo.getTimeline();
System.out.println();
- if (/*timeline.getTotalDuration().greaterThanOrEqualTo(maxDuration)*/ true){
-
- }
-
- if (i == timelineInfos.values().size() - 1) {
- timeline.setOnFinished(event -> {
- setContentPane("/FinishView.fxml");
-
- for (Boat boat : race.getFinishedBoats()) {
- System.out.println(boat.getTeamName());
- }
-
- });
- System.out.println("B");
- }
- else{
- System.out.println("A");
+ if (timeline.getTotalDuration().toMillis() >= maxDuration) {
+ maxDuration = timeline.getTotalDuration().toMillis();
+ maxTimeline = timeline;
}
timeline.play();
-
- i++;
}
+
+ maxTimeline.setOnFinished(event -> loadRaceResultView());
}
/**
@@ -210,7 +196,6 @@ public class CanvasController {
gc.setFill(color);
gc.fillRect(x,y,0.5,0.5);
- //gc.fillOval(x, y, 0.5, 0.5);
}
/**
@@ -221,10 +206,14 @@ public class CanvasController {
private void drawGateMark(GateMark gateMark) {
Color color = Color.BLUE;
- if (gateMark.getName().equals("Start") || gateMark.getName().equals("Finish")){
+ if (gateMark.getName().equals("Start")){
color = Color.RED;
}
+ if (gateMark.getName().equals("Finish")){
+ color = Color.GREEN;
+ }
+
drawSingleMark(gateMark.getSingleMark1(), color);
drawSingleMark(gateMark.getSingleMark2(), color);
@@ -232,15 +221,18 @@ public class CanvasController {
gc.setStroke(color);
- //@todo Put this in Mark class
+ // Convert lat/lon to x,y
double x1 = (gateMark.getSingleMark1().getLongitude()- ORIGIN_LON) * 1000;
double y1 = (ORIGIN_LAT - gateMark.getSingleMark1().getLatitude()) * 1000;
double x2 = (gateMark.getSingleMark2().getLongitude() - ORIGIN_LON) * 1000;
double y2 = (ORIGIN_LAT - gateMark.getSingleMark2().getLatitude()) * 1000;
- gc.setLineWidth(0.1);
-
+ gc.setLineWidth(0.07);
gc.strokeLine(x1, y1, x2, y2);
}
+
+ public Race getRace(){
+ return this.race;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/seng302/controllers/RaceController.java b/src/main/java/seng302/controllers/RaceController.java
index fa5d89f0..e8471426 100644
--- a/src/main/java/seng302/controllers/RaceController.java
+++ b/src/main/java/seng302/controllers/RaceController.java
@@ -55,13 +55,18 @@ public class RaceController {
//get race size
int numberOfBoats = (int) fp.getRaceSize();
+ int boatsAdded = 0;
//get time scale
double timeScale = fp.getTimeScale();
race.setTimeScale(timeScale);
for (Map team : teams) {
- boatNames.add((String) team.get("team-name"));
+ if (boatsAdded < numberOfBoats){
+ boatNames.add((String) team.get("team-name"));
+ race.addBoat(new Boat(team.get("team-name").toString(), (Double) (team.get("velocity"))));
+ }
+ boatsAdded++;
}
// Shuffle team names
@@ -72,11 +77,6 @@ public class RaceController {
return null;
}
- // Add boats to the race
- for (int i = 0; i < numberOfBoats; i++) {
- race.addBoat(new Boat(boatNames.get(i), (Double) (teams.get(i).get("velocity"))));
- }
-
CourseParser cp = new CourseParser("doc/examples/course.xml");
race.addCourse(cp.getCourse());
diff --git a/src/main/java/seng302/controllers/RaceResultController.java b/src/main/java/seng302/controllers/RaceResultController.java
index ce0fc868..7378fa68 100644
--- a/src/main/java/seng302/controllers/RaceResultController.java
+++ b/src/main/java/seng302/controllers/RaceResultController.java
@@ -2,8 +2,10 @@ package seng302.controllers;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
-import javafx.scene.Parent;
import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.VBox;
+import javafx.scene.text.Text;
+import seng302.models.Race;
import java.net.URL;
import java.util.ResourceBundle;
@@ -13,15 +15,23 @@ import java.util.ResourceBundle;
*/
public class RaceResultController implements Initializable{
@FXML private AnchorPane window;
- @FXML private Parent raceView;
- @FXML private RaceController raceViewController;
+ @FXML private VBox resultsVBox;
+ private Race race;
- public void setResults(){
- System.out.println("HI MOM");
+ RaceResultController(Race race){
+ this.race = race;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
+ int boatPosition = this.race.getFinishedBoats().length;
+
+ for (int i = this.race.getFinishedBoats().length - 1; i >= 0; i--){
+ resultsVBox.getChildren().add(0, new Text(boatPosition + ": " + this.race.getFinishedBoats()[i].getTeamName()));
+ boatPosition--;
+ }
+
+
}
}
diff --git a/src/main/java/seng302/models/Race.java b/src/main/java/seng302/models/Race.java
index 8ac21386..7361ebec 100644
--- a/src/main/java/seng302/models/Race.java
+++ b/src/main/java/seng302/models/Race.java
@@ -135,6 +135,7 @@ public class Race {
}
public void setBoatFinished(Boat boat){
+ System.out.println(boat.getTeamName() + " finished");
this.finishingOrder.add(boat);
}
}
\ No newline at end of file
diff --git a/src/main/resources/FinishView.fxml b/src/main/resources/FinishView.fxml
index ba9e3d51..debdea26 100644
--- a/src/main/resources/FinishView.fxml
+++ b/src/main/resources/FinishView.fxml
@@ -1,36 +1,53 @@
+
-
+
-
-
+
+
-
-
-
+
+
+
+
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/RaceView.fxml b/src/main/resources/RaceView.fxml
index d14c7c88..e658a8bf 100644
--- a/src/main/resources/RaceView.fxml
+++ b/src/main/resources/RaceView.fxml
@@ -18,7 +18,7 @@
-
+