Added table column to display speed of each boat
-BoatInRace now has a column to called boatSpeedColumn that displays boat #story [17] #pair[fwy13, zwu18]
This commit is contained in:
@@ -46,6 +46,8 @@ public class RaceController extends Controller{
|
|||||||
TableColumn<BoatInRace, String> boatTeamColumn;
|
TableColumn<BoatInRace, String> boatTeamColumn;
|
||||||
@FXML
|
@FXML
|
||||||
TableColumn<BoatInRace, String> boatMarkColumn;
|
TableColumn<BoatInRace, String> boatMarkColumn;
|
||||||
|
@FXML
|
||||||
|
TableColumn<BoatInRace, String> boatSpeedColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates the ResizableRaceCanvas (raceMap) with most recent data
|
* updates the ResizableRaceCanvas (raceMap) with most recent data
|
||||||
@@ -68,6 +70,7 @@ public class RaceController extends Controller{
|
|||||||
boatInfoTable.setItems(race.getStartingBoats());
|
boatInfoTable.setItems(race.getStartingBoats());
|
||||||
|
|
||||||
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
||||||
|
boatSpeedColumn.setCellValueFactory(cellData -> cellData.getValue().getVelocityProp());
|
||||||
boatMarkColumn.setCellValueFactory(cellData -> cellData.getValue().getCurrentLegName());
|
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
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package seng302.Model;
|
package seng302.Model;
|
||||||
|
|
||||||
|
import javafx.beans.property.DoubleProperty;
|
||||||
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
|
|
||||||
@@ -11,6 +13,7 @@ import java.util.ArrayList;
|
|||||||
public class Boat {
|
public class Boat {
|
||||||
private StringProperty name;
|
private StringProperty name;
|
||||||
private double velocity;
|
private double velocity;
|
||||||
|
private StringProperty velocityProp;
|
||||||
private String abbrev;
|
private String abbrev;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,6 +23,7 @@ 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.velocityProp = new SimpleStringProperty(String.valueOf(velocity));
|
||||||
this.abbrev = abbrev;
|
this.abbrev = abbrev;
|
||||||
this.name = new SimpleStringProperty(name);
|
this.name = new SimpleStringProperty(name);
|
||||||
}
|
}
|
||||||
@@ -52,6 +56,10 @@ public class Boat {
|
|||||||
return getName().getValue();
|
return getName().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringProperty getVelocityProp() {
|
||||||
|
return velocityProp;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAbbrev() { return abbrev; }
|
public String getAbbrev() { return abbrev; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place" />
|
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place" />
|
||||||
<TableColumn fx:id="boatTeamColumn" prefWidth="50.0" text="Team" />
|
<TableColumn fx:id="boatTeamColumn" prefWidth="50.0" text="Team" />
|
||||||
<TableColumn fx:id="boatMarkColumn" prefWidth="50.0" text="Mark" />
|
<TableColumn fx:id="boatMarkColumn" prefWidth="50.0" text="Mark" />
|
||||||
|
<TableColumn fx:id="boatSpeedColumn" prefWidth="75.0" text="Speed" />
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user