Made sure only boats in participant list are replaced. Also removed mark coloring as it wasn't as accurate as was necessary.

#story[923]
This commit is contained in:
Alistair McIntyre
2017-05-22 16:05:24 +12:00
parent c30629542b
commit e51c966969
4 changed files with 15 additions and 9 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ public class App extends Application {
//Change the StreamReceiver in this else block to change the default data source. //Change the StreamReceiver in this else block to change the default data source.
else{ else{
// sr = new StreamReceiver("localhost", 4949, "RaceStream"); // sr = new StreamReceiver("localhost", 4949, "RaceStream");
sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941, "RaceStream"); sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream");
} }
sr.start(); sr.start();
@@ -26,6 +26,7 @@ import seng302.models.mark.SingleMark;
import seng302.models.stream.StreamParser; import seng302.models.stream.StreamParser;
import seng302.models.stream.XMLParser; import seng302.models.stream.XMLParser;
import seng302.models.stream.XMLParser.RaceXMLObject.Limit; import seng302.models.stream.XMLParser.RaceXMLObject.Limit;
import seng302.models.stream.XMLParser.RaceXMLObject.Participant;
import seng302.models.stream.packets.BoatPositionPacket; import seng302.models.stream.packets.BoatPositionPacket;
/** /**
@@ -244,12 +245,20 @@ public class CanvasController {
Map<Integer, Yacht> boats = StreamParser.getBoats(); Map<Integer, Yacht> boats = StreamParser.getBoats();
Group boatAnnotations = new Group(); Group boatAnnotations = new Group();
ArrayList<Participant> participants = StreamParser.getXmlObject().getRaceXML().getParticipants();
ArrayList<Integer> participantIDs = new ArrayList<>();
for (Participant p : participants) {
participantIDs.add(p.getsourceID());
}
for (Yacht boat : boats.values()) { for (Yacht boat : boats.values()) {
if (participantIDs.contains(boat.getSourceID())) {
boat.setColour(Colors.getColor()); boat.setColour(Colors.getColor());
BoatGroup boatGroup = new BoatGroup(boat, boat.getColour()); BoatGroup boatGroup = new BoatGroup(boat, boat.getColour());
boatGroups.add(boatGroup); boatGroups.add(boatGroup);
boatAnnotations.getChildren().add(boatGroup.getLowPriorityAnnotations()); boatAnnotations.getChildren().add(boatGroup.getLowPriorityAnnotations());
} }
}
group.getChildren().add(boatAnnotations); group.getChildren().add(boatAnnotations);
group.getChildren().addAll(boatGroups); group.getChildren().addAll(boatGroups);
} }
@@ -307,6 +307,7 @@ public class StreamParser extends Thread{
boats = xmlObject.getBoatXML().getCompetingBoats(); boats = xmlObject.getBoatXML().getCompetingBoats();
} }
if (messageType == 6) { //6 is race info xml if (messageType == 6) { //6 is race info xml
newRaceXmlReceived = true; newRaceXmlReceived = true;
} }
} }
@@ -326,10 +326,6 @@ public class XMLParser {
} }
} }
// This is awful but it works.
cMarks.get(0).setName("Start");
cMarks.get(cMarks.size()-1).setName("Finish");
return cMarks; return cMarks;
} }