Skip to content
Snippets Groups Projects
SimulatorApplication.java 2.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • LABOUREL Arnaud's avatar
    LABOUREL Arnaud committed
    package app;
    
    LABOUREL Arnaud's avatar
    LABOUREL Arnaud committed
    import controller.Controller;
    
    import javafx.application.Platform;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    
    import java.io.IOException;
    import java.net.URL;
    
    
    public class SimulatorApplication extends javafx.application.Application {
    
    LABOUREL Arnaud's avatar
    LABOUREL Arnaud committed
      private static final String VIEW_RESOURCE_PATH = "/view/view.fxml";
    
      private static final String APP_NAME = "Firefighter simulator";
    
      private static final int ROW_COUNT = 20;
      private static final int COLUMN_COUNT = 20;
    
    LABOUREL Arnaud's avatar
    LABOUREL Arnaud committed
      private static final int BOX_WIDTH = 50;
      private static final int BOX_HEIGHT = 50;
    
      public static final int INITIAL_FIRE_COUNT = 10;
    
      public static final int INITIAL_FIREFIGHTER_COUNT = 3;
    
      public static final int INITIAL_CLOUD_COUNT = 3;
    
      public static final int INITIAL_MOTORIZED_COUNT = 3;
    
      public static final int INITIAL_ROCKY_COUNT = 3;
    
    
      private Stage primaryStage;
      private Parent view;
      private void initializePrimaryStage(Stage primaryStage) {
        this.primaryStage = primaryStage;
        this.primaryStage.setTitle(APP_NAME);
        this.primaryStage.setOnCloseRequest(event -> Platform.exit());
    
    COUETOUX Basile's avatar
    COUETOUX Basile committed
        this.primaryStage.setResizable(true);
    
        this.primaryStage.sizeToScene();
      }
    
      @Override
      public void start(Stage primaryStage) throws IOException {
        initializePrimaryStage(primaryStage);
        initializeView();
        showScene();
      }
    
      private void initializeView() throws IOException {
        FXMLLoader loader = new FXMLLoader();
    
        URL location = SimulatorApplication.class.getResource(VIEW_RESOURCE_PATH);
    
        loader.setLocation(location);
        view = loader.load();
        Controller controller = loader.getController();
    
    LABOUREL Arnaud's avatar
    LABOUREL Arnaud committed
        controller.initialize(BOX_WIDTH, BOX_HEIGHT, COLUMN_COUNT, ROW_COUNT,
    
                INITIAL_FIRE_COUNT, INITIAL_FIREFIGHTER_COUNT,INITIAL_CLOUD_COUNT,INITIAL_MOTORIZED_COUNT,INITIAL_ROCKY_COUNT);
    
      }
    
      private void showScene() {
        Scene scene = new Scene(view);
        primaryStage.setScene(scene);
        primaryStage.show();
      }
    
    
      public static void main(String[] args) {
        launch(args);
      }