Synchronised GUI with VisualiserInput thread.

- Made StreamedCourse extend Observable
- Initialised StartController after data pulled from network
- Moved VisualiserInput to visualiser module
- Deleted Networking subpackage from visualiser module

#story[782]
This commit is contained in:
cbt24
2017-05-01 15:21:12 +12:00
parent 7e569b59b7
commit ccbe467090
35 changed files with 56 additions and 2093 deletions
@@ -16,20 +16,23 @@ import org.xml.sax.SAXException;
import seng302.Mock.*;
import seng302.Model.Boat;
import seng302.Model.RaceClock;
import seng302.VisualiserInput;
import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.URL;
import java.text.ParseException;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.ResourceBundle;
import java.util.stream.Stream;
/**
* Created by esa46 on 6/04/17.
*/
public class StartController extends Controller {
public class StartController extends Controller implements Observer {
@FXML private GridPane start;
@FXML private AnchorPane startWrapper;
@@ -47,7 +50,7 @@ public class StartController extends Controller {
private RaceClock raceClock;
private RaceDataSource raceData;
private StreamedCourse raceData;
private long timeLeft = 1;
/**
@@ -83,23 +86,25 @@ public class StartController extends Controller {
public void initialize(URL location, ResourceBundle resources){
raceData = null;
try {
StreamedCourse streamedCourse = new StreamedCourse(new BoatXMLReader("mockXML/boatXML/boatTest.xml"));
streamedCourse.setStreamedCourseXMLReader(new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml"));
streamedCourse.setRegattaXMLReader(new RegattaXMLReader("mockXML/regattaXML/regattaTest.xml"));
raceData = streamedCourse;
raceData = new StreamedCourse();
raceData.addObserver(this);
VisualiserInput visualiserInput = new VisualiserInput(raceData);
new Thread(visualiserInput).start();
// StreamedCourse streamedCourse = new StreamedCourse(new BoatXMLReader("mockXML/boatXML/boatTest.xml"));
// streamedCourse.setStreamedCourseXMLReader(new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml"));
// streamedCourse.setRegattaXMLReader(new RegattaXMLReader("mockXML/regattaXML/regattaTest.xml"));
// raceData = streamedCourse;
// }catch (ParseException e) {
// e.printStackTrace();
// } catch (ParserConfigurationException e) {
// e.printStackTrace();
// } catch (SAXException e) {
// e.printStackTrace();
// } catch (StreamedCourseXMLException e) {
// e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (StreamedCourseXMLException e) {
e.printStackTrace();
}
initialiseTables();
setRaceClock();
}
public AnchorPane startWrapper(){
@@ -178,4 +183,13 @@ public class StartController extends Controller {
}.start();
}
@Override
public void update(Observable o, Object arg) {
if(o instanceof StreamedCourse) {
if(((StreamedCourse) o).getBoats() != null) {
initialiseTables();
setRaceClock();
}
}
}
}