Skip to content

Commit

Permalink
initial params window updated
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMakarewicz committed Dec 20, 2020
1 parent 2bcba04 commit 5f29f00
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
23 changes: 19 additions & 4 deletions src/sample/InitialParamsWindowController.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -18,10 +22,13 @@ public class InitialParamsWindowController {
private Spinner<Integer> initialAnimalsSpinner;

@FXML
private Spinner<Integer> plantEnergySpinner;
private Spinner<Double> initialEnergySpinner;

@FXML
private Spinner<Double> plantEnergySpinner;

@FXML
private Spinner<Integer> moveEnergySpinner;
private Spinner<Double> moveEnergySpinner;

@FXML
private Spinner<Double> jungleRatioSpinner;
Expand All @@ -35,21 +42,29 @@ 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'.";
assert boardHeightSpinner != null : "fx:id=\"boardHeightSpinner\" was not injected: check your FXML file 'initialParamsWindow.fxml'.";
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;
}
}

12 changes: 10 additions & 2 deletions src/sample/Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
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;

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 -> {

});
}


Expand Down
10 changes: 6 additions & 4 deletions src/sample/initialParamsWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
<?import javafx.scene.control.Spinner?>
<?import javafx.scene.layout.Pane?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="245.0" prefWidth="261.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.InitialParamsWindowController">
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="261.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.InitialParamsWindowController">
<children>
<Spinner fx:id="initialAnimalsSpinner" layoutX="162.0" layoutY="80.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="83.0" text="Initial number of animals" />
<Spinner fx:id="plantEnergySpinner" layoutX="162.0" layoutY="110.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="113.0" text="Plant energy" />
<Spinner fx:id="moveEnergySpinner" layoutX="162.0" layoutY="140.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="143.0" text="Move energy" />
<Spinner fx:id="jungleRatioSpinner" layoutX="162.0" layoutY="170.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="173.0" text="Jungle ratio" />
<Spinner fx:id="jungleRatioSpinner" layoutX="162.0" layoutY="199.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="203.0" text="Jungle ratio" />
<Spinner fx:id="boardHeightSpinner" layoutX="162.0" layoutY="50.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="53.0" text="Board height" />
<Spinner fx:id="boardWidthSpinner" layoutX="162.0" layoutY="20.0" maxWidth="75.0" />
<Label layoutX="20.0" layoutY="23.0" text="Board width" />
<Button fx:id="startSimulationButton" layoutX="162.0" layoutY="200.0" maxWidth="75.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="75.0" text="Start!" />
<Button fx:id="startSimulationButton" layoutX="162.0" layoutY="230.0" maxWidth="75.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="75.0" text="Start!" />
<Spinner fx:id="initialEnergySpinner" layoutX="162.0" layoutY="169.0" prefHeight="25.0" prefWidth="75.0" />
<Label layoutX="20.0" layoutY="173.0" text="Initial energy" />
</children>
</Pane>

0 comments on commit 5f29f00

Please sign in to comment.