Partially completed story 13
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
package seng302.Controllers;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import seng302.GPSCoordinate;
|
||||
import seng302.GraphCoordinate;
|
||||
import seng302.Model.Boat;
|
||||
import seng302.Model.BoatInRace;
|
||||
import seng302.Model.ConstantVelocityRace;
|
||||
import seng302.Model.Leg;
|
||||
import seng302.RaceMap;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -20,10 +28,19 @@ public class RaceController extends Controller{
|
||||
@FXML
|
||||
Canvas raceMap;
|
||||
@FXML
|
||||
TableView boatInfoTable;
|
||||
TableView<BoatInRace> boatInfoTable;
|
||||
@FXML
|
||||
AnchorPane canvasBase;
|
||||
|
||||
/*
|
||||
@FXML
|
||||
TableColumn<BoatInRace, String> boatPlacingColumn;
|
||||
*/
|
||||
@FXML
|
||||
TableColumn<BoatInRace, String> boatTeamColumn;
|
||||
/*
|
||||
@FXML
|
||||
TableColumn<BoatInRace, String> boatMarkColumn;
|
||||
*/
|
||||
private GraphicsContext gc;
|
||||
private RaceMap map;
|
||||
|
||||
@@ -50,8 +67,22 @@ public class RaceController extends Controller{
|
||||
public void initialize(URL location, ResourceBundle resources) {/*
|
||||
raceMap.widthProperty().bind(canvasBase.widthProperty());
|
||||
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.gc = raceMap.getGraphicsContext2D();
|
||||
//boat
|
||||
GraphCoordinate boat1coord = this.map.convertGPS(32.296577, -64.854304);
|
||||
displayBoat(boat1coord, Color.AQUAMARINE);
|
||||
|
||||
@@ -27,6 +27,10 @@ public class Boat {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return returns the speed of the boat.
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.*;
|
||||
* Parent class for races
|
||||
* Created by fwy13 on 3/03/17.
|
||||
*/
|
||||
public abstract class Race {
|
||||
public abstract class Race implements Runnable {
|
||||
protected BoatInRace[] startingBoats;
|
||||
protected ArrayList<BoatInRace> finishingBoats = new ArrayList<>();
|
||||
protected Leg[] legs;
|
||||
@@ -26,9 +26,11 @@ public abstract class Race {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
long time = System.currentTimeMillis();
|
||||
preRace();
|
||||
simulateRace();
|
||||
|
||||
System.out.println(System.currentTimeMillis() - time);
|
||||
System.out.println(finishingBoats.get(0));
|
||||
}
|
||||
|
||||
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.
|
||||
* Is automatically called by the initialiser function, so that simulateRace() does not return an empty race.
|
||||
|
||||
Reference in New Issue
Block a user