General code tidy up
- access modifiers adjusted - unused declarations removed - spelling fixes - removed redundant code
This commit is contained in:
@@ -6,14 +6,10 @@ import javafx.event.EventHandler;
|
|||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.layout.BorderPane;
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.WindowEvent;
|
import javafx.stage.WindowEvent;
|
||||||
|
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
Stage primaryStage;
|
|
||||||
BorderPane mainContainer;
|
|
||||||
Scene mainScene;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for running the programme
|
* Entry point for running the programme
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import seng302.RaceConnection;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,13 +7,9 @@ import javafx.scene.control.Label;
|
|||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
|
|
||||||
import seng302.Model.Race;
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +37,7 @@ public class FinishController extends Controller {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setFinishTable(ObservableList<Boat> boats){
|
private void setFinishTable(ObservableList<Boat> boats){
|
||||||
boatInfoTable.setItems(boats);
|
boatInfoTable.setItems(boats);
|
||||||
boatNameColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
boatNameColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
||||||
boatRankColumn.setCellValueFactory(cellData -> cellData.getValue().positionProperty());
|
boatRankColumn.setCellValueFactory(cellData -> cellData.getValue().positionProperty());
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import javafx.collections.ObservableList;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.Model.BoatInRace;
|
|
||||||
import seng302.Model.RaceClock;
|
import seng302.Model.RaceClock;
|
||||||
import seng302.RaceDataSource;
|
|
||||||
import seng302.VisualiserInput;
|
import seng302.VisualiserInput;
|
||||||
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@@ -17,14 +15,10 @@ import java.util.ResourceBundle;
|
|||||||
* Created by fwy13 on 15/03/2017.
|
* Created by fwy13 on 15/03/2017.
|
||||||
*/
|
*/
|
||||||
public class MainController extends Controller {
|
public class MainController extends Controller {
|
||||||
@FXML
|
@FXML private StartController startController;
|
||||||
StartController startController;
|
@FXML private RaceController raceController;
|
||||||
@FXML
|
@FXML private ConnectionController connectionController;
|
||||||
RaceController raceController;
|
@FXML private FinishController finishController;
|
||||||
@FXML
|
|
||||||
ConnectionController connectionController;
|
|
||||||
@FXML
|
|
||||||
FinishController finishController;
|
|
||||||
|
|
||||||
public void beginRace(VisualiserInput visualiserInput, RaceClock raceClock) {
|
public void beginRace(VisualiserInput visualiserInput, RaceClock raceClock) {
|
||||||
raceController.startRace(visualiserInput, raceClock);
|
raceController.startRace(visualiserInput, raceClock);
|
||||||
|
|||||||
@@ -1,81 +1,46 @@
|
|||||||
package seng302.Controllers;
|
package seng302.Controllers;
|
||||||
|
|
||||||
|
|
||||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
import seng302.Mock.StreamedRace;
|
import seng302.Mock.StreamedRace;
|
||||||
import seng302.Model.*;
|
import seng302.Model.*;
|
||||||
import seng302.RaceDataSource;
|
|
||||||
import seng302.RaceXMLReader;
|
|
||||||
import seng302.VisualiserInput;
|
import seng302.VisualiserInput;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 15/03/2017.
|
* Created by fwy13 on 15/03/2017.
|
||||||
*/
|
*/
|
||||||
public class RaceController extends Controller {
|
public class RaceController extends Controller {
|
||||||
@FXML
|
@FXML GridPane canvasBase;
|
||||||
GridPane canvasBase;
|
|
||||||
|
|
||||||
//user saved data for annotation display
|
//user saved data for annotation display
|
||||||
private ArrayList<Boolean> presetAnno;
|
private ArrayList<Boolean> presetAnno;
|
||||||
|
|
||||||
private ObservableList<Boat> startingBoats;
|
private ResizableRaceCanvas raceMap;
|
||||||
|
private ResizableRaceMap raceBoundaries;
|
||||||
ResizableRaceCanvas raceMap;
|
@FXML SplitPane race;
|
||||||
ResizableRaceMap raceBoundaries;
|
@FXML CheckBox showFPS;
|
||||||
@FXML
|
@FXML CheckBox showBoatPath;
|
||||||
SplitPane race;
|
@FXML CheckBox showAnnotations;
|
||||||
@FXML
|
@FXML Label timer;
|
||||||
CheckBox showFPS;
|
@FXML Label FPS;
|
||||||
|
@FXML Label timeZone;
|
||||||
@FXML
|
@FXML CheckBox showName;
|
||||||
CheckBox showBoatPath;
|
@FXML CheckBox showAbbrev;
|
||||||
@FXML
|
@FXML CheckBox showSpeed;
|
||||||
CheckBox showAnnotations;
|
@FXML Button saveAnno;
|
||||||
@FXML
|
@FXML Button showSetAnno;
|
||||||
Label timer;
|
@FXML TableView<Boat> boatInfoTable;
|
||||||
@FXML
|
@FXML TableColumn<Boat, String> boatPlacingColumn;
|
||||||
Label FPS;
|
@FXML TableColumn<Boat, String> boatTeamColumn;
|
||||||
@FXML
|
@FXML TableColumn<Boat, String> boatMarkColumn;
|
||||||
Label timeZone;
|
@FXML TableColumn<Boat, String> boatSpeedColumn;
|
||||||
|
|
||||||
@FXML
|
|
||||||
CheckBox showName;
|
|
||||||
@FXML
|
|
||||||
CheckBox showAbbrev;
|
|
||||||
@FXML
|
|
||||||
CheckBox showSpeed;
|
|
||||||
@FXML
|
|
||||||
Button saveAnno;
|
|
||||||
@FXML
|
|
||||||
Button showSetAnno;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
TableView<Boat> boatInfoTable;
|
|
||||||
@FXML
|
|
||||||
TableColumn<Boat, String> boatPlacingColumn;
|
|
||||||
@FXML
|
|
||||||
TableColumn<Boat, String> boatTeamColumn;
|
|
||||||
@FXML
|
|
||||||
TableColumn<Boat, String> boatMarkColumn;
|
|
||||||
@FXML
|
|
||||||
TableColumn<Boat, String> boatSpeedColumn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ResizableRaceCanvas (raceMap) with most recent data
|
* Updates the ResizableRaceCanvas (raceMap) with most recent data
|
||||||
@@ -97,7 +62,7 @@ public class RaceController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public void setInfoTable(Race race) {
|
public void setInfoTable(Race race) {
|
||||||
//boatInfoTable.getItems().clear();
|
//boatInfoTable.getItems().clear();
|
||||||
startingBoats = race.getStartingBoats();
|
ObservableList<Boat> startingBoats = race.getStartingBoats();
|
||||||
boatInfoTable.setItems(race.getStartingBoats());
|
boatInfoTable.setItems(race.getStartingBoats());
|
||||||
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
||||||
boatSpeedColumn.setCellValueFactory(cellData -> cellData.getValue().getVelocityProp());
|
boatSpeedColumn.setCellValueFactory(cellData -> cellData.getValue().getVelocityProp());
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import javafx.application.Platform;
|
|||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import seng302.Mock.*;
|
import seng302.Mock.StreamedCourse;
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.Model.RaceClock;
|
import seng302.Model.RaceClock;
|
||||||
import seng302.VisualiserInput;
|
import seng302.VisualiserInput;
|
||||||
@@ -20,12 +19,12 @@ import seng302.VisualiserInput;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by esa46 on 6/04/17.
|
* Created by esa46 on 6/04/17.
|
||||||
@@ -56,12 +55,12 @@ public class StartController extends Controller implements Observer {
|
|||||||
private VisualiserInput visualiserInput;
|
private VisualiserInput visualiserInput;
|
||||||
|
|
||||||
///Tracks whether the race has been started (that is, has startRaceNoScaling() be called).
|
///Tracks whether the race has been started (that is, has startRaceNoScaling() be called).
|
||||||
boolean hasRaceStarted = false;
|
private boolean hasRaceStarted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins the race with a scale factor of 1
|
* Begins the race with a scale factor of 1
|
||||||
*/
|
*/
|
||||||
public void startRaceNoScaling() {
|
private void startRaceNoScaling() {
|
||||||
//startRace(1);
|
//startRace(1);
|
||||||
while(visualiserInput.getRaceStatus() == null);//TODO probably remove this.
|
while(visualiserInput.getRaceStatus() == null);//TODO probably remove this.
|
||||||
|
|
||||||
@@ -95,7 +94,7 @@ public class StartController extends Controller implements Observer {
|
|||||||
/**
|
/**
|
||||||
* Countdown timer until race starts.
|
* Countdown timer until race starts.
|
||||||
*/
|
*/
|
||||||
protected void countdownTimer() {
|
private void countdownTimer() {
|
||||||
new AnimationTimer() {
|
new AnimationTimer() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(long arg0) {
|
public void handle(long arg0) {
|
||||||
@@ -151,7 +150,7 @@ public class StartController extends Controller implements Observer {
|
|||||||
setRaceClock();
|
setRaceClock();
|
||||||
if(visualiserInput.getRaceStatus() == null){
|
if(visualiserInput.getRaceStatus() == null){
|
||||||
return;//TEMP BUG FIX if the race isn't sending race status messages (our mock currently doesn't), then it would block the javafx thread with the previous while loop.
|
return;//TEMP BUG FIX if the race isn't sending race status messages (our mock currently doesn't), then it would block the javafx thread with the previous while loop.
|
||||||
}; // TODO - replace with observer on VisualiserInput
|
}// TODO - replace with observer on VisualiserInput
|
||||||
setStartingTime();
|
setStartingTime();
|
||||||
setCurrentTime();
|
setCurrentTime();
|
||||||
});
|
});
|
||||||
@@ -163,7 +162,6 @@ public class StartController extends Controller implements Observer {
|
|||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (!this.hasRaceStarted) {
|
if (!this.hasRaceStarted) {
|
||||||
if(visualiserInput.getRaceStatus() == null) {
|
if(visualiserInput.getRaceStatus() == null) {
|
||||||
return;//TEMP
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.hasRaceStarted = true;
|
this.hasRaceStarted = true;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ package seng302;
|
|||||||
*/
|
*/
|
||||||
public class GPSCoordinate {
|
public class GPSCoordinate {
|
||||||
|
|
||||||
private double latitude;
|
private final double latitude;
|
||||||
private double longitude;
|
private final double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor Method
|
* Constructor Method
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ package seng302;
|
|||||||
* Created by cbt24 on 15/03/17.
|
* Created by cbt24 on 15/03/17.
|
||||||
*/
|
*/
|
||||||
public class GraphCoordinate {
|
public class GraphCoordinate {
|
||||||
private int x;
|
private final int x;
|
||||||
private int y;
|
private final int y;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor method.
|
* Constructor method.
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package seng302.Mock;
|
package seng302.Mock;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.XMLReader;
|
import seng302.XMLReader;
|
||||||
@@ -12,16 +9,18 @@ import seng302.XMLReader;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Joseph on 24/04/2017.
|
* Created by Joseph on 24/04/2017.
|
||||||
*/
|
*/
|
||||||
public class BoatXMLReader extends XMLReader {
|
public class BoatXMLReader extends XMLReader {
|
||||||
Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
|
private final Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
|
||||||
Map<Integer, StreamedBoat> participants = new HashMap<>();
|
private Map<Integer, StreamedBoat> participants = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Boat XML Reader
|
* Constructor for Boat XML Reader
|
||||||
@@ -31,7 +30,7 @@ public class BoatXMLReader extends XMLReader {
|
|||||||
* @throws ParserConfigurationException error
|
* @throws ParserConfigurationException error
|
||||||
* @throws ParseException error
|
* @throws ParseException error
|
||||||
*/
|
*/
|
||||||
public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException {
|
public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
|
||||||
this(filePath, true);
|
this(filePath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ public class BoatXMLReader extends XMLReader {
|
|||||||
* @throws ParserConfigurationException error
|
* @throws ParserConfigurationException error
|
||||||
* @throws ParseException error
|
* @throws ParseException error
|
||||||
*/
|
*/
|
||||||
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException {
|
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
|
||||||
super(filePath);
|
super(filePath);
|
||||||
if (read) {
|
if (read) {
|
||||||
read();
|
read();
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ import seng302.GPSCoordinate;
|
|||||||
* @deprecated use the RegattaXMLReader
|
* @deprecated use the RegattaXMLReader
|
||||||
*/
|
*/
|
||||||
public class Regatta {
|
public class Regatta {
|
||||||
int regattaID;
|
private int regattaID;
|
||||||
String RegattaName;
|
private String RegattaName;
|
||||||
int raceID = 0;
|
private int raceID = 0;
|
||||||
String courseName;
|
private String courseName;
|
||||||
double centralLatitude;
|
private double centralLatitude;
|
||||||
double centralLongitude;
|
private double centralLongitude;
|
||||||
double centralAltitude;
|
private double centralAltitude;
|
||||||
float utcOffset;
|
private float utcOffset;
|
||||||
float magneticVariation;
|
private float magneticVariation;
|
||||||
|
|
||||||
public Regatta(int regattaID, String regattaName, String courseName, double centralLatitude, double centralLongitude, double centralAltitude, float utcOffset, float magneticVariation) {
|
public Regatta(int regattaID, String regattaName, String courseName, double centralLatitude, double centralLongitude, double centralAltitude, float utcOffset, float magneticVariation) {
|
||||||
this.regattaID = regattaID;
|
this.regattaID = regattaID;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package seng302.Mock;
|
|||||||
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.XMLReader;
|
import seng302.XMLReader;
|
||||||
@@ -16,15 +15,15 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
public class RegattaXMLReader extends XMLReader {
|
public class RegattaXMLReader extends XMLReader {
|
||||||
private Regatta regatta;
|
private Regatta regatta;
|
||||||
int regattaID;
|
private int regattaID;
|
||||||
String regattaName;
|
private String regattaName;
|
||||||
int raceID = 0;
|
private int raceID = 0;
|
||||||
String courseName;
|
private String courseName;
|
||||||
double centralLatitude;
|
private double centralLatitude;
|
||||||
double centralLongitude;
|
private double centralLongitude;
|
||||||
double centralAltitude;
|
private double centralAltitude;
|
||||||
float utcOffset;
|
private float utcOffset;
|
||||||
float magneticVariation;
|
private float magneticVariation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Regatta XML
|
* Constructor for Regatta XML
|
||||||
@@ -47,7 +46,7 @@ public class RegattaXMLReader extends XMLReader {
|
|||||||
* @throws SAXException error
|
* @throws SAXException error
|
||||||
* @throws ParserConfigurationException error
|
* @throws ParserConfigurationException error
|
||||||
*/
|
*/
|
||||||
public RegattaXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
|
private RegattaXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
|
||||||
super(filePath);
|
super(filePath);
|
||||||
if (read) {
|
if (read) {
|
||||||
read();
|
read();
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
package seng302.Mock;
|
package seng302.Mock;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import org.geotools.referencing.GeodeticCalculator;
|
|
||||||
import seng302.GPSCoordinate;
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.Model.BoatInRace;
|
|
||||||
import seng302.Model.Leg;
|
|
||||||
import seng302.Model.Marker;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Joseph on 24/04/2017.
|
* Created by Joseph on 24/04/2017.
|
||||||
*/
|
*/
|
||||||
public class StreamedBoat extends Boat {
|
public class StreamedBoat extends Boat {
|
||||||
private int sourceID;
|
private final int sourceID;
|
||||||
private boolean dnf = false;
|
private boolean dnf = false;
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
package seng302.Mock;
|
package seng302.Mock;
|
||||||
|
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.Model.*;
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.Leg;
|
||||||
|
import seng302.Model.Marker;
|
||||||
import seng302.RaceDataSource;
|
import seng302.RaceDataSource;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Observable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jjg64 on 21/04/17.
|
* Created by jjg64 on 21/04/17.
|
||||||
*/
|
*/
|
||||||
public class StreamedCourse extends Observable implements RaceDataSource {
|
public class StreamedCourse extends Observable implements RaceDataSource {
|
||||||
StreamedCourseXMLReader streamedCourseXMLReader = null;
|
private StreamedCourseXMLReader streamedCourseXMLReader = null;
|
||||||
BoatXMLReader boatXMLReader = null;
|
private BoatXMLReader boatXMLReader = null;
|
||||||
RegattaXMLReader regattaXMLReader = null;
|
private RegattaXMLReader regattaXMLReader = null;
|
||||||
private double windDirection = 0;
|
private double windDirection = 0;
|
||||||
|
|
||||||
public StreamedCourse() {}
|
public StreamedCourse() {}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package seng302.Mock;
|
package seng302.Mock;
|
||||||
|
|
||||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
@@ -16,9 +13,7 @@ import seng302.XMLReader;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -27,18 +22,18 @@ import java.util.*;
|
|||||||
* Created by jjg64 on 21/04/17.
|
* Created by jjg64 on 21/04/17.
|
||||||
*/
|
*/
|
||||||
public class StreamedCourseXMLReader extends XMLReader {
|
public class StreamedCourseXMLReader extends XMLReader {
|
||||||
private static double COORDINATEPADDING = 0.000;
|
private static final double COORDINATEPADDING = 0.000;
|
||||||
private GPSCoordinate mapTopLeft, mapBottomRight;
|
private GPSCoordinate mapTopLeft, mapBottomRight;
|
||||||
private List<GPSCoordinate> boundary = new ArrayList<>();
|
private final List<GPSCoordinate> boundary = new ArrayList<>();
|
||||||
private Map<Integer,Element> compoundMarks = new HashMap<>();
|
private final Map<Integer,Element> compoundMarks = new HashMap<>();
|
||||||
private Map<Integer, StreamedBoat> participants = new HashMap<>();
|
private final Map<Integer, StreamedBoat> participants = new HashMap<>();
|
||||||
private List<Leg> legs = new ArrayList<>();
|
private final List<Leg> legs = new ArrayList<>();
|
||||||
private List<Marker> markers = new ArrayList<>();
|
private final List<Marker> markers = new ArrayList<>();
|
||||||
ZonedDateTime creationTimeDate;
|
private ZonedDateTime creationTimeDate;
|
||||||
ZonedDateTime raceStartTime;
|
private ZonedDateTime raceStartTime;
|
||||||
int raceID;
|
private int raceID;
|
||||||
String raceType;
|
private String raceType;
|
||||||
boolean postpone;
|
private boolean postpone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Streamed Race XML
|
* Constructor for Streamed Race XML
|
||||||
@@ -89,7 +84,7 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
* @throws ParseException error
|
* @throws ParseException error
|
||||||
* @throws StreamedCourseXMLException error
|
* @throws StreamedCourseXMLException error
|
||||||
*/
|
*/
|
||||||
private void read() throws ParseException, StreamedCourseXMLException {
|
private void read() throws StreamedCourseXMLException {
|
||||||
readRace();
|
readRace();
|
||||||
readParticipants();
|
readParticipants();
|
||||||
readCourse();
|
readCourse();
|
||||||
@@ -99,7 +94,7 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
* reads a race
|
* reads a race
|
||||||
* @throws ParseException error
|
* @throws ParseException error
|
||||||
*/
|
*/
|
||||||
private void readRace() throws ParseException {
|
private void readRace() {
|
||||||
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||||
Element settings = (Element) doc.getElementsByTagName("Race").item(0);
|
Element settings = (Element) doc.getElementsByTagName("Race").item(0);
|
||||||
NamedNodeMap raceTimeTag = doc.getElementsByTagName("RaceStartTime").item(0).getAttributes();
|
NamedNodeMap raceTimeTag = doc.getElementsByTagName("RaceStartTime").item(0).getAttributes();
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import seng302.Model.Boat;
|
|||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
import seng302.Model.Marker;
|
||||||
import seng302.Model.Race;
|
import seng302.Model.Race;
|
||||||
import seng302.Networking.Messages.BoatStatus;
|
|
||||||
import seng302.Networking.Messages.BoatLocation;
|
import seng302.Networking.Messages.BoatLocation;
|
||||||
|
import seng302.Networking.Messages.BoatStatus;
|
||||||
import seng302.Networking.Messages.Enums.BoatStatusEnum;
|
import seng302.Networking.Messages.Enums.BoatStatusEnum;
|
||||||
import seng302.VisualiserInput;
|
import seng302.VisualiserInput;
|
||||||
|
|
||||||
@@ -15,8 +15,7 @@ import seng302.VisualiserInput;
|
|||||||
* Created by jjg64 on 21/04/17.
|
* Created by jjg64 on 21/04/17.
|
||||||
*/
|
*/
|
||||||
public class StreamedRace extends Race {
|
public class StreamedRace extends Race {
|
||||||
private VisualiserInput visualiserInput;
|
private final VisualiserInput visualiserInput;
|
||||||
private double MMPS_TO_KN = 0.001944;
|
|
||||||
|
|
||||||
public StreamedRace(VisualiserInput visualiserInput, RaceController controller) {
|
public StreamedRace(VisualiserInput visualiserInput, RaceController controller) {
|
||||||
super(visualiserInput.getCourse(), controller, 1);
|
super(visualiserInput.getCourse(), controller, 1);
|
||||||
@@ -94,6 +93,7 @@ public class StreamedRace extends Race {
|
|||||||
double lon = boatLocation.getLongitudeDouble();
|
double lon = boatLocation.getLongitudeDouble();
|
||||||
boat.setCurrentPosition(new GPSCoordinate(lat, lon));
|
boat.setCurrentPosition(new GPSCoordinate(lat, lon));
|
||||||
boat.setHeading(boatLocation.getHeadingDegrees());
|
boat.setHeading(boatLocation.getHeadingDegrees());
|
||||||
|
double MMPS_TO_KN = 0.001944;
|
||||||
boat.setVelocity(boatLocation.getBoatSOG() * MMPS_TO_KN);
|
boat.setVelocity(boatLocation.getBoatSOG() * MMPS_TO_KN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package seng302.Model;
|
|||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import org.geotools.referencing.GeodeticCalculator;
|
import org.geotools.referencing.GeodeticCalculator;
|
||||||
import seng302.Constants;
|
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
@@ -15,32 +14,25 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
*/
|
*/
|
||||||
public class Boat {
|
public class Boat {
|
||||||
|
|
||||||
protected StringProperty name;
|
private final StringProperty name;
|
||||||
protected double velocity;
|
protected double velocity;
|
||||||
private StringProperty velocityProp;
|
private final StringProperty velocityProp;
|
||||||
protected String abbrev;
|
private final String abbrev;
|
||||||
protected GPSCoordinate currentPosition;
|
private GPSCoordinate currentPosition;
|
||||||
protected double heading;
|
protected double heading;
|
||||||
protected Leg currentLeg;
|
private Leg currentLeg;
|
||||||
protected StringProperty currentLegName;
|
private final StringProperty currentLegName;
|
||||||
protected boolean finished = false;
|
private boolean finished = false;
|
||||||
protected long timeFinished;
|
private long timeFinished;
|
||||||
protected StringProperty position;
|
private final StringProperty position;
|
||||||
protected boolean started = false;
|
private boolean started = false;
|
||||||
protected boolean dnf = false;
|
private boolean dnf = false;
|
||||||
private double wakeScale = 3;
|
|
||||||
private int sourceID;
|
private int sourceID;
|
||||||
|
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
||||||
|
private long nextValidTime = 0;
|
||||||
protected Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
|
||||||
protected long nextValidTime = 0;
|
|
||||||
|
|
||||||
protected static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
|
|
||||||
protected static float trackPointTimeInterval = 5000; // every 1 seconds
|
|
||||||
protected final int TRACK_POINT_LIMIT = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boat initialiser which keeps all of the information of the boat.
|
* Boat initializer which keeps all of the information of the boat.
|
||||||
*
|
*
|
||||||
* @param name Name of the Boat.
|
* @param name Name of the Boat.
|
||||||
* @param velocity Speed in m/s that the boat travels at.
|
* @param velocity Speed in m/s that the boat travels at.
|
||||||
@@ -56,12 +48,12 @@ public class Boat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boat initialiser which keeps all of the information of the boat.
|
* Boat initializer which keeps all of the information of the boat.
|
||||||
*
|
*
|
||||||
* @param name Name of the Boat.
|
* @param name Name of the Boat.
|
||||||
* @param abbrev nam abbreviation
|
* @param abbrev nam abbreviation
|
||||||
*/
|
*/
|
||||||
public Boat(String name, String abbrev) {
|
protected Boat(String name, String abbrev) {
|
||||||
this(name, 0, abbrev);
|
this(name, 0, abbrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +66,7 @@ public class Boat {
|
|||||||
*/
|
*/
|
||||||
public GPSCoordinate getWake() {
|
public GPSCoordinate getWake() {
|
||||||
double reverseHeading = getHeading() - 180;
|
double reverseHeading = getHeading() - 180;
|
||||||
|
double wakeScale = 3;
|
||||||
double distance = wakeScale * getVelocity();
|
double distance = wakeScale * getVelocity();
|
||||||
|
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
@@ -91,14 +84,15 @@ public class Boat {
|
|||||||
* @return whether add is successful
|
* @return whether add is successful
|
||||||
* @see seng302.Model.TrackPoint
|
* @see seng302.Model.TrackPoint
|
||||||
*/
|
*/
|
||||||
public boolean addTrackPoint(GPSCoordinate coordinate) {
|
public void addTrackPoint(GPSCoordinate coordinate) {
|
||||||
Boolean added = System.currentTimeMillis() >= nextValidTime;
|
Boolean added = System.currentTimeMillis() >= nextValidTime;
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (added && this.started) {
|
if (added && this.started) {
|
||||||
|
float trackPointTimeInterval = 5000;
|
||||||
nextValidTime = currentTime + (long) trackPointTimeInterval;
|
nextValidTime = currentTime + (long) trackPointTimeInterval;
|
||||||
|
int TRACK_POINT_LIMIT = 10;
|
||||||
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
||||||
}
|
}
|
||||||
return added;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,24 +17,23 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
*/
|
*/
|
||||||
public class BoatInRace extends Boat {
|
public class BoatInRace extends Boat {
|
||||||
|
|
||||||
protected Leg currentLeg;
|
private Leg currentLeg;
|
||||||
protected double scaledVelocity;
|
private double scaledVelocity;
|
||||||
protected double distanceTravelledInLeg;
|
private double distanceTravelledInLeg;
|
||||||
protected GPSCoordinate currentPosition;
|
private GPSCoordinate currentPosition;
|
||||||
protected long timeFinished;
|
private long timeFinished;
|
||||||
protected Color colour;
|
private Color colour;
|
||||||
protected boolean finished = false;
|
private boolean finished = false;
|
||||||
protected StringProperty currentLegName;
|
private final StringProperty currentLegName;
|
||||||
protected boolean started = false;
|
private boolean started = false;
|
||||||
protected StringProperty position;
|
private final StringProperty position;
|
||||||
protected double heading;
|
private double heading;
|
||||||
|
|
||||||
protected Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
||||||
protected long nextValidTime = 0;
|
private long nextValidTime = 0;
|
||||||
|
|
||||||
protected static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
|
private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
|
||||||
protected static float trackPointTimeInterval = 5000; // every 1 seconds
|
private static float trackPointTimeInterval = 5000; // every 1 seconds
|
||||||
protected final int TRACK_POINT_LIMIT = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor method.
|
* Constructor method.
|
||||||
@@ -88,7 +87,7 @@ public class BoatInRace extends Boat {
|
|||||||
* @param azimuth azimuth value to be converted
|
* @param azimuth azimuth value to be converted
|
||||||
* @return the bearings in degrees (0 to 360).
|
* @return the bearings in degrees (0 to 360).
|
||||||
*/
|
*/
|
||||||
public static double calculateHeading(double azimuth) {
|
private static double calculateHeading(double azimuth) {
|
||||||
if (azimuth >= 0) {
|
if (azimuth >= 0) {
|
||||||
return azimuth;
|
return azimuth;
|
||||||
} else {
|
} else {
|
||||||
@@ -197,7 +196,7 @@ public class BoatInRace extends Boat {
|
|||||||
* @param colour Colour that the boat is to be set to.
|
* @param colour Colour that the boat is to be set to.
|
||||||
* @see ResizableRaceCanvas
|
* @see ResizableRaceCanvas
|
||||||
*/
|
*/
|
||||||
public void setColour(Color colour) {
|
private void setColour(Color colour) {
|
||||||
this.colour = colour;
|
this.colour = colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,14 +288,14 @@ public class BoatInRace extends Boat {
|
|||||||
* @return whether add is successful
|
* @return whether add is successful
|
||||||
* @see seng302.Model.TrackPoint
|
* @see seng302.Model.TrackPoint
|
||||||
*/
|
*/
|
||||||
public boolean addTrackPoint(GPSCoordinate coordinate) {
|
public void addTrackPoint(GPSCoordinate coordinate) {
|
||||||
Boolean added = System.currentTimeMillis() >= nextValidTime;
|
Boolean added = System.currentTimeMillis() >= nextValidTime;
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (added && this.started) {
|
if (added && this.started) {
|
||||||
nextValidTime = currentTime + (long) trackPointTimeInterval;
|
nextValidTime = currentTime + (long) trackPointTimeInterval;
|
||||||
|
int TRACK_POINT_LIMIT = 10;
|
||||||
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
||||||
}
|
}
|
||||||
return added;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
// private int dnfChance = 0; //%percentage chance a boat fails at each checkpoint
|
// private int dnfChance = 0; //%percentage chance a boat fails at each checkpoint
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Initialiser for a constant velocity race without standard data source
|
// * Initializer for a constant velocity race without standard data source
|
||||||
// *
|
// *
|
||||||
// * @param startingBoats in race
|
// * @param startingBoats in race
|
||||||
// * @param legs in race
|
// * @param legs in race
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Initialiser for legacy tests
|
// * Initializer for legacy tests
|
||||||
// *
|
// *
|
||||||
// * @param startingBoats in race
|
// * @param startingBoats in race
|
||||||
// * @param legs in race
|
// * @param legs in race
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Initialiser for constant velocity race with standard data source
|
// * Initializer for constant velocity race with standard data source
|
||||||
// * @param raceData for race
|
// * @param raceData for race
|
||||||
// * @param controller for graphics
|
// * @param controller for graphics
|
||||||
// * @param scaleFactor of timer
|
// * @param scaleFactor of timer
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import seng302.GPSCoordinate;
|
|||||||
* Created by cbt24 on 6/03/17.
|
* Created by cbt24 on 6/03/17.
|
||||||
*/
|
*/
|
||||||
public class Leg {
|
public class Leg {
|
||||||
private String name; //nautical miles
|
private final String name; //nautical miles
|
||||||
private double distance;
|
private double distance;
|
||||||
private Marker startMarker;
|
private Marker startMarker;
|
||||||
private Marker endMarker;
|
private Marker endMarker;
|
||||||
private int legNumber;
|
private final int legNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leg Initialiser
|
* Leg Initializer
|
||||||
*
|
*
|
||||||
* @param name Name of the Leg
|
* @param name Name of the Leg
|
||||||
* @param start marker
|
* @param start marker
|
||||||
@@ -89,7 +89,7 @@ public class Leg {
|
|||||||
/**
|
/**
|
||||||
* Calculates the distance that the legs are in nautical miles (1.852 km).
|
* Calculates the distance that the legs are in nautical miles (1.852 km).
|
||||||
*/
|
*/
|
||||||
public void calculateDistance() {
|
private void calculateDistance() {
|
||||||
|
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
//Load start and end of leg
|
//Load start and end of leg
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import java.awt.geom.Point2D;
|
|||||||
* Created by esa46 on 29/03/17.
|
* Created by esa46 on 29/03/17.
|
||||||
*/
|
*/
|
||||||
public class Marker {
|
public class Marker {
|
||||||
private GPSCoordinate averageGPSCoordinate;
|
private final GPSCoordinate averageGPSCoordinate;
|
||||||
private GPSCoordinate mark1;
|
private final GPSCoordinate mark1;
|
||||||
private GPSCoordinate mark2;
|
private final GPSCoordinate mark2;
|
||||||
|
|
||||||
public Marker(GPSCoordinate mark1) {
|
public Marker(GPSCoordinate mark1) {
|
||||||
|
|
||||||
|
|||||||
@@ -4,55 +4,47 @@ import javafx.animation.AnimationTimer;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import org.geotools.referencing.GeodeticCalculator;
|
|
||||||
import seng302.Controllers.FinishController;
|
import seng302.Controllers.FinishController;
|
||||||
import seng302.Controllers.RaceController;
|
import seng302.Controllers.RaceController;
|
||||||
import seng302.GPSCoordinate;
|
|
||||||
import seng302.RaceDataSource;
|
import seng302.RaceDataSource;
|
||||||
import seng302.VisualiserInput;
|
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class for races
|
* Parent class for races
|
||||||
* Created by fwy13 on 3/03/17.
|
* Created by fwy13 on 3/03/17.
|
||||||
*/
|
*/
|
||||||
public abstract class Race implements Runnable {
|
public abstract class Race implements Runnable {
|
||||||
protected ObservableList<Boat> startingBoats;
|
protected final ObservableList<Boat> startingBoats;
|
||||||
protected List<Leg> legs;
|
protected final List<Leg> legs;
|
||||||
protected RaceController controller;
|
private RaceController controller;
|
||||||
protected FinishController finishController;
|
protected FinishController finishController;
|
||||||
protected int boatsFinished = 0;
|
protected int boatsFinished = 0;
|
||||||
protected long totalTimeElapsed;
|
private long totalTimeElapsed;
|
||||||
|
|
||||||
protected int scaleFactor;
|
|
||||||
private int lastFPS = 20;
|
private int lastFPS = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initailiser for Race
|
* Initializer for Race
|
||||||
*
|
*
|
||||||
* @param boats Takes in an array of boats that are participating in the race.
|
* @param boats Takes in an array of boats that are participating in the race.
|
||||||
* @param legs Number of marks in order that the boats pass in order to complete the race.
|
* @param legs Number of marks in order that the boats pass in order to complete the race.
|
||||||
* @param controller race controller
|
* @param controller race controller
|
||||||
* @param scaleFactor for race
|
* @param scaleFactor for race
|
||||||
*/
|
*/
|
||||||
public Race(List<Boat> boats, List<Leg> legs, RaceController controller, int scaleFactor) {
|
private Race(List<Boat> boats, List<Leg> legs, RaceController controller, int scaleFactor) {
|
||||||
|
|
||||||
this.startingBoats = FXCollections.observableArrayList(boats);
|
this.startingBoats = FXCollections.observableArrayList(boats);
|
||||||
this.legs = legs;
|
this.legs = legs;
|
||||||
this.legs.add(new Leg("Finish", this.legs.size()));
|
this.legs.add(new Leg("Finish", this.legs.size()));
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
this.scaleFactor = scaleFactor;
|
|
||||||
if (startingBoats != null && startingBoats.size() > 0) {
|
if (startingBoats != null && startingBoats.size() > 0) {
|
||||||
initialiseBoats();
|
initialiseBoats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Race(RaceDataSource raceData, RaceController controller, int scaleFactor) {
|
protected Race(RaceDataSource raceData, RaceController controller, int scaleFactor) {
|
||||||
this(raceData.getBoats(), raceData.getLegs(), controller, scaleFactor);
|
this(raceData.getBoats(), raceData.getLegs(), controller, scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +63,7 @@ public abstract class Race implements Runnable {
|
|||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void initialiseBoats();
|
protected abstract void initialiseBoats();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the boat cannot finish the race
|
* Checks if the boat cannot finish the race
|
||||||
@@ -82,7 +74,7 @@ public abstract class Race implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Checks the position of the boat, this updates the boats current position.
|
* Checks the position of the boat, this updates the boats current position.
|
||||||
*
|
*
|
||||||
* @param boat Boat that the postion is to be updated for.
|
* @param boat Boat that the position is to be updated for.
|
||||||
* @param timeElapsed Time that has elapse since the start of the the race.
|
* @param timeElapsed Time that has elapse since the start of the the race.
|
||||||
* @see Boat
|
* @see Boat
|
||||||
*/
|
*/
|
||||||
@@ -112,16 +104,14 @@ public abstract class Race implements Runnable {
|
|||||||
* @param fps The new calculated fps value
|
* @param fps The new calculated fps value
|
||||||
*/
|
*/
|
||||||
private void updateFPS(int fps) {
|
private void updateFPS(int fps) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> controller.setFrames("FPS: " + fps));
|
||||||
controller.setFrames("FPS: " + fps);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Race Simulation, playing the race start to finish with the timescale.
|
* 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.
|
* This prints the boats participating, the order that the events occur in time order, and the respective information of the events.
|
||||||
*/
|
*/
|
||||||
protected final void simulateRace() {
|
private void simulateRace() {
|
||||||
|
|
||||||
System.setProperty("javafx.animation.fullspeed", "true");
|
System.setProperty("javafx.animation.fullspeed", "true");
|
||||||
|
|
||||||
@@ -131,7 +121,7 @@ public abstract class Race implements Runnable {
|
|||||||
|
|
||||||
new AnimationTimer() {
|
new AnimationTimer() {
|
||||||
|
|
||||||
long timeRaceStarted = System.currentTimeMillis(); //start time of loop
|
final long timeRaceStarted = System.currentTimeMillis(); //start time of loop
|
||||||
int fps = 0; //init fps value
|
int fps = 0; //init fps value
|
||||||
long timeCurrent = System.currentTimeMillis(); //current time
|
long timeCurrent = System.currentTimeMillis(); //current time
|
||||||
|
|
||||||
@@ -184,7 +174,7 @@ public abstract class Race implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Update call for the controller.
|
* Update call for the controller.
|
||||||
*/
|
*/
|
||||||
protected void setControllerListeners() {
|
private void setControllerListeners() {
|
||||||
if (controller != null) controller.setInfoTable(this);
|
if (controller != null) controller.setInfoTable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
public class RaceClock implements Runnable {
|
public class RaceClock implements Runnable {
|
||||||
private long lastTime;
|
private long lastTime;
|
||||||
private ZoneId zoneId;
|
private final ZoneId zoneId;
|
||||||
private ZonedDateTime time;
|
private ZonedDateTime time;
|
||||||
private ZonedDateTime startingTime;
|
private ZonedDateTime startingTime;
|
||||||
private StringProperty timeString;
|
private final StringProperty timeString;
|
||||||
private StringProperty duration;
|
private StringProperty duration;
|
||||||
|
|
||||||
public RaceClock(ZonedDateTime zonedDateTime) {
|
public RaceClock(ZonedDateTime zonedDateTime) {
|
||||||
@@ -62,16 +62,16 @@ public class RaceClock implements Runnable {
|
|||||||
*
|
*
|
||||||
* @param time arbitrary time with timezone.
|
* @param time arbitrary time with timezone.
|
||||||
*/
|
*/
|
||||||
public void setTime(ZonedDateTime time) {
|
private void setTime(ZonedDateTime time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.timeString.set(DateTimeFormatter.ofPattern("HH:mm:ss dd/MM/YYYY Z").format(time));
|
this.timeString.set(DateTimeFormatter.ofPattern("HH:mm:ss dd/MM/YYYY Z").format(time));
|
||||||
this.lastTime = System.currentTimeMillis();
|
this.lastTime = System.currentTimeMillis();
|
||||||
if(startingTime != null) {
|
if(startingTime != null) {
|
||||||
long seconds = Duration.between(startingTime.toLocalDateTime(), time.toLocalDateTime()).getSeconds();
|
long seconds = Duration.between(startingTime.toLocalDateTime(), time.toLocalDateTime()).getSeconds();
|
||||||
if(seconds < 0)
|
if(seconds < 0)
|
||||||
duration.set(String.format(String.format("Starting in: %02d:%02d:%02d", -seconds/3600, -(seconds%3600)/60, -seconds%60)));
|
duration.set(String.format("Starting in: %02d:%02d:%02d", -seconds/3600, -(seconds%3600)/60, -seconds%60));
|
||||||
else
|
else
|
||||||
duration.set(String.format(String.format("Time: %02d:%02d:%02d", seconds/3600, (seconds%3600)/60, seconds%60)));
|
duration.set(String.format("Time: %02d:%02d:%02d", seconds/3600, (seconds%3600)/60, seconds%60));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class RaceClock implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Updates time by duration elapsed since last update.
|
* Updates time by duration elapsed since last update.
|
||||||
*/
|
*/
|
||||||
public void updateTime() {
|
private void updateTime() {
|
||||||
this.time = this.time.plus(Duration.of(System.currentTimeMillis() - this.lastTime, ChronoUnit.MILLIS));
|
this.time = this.time.plus(Duration.of(System.currentTimeMillis() - this.lastTime, ChronoUnit.MILLIS));
|
||||||
this.lastTime = System.currentTimeMillis();
|
this.lastTime = System.currentTimeMillis();
|
||||||
setTime(time);
|
setTime(time);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import javafx.scene.canvas.GraphicsContext;
|
|||||||
* Created by fwy13 on 4/05/17.
|
* Created by fwy13 on 4/05/17.
|
||||||
*/
|
*/
|
||||||
public abstract class ResizableCanvas extends Canvas {
|
public abstract class ResizableCanvas extends Canvas {
|
||||||
protected GraphicsContext gc;
|
protected final GraphicsContext gc;
|
||||||
|
|
||||||
public ResizableCanvas(){
|
public ResizableCanvas(){
|
||||||
this.gc = this.getGraphicsContext2D();
|
this.gc = this.getGraphicsContext2D();
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package seng302.Model;
|
package seng302.Model;
|
||||||
|
|
||||||
|
|
||||||
import javafx.scene.canvas.Canvas;
|
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.Paint;
|
import javafx.scene.paint.Paint;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
import seng302.*;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.Controllers.RaceController;
|
import seng302.GraphCoordinate;
|
||||||
import seng302.Mock.StreamedCourse;
|
import seng302.Mock.StreamedCourse;
|
||||||
|
import seng302.RaceDataSource;
|
||||||
|
import seng302.RaceMap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -28,9 +28,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
private boolean annoSpeed = true;
|
private boolean annoSpeed = true;
|
||||||
private boolean annoPath = true;
|
private boolean annoPath = true;
|
||||||
private List<Color> colours;
|
private List<Color> colours;
|
||||||
private List<Marker> markers;
|
private final List<Marker> markers;
|
||||||
double[] xpoints = {}, ypoints = {};
|
double[] xpoints = {}, ypoints = {};
|
||||||
RaceDataSource raceData;
|
private final RaceDataSource raceData;
|
||||||
|
|
||||||
public ResizableRaceCanvas(RaceDataSource raceData) {
|
public ResizableRaceCanvas(RaceDataSource raceData) {
|
||||||
super();
|
super();
|
||||||
@@ -61,14 +61,15 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
*
|
*
|
||||||
* @param map race map
|
* @param map race map
|
||||||
*/
|
*/
|
||||||
public void setMap(RaceMap map) {
|
private void setMap(RaceMap map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the mark of a race as a circle.
|
* Displays the mark of a race as a circle.
|
||||||
*
|
*
|
||||||
* @param graphCoordinate Latitude and Logintude in GraphCoordinate that it is to be displayed as.
|
* @param graphCoordinate Latitude and Longitude in GraphCoordinate that it
|
||||||
|
* is to be displayed as.
|
||||||
* @param paint Colour the mark is to be coloured.
|
* @param paint Colour the mark is to be coloured.
|
||||||
* @see GraphCoordinate
|
* @see GraphCoordinate
|
||||||
* @see Color
|
* @see Color
|
||||||
@@ -80,14 +81,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
gc.fillOval(graphCoordinate.getX() - (d / 2), graphCoordinate.getY() - (d / 2), d, d);
|
gc.fillOval(graphCoordinate.getX() - (d / 2), graphCoordinate.getY() - (d / 2), d, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayBoat(Boat boat, double angle, Color colour) {
|
private void displayBoat(Boat boat, double angle, Color colour) {
|
||||||
if (boat.getCurrentPosition() != null) {
|
if (boat.getCurrentPosition() != null) {
|
||||||
GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition());
|
GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition());
|
||||||
Paint paint = colour;
|
|
||||||
|
|
||||||
double[] x = {pos.getX() - 6, pos.getX(), pos.getX() + 6};
|
double[] x = {pos.getX() - 6, pos.getX(), pos.getX() + 6};
|
||||||
double[] y = {pos.getY() + 12, pos.getY() - 12, pos.getY() + 12};
|
double[] y = {pos.getY() + 12, pos.getY() - 12, pos.getY() + 12};
|
||||||
gc.setFill(paint);
|
gc.setFill(colour);
|
||||||
|
|
||||||
gc.save();
|
gc.save();
|
||||||
rotate(angle, pos.getX(), pos.getY());
|
rotate(angle, pos.getX(), pos.getY());
|
||||||
@@ -203,7 +203,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
/**
|
/**
|
||||||
* Draw race markers
|
* Draw race markers
|
||||||
*/
|
*/
|
||||||
public void drawMarkers() {
|
private void drawMarkers() {
|
||||||
for(Marker marker: markers) {
|
for(Marker marker: markers) {
|
||||||
GraphCoordinate mark1 = this.map.convertGPS(marker.getMark1());
|
GraphCoordinate mark1 = this.map.convertGPS(marker.getMark1());
|
||||||
// removed drawing of lines between the marks as only
|
// removed drawing of lines between the marks as only
|
||||||
@@ -263,58 +263,38 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
* Toggle the raceAnno value
|
* Toggle the raceAnno value
|
||||||
*/
|
*/
|
||||||
public void toggleAnnotations() {
|
public void toggleAnnotations() {
|
||||||
if (raceAnno) {
|
raceAnno = !raceAnno;
|
||||||
raceAnno = false;
|
|
||||||
} else {
|
|
||||||
raceAnno = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle name display in annotation
|
* Toggle name display in annotation
|
||||||
*/
|
*/
|
||||||
public void toggleAnnoName() {
|
public void toggleAnnoName() {
|
||||||
if (annoName) {
|
annoName = !annoName;
|
||||||
annoName = false;
|
|
||||||
} else {
|
|
||||||
annoName = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleBoatPath() {
|
public void toggleBoatPath() {
|
||||||
if (annoPath) {
|
annoPath = !annoPath;
|
||||||
annoPath = false;
|
|
||||||
} else {
|
|
||||||
annoPath = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle abbreviation display in annotation
|
* Toggle abbreviation display in annotation
|
||||||
*/
|
*/
|
||||||
public void toggleAnnoAbbrev() {
|
public void toggleAnnoAbbrev() {
|
||||||
if (annoAbbrev) {
|
annoAbbrev = !annoAbbrev;
|
||||||
annoAbbrev = false;
|
|
||||||
} else {
|
|
||||||
annoAbbrev = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle speed display in annotation
|
* Toggle speed display in annotation
|
||||||
*/
|
*/
|
||||||
public void toggleAnnoSpeed() {
|
public void toggleAnnoSpeed() {
|
||||||
if (annoSpeed) {
|
annoSpeed = !annoSpeed;
|
||||||
annoSpeed = false;
|
|
||||||
} else {
|
|
||||||
annoSpeed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws boats while race in progress, when leg heading is set.
|
* Draws boats while race in progress, when leg heading is set.
|
||||||
*/
|
*/
|
||||||
public void updateBoats() {
|
private void updateBoats() {
|
||||||
int currentColour = 0;
|
int currentColour = 0;
|
||||||
if (boats != null) {
|
if (boats != null) {
|
||||||
for (Boat boat : boats) {
|
for (Boat boat : boats) {
|
||||||
@@ -349,15 +329,14 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
if (annoPath && raceAnno) {
|
if (annoPath && raceAnno) {
|
||||||
for (TrackPoint point : boat.getTrack()) {
|
for (TrackPoint point : boat.getTrack()) {
|
||||||
GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate());
|
GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate());
|
||||||
Color boatColour = colour;
|
gc.setFill(new Color(colour.getRed(), colour.getGreen(), colour.getBlue(), point.getAlpha()));
|
||||||
gc.setFill(new Color(boatColour.getRed(), boatColour.getGreen(), boatColour.getBlue(), point.getAlpha()));
|
|
||||||
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), 5, 5);
|
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), 5, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeColours() {
|
private void makeColours() {
|
||||||
colours = new ArrayList<Color>(Arrays.asList(
|
colours = new ArrayList<>(Arrays.asList(
|
||||||
Color.BLUEVIOLET,
|
Color.BLUEVIOLET,
|
||||||
Color.BLACK,
|
Color.BLACK,
|
||||||
Color.RED,
|
Color.RED,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package seng302.Model;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.GraphCoordinate;
|
import seng302.GraphCoordinate;
|
||||||
import seng302.Mock.StreamedCourse;
|
|
||||||
import seng302.RaceDataSource;
|
import seng302.RaceDataSource;
|
||||||
import seng302.RaceMap;
|
import seng302.RaceMap;
|
||||||
|
|
||||||
@@ -14,14 +13,13 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ResizableRaceMap extends ResizableCanvas {
|
public class ResizableRaceMap extends ResizableCanvas {
|
||||||
private RaceMap map;
|
private RaceMap map;
|
||||||
RaceDataSource raceData;
|
private final List<GPSCoordinate> raceBoundaries;
|
||||||
private List<GPSCoordinate> raceBoundaries;
|
private double[] xpoints = {};
|
||||||
double[] xpoints = {}, ypoints = {};
|
private double[] ypoints = {};
|
||||||
|
|
||||||
public ResizableRaceMap(RaceDataSource raceData){
|
public ResizableRaceMap(RaceDataSource raceData){
|
||||||
super();
|
super();
|
||||||
this.raceData = raceData;
|
raceBoundaries = raceData.getBoundary();
|
||||||
raceBoundaries = this.raceData.getBoundary();
|
|
||||||
|
|
||||||
double lat1 = raceData.getMapTopLeft().getLatitude();
|
double lat1 = raceData.getMapTopLeft().getLatitude();
|
||||||
double long1 = raceData.getMapTopLeft().getLongitude();
|
double long1 = raceData.getMapTopLeft().getLongitude();
|
||||||
@@ -31,13 +29,13 @@ public class ResizableRaceMap extends ResizableCanvas {
|
|||||||
//draw();
|
//draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMap(RaceMap map) {
|
private void setMap(RaceMap map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Draw boundary of the race.
|
* Draw boundary of the race.
|
||||||
*/
|
*/
|
||||||
public void drawBoundaries() {
|
private void drawBoundaries() {
|
||||||
if (this.raceBoundaries == null) {
|
if (this.raceBoundaries == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -48,7 +46,7 @@ public class ResizableRaceMap extends ResizableCanvas {
|
|||||||
gc.fillPolygon(xpoints, ypoints, xpoints.length);
|
gc.fillPolygon(xpoints, ypoints, xpoints.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRaceBoundCoordinates() {
|
private void setRaceBoundCoordinates() {
|
||||||
xpoints = new double[this.raceBoundaries.size()];
|
xpoints = new double[this.raceBoundaries.size()];
|
||||||
ypoints = new double[this.raceBoundaries.size()];
|
ypoints = new double[this.raceBoundaries.size()];
|
||||||
for (int i = 0; i < raceBoundaries.size(); i++) {
|
for (int i = 0; i < raceBoundaries.size(); i++) {
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import seng302.GPSCoordinate;
|
|||||||
* Created by cbt24 on 7/04/17.
|
* Created by cbt24 on 7/04/17.
|
||||||
*/
|
*/
|
||||||
public class TrackPoint {
|
public class TrackPoint {
|
||||||
private GPSCoordinate coordinate;
|
private final GPSCoordinate coordinate;
|
||||||
private long timeAdded;
|
private final long timeAdded;
|
||||||
private long expiry;
|
private final long expiry;
|
||||||
private double minAlpha;
|
private final double minAlpha;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
|
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import java.net.Socket;
|
|||||||
* Created by cbt24 on 3/05/17.
|
* Created by cbt24 on 3/05/17.
|
||||||
*/
|
*/
|
||||||
public class RaceConnection {
|
public class RaceConnection {
|
||||||
private StringProperty hostname;
|
private final StringProperty hostname;
|
||||||
private int port;
|
private final int port;
|
||||||
private StringProperty status;
|
private final StringProperty status;
|
||||||
|
|
||||||
public RaceConnection(String hostname, int port) {
|
public RaceConnection(String hostname, int port) {
|
||||||
this.hostname = new SimpleStringProperty(hostname);
|
this.hostname = new SimpleStringProperty(hostname);
|
||||||
@@ -29,7 +29,7 @@ public class RaceConnection {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
InetSocketAddress i = new InetSocketAddress(hostname.get(), port);
|
InetSocketAddress i = new InetSocketAddress(hostname.get(), port);
|
||||||
try (Socket s = new Socket();){
|
try (Socket s = new Socket()){
|
||||||
s.connect(i, 5000);
|
s.connect(i, 5000);
|
||||||
status.set("Ready");
|
status.set("Ready");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.Model.BoatInRace;
|
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
import seng302.Model.Marker;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Observable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by connortaylorbrown on 19/04/17.
|
* Created by connortaylorbrown on 19/04/17.
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ package seng302;
|
|||||||
* Created by cbt24 on 15/03/17.
|
* Created by cbt24 on 15/03/17.
|
||||||
*/
|
*/
|
||||||
public class RaceMap {
|
public class RaceMap {
|
||||||
private double x1, x2, y1, y2;
|
private final double x1;
|
||||||
|
private final double x2;
|
||||||
|
private final double y1;
|
||||||
|
private final double y2;
|
||||||
private int width, height;
|
private int width, height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +37,7 @@ public class RaceMap {
|
|||||||
* @return GraphCoordinate (pair of doubles)
|
* @return GraphCoordinate (pair of doubles)
|
||||||
* @see GraphCoordinate
|
* @see GraphCoordinate
|
||||||
*/
|
*/
|
||||||
public GraphCoordinate convertGPS(double lat, double lon) {
|
private GraphCoordinate convertGPS(double lat, double lon) {
|
||||||
int difference = Math.abs(width - height);
|
int difference = Math.abs(width - height);
|
||||||
int size = width;
|
int size = width;
|
||||||
if (width > height) {
|
if (width > height) {
|
||||||
|
|||||||
@@ -17,16 +17,15 @@ import java.util.List;
|
|||||||
* @deprecated use {@link seng302.Mock.StreamedCourseXMLReader}
|
* @deprecated use {@link seng302.Mock.StreamedCourseXMLReader}
|
||||||
*/
|
*/
|
||||||
public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||||
private List<Boat> boats = new ArrayList<>();
|
private final List<Boat> boats = new ArrayList<>();
|
||||||
private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system.
|
private final Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system.
|
||||||
private List<Leg> legs = new ArrayList<>();
|
private final List<Leg> legs = new ArrayList<>();
|
||||||
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
|
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
|
||||||
private GPSCoordinate mapTopLeft, mapBottomRight;
|
private GPSCoordinate mapTopLeft, mapBottomRight;
|
||||||
private List<GPSCoordinate> boundary = new ArrayList<>();
|
private final List<GPSCoordinate> boundary = new ArrayList<>();
|
||||||
private static double COORDINATEPADDING = 0.0005;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constractor for Race XML
|
* Constructor for Race XML
|
||||||
* @param filePath path of the file
|
* @param filePath path of the file
|
||||||
* @throws IOException error
|
* @throws IOException error
|
||||||
* @throws SAXException error
|
* @throws SAXException error
|
||||||
@@ -37,7 +36,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COnstructor for Race XML
|
* Constructor for Race XML
|
||||||
* @param filePath file path to read
|
* @param filePath file path to read
|
||||||
* @param read whether or not to read and store the files straight away.
|
* @param read whether or not to read and store the files straight away.
|
||||||
* @throws IOException error
|
* @throws IOException error
|
||||||
@@ -145,12 +144,13 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
maxLatitude += difference / 2;
|
maxLatitude += difference / 2;
|
||||||
minLatitude -= difference / 2;
|
minLatitude -= difference / 2;
|
||||||
}
|
}
|
||||||
|
double COORDINATEPADDING = 0.0005;
|
||||||
maxLatitude += COORDINATEPADDING;
|
maxLatitude += COORDINATEPADDING;
|
||||||
minLatitude -= COORDINATEPADDING;
|
minLatitude -= COORDINATEPADDING;
|
||||||
maxLongitude += COORDINATEPADDING;
|
maxLongitude += COORDINATEPADDING;
|
||||||
minLongitude -= COORDINATEPADDING;
|
minLongitude -= COORDINATEPADDING;
|
||||||
//now create map boundaries
|
//now create map boundaries
|
||||||
//top left canvas point is min logitude, max latitude
|
//top left canvas point is min longitude, max latitude
|
||||||
//bottom right of canvas point is min longitude, max latitude.
|
//bottom right of canvas point is min longitude, max latitude.
|
||||||
mapTopLeft = new GPSCoordinate(minLatitude, minLongitude);
|
mapTopLeft = new GPSCoordinate(minLatitude, minLongitude);
|
||||||
mapBottomRight = new GPSCoordinate(maxLatitude, maxLongitude);
|
mapBottomRight = new GPSCoordinate(maxLatitude, maxLongitude);
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ import seng302.Networking.Exceptions.InvalidMessageException;
|
|||||||
import seng302.Networking.Messages.*;
|
import seng302.Networking.Messages.*;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.*;
|
import java.io.DataInputStream;
|
||||||
import java.net.*;
|
import java.io.IOException;
|
||||||
|
import java.net.Socket;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -15,7 +16,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
import static seng302.Networking.Utils.ByteConverter.bytesToInt;
|
|
||||||
import static seng302.Networking.Utils.ByteConverter.bytesToShort;
|
import static seng302.Networking.Utils.ByteConverter.bytesToShort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,14 +24,12 @@ import static seng302.Networking.Utils.ByteConverter.bytesToShort;
|
|||||||
public class VisualiserInput implements Runnable {
|
public class VisualiserInput implements Runnable {
|
||||||
|
|
||||||
///A queue that contains messages that have been received, and need to be handled.
|
///A queue that contains messages that have been received, and need to be handled.
|
||||||
private ArrayBlockingQueue<AC35Data> messagesReceivedQueue = new ArrayBlockingQueue<>(1000000);//We have room for 1,000,000. Is this much capacity actually needed?
|
private final ArrayBlockingQueue<AC35Data> messagesReceivedQueue = new ArrayBlockingQueue<>(1000000);//We have room for 1,000,000. Is this much capacity actually needed?
|
||||||
|
|
||||||
///Timestamp of the last heartbeat.
|
///Timestamp of the last heartbeat.
|
||||||
private long lastHeartbeatTime = -1;
|
private long lastHeartbeatTime = -1;
|
||||||
///Sequence number of the last heartbeat.
|
///Sequence number of the last heartbeat.
|
||||||
private long lastHeartbeatSequenceNum = -1;
|
private long lastHeartbeatSequenceNum = -1;
|
||||||
///How long we should wait for a heartbeat before assuming the connection is dead. Measured in milliseconds.
|
|
||||||
private long heartBeatPeriod = 10 * 1000;
|
|
||||||
|
|
||||||
///The socket that we have connected to.
|
///The socket that we have connected to.
|
||||||
private Socket connectionSocket;
|
private Socket connectionSocket;
|
||||||
@@ -43,10 +41,10 @@ public class VisualiserInput implements Runnable {
|
|||||||
private RaceStatus raceStatus;
|
private RaceStatus raceStatus;
|
||||||
|
|
||||||
///A map of the last BoatStatus message received, for each boat.
|
///A map of the last BoatStatus message received, for each boat.
|
||||||
private Map<Integer, BoatStatus> boatStatusMap = new HashMap<>();;
|
private final Map<Integer, BoatStatus> boatStatusMap = new HashMap<>();
|
||||||
|
|
||||||
///A map of the last BoatLocation message received, for each boat.
|
///A map of the last BoatLocation message received, for each boat.
|
||||||
private Map<Integer, BoatLocation> boatLocationMap = new HashMap<>();
|
private final Map<Integer, BoatLocation> boatLocationMap = new HashMap<>();
|
||||||
|
|
||||||
///The last AverageWind message received.
|
///The last AverageWind message received.
|
||||||
private AverageWind averageWind;
|
private AverageWind averageWind;
|
||||||
@@ -55,17 +53,11 @@ public class VisualiserInput implements Runnable {
|
|||||||
private CourseWinds courseWinds;
|
private CourseWinds courseWinds;
|
||||||
|
|
||||||
///A map of the last MarkRounding message received, for each boat.
|
///A map of the last MarkRounding message received, for each boat.
|
||||||
private Map<Integer, MarkRounding> markRoundingMap = new HashMap<>();
|
private final Map<Integer, MarkRounding> markRoundingMap = new HashMap<>();
|
||||||
|
|
||||||
///The last RaceStartStatus message received.
|
|
||||||
private RaceStartStatus raceStartStatus;
|
|
||||||
|
|
||||||
///InputStream (from the socket).
|
///InputStream (from the socket).
|
||||||
private DataInputStream inStream;
|
private DataInputStream inStream;
|
||||||
|
|
||||||
///TODO comment?
|
|
||||||
private boolean receiverLoop = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ctor.
|
* Ctor.
|
||||||
* @param socket Socket from which we will receive race data.
|
* @param socket Socket from which we will receive race data.
|
||||||
@@ -212,9 +204,8 @@ public class VisualiserInput implements Runnable {
|
|||||||
|
|
||||||
//Decode the binary message into an appropriate message object.
|
//Decode the binary message into an appropriate message object.
|
||||||
BinaryMessageDecoder decoder = new BinaryMessageDecoder(messageBytes);
|
BinaryMessageDecoder decoder = new BinaryMessageDecoder(messageBytes);
|
||||||
AC35Data message = decoder.decode();
|
|
||||||
|
|
||||||
return message;
|
return decoder.decode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,14 +213,15 @@ public class VisualiserInput implements Runnable {
|
|||||||
* Main loop which reads messages from the socket, and exposes them.
|
* Main loop which reads messages from the socket, and exposes them.
|
||||||
*/
|
*/
|
||||||
public void run(){
|
public void run(){
|
||||||
this.receiverLoop = true;
|
boolean receiverLoop = true;
|
||||||
//receiver loop that gets the input
|
//receiver loop that gets the input
|
||||||
while (receiverLoop) {
|
while (receiverLoop) {
|
||||||
|
|
||||||
//If no heartbeat has been received in more the heartbeat period
|
//If no heartbeat has been received in more the heartbeat period
|
||||||
//then the connection will need to be restarted.
|
//then the connection will need to be restarted.
|
||||||
System.out.println("time since last heartbeat: " + timeSinceHeartbeat());//TEMP REMOVE
|
System.out.println("time since last heartbeat: " + timeSinceHeartbeat());//TEMP REMOVE
|
||||||
if (timeSinceHeartbeat() > this.heartBeatPeriod) {
|
long heartBeatPeriod = 10 * 1000;
|
||||||
|
if (timeSinceHeartbeat() > heartBeatPeriod) {
|
||||||
System.out.println("Connection has stopped, trying to reconnect.");
|
System.out.println("Connection has stopped, trying to reconnect.");
|
||||||
|
|
||||||
//Attempt to reconnect the socket.
|
//Attempt to reconnect the socket.
|
||||||
@@ -257,7 +249,7 @@ public class VisualiserInput implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Reads the next message.
|
//Reads the next message.
|
||||||
AC35Data message = null;
|
AC35Data message;
|
||||||
try {
|
try {
|
||||||
message = this.getNextMessage();
|
message = this.getNextMessage();
|
||||||
}
|
}
|
||||||
@@ -306,7 +298,7 @@ public class VisualiserInput implements Runnable {
|
|||||||
|
|
||||||
//System.out.println("XML Message!");
|
//System.out.println("XML Message!");
|
||||||
|
|
||||||
if (xmlMessage.getXmlMsgSubType() == xmlMessage.XMLTypeRegatta){
|
if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRegatta){
|
||||||
//System.out.println("Setting Regatta");
|
//System.out.println("Setting Regatta");
|
||||||
try {
|
try {
|
||||||
course.setRegattaXMLReader(new RegattaXMLReader(xmlMessage.getXmlMessage()));
|
course.setRegattaXMLReader(new RegattaXMLReader(xmlMessage.getXmlMessage()));
|
||||||
@@ -315,10 +307,9 @@ public class VisualiserInput implements Runnable {
|
|||||||
catch (IOException | SAXException | ParserConfigurationException e) {
|
catch (IOException | SAXException | ParserConfigurationException e) {
|
||||||
System.err.println("Error creating RegattaXMLReader: " + e.getMessage());
|
System.err.println("Error creating RegattaXMLReader: " + e.getMessage());
|
||||||
//Continue to the next loop iteration/message.
|
//Continue to the next loop iteration/message.
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (xmlMessage.getXmlMsgSubType() == xmlMessage.XMLTypeRace){
|
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRace){
|
||||||
//System.out.println("Setting Course");
|
//System.out.println("Setting Course");
|
||||||
try {
|
try {
|
||||||
course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage()));
|
course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage()));
|
||||||
@@ -327,10 +318,9 @@ public class VisualiserInput implements Runnable {
|
|||||||
catch (IOException | SAXException | ParserConfigurationException | ParseException | StreamedCourseXMLException e) {
|
catch (IOException | SAXException | ParserConfigurationException | ParseException | StreamedCourseXMLException e) {
|
||||||
System.err.println("Error creating StreamedCourseXMLReader: " + e.getMessage());
|
System.err.println("Error creating StreamedCourseXMLReader: " + e.getMessage());
|
||||||
//Continue to the next loop iteration/message.
|
//Continue to the next loop iteration/message.
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (xmlMessage.getXmlMsgSubType() == xmlMessage.XMLTypeBoat){
|
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeBoat){
|
||||||
//System.out.println("Setting Boats");
|
//System.out.println("Setting Boats");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -340,7 +330,6 @@ public class VisualiserInput implements Runnable {
|
|||||||
catch (IOException | SAXException | ParserConfigurationException e) {
|
catch (IOException | SAXException | ParserConfigurationException e) {
|
||||||
System.err.println("Error creating BoatXMLReader: " + e.getMessage());
|
System.err.println("Error creating BoatXMLReader: " + e.getMessage());
|
||||||
//Continue to the next loop iteration/message.
|
//Continue to the next loop iteration/message.
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -348,10 +337,8 @@ public class VisualiserInput implements Runnable {
|
|||||||
}
|
}
|
||||||
//RaceStartStatus.
|
//RaceStartStatus.
|
||||||
else if (message instanceof RaceStartStatus) {
|
else if (message instanceof RaceStartStatus) {
|
||||||
RaceStartStatus raceStartStatus = (RaceStartStatus) message;
|
|
||||||
|
|
||||||
//System.out.println("Race Start Status Message");
|
//System.out.println("Race Start Status Message");
|
||||||
this.raceStartStatus = raceStartStatus;
|
|
||||||
}
|
}
|
||||||
//YachtEventCode.
|
//YachtEventCode.
|
||||||
/*else if (message instanceof YachtEventCode) {
|
/*else if (message instanceof YachtEventCode) {
|
||||||
@@ -414,18 +401,16 @@ public class VisualiserInput implements Runnable {
|
|||||||
}
|
}
|
||||||
//CourseWinds.
|
//CourseWinds.
|
||||||
else if (message instanceof CourseWinds) {
|
else if (message instanceof CourseWinds) {
|
||||||
CourseWinds courseWinds = (CourseWinds) message;
|
|
||||||
|
|
||||||
//System.out.println("Course Wind Message!");
|
//System.out.println("Course Wind Message!");
|
||||||
this.courseWinds = courseWinds;
|
this.courseWinds = (CourseWinds) message;
|
||||||
|
|
||||||
}
|
}
|
||||||
//AverageWind.
|
//AverageWind.
|
||||||
else if (message instanceof AverageWind) {
|
else if (message instanceof AverageWind) {
|
||||||
AverageWind averageWind = (AverageWind) message;
|
|
||||||
|
|
||||||
//System.out.println("Average Wind Message!");
|
//System.out.println("Average Wind Message!");
|
||||||
this.averageWind = averageWind;
|
this.averageWind = (AverageWind) message;
|
||||||
|
|
||||||
}
|
}
|
||||||
//Unrecognised message.
|
//Unrecognised message.
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package seng302;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
@@ -11,7 +10,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 26/03/2017.
|
* Created by fwy13 on 26/03/2017.
|
||||||
@@ -20,7 +18,7 @@ public abstract class XMLReader {
|
|||||||
|
|
||||||
protected Document doc;
|
protected Document doc;
|
||||||
|
|
||||||
public XMLReader(String filePath) throws ParserConfigurationException, IOException, SAXException {
|
protected XMLReader(String filePath) throws ParserConfigurationException, IOException, SAXException {
|
||||||
InputStream fXmlFile = getClass().getClassLoader().getResourceAsStream(filePath);
|
InputStream fXmlFile = getClass().getClassLoader().getResourceAsStream(filePath);
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||||
@@ -28,7 +26,7 @@ public abstract class XMLReader {
|
|||||||
doc.getDocumentElement().normalize();
|
doc.getDocumentElement().normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public XMLReader(InputStream xmlInput) throws ParserConfigurationException, IOException, SAXException {
|
protected XMLReader(InputStream xmlInput) throws ParserConfigurationException, IOException, SAXException {
|
||||||
|
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||||
@@ -39,11 +37,11 @@ public abstract class XMLReader {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextValueOfNode(Element n, String tagName) {
|
protected String getTextValueOfNode(Element n, String tagName) {
|
||||||
return n.getElementsByTagName(tagName).item(0).getTextContent();
|
return n.getElementsByTagName(tagName).item(0).getTextContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exists(Node node, String attribute) {
|
protected boolean exists(Node node, String attribute) {
|
||||||
return node.getAttributes().getNamedItem(attribute) != null;
|
return node.getAttributes().getNamedItem(attribute) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.TableColumn?>
|
|
||||||
<?import javafx.scene.control.TableView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.ConnectionController">
|
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.ConnectionController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
|||||||
@@ -1,19 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.TableColumn?>
|
|
||||||
<?import javafx.scene.control.TableView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane fx:id="finishWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.FinishController">
|
<AnchorPane fx:id="finishWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.FinishController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane fx:id="start" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane fx:id="start" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainController">
|
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainController">
|
||||||
<children>
|
<children>
|
||||||
<fx:include fx:id="race" source="race.fxml" />
|
<fx:include fx:id="race" source="race.fxml" />
|
||||||
|
|||||||
@@ -1,19 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.TableColumn?>
|
|
||||||
<?import javafx.scene.control.TableView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController">
|
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane fx:id="start" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane fx:id="start" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
|||||||
@@ -7,13 +7,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jjg64 on 21/04/17.
|
* Created by jjg64 on 21/04/17.
|
||||||
*/
|
*/
|
||||||
public class BoatsXMLTest {
|
public class BoatsXMLTest {
|
||||||
BoatXMLReader boatXMLReader;
|
private BoatXMLReader boatXMLReader;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|||||||
@@ -1,25 +1,17 @@
|
|||||||
package seng302.Mock;
|
package seng302.Mock;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jjg64 on 1/05/17.
|
* Created by jjg64 on 1/05/17.
|
||||||
*/
|
*/
|
||||||
public class FailBoatXMLTest {
|
public class FailBoatXMLTest {
|
||||||
String path = "mockXML/boatXML/";
|
private final String path = "mockXML/boatXML/";
|
||||||
|
|
||||||
@Test(expected = NumberFormatException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void invalidSourceID() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
public void invalidSourceID() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package seng302.Mock;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jjg64 on 19/04/17.
|
* Created by jjg64 on 19/04/17.
|
||||||
|
|||||||
@@ -11,25 +11,22 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests only work on the current version of mockXML/raceXML/raceTest.xml
|
* Tests only work on the current version of mockXML/raceXML/raceTest.xml
|
||||||
*/
|
*/
|
||||||
public class StreamedRaceTest {
|
public class StreamedRaceTest {
|
||||||
StreamedCourseXMLReader streamedCourseXMLReader;
|
private StreamedCourseXMLReader streamedCourseXMLReader;
|
||||||
List<GPSCoordinate> boundary;
|
private List<GPSCoordinate> boundary;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
try {
|
try {
|
||||||
streamedCourseXMLReader = new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml", true);
|
streamedCourseXMLReader = new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml", true);
|
||||||
boundary = streamedCourseXMLReader.getBoundary();
|
boundary = streamedCourseXMLReader.getBoundary();
|
||||||
} catch (Exception e) {
|
} catch (Exception | StreamedCourseXMLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
|
//fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
|
||||||
} catch (StreamedCourseXMLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import static junit.framework.TestCase.*;
|
|||||||
public class BoatInRaceTest {
|
public class BoatInRaceTest {
|
||||||
|
|
||||||
|
|
||||||
private GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
private final GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||||
private BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
private final BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class LegTest {
|
public class LegTest {
|
||||||
|
|
||||||
private Marker ORIGIN_MARKER = new Marker(new GPSCoordinate(0, 0));
|
private final Marker ORIGIN_MARKER = new Marker(new GPSCoordinate(0, 0));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDistanceHandles5nmNorth() {
|
public void calculateDistanceHandles5nmNorth() {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
*/
|
*/
|
||||||
public class MarkerTest {
|
public class MarkerTest {
|
||||||
|
|
||||||
GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
private final GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package seng302.Model;/**
|
package seng302.Model;
|
||||||
|
/**
|
||||||
* Created by Gondr on 26/03/2017.
|
* Created by Gondr on 26/03/2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user