diff --git a/src/sample/InitialParamsWindowController.java b/src/sample/InitialParamsWindowController.java index 1fbeba4..f9228f9 100644 --- a/src/sample/InitialParamsWindowController.java +++ b/src/sample/InitialParamsWindowController.java @@ -1,10 +1,14 @@ package sample; import java.net.URL; import java.util.ResourceBundle; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.Spinner; import javafx.scene.control.SpinnerValueFactory; +import simulation.Simulation; public class InitialParamsWindowController { @@ -18,10 +22,13 @@ public class InitialParamsWindowController { private Spinner initialAnimalsSpinner; @FXML - private Spinner plantEnergySpinner; + private Spinner initialEnergySpinner; + + @FXML + private Spinner plantEnergySpinner; @FXML - private Spinner moveEnergySpinner; + private Spinner moveEnergySpinner; @FXML private Spinner jungleRatioSpinner; @@ -35,9 +42,12 @@ public class InitialParamsWindowController { @FXML private Button startSimulationButton; + + @FXML void initialize() { assert initialAnimalsSpinner != null : "fx:id=\"initialAnimalsSpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; + assert initialEnergySpinner != null : "fx:id=\"initialEnergySpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; assert plantEnergySpinner != null : "fx:id=\"plantEnergySpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; assert moveEnergySpinner != null : "fx:id=\"moveEnergySpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; assert jungleRatioSpinner != null : "fx:id=\"jungleRatioSpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; @@ -45,11 +55,16 @@ void initialize() { assert boardWidthSpinner != null : "fx:id=\"boardWidthSpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; assert startSimulationButton != null : "fx:id=\"startSimulationButton\" was not injected: check your FXML file 'initialParamsWindow.fxml'."; initialAnimalsSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 25,10)); - plantEnergySpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100,50)); - moveEnergySpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100,10)); + plantEnergySpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0, 100,50)); + moveEnergySpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0, 100,10)); jungleRatioSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.1, 0.9,0.5,0.01)); boardHeightSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(10, 100)); boardWidthSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(10, 100)); + initialEnergySpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0,100,50)); + } + + public Button getStartSimulationButton() { + return startSimulationButton; } } diff --git a/src/sample/Main.java b/src/sample/Main.java index d4e2364..094f585 100644 --- a/src/sample/Main.java +++ b/src/sample/Main.java @@ -1,9 +1,11 @@ package sample; import javafx.application.Application; +import javafx.event.ActionEvent; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.control.Button; import javafx.stage.Stage; import simulation.Simulation; @@ -11,11 +13,17 @@ public class Main extends Application { @Override public void start(Stage stage) throws Exception{ - Parent loader = FXMLLoader.load(getClass().getResource("initialParamsWindow.fxml")); + FXMLLoader loader = new FXMLLoader(getClass().getResource("initialParamsWindow.fxml")); + Parent root = loader.load(); stage.setTitle("Evolution Simulator"); - stage.setScene(new Scene(loader)); + stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); + InitialParamsWindowController controller = loader.getController(); + Button startButton = controller.getStartSimulationButton(); + startButton.addEventHandler(ActionEvent.ACTION,e -> { + + }); } diff --git a/src/sample/initialParamsWindow.fxml b/src/sample/initialParamsWindow.fxml index 9071f9b..a4702d2 100644 --- a/src/sample/initialParamsWindow.fxml +++ b/src/sample/initialParamsWindow.fxml @@ -5,7 +5,7 @@ - +