|
|
|
|
@ -5,27 +5,16 @@ import javafx.beans.property.ReadOnlyObjectWrapper;
|
|
|
|
|
import javafx.beans.value.ChangeListener;
|
|
|
|
|
import javafx.beans.value.ObservableValue;
|
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
|
import javafx.event.EventHandler;
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
|
import javafx.scene.control.*;
|
|
|
|
|
import javafx.scene.control.cell.PropertyValueFactory;
|
|
|
|
|
import javafx.scene.input.MouseEvent;
|
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
|
import javafx.scene.layout.HBox;
|
|
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
|
import javafx.util.Callback;
|
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
import org.geotools.referencing.GeodeticCalculator;
|
|
|
|
|
import seng302.Constants;
|
|
|
|
|
import seng302.GPSCoordinate;
|
|
|
|
|
import seng302.Model.*;
|
|
|
|
|
import seng302.RaceXMLReader;
|
|
|
|
|
|
|
|
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.awt.geom.Point2D;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.ResourceBundle;
|
|
|
|
|
@ -43,16 +32,12 @@ public class RaceController extends Controller{
|
|
|
|
|
GridPane startScreen;
|
|
|
|
|
@FXML
|
|
|
|
|
SplitPane ongoingRacePane;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
CheckBox showFPS;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
CheckBox showAnno;
|
|
|
|
|
|
|
|
|
|
CheckBox showAnnotations;
|
|
|
|
|
@FXML
|
|
|
|
|
Label timer;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
Label FPS;
|
|
|
|
|
|
|
|
|
|
@ -123,8 +108,6 @@ public class RaceController extends Controller{
|
|
|
|
|
@Override
|
|
|
|
|
public void initialize(URL location, ResourceBundle resources) {
|
|
|
|
|
//listener for fps
|
|
|
|
|
/*Tooltip tp = new Tooltip("");
|
|
|
|
|
tp.install(timer, tp);*/
|
|
|
|
|
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
|
|
|
|
public void changed(ObservableValue<? extends Boolean> ov,
|
|
|
|
|
Boolean old_val, Boolean new_val) {
|
|
|
|
|
@ -154,9 +137,9 @@ public class RaceController extends Controller{
|
|
|
|
|
} catch (ParserConfigurationException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BoatInRace[] boats = new BoatInRace[raceXMLReader.getBoats().size()];
|
|
|
|
|
boats = raceXMLReader.getBoats().toArray(boats);
|
|
|
|
|
//BoatInRace[] boats = generateAC35Competitors();
|
|
|
|
|
double lat1 = raceXMLReader.getMapTopLeft().getLatitude();
|
|
|
|
|
double long1 = raceXMLReader.getMapTopLeft().getLongitude();
|
|
|
|
|
double lat2 = raceXMLReader.getMapBottomRight().getLatitude();
|
|
|
|
|
@ -174,14 +157,12 @@ public class RaceController extends Controller{
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raceMap = new ResizableRaceCanvas(lat1, long1, lat2, long2);
|
|
|
|
|
raceMap.setMouseTransparent(true);
|
|
|
|
|
raceMap.widthProperty().bind(canvasBase.widthProperty());
|
|
|
|
|
raceMap.heightProperty().bind(canvasBase.heightProperty());
|
|
|
|
|
raceMap.setBoats(startingBoats);
|
|
|
|
|
raceMap.setRaceBoundaries(raceXMLReader.getBoundary());
|
|
|
|
|
//raceMap.drawBoats();
|
|
|
|
|
raceMap.drawRaceMap();
|
|
|
|
|
raceMap.setVisible(true);
|
|
|
|
|
|
|
|
|
|
@ -190,7 +171,35 @@ public class RaceController extends Controller{
|
|
|
|
|
ongoingRacePane.setVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initializeFPS();
|
|
|
|
|
initializeAnnotations();
|
|
|
|
|
|
|
|
|
|
new Thread((race)).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the value for the race clock label
|
|
|
|
|
*
|
|
|
|
|
* @param time time that the label will be updated to
|
|
|
|
|
*/
|
|
|
|
|
public void setTimer(String time) {
|
|
|
|
|
timer.setText(time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the value for the fps label
|
|
|
|
|
*
|
|
|
|
|
* @param fps fps that the label will be updated to
|
|
|
|
|
*/
|
|
|
|
|
public void setFrames(String fps) {
|
|
|
|
|
FPS.setText((fps));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up FPS display at bottom of screen
|
|
|
|
|
*/
|
|
|
|
|
private void initializeFPS() {
|
|
|
|
|
showFPS.setVisible(true);
|
|
|
|
|
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
|
|
|
|
public void changed(ObservableValue<? extends Boolean> ov,
|
|
|
|
|
@ -202,32 +211,20 @@ public class RaceController extends Controller{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up boat annotations
|
|
|
|
|
*/
|
|
|
|
|
private void initializeAnnotations() {
|
|
|
|
|
//listener for annotation
|
|
|
|
|
showAnno.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
|
|
|
|
showAnnotations.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
|
|
|
|
public void changed(ObservableValue<? extends Boolean> ov,
|
|
|
|
|
Boolean old_val, Boolean new_val) {
|
|
|
|
|
raceMap.toggleAnno();
|
|
|
|
|
raceMap.toggleAnnotations();
|
|
|
|
|
raceMap.update();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
new Thread((race)).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the value for the race clock label
|
|
|
|
|
* @param time time that the label will be updated to
|
|
|
|
|
*/
|
|
|
|
|
public void setTimer(String time) {
|
|
|
|
|
timer.setText(time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the value for the fps label
|
|
|
|
|
* @param fps fps that the label will be updated to
|
|
|
|
|
*/
|
|
|
|
|
public void setFrames(String fps) { FPS.setText((fps)); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|