Deleted redundant and deprecated code (Visualiser)

- References to deprecated objects replaced
- Deprecated Constants class removed
- general redundant code deleted
main
Jessica McAuslin 9 years ago
parent 045e69a637
commit d294ee7994

@ -1,34 +0,0 @@
package seng302;
import javafx.scene.paint.Color;
import seng302.Model.BoatInRace;
/**
* Constants that are used throughout the program
* Created by Erika on 19-Mar-17.
* @deprecated please use XML for constant data
*/
public class Constants {
public static final int NMToMetersConversion = 1852; // 1 nautical mile = 1852 meters
public static final GPSCoordinate startLineMarker1 = new GPSCoordinate(32.296577, -64.854304);
public static final GPSCoordinate startLineMarker2 = new GPSCoordinate(32.293771, -64.855242);
public static final GPSCoordinate mark1 = new GPSCoordinate(32.293039, -64.843983);
public static final GPSCoordinate windwardGate1 = new GPSCoordinate(32.284680, -64.850045);
public static final GPSCoordinate windwardGate2 = new GPSCoordinate(32.280164, -64.847591);
public static final GPSCoordinate leewardGate1 = new GPSCoordinate(32.309693, -64.835249);
public static final GPSCoordinate leewardGate2 = new GPSCoordinate(32.308046, -64.831785);
public static final GPSCoordinate finishLineMarker1 = new GPSCoordinate(32.317379, -64.839291);
public static final GPSCoordinate finishLineMarker2 = new GPSCoordinate(32.317257, -64.836260);
public static final double wakeScale = 10;
public static final BoatInRace[] OFFICIAL_AC35_COMPETITORS = new BoatInRace[]
{new BoatInRace("Oracle Team USA", 30.0, Color.BLUEVIOLET, "Oracle"),
new BoatInRace("Land Rover BAR", 23.0, Color.BLACK, "BGR"),
new BoatInRace("SoftBank Team Japan", 27.0, Color.RED, "JPN"),
new BoatInRace("Groupama Team France", 25.0, Color.ORANGE, "FRA"),
new BoatInRace("Artemis Racing", 22.5, Color.DARKOLIVEGREEN, "SWE"),
new BoatInRace("Emirates Team New Zealand", 62, Color.LIMEGREEN, "ETNZ")};
}

@ -19,7 +19,6 @@ 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.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Observable; import java.util.Observable;
@ -43,8 +42,6 @@ public class StartController extends Controller implements Observer {
@FXML private Label timer; @FXML private Label timer;
@FXML private Label raceStatusLabel; @FXML private Label raceStatusLabel;
private ZonedDateTime startingTime;
//@FXML Button fifteenMinButton; //@FXML Button fifteenMinButton;
private RaceClock raceClock; private RaceClock raceClock;
@ -61,17 +58,11 @@ public class StartController extends Controller implements Observer {
* Begins the race with a scale factor of 1 * Begins the race with a scale factor of 1
*/ */
private void startRaceNoScaling() { private void startRaceNoScaling() {
//startRace(1);
while(visualiserInput.getRaceStatus() == null);//TODO probably remove this. while(visualiserInput.getRaceStatus() == null);//TODO probably remove this.
countdownTimer(); countdownTimer();
} }
private void startRace(int raceScale){
//fifteenMinButton.setDisable(true);
//countdownTimer(raceScale);
}
@Override @Override
public void initialize(URL location, ResourceBundle resources){ public void initialize(URL location, ResourceBundle resources){
raceData = new StreamedCourse(); raceData = new StreamedCourse();

@ -21,14 +21,6 @@ public class StreamedCourse extends Observable implements RaceDataSource {
public StreamedCourse() {} public StreamedCourse() {}
public StreamedCourse(StreamedCourseXMLReader streamedCourseXMLReader) {
this.streamedCourseXMLReader = streamedCourseXMLReader;
}
public StreamedCourse(BoatXMLReader boatXMLReader) {
this.boatXMLReader = boatXMLReader;
}
public void setBoatXMLReader(BoatXMLReader boatXMLReader) { public void setBoatXMLReader(BoatXMLReader boatXMLReader) {
this.boatXMLReader = boatXMLReader; this.boatXMLReader = boatXMLReader;
if (streamedCourseXMLReader != null && boatXMLReader != null) { if (streamedCourseXMLReader != null && boatXMLReader != null) {

@ -13,7 +13,6 @@ 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.ParseException;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@ -35,19 +34,6 @@ public class StreamedCourseXMLReader extends XMLReader {
private String raceType; private String raceType;
private boolean postpone; private boolean postpone;
/**
* Constructor for Streamed Race XML
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws ParseException error
* @throws StreamedCourseXMLException error
*/
public StreamedCourseXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException {
this(filePath, true);
}
/** /**
* Constructor for Streamed Race XML * Constructor for Streamed Race XML
* @param filePath file path to read * @param filePath file path to read
@ -55,10 +41,9 @@ public class StreamedCourseXMLReader extends XMLReader {
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
* @throws ParserConfigurationException error * @throws ParserConfigurationException error
* @throws ParseException error
* @throws StreamedCourseXMLException error * @throws StreamedCourseXMLException error
*/ */
public StreamedCourseXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException { public StreamedCourseXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, StreamedCourseXMLException {
super(filePath); super(filePath);
if (read) { if (read) {
read(); read();
@ -71,10 +56,9 @@ public class StreamedCourseXMLReader extends XMLReader {
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
* @throws ParserConfigurationException error * @throws ParserConfigurationException error
* @throws ParseException error
* @throws StreamedCourseXMLException error * @throws StreamedCourseXMLException error
*/ */
public StreamedCourseXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException, ParseException, StreamedCourseXMLException { public StreamedCourseXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException, StreamedCourseXMLException {
super(xmlString); super(xmlString);
read(); read();
} }
@ -268,10 +252,6 @@ public class StreamedCourseXMLReader extends XMLReader {
return COORDINATEPADDING; return COORDINATEPADDING;
} }
public ZonedDateTime getCreationTimeDate() {
return creationTimeDate;
}
public ZonedDateTime getRaceStartTime() { public ZonedDateTime getRaceStartTime() {
return raceStartTime; return raceStartTime;
} }

@ -27,8 +27,7 @@ public class StreamedRace extends Race {
String name = officialStart.getName(); String name = officialStart.getName();
Marker endMarker = officialStart.getEndMarker(); Marker endMarker = officialStart.getEndMarker();
for (int i = 0; i < startingBoats.size(); i++) { for (Boat boat : startingBoats) {
Boat boat = startingBoats.get(i);
if (boat != null) { if (boat != null) {
Leg startLeg = new Leg(name, 0); Leg startLeg = new Leg(name, 0);
startLeg.setEndMarker(endMarker); startLeg.setEndMarker(endMarker);

@ -4,7 +4,6 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
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;
@ -28,6 +27,7 @@ public class BoatInRace extends Boat {
private boolean started = false; private boolean started = false;
private final StringProperty position; private final StringProperty position;
private double heading; private double heading;
private static final double WAKE_SCALE = 10;
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>(); private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
private long nextValidTime = 0; private long nextValidTime = 0;
@ -108,7 +108,7 @@ public class BoatInRace extends Boat {
*/ */
public GPSCoordinate getWake() { public GPSCoordinate getWake() {
double reverseHeading = getHeading() - 180; double reverseHeading = getHeading() - 180;
double distance = Constants.wakeScale * getVelocity(); double distance = WAKE_SCALE * getVelocity();
GeodeticCalculator calc = new GeodeticCalculator(); GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint( calc.setStartingGeographicPoint(

@ -1,7 +1,6 @@
package seng302.Model; package seng302.Model;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants;
import seng302.GPSCoordinate; import seng302.GPSCoordinate;
/** /**
@ -13,6 +12,8 @@ public class Leg {
private Marker startMarker; private Marker startMarker;
private Marker endMarker; private Marker endMarker;
private final int legNumber; private final int legNumber;
// 1 nautical mile = 1852 meters
public static final int NM_TO_METERS = 1852;
/** /**
* Leg Initializer * Leg Initializer
@ -97,7 +98,7 @@ public class Leg {
GPSCoordinate endMarker = this.endMarker.getAverageGPSCoordinate(); GPSCoordinate endMarker = this.endMarker.getAverageGPSCoordinate();
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude()); calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude()); calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
this.distance = calc.getOrthodromicDistance() / Constants.NMToMetersConversion; this.distance = calc.getOrthodromicDistance() / NM_TO_METERS;
} }

@ -34,13 +34,6 @@ public class RaceClock implements Runnable {
setTime(time); setTime(time);
} }
public RaceClock(long utcTime, ZoneId zoneId) {
this.zoneId = zoneId;
this.timeString = new SimpleStringProperty();
this.time = (new Date(utcTime)).toInstant().atZone(zoneId);
setTime(time);
}
public static ZonedDateTime getCurrentZonedDateTime(GPSCoordinate gpsCoordinate) { public static ZonedDateTime getCurrentZonedDateTime(GPSCoordinate gpsCoordinate) {
TimeZoneLookup timeZoneLookup = new TimeZoneLookup(); TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude()); TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());

@ -5,7 +5,6 @@ import javafx.collections.ObservableList;
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.GPSCoordinate;
import seng302.GraphCoordinate; import seng302.GraphCoordinate;
import seng302.Mock.StreamedCourse; import seng302.Mock.StreamedCourse;
import seng302.RaceDataSource; import seng302.RaceDataSource;

@ -1,7 +1,6 @@
package seng302; package seng302;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.Mock.*; import seng302.Mock.*;
import seng302.Model.Boat;
import seng302.Networking.BinaryMessageDecoder; import seng302.Networking.BinaryMessageDecoder;
import seng302.Networking.Exceptions.InvalidMessageException; import seng302.Networking.Exceptions.InvalidMessageException;
import seng302.Networking.Messages.*; import seng302.Networking.Messages.*;
@ -11,10 +10,8 @@ import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.text.ParseException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
@ -317,7 +314,7 @@ public class VisualiserInput implements Runnable {
course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage())); course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage()));
} }
//TODO REFACTOR should put all of these exceptions behind a StreamedCourseXMLReaderException. //TODO REFACTOR should put all of these exceptions behind a StreamedCourseXMLReaderException.
catch (IOException | SAXException | ParserConfigurationException | ParseException | StreamedCourseXMLException e) { catch (IOException | SAXException | ParserConfigurationException | 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.
} }

@ -2,12 +2,12 @@ package seng302.Model;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import org.junit.Test; import org.junit.Test;
import seng302.Constants;
import seng302.GPSCoordinate; import seng302.GPSCoordinate;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertEquals;
import static seng302.Model.Leg.NM_TO_METERS;
/** /**
* Created by esa46 on 22/03/17. * Created by esa46 on 22/03/17.
@ -20,7 +20,7 @@ public class LegTest {
public void calculateDistanceHandles5nmNorth() { public void calculateDistanceHandles5nmNorth() {
GeodeticCalculator calc = new GeodeticCalculator(); GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0); calc.setStartingGeographicPoint(0, 0);
calc.setDirection(0, 5 * Constants.NMToMetersConversion); calc.setDirection(0, 5 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint()); Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0); Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
@ -31,7 +31,7 @@ public class LegTest {
public void calculateDistanceHandles12nmEast() { public void calculateDistanceHandles12nmEast() {
GeodeticCalculator calc = new GeodeticCalculator(); GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0); calc.setStartingGeographicPoint(0, 0);
calc.setDirection(90, 12 * Constants.NMToMetersConversion); calc.setDirection(90, 12 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint()); Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0); Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
@ -42,7 +42,7 @@ public class LegTest {
public void calculateDistanceHandlesHalfnmSouth() { public void calculateDistanceHandlesHalfnmSouth() {
GeodeticCalculator calc = new GeodeticCalculator(); GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0); calc.setStartingGeographicPoint(0, 0);
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion); calc.setDirection(180, 0.5 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint()); Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0); Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
@ -53,7 +53,7 @@ public class LegTest {
public void calculateDistanceHandlesPoint1nmWest() { public void calculateDistanceHandlesPoint1nmWest() {
GeodeticCalculator calc = new GeodeticCalculator(); GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0); calc.setStartingGeographicPoint(0, 0);
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion); calc.setDirection(-90, 0.1 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint()); Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0); Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);

Loading…
Cancel
Save