You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.2 KiB
107 lines
3.2 KiB
package seng302.Mock;
|
|
|
|
import seng302.GPSCoordinate;
|
|
import seng302.Model.Boat;
|
|
import seng302.Model.Leg;
|
|
import seng302.Model.Marker;
|
|
import seng302.RaceDataSource;
|
|
|
|
import java.time.ZonedDateTime;
|
|
import java.util.List;
|
|
import java.util.Observable;
|
|
|
|
/**
|
|
* COurse that the is being received.
|
|
*/
|
|
public class StreamedCourse extends Observable implements RaceDataSource {
|
|
private StreamedCourseXMLReader streamedCourseXMLReader = null;
|
|
private BoatXMLReader boatXMLReader = null;
|
|
private RegattaXMLReader regattaXMLReader = null;
|
|
private double windDirection = 0;
|
|
|
|
public StreamedCourse() {}
|
|
|
|
/**
|
|
* Read and set the new XML that has been received.
|
|
* @param boatXMLReader new XMl of the boats.
|
|
*/
|
|
public void setBoatXMLReader(BoatXMLReader boatXMLReader) {
|
|
this.boatXMLReader = boatXMLReader;
|
|
if (streamedCourseXMLReader != null && boatXMLReader != null) {
|
|
this.boatXMLReader.setParticipants(streamedCourseXMLReader.getParticipants());
|
|
|
|
boatXMLReader.read();
|
|
}
|
|
setChanged();
|
|
notifyObservers();
|
|
}
|
|
|
|
public StreamedCourseXMLReader getStreamedCourseXMLReader() {
|
|
return streamedCourseXMLReader;
|
|
}
|
|
|
|
/**
|
|
* Read and sets the new Course that has been received
|
|
* @param streamedCourseXMLReader COurse XML that has been received
|
|
*/
|
|
public void setStreamedCourseXMLReader(StreamedCourseXMLReader streamedCourseXMLReader) {
|
|
this.streamedCourseXMLReader = streamedCourseXMLReader;
|
|
if (streamedCourseXMLReader != null && boatXMLReader != null) {
|
|
boatXMLReader.setParticipants(streamedCourseXMLReader.getParticipants());
|
|
boatXMLReader.read();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reads and sets the new Regatta that has been received
|
|
* @param regattaXMLReader Regatta XMl that has been received.
|
|
*/
|
|
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
|
|
this.regattaXMLReader = regattaXMLReader;
|
|
setChanged();
|
|
notifyObservers();
|
|
}
|
|
|
|
public void setWindDirection(double windDirection) {
|
|
this.windDirection = windDirection;
|
|
}
|
|
|
|
public double getWindDirection() {
|
|
return windDirection;
|
|
}
|
|
|
|
public boolean hasReadRegatta() { return regattaXMLReader != null; }
|
|
|
|
public boolean hasReadBoats() { return boatXMLReader != null; }
|
|
|
|
public boolean hasReadCourse() { return streamedCourseXMLReader != null; }
|
|
|
|
public String getRegattaName() { return regattaXMLReader.getRegattaName(); }
|
|
|
|
public List<Boat> getBoats() {
|
|
return boatXMLReader.getBoats();
|
|
}
|
|
|
|
public List<Leg> getLegs() {
|
|
return streamedCourseXMLReader.getLegs();
|
|
}
|
|
|
|
public List<Marker> getMarkers() { return streamedCourseXMLReader.getMarkers(); }
|
|
|
|
public List<GPSCoordinate> getBoundary() {
|
|
return streamedCourseXMLReader.getBoundary();
|
|
}
|
|
|
|
public ZonedDateTime getZonedDateTime() {
|
|
return streamedCourseXMLReader.getRaceStartTime();
|
|
}
|
|
|
|
public GPSCoordinate getMapTopLeft() {
|
|
return streamedCourseXMLReader.getMapTopLeft();
|
|
}
|
|
|
|
public GPSCoordinate getMapBottomRight() {
|
|
return streamedCourseXMLReader.getMapBottomRight();
|
|
}
|
|
}
|