Partially completed story 13
This commit is contained in:
@@ -1,13 +1,21 @@
|
|||||||
package seng302.Controllers;
|
package seng302.Controllers;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.Paint;
|
import javafx.scene.paint.Paint;
|
||||||
|
import seng302.GPSCoordinate;
|
||||||
import seng302.GraphCoordinate;
|
import seng302.GraphCoordinate;
|
||||||
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.BoatInRace;
|
||||||
|
import seng302.Model.ConstantVelocityRace;
|
||||||
|
import seng302.Model.Leg;
|
||||||
import seng302.RaceMap;
|
import seng302.RaceMap;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -20,10 +28,19 @@ public class RaceController extends Controller{
|
|||||||
@FXML
|
@FXML
|
||||||
Canvas raceMap;
|
Canvas raceMap;
|
||||||
@FXML
|
@FXML
|
||||||
TableView boatInfoTable;
|
TableView<BoatInRace> boatInfoTable;
|
||||||
@FXML
|
@FXML
|
||||||
AnchorPane canvasBase;
|
AnchorPane canvasBase;
|
||||||
|
/*
|
||||||
|
@FXML
|
||||||
|
TableColumn<BoatInRace, String> boatPlacingColumn;
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
TableColumn<BoatInRace, String> boatTeamColumn;
|
||||||
|
/*
|
||||||
|
@FXML
|
||||||
|
TableColumn<BoatInRace, String> boatMarkColumn;
|
||||||
|
*/
|
||||||
private GraphicsContext gc;
|
private GraphicsContext gc;
|
||||||
private RaceMap map;
|
private RaceMap map;
|
||||||
|
|
||||||
@@ -50,8 +67,22 @@ public class RaceController extends Controller{
|
|||||||
public void initialize(URL location, ResourceBundle resources) {/*
|
public void initialize(URL location, ResourceBundle resources) {/*
|
||||||
raceMap.widthProperty().bind(canvasBase.widthProperty());
|
raceMap.widthProperty().bind(canvasBase.widthProperty());
|
||||||
raceMap.heightProperty().bind(canvasBase.heightProperty());*/
|
raceMap.heightProperty().bind(canvasBase.heightProperty());*/
|
||||||
this.gc = raceMap.getGraphicsContext2D();
|
|
||||||
|
BoatInRace boat = new BoatInRace("NZ", 10000);
|
||||||
|
BoatInRace[] boats = new BoatInRace[] {boat};
|
||||||
|
Leg leg1 = new Leg("first leg", 1, new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
||||||
|
Leg[] legs = new Leg[] {leg1};
|
||||||
|
|
||||||
|
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs);
|
||||||
|
|
||||||
|
(new Thread(race)).start();
|
||||||
|
//table view
|
||||||
|
boatTeamColumn.setCellValueFactory(new PropertyValueFactory<BoatInRace,String>("Name"));
|
||||||
|
boatInfoTable.setItems(FXCollections.observableArrayList(race.getFinishingBoats()));
|
||||||
|
|
||||||
this.map = new RaceMap(32.321989, -64.8553, 32.246, -64.831, (int)raceMap.getWidth(), (int)raceMap.getHeight());
|
this.map = new RaceMap(32.321989, -64.8553, 32.246, -64.831, (int)raceMap.getWidth(), (int)raceMap.getHeight());
|
||||||
|
|
||||||
|
this.gc = raceMap.getGraphicsContext2D();
|
||||||
//boat
|
//boat
|
||||||
GraphCoordinate boat1coord = this.map.convertGPS(32.296577, -64.854304);
|
GraphCoordinate boat1coord = this.map.convertGPS(32.296577, -64.854304);
|
||||||
displayBoat(boat1coord, Color.AQUAMARINE);
|
displayBoat(boat1coord, Color.AQUAMARINE);
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ public class Boat {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return returns the speed of the boat.
|
* @return returns the speed of the boat.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.*;
|
|||||||
* 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 {
|
public abstract class Race implements Runnable {
|
||||||
protected BoatInRace[] startingBoats;
|
protected BoatInRace[] startingBoats;
|
||||||
protected ArrayList<BoatInRace> finishingBoats = new ArrayList<>();
|
protected ArrayList<BoatInRace> finishingBoats = new ArrayList<>();
|
||||||
protected Leg[] legs;
|
protected Leg[] legs;
|
||||||
@@ -26,9 +26,11 @@ public abstract class Race {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
preRace();
|
preRace();
|
||||||
simulateRace();
|
simulateRace();
|
||||||
|
System.out.println(System.currentTimeMillis() - time);
|
||||||
|
System.out.println(finishingBoats.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preRace() {
|
private void preRace() {
|
||||||
@@ -90,6 +92,11 @@ public abstract class Race {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<BoatInRace> getFinishingBoats() {
|
||||||
|
return finishingBoats;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is a function that generates the Race and populates the events list.
|
* This function is a function that generates the Race and populates the events list.
|
||||||
* Is automatically called by the initialiser function, so that simulateRace() does not return an empty race.
|
* Is automatically called by the initialiser function, so that simulateRace() does not return an empty race.
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
<children>
|
<children>
|
||||||
<TableView fx:id="boatInfoTable" prefHeight="400.0" prefWidth="146.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<TableView fx:id="boatInfoTable" prefHeight="400.0" prefWidth="146.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn prefWidth="75.0" text="C1" />
|
<TableColumn fx:id="boatTeamColumn" prefWidth="150.0" text="Team" />
|
||||||
<TableColumn prefWidth="75.0" text="C2" />
|
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user