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;
|
||||
@FXML
|
||||
TableColumn<BoatInRace, String> boatMarkColumn;
|
||||
@FXML
|
||||
TableColumn<BoatInRace, String> boatSpeedColumn;
|
||||
|
||||
/**
|
||||
* updates the ResizableRaceCanvas (raceMap) with most recent data
|
||||
@@ -68,6 +70,7 @@ public class RaceController extends Controller{
|
||||
boatInfoTable.setItems(race.getStartingBoats());
|
||||
|
||||
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
|
||||
boatSpeedColumn.setCellValueFactory(cellData -> cellData.getValue().getVelocityProp());
|
||||
boatMarkColumn.setCellValueFactory(cellData -> cellData.getValue().getCurrentLegName());
|
||||
boatPlacingColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<BoatInRace, String>, ObservableValue<String>>() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package seng302.Model;
|
||||
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
@@ -11,6 +13,7 @@ import java.util.ArrayList;
|
||||
public class Boat {
|
||||
private StringProperty name;
|
||||
private double velocity;
|
||||
private StringProperty velocityProp;
|
||||
private String abbrev;
|
||||
|
||||
/**
|
||||
@@ -20,6 +23,7 @@ public class Boat {
|
||||
*/
|
||||
public Boat(String name, double velocity, String abbrev){
|
||||
this.velocity = velocity;
|
||||
this.velocityProp = new SimpleStringProperty(String.valueOf(velocity));
|
||||
this.abbrev = abbrev;
|
||||
this.name = new SimpleStringProperty(name);
|
||||
}
|
||||
@@ -52,6 +56,10 @@ public class Boat {
|
||||
return getName().getValue();
|
||||
}
|
||||
|
||||
public StringProperty getVelocityProp() {
|
||||
return velocityProp;
|
||||
}
|
||||
|
||||
public String getAbbrev() { return abbrev; }
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place" />
|
||||
<TableColumn fx:id="boatTeamColumn" prefWidth="50.0" text="Team" />
|
||||
<TableColumn fx:id="boatMarkColumn" prefWidth="50.0" text="Mark" />
|
||||
<TableColumn fx:id="boatSpeedColumn" prefWidth="75.0" text="Speed" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user