Fix finish screen showing wrong ("-" as) position

This commit is contained in:
Zhi You Tan
2017-05-25 12:28:13 +12:00
parent e7060d4b6f
commit 66d4a4b958
2 changed files with 16 additions and 5 deletions
@@ -2,6 +2,7 @@ package seng302.controllers;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@@ -16,6 +17,7 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import seng302.models.Yacht;
import seng302.models.stream.StreamParser;
import seng302.models.stream.XMLParser.RaceXMLObject.Participant;
public class FinishScreenViewController implements Initializable {
@@ -56,8 +58,21 @@ public class FinishScreenViewController implements Initializable {
new PropertyValueFactory<>("country")
);
// check if the boat is racing
ArrayList<Participant> participants = StreamParser.getXmlObject().getRaceXML()
.getParticipants();
ArrayList<Integer> participantIDs = new ArrayList<>();
for (Participant p : participants) {
participantIDs.add(p.getsourceID());
}
// add data to table
data.addAll(StreamParser.getBoatsPos().values());
for (Yacht boat : StreamParser.getBoatsPos().values()) {
if (participantIDs.contains(boat.getSourceID())) {
data.add(boat);
System.out.println(boat.getBoatName() + ": " + boat.getPosition());
}
}
finishOrderTable.refresh();
}
@@ -252,10 +252,6 @@ public class StreamParser extends Thread{
yacht.setPosition(String.valueOf(pos));
pos++;
}
} else {
for (Yacht yacht : boatsPos.values()) {
yacht.setPosition("-");
}
}
}