mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Making the course limits change when a new xml packet is received..
#story[889]
This commit is contained in:
@@ -62,7 +62,9 @@ public class App extends Application
|
||||
}
|
||||
//Change the StreamReceiver in this else block to change the default data source.
|
||||
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();
|
||||
|
||||
@@ -240,6 +240,17 @@ public class CanvasController {
|
||||
}
|
||||
}
|
||||
}
|
||||
checkForCourseChanges();
|
||||
}
|
||||
|
||||
private void checkForCourseChanges() {
|
||||
if (StreamParser.isNewXmlRecieved()){
|
||||
System.out.println("New Canvas found");
|
||||
gc.setFill(Color.SKYBLUE);
|
||||
gc.fillRect(0,0, CANVAS_WIDTH, CANVAS_HEIGHT);
|
||||
gc.restore();
|
||||
addRaceBorder();
|
||||
}
|
||||
}
|
||||
|
||||
private void move(long id, RaceObject raceObject){
|
||||
@@ -345,6 +356,7 @@ public class CanvasController {
|
||||
* Calculates x and y location for every marker that fits it to the canvas the race will be drawn on.
|
||||
*/
|
||||
private void fitMarksToCanvas() {
|
||||
StreamParser.isNewXmlRecieved();
|
||||
findMinMaxPoint();
|
||||
double minLonToMaxLon = scaleRaceExtremities();
|
||||
calculateReferencePointLocation(minLonToMaxLon);
|
||||
|
||||
@@ -31,6 +31,7 @@ public class StreamParser extends Thread{
|
||||
public static ConcurrentHashMap<Long, PriorityBlockingQueue<BoatPositionPacket>> boatPositions = new ConcurrentHashMap<>();
|
||||
private String threadName;
|
||||
private Thread t;
|
||||
private static boolean newXmlRecieved = false;
|
||||
private static boolean raceStarted = false;
|
||||
private static XMLParser xmlObject;
|
||||
private static boolean raceFinished = false;
|
||||
@@ -122,6 +123,8 @@ public class StreamParser extends Thread{
|
||||
extractDisplayMessage(packet);
|
||||
break;
|
||||
case XML_MESSAGE:
|
||||
System.out.println("XML MESSAGE GOT");
|
||||
newXmlRecieved = true;
|
||||
extractXmlMessage(packet);
|
||||
break;
|
||||
case RACE_START_STATUS:
|
||||
@@ -313,6 +316,9 @@ public class StreamParser extends Thread{
|
||||
if (messageType == 7) { //7 is the boat XML
|
||||
boats = xmlObject.getBoatXML().getCompetingBoats();
|
||||
}
|
||||
if (messageType == 6) { //6 is race info xml
|
||||
newXmlRecieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -579,5 +585,14 @@ public class StreamParser extends Thread{
|
||||
appRunning = false;
|
||||
System.out.println("[CLIENT] Shutting down stream parser");
|
||||
}
|
||||
|
||||
public static boolean isNewXmlRecieved(){
|
||||
if (newXmlRecieved){
|
||||
newXmlRecieved = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Slider?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
@@ -35,9 +36,9 @@
|
||||
<Label layoutX="11.0" layoutY="14.0" text="Timer" />
|
||||
<Label layoutX="11.0" layoutY="88.0" text="Wind direction" />
|
||||
<Circle fx:id="windBackgroundCircle" blendMode="DARKEN" fill="#76baf8" layoutX="110.0" layoutY="166.0" radius="35.0" stroke="#686868" strokeType="INSIDE" strokeWidth="3.0" />
|
||||
<Text fx:id="windArrowText" fill="#686868" layoutX="86.0" layoutY="186.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↑">
|
||||
<Text fx:id="windArrowText" fill="#686868" layoutX="96.0" layoutY="186.0" strokeType="OUTSIDE" strokeWidth="0.0" text="↑" wrappingWidth="27.5">
|
||||
<font>
|
||||
<Font name="AdobeArabic-Regular" size="55.0" />
|
||||
<Font name="Arial Black" size="55.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Text fx:id="windDirectionText" fill="#a8a7a7" layoutX="171.0" layoutY="214.0" strokeType="OUTSIDE" strokeWidth="0.0" text="0.0°" textAlignment="RIGHT">
|
||||
|
||||
Reference in New Issue
Block a user