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