From b2d9e44d039ef644fdd17f34436312f8e2114a9f Mon Sep 17 00:00:00 2001 From: Fan-Wu Yang Date: Sun, 14 May 2017 15:36:40 +1200 Subject: [PATCH] Deleted Unecessary code - StreamedRace no longer sets the positions of boats - The Visualiser has blocking queue removed - The Regatta XML Reader not longer has a variable to the deleted Regatta class #story[881] --- .../java/seng302/Mock/RegattaXMLReader.java | 5 --- .../main/java/seng302/Mock/StreamedRace.java | 34 +++++++------------ .../main/java/seng302/VisualiserInput.java | 9 +---- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/visualiser/src/main/java/seng302/Mock/RegattaXMLReader.java b/visualiser/src/main/java/seng302/Mock/RegattaXMLReader.java index 70ff8371..bb52f148 100644 --- a/visualiser/src/main/java/seng302/Mock/RegattaXMLReader.java +++ b/visualiser/src/main/java/seng302/Mock/RegattaXMLReader.java @@ -14,7 +14,6 @@ import java.io.InputStream; * Created by jjg64 on 19/04/17. */ public class RegattaXMLReader extends XMLReader { - private Regatta regatta; private int regattaID; private String regattaName; private int raceID = 0; @@ -78,10 +77,6 @@ public class RegattaXMLReader extends XMLReader { this.magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation")); } - public Regatta getRegatta() { - return regatta; - } - public int getRegattaID() { return regattaID; } diff --git a/visualiser/src/main/java/seng302/Mock/StreamedRace.java b/visualiser/src/main/java/seng302/Mock/StreamedRace.java index 3ad7768b..68837025 100644 --- a/visualiser/src/main/java/seng302/Mock/StreamedRace.java +++ b/visualiser/src/main/java/seng302/Mock/StreamedRace.java @@ -22,12 +22,12 @@ import java.util.List; */ public class StreamedRace implements Runnable { private final VisualiserInput visualiserInput; - protected final ObservableList startingBoats; - protected final ObservableList boatMarkers; - protected final List legs; + private final ObservableList startingBoats; + private final ObservableList boatMarkers; + private final List legs; private RaceController controller; protected FinishController finishController; - protected int boatsFinished = 0; + private int boatsFinished = 0; private long totalTimeElapsed; private int lastFPS = 20; @@ -46,7 +46,7 @@ public class StreamedRace implements Runnable { this.visualiserInput = visualiserInput; } - public void initialiseBoats() { + private void initialiseBoats() { Leg officialStart = legs.get(0); String name = officialStart.getName(); Marker endMarker = officialStart.getEndMarker(); @@ -75,7 +75,7 @@ public class StreamedRace implements Runnable { * @param boat Boat that the position is to be updated for. * @param timeElapsed Time that has elapse since the start of the the race. */ - protected void checkPosition(Boat boat, long timeElapsed) { + private void checkPosition(Boat boat, long timeElapsed) { StreamedCourse raceData = visualiserInput.getCourse(); BoatStatus boatStatusMessage = visualiserInput.getBoatStatusMap().get(boat.getSourceID()); if (boatStatusMessage != null) { @@ -95,7 +95,7 @@ public class StreamedRace implements Runnable { boatsFinished++; boat.setTimeFinished(timeElapsed); boat.setFinished(true); - System.out.println("Boat finished"); + //System.out.println("Boat finished"); } } //Update the boat display table in the GUI to reflect the leg change @@ -108,7 +108,7 @@ public class StreamedRace implements Runnable { * @param boat to be updated * @param millisecondsElapsed time since last update */ - protected void updatePosition(Boat boat, int millisecondsElapsed) { + private void updatePosition(Boat boat, int millisecondsElapsed) { int sourceID = boat.getSourceID(); BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID); if(boatLocation != null) { @@ -126,7 +126,7 @@ public class StreamedRace implements Runnable { * * @param mark to be updated */ - protected void updateMarker(Marker mark) { + private void updateMarker(Marker mark) { int sourceID = mark.getSourceId1(); BoatLocation boatLocation1 = visualiserInput.getBoatLocationMessage(sourceID); if(boatLocation1 != null) { @@ -143,16 +143,6 @@ public class StreamedRace implements Runnable { } } - /** - * sets the position of a boat from coordinate - * @param boat the boat to set - * @param coordinate the position of the boat - */ - protected void setPosition(Boat boat, GPSCoordinate coordinate) { - boat.setCurrentPosition(coordinate); - } - - public void setController(RaceController controller) { this.controller = controller; } @@ -164,7 +154,7 @@ public class StreamedRace implements Runnable { public void run() { setControllerListeners(); initialiseBoats(); - simulateRace(); + startRaceStream(); } @@ -181,7 +171,7 @@ public class StreamedRace implements Runnable { * Starts the Race Simulation, playing the race start to finish with the timescale. * This prints the boats participating, the order that the events occur in time order, and the respective information of the events. */ - private void simulateRace() { + private void startRaceStream() { System.setProperty("javafx.animation.fullspeed", "true"); @@ -235,7 +225,7 @@ public class StreamedRace implements Runnable { /** * Update position of boats in race, no position if on starting leg or DNF. */ - protected void updatePositions() { + private void updatePositions() { FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber()); for(Boat boat: startingBoats) { if(boat != null) { diff --git a/visualiser/src/main/java/seng302/VisualiserInput.java b/visualiser/src/main/java/seng302/VisualiserInput.java index 4f2b3ce9..6a1c30b9 100644 --- a/visualiser/src/main/java/seng302/VisualiserInput.java +++ b/visualiser/src/main/java/seng302/VisualiserInput.java @@ -22,9 +22,6 @@ import static seng302.Networking.Utils.ByteConverter.bytesToShort; */ public class VisualiserInput implements Runnable { - ///A queue that contains messages that have been received, and need to be handled. - private final ArrayBlockingQueue messagesReceivedQueue = new ArrayBlockingQueue<>(1000000);//We have room for 1,000,000. Is this much capacity actually needed? - ///Timestamp of the last heartbeat. private long lastHeartbeatTime = -1; ///Sequence number of the last heartbeat. @@ -257,11 +254,7 @@ public class VisualiserInput implements Runnable { System.err.println("Unable to read message: " + e.getMessage()); //Continue to the next loop iteration/message. continue; - }/* - - //Add it to message queue. - this.messagesReceivedQueue.add(message);*/ - + } //Checks which message is being received and does what is needed for that message. //Heartbeat.