@ -1,5 +1,7 @@
package seng302.Controllers ;
package seng302.Controllers ;
import javafx.beans.property.ReadOnlyObjectWrapper ;
import javafx.beans.value.ObservableValue ;
import javafx.collections.FXCollections ;
import javafx.collections.FXCollections ;
import javafx.fxml.FXML ;
import javafx.fxml.FXML ;
import javafx.scene.canvas.Canvas ;
import javafx.scene.canvas.Canvas ;
@ -10,15 +12,16 @@ import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane ;
import javafx.scene.layout.AnchorPane ;
import javafx.scene.paint.Color ;
import javafx.scene.paint.Color ;
import javafx.scene.paint.Paint ;
import javafx.scene.paint.Paint ;
import javafx.util.Callback ;
import seng302.GPSCoordinate ;
import seng302.GPSCoordinate ;
import seng302.GraphCoordinate ;
import seng302.GraphCoordinate ;
import seng302.Model.Boat ;
import seng302.Model.* ;
import seng302.Model.BoatInRace ;
import seng302.Model.ConstantVelocityRace ;
import seng302.Model.Leg ;
import seng302.RaceMap ;
import seng302.RaceMap ;
import java.net.URL ;
import java.net.URL ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Observable ;
import java.util.ResourceBundle ;
import java.util.ResourceBundle ;
/ * *
/ * *
@ -31,16 +34,13 @@ public class RaceController extends Controller{
TableView < BoatInRace > boatInfoTable ;
TableView < BoatInRace > boatInfoTable ;
@FXML
@FXML
AnchorPane canvasBase ;
AnchorPane canvasBase ;
/ *
@FXML
@FXML
TableColumn < BoatInRace , String > boatPlacingColumn ;
TableColumn < BoatInRace , String > boatPlacingColumn ;
* /
@FXML
@FXML
TableColumn < BoatInRace , String > boatTeamColumn ;
TableColumn < BoatInRace , String > boatTeamColumn ;
/ *
@FXML
@FXML
TableColumn < BoatInRace , String > boatMarkColumn ;
TableColumn < BoatInRace , String > boatMarkColumn ;
* /
private GraphicsContext gc ;
private GraphicsContext gc ;
private RaceMap map ;
private RaceMap map ;
@ -63,6 +63,19 @@ public class RaceController extends Controller{
gc . fillOval ( graphCoordinate . getX ( ) , graphCoordinate . getY ( ) , 10 , 10 ) ;
gc . fillOval ( graphCoordinate . getX ( ) , graphCoordinate . getY ( ) , 10 , 10 ) ;
}
}
public void updateInfoTable ( Race race ) {
boatInfoTable . setItems ( FXCollections . observableArrayList ( race . getFinishingBoats ( ) ) ) ;
boatTeamColumn . setCellValueFactory ( new PropertyValueFactory < BoatInRace , String > ( "Name" ) ) ;
boatMarkColumn . setCellValueFactory ( new PropertyValueFactory < BoatInRace , String > ( "CurrentLeg" ) ) ;
boatPlacingColumn . setCellValueFactory ( new Callback < TableColumn . CellDataFeatures < BoatInRace , String > , ObservableValue < String > > ( ) {
@Override
public ObservableValue < String > call ( TableColumn . CellDataFeatures < BoatInRace , String > table ) {
return new ReadOnlyObjectWrapper ( boatInfoTable . getItems ( ) . indexOf ( table . getValue ( ) ) + 1 ) ;
}
} ) ;
}
@Override
@Override
public void initialize ( URL location , ResourceBundle resources ) { / *
public void initialize ( URL location , ResourceBundle resources ) { / *
raceMap . widthProperty ( ) . bind ( canvasBase . widthProperty ( ) ) ;
raceMap . widthProperty ( ) . bind ( canvasBase . widthProperty ( ) ) ;
@ -73,12 +86,9 @@ public class RaceController extends Controller{
Leg leg1 = new Leg ( "first leg" , 1 , new GPSCoordinate ( 0 , 0 ) , new GPSCoordinate ( 1 , 1 ) , 0 ) ;
Leg leg1 = new Leg ( "first leg" , 1 , new GPSCoordinate ( 0 , 0 ) , new GPSCoordinate ( 1 , 1 ) , 0 ) ;
Leg [ ] legs = new Leg [ ] { leg1 } ;
Leg [ ] legs = new Leg [ ] { leg1 } ;
ConstantVelocityRace race = new ConstantVelocityRace ( boats , legs );
ConstantVelocityRace race = new ConstantVelocityRace ( boats , legs , this );
( new Thread ( race ) ) . start ( ) ;
( 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 . map = new RaceMap ( 32.321989 , - 64.8553 , 32.246 , - 64.831 , ( int ) raceMap . getWidth ( ) , ( int ) raceMap . getHeight ( ) ) ;