Merge remote-tracking branch 'origin/story9' into story9
# Conflicts: # src/main/java/seng302/Model/Boat.java
This commit is contained in:
@@ -2,7 +2,6 @@ package seng302.Controllers;
|
|||||||
|
|
||||||
|
|
||||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||||
import javafx.beans.property.StringProperty;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
@@ -40,7 +39,7 @@ public class RaceController extends Controller{
|
|||||||
Label timer;
|
Label timer;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
TableView boatInfoTable;
|
TableView<BoatInRace> boatInfoTable;
|
||||||
@FXML
|
@FXML
|
||||||
TableColumn<BoatInRace, String> boatPlacingColumn;
|
TableColumn<BoatInRace, String> boatPlacingColumn;
|
||||||
@FXML
|
@FXML
|
||||||
@@ -64,12 +63,12 @@ public class RaceController extends Controller{
|
|||||||
* Updates the array listened by the TableView (boatInfoTable) that displays the boat information.
|
* Updates the array listened by the TableView (boatInfoTable) that displays the boat information.
|
||||||
* @param race Race to listen to.
|
* @param race Race to listen to.
|
||||||
*/
|
*/
|
||||||
public void updateInfoTable(Race race) {
|
public void setInfoTable(Race race) {
|
||||||
boatInfoTable.getItems().clear();
|
//boatInfoTable.getItems().clear();
|
||||||
boatInfoTable.setItems(race.getStartingBoats());
|
boatInfoTable.setItems(race.getStartingBoats());
|
||||||
|
|
||||||
boatTeamColumn.setCellValueFactory(new PropertyValueFactory<BoatInRace,String>("Name"));
|
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
||||||
boatMarkColumn.setCellValueFactory(new PropertyValueFactory<BoatInRace, String>("CurrentLeg"));
|
boatMarkColumn.setCellValueFactory(cellData -> cellData.getValue().getCurrentLegName());
|
||||||
boatPlacingColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<BoatInRace, String>, ObservableValue<String>>() {
|
boatPlacingColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<BoatInRace, String>, ObservableValue<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public ObservableValue<String> call(TableColumn.CellDataFeatures<BoatInRace, String> table) {
|
public ObservableValue<String> call(TableColumn.CellDataFeatures<BoatInRace, String> table) {
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package seng302.Model;
|
package seng302.Model;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 3/03/17.
|
* Created by fwy13 on 3/03/17.
|
||||||
*/
|
*/
|
||||||
public class Boat {
|
public class Boat {
|
||||||
private String name;
|
private StringProperty name;
|
||||||
private double velocity;
|
private double velocity;
|
||||||
private String abbrev;
|
private String abbrev;
|
||||||
|
|
||||||
@@ -17,18 +20,22 @@ public class Boat {
|
|||||||
*/
|
*/
|
||||||
public Boat(String name, double velocity, String abbrev){
|
public Boat(String name, double velocity, String abbrev){
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
this.name = name;
|
|
||||||
this.abbrev = abbrev;
|
this.abbrev = abbrev;
|
||||||
|
this.name = new SimpleStringProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return The name of the boat
|
* @return The name of the boat
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public StringProperty getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name.setValue(name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return returns the speed of the boat.
|
* @return returns the speed of the boat.
|
||||||
@@ -42,7 +49,7 @@ public class Boat {
|
|||||||
* @return The Name of the boat.
|
* @return The Name of the boat.
|
||||||
*/
|
*/
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return getName();
|
return getName().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbbrev() { return abbrev; }
|
public String getAbbrev() { return abbrev; }
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package seng302.Model;
|
package seng302.Model;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import org.geotools.referencing.GeodeticCalculator;
|
import org.geotools.referencing.GeodeticCalculator;
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
@@ -18,6 +20,7 @@ public class BoatInRace extends Boat {
|
|||||||
private long timeFinished;
|
private long timeFinished;
|
||||||
private Color colour;
|
private Color colour;
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
private StringProperty currentLegName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor method.
|
* Constructor method.
|
||||||
@@ -28,6 +31,7 @@ public class BoatInRace extends Boat {
|
|||||||
public BoatInRace(String name, double velocity, Color colour, String abbrev) {
|
public BoatInRace(String name, double velocity, Color colour, String abbrev) {
|
||||||
super(name, velocity, abbrev);
|
super(name, velocity, abbrev);
|
||||||
setColour(colour);
|
setColour(colour);
|
||||||
|
currentLegName = new SimpleStringProperty("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,6 +92,11 @@ public class BoatInRace extends Boat {
|
|||||||
*/
|
*/
|
||||||
public void setCurrentLeg(Leg currentLeg) {
|
public void setCurrentLeg(Leg currentLeg) {
|
||||||
this.currentLeg = currentLeg;
|
this.currentLeg = currentLeg;
|
||||||
|
this.currentLegName.setValue(currentLeg.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringProperty getCurrentLegName(){
|
||||||
|
return currentLegName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public abstract class Race implements Runnable {
|
|||||||
* Runnable for the thread.
|
* Runnable for the thread.
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
updateController();
|
setControllerListeners();
|
||||||
preRace();
|
preRace();
|
||||||
countdownTimer();
|
countdownTimer();
|
||||||
simulateRace();
|
simulateRace();
|
||||||
@@ -165,7 +165,6 @@ public abstract class Race implements Runnable {
|
|||||||
*/
|
*/
|
||||||
protected void checkPosition(BoatInRace boat, long timeElapsed) {
|
protected void checkPosition(BoatInRace boat, long timeElapsed) {
|
||||||
if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()){
|
if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()){
|
||||||
// updateController();
|
|
||||||
//boat has passed onto new leg
|
//boat has passed onto new leg
|
||||||
if (boat.getCurrentLeg().getName().equals("Finish")) {
|
if (boat.getCurrentLeg().getName().equals("Finish")) {
|
||||||
//boat has finished
|
//boat has finished
|
||||||
@@ -184,8 +183,8 @@ public abstract class Race implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Update call for the controller.
|
* Update call for the controller.
|
||||||
*/
|
*/
|
||||||
protected void updateController() {
|
protected void setControllerListeners() {
|
||||||
if(controller != null) controller.updateInfoTable(this);
|
if(controller != null) controller.setInfoTable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user