Skip to content
Snippets Groups Projects
Select Git revision
  • 84a3fbdcf26c3fd833f299c63c7e6948f0367ef9
  • master default protected
  • Eilerts_branch
  • Karins_branch
  • Mads_branch
5 results

Main.java

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Main.java 7.96 KiB
    package com.application;
    
    import com.application.GUI.Panes.CreateMenuBar;
    import com.application.GUI.PopUpWindows.InputPopup;
    import com.application.GUI.Panes.CreateBottomBar;
    import com.application.GUI.Panes.CreateLogoBar;
    import com.application.GUI.Panes.CreateSideBar;
    import com.application.GUI.LineChartFunctionality;
    
    import com.application.GUI.PopUpWindows.LoginPopup;
    import javafx.application.Application;
    import javafx.application.Platform;
    import javafx.scene.chart.LineChart;
    import javafx.scene.control.*;
    import javafx.scene.layout.*;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    
    import java.io.IOException;
    
    /**
     * This class launches the application
     *
     * @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
     * @version 1.0.0
     */
    public class Main extends Application {
    
        private final CreateBottomBar createBottomBar1 = new CreateBottomBar(this);
        private final CreateMenuBar createMenuBar1 = new CreateMenuBar(this);
        private final CreateSideBar createSideBar1 = new CreateSideBar(this);
        private final CreateLogoBar createLogoBar1 = new CreateLogoBar();
    
        private BorderPane topBar;
        private HBox logoBar;
        private VBox sideBar;
        private MenuBar menuBar;
        private HBox bottomBar;
    
        private static TextField treeSpeciesText;
        private static TextField dimensionsText;
        private static TextField sawsetText;
        private static TextField moistureGoalText;
        private static TextField timeLeftText;
    
        private static CheckMenuItem menuViewLiveData;
        private static CheckMenuItem menuViewRegression;
        private static CheckMenuItem menuViewRegressionShadow;
        private static CheckMenuItem menuViewPreviousData;
    
        private static CheckBox liveDataBox;
        private static CheckBox regressionBox;
        private static CheckBox regressionConfidenceIntervalBox;
        private static CheckBox previousBox;
    
        /**
         * Starts the application
         *
         * @param args
         * @throws IOException
         */
        public static void main(String[] args) throws IOException {
            launch(args);
        }
    
        public static void exitApplication(){
            Platform.exit();
            System.exit(0);
        }
    
        /**
         * Initializes the application with all the different panes.
         *
         * @throws Exception Exception in super.
         */
        @Override
        public void init() throws Exception {
            super.init();
    
            // Initializing variables
            LineChartFunctionality lineChartFunctionality = new LineChartFunctionality();
            this.topBar = new BorderPane();
            this.logoBar = new HBox();
            this.sideBar = new VBox();
            this.menuBar = new MenuBar();
            this.bottomBar = new HBox();
        }
    
        /**
         * Sets the primaryStage and sets the scene for the window.
         *
         * @param primaryStage
         * @throws Exception
         */
        @Override
        public void start(Stage primaryStage) throws Exception {
    
            // Create panes for root
            BorderPane root = new BorderPane();
            this.menuBar = createMenuBar1.createMenuBar();
            this.sideBar = createSideBar1.createSideBar();
            this.logoBar = createLogoBar1.createLogoBar();
    
            LineChart<String, Number> lineChart = LineChartFunctionality.getLineChart();
    
            //Set id's to connect to css stylesheet
            root.setId("root");
            this.logoBar.setId("logoBar");
            this.menuBar.setId("menuBar");
            this.sideBar.setId("sideBar");
            this.bottomBar = createBottomBar1.createBottomBar();
            this.bottomBar.setId("bottomBar");
            lineChart.setId("lineChart");
    
            // Sett the menubar in a vbox inorder to stretch over the whole screen
            VBox vBox = new VBox(this.menuBar);
    
            // Sets alignment for the topBar
            this.topBar.setTop(vBox);
            this.topBar.setCenter(logoBar);
    
            // Sets alignment for the panes to the parent root
            root.setTop(this.topBar);
            root.setLeft(this.sideBar);
            root.setCenter(lineChart);
            root.setBottom(this.bottomBar);
    
            VBox.setVgrow(this.logoBar, Priority.ALWAYS);
    
            // Sets the scene and defines boundaries
            Scene scene = new Scene(root, 1200, 600);
            scene.getStylesheets().add(getClass().getResource("/com.application/CSS/styleSheet.css").toExternalForm());
    
            primaryStage.setTitle("Moelven Drying Application");
            primaryStage.setMaximized(true);
            primaryStage.setMinHeight(600);
            primaryStage.setMinWidth(1200);
            primaryStage.setScene(scene);
            primaryStage.show();
    
            // Displays the input parameters popup window
            LoginPopup.login();
            InputPopup.display();
        }
    
        public static void setTreeSpeciesText(String treeSpeciesText) {
            Main.treeSpeciesText.setText(treeSpeciesText);
        }
    
        public static void setDimensionsText(String dimensionsText)  {
            Main.dimensionsText.setText(dimensionsText);
        }
    
        public static void setSawsetText(String sawsetText) {
            Main.sawsetText.setText(sawsetText);
        }
    
        public static void setMoistureGoalText(String moistureGoalText) {
            Main.moistureGoalText.setText(moistureGoalText);
        }
    
        public static void setTimeLeftText(String moistureGoalText) {
            Main.timeLeftText.setText(moistureGoalText);
        }
    
        public static CheckMenuItem getMenuViewLiveData() {
            return menuViewLiveData;
        }
    
        public static void setMenuViewLiveData(CheckMenuItem menuViewLiveData) {
            Main.menuViewLiveData = menuViewLiveData;
        }
    
        public static CheckMenuItem getMenuViewRegression() {
            return menuViewRegression;
        }
    
        public void setMenuViewRegression(CheckMenuItem menuViewRegression) {
            Main.menuViewRegression = menuViewRegression;
        }
    
        public static CheckMenuItem getMenuViewRegressionShadow() {
            return menuViewRegressionShadow;
        }
    
        public void setMenuViewRegressionShadow(CheckMenuItem menuViewRegressionShadow) {
            Main.menuViewRegressionShadow = menuViewRegressionShadow;
        }
    
        public static CheckMenuItem getMenuViewPreviousData() {
            return menuViewPreviousData;
        }
    
        public void setMenuViewPreviousData(CheckMenuItem menuViewPreviousData) {
            Main.menuViewPreviousData = menuViewPreviousData;
        }
    
        public static CheckBox getLiveDataBox() {
            return liveDataBox;
        }
    
        public void setLiveDataBox(CheckBox liveDataBox) {
            Main.liveDataBox = liveDataBox;
        }
    
        public static CheckBox getRegressionBox() {
            return regressionBox;
        }
    
        public void setRegressionBox(CheckBox regressionBox) {
            Main.regressionBox = regressionBox;
        }
    
        public static CheckBox getRegressionConfidenceIntervalBox() {
            return regressionConfidenceIntervalBox;
        }
    
        public void setRegressionConfidenceIntervalBox(CheckBox regressionConfidenceIntervalBox) {
            Main.regressionConfidenceIntervalBox = regressionConfidenceIntervalBox;
        }
    
        public static CheckBox getPreviousBox() {
            return previousBox;
        }
    
        public void setPreviousBox(CheckBox previousBox) {
            Main.previousBox = previousBox;
        }
    
        public static TextField getTreeSpeciesText() {
            return treeSpeciesText;
        }
    
        public static void setTreeSpeciesText(TextField treeSpeciesText) {
            Main.treeSpeciesText = treeSpeciesText;
        }
    
        public static TextField getDimensionsText() {
            return dimensionsText;
        }
    
        public static void setDimensionsText(TextField dimensionsText) {
            Main.dimensionsText = dimensionsText;
        }
    
        public static TextField getSawsetText() {
            return sawsetText;
        }
    
        public static void setSawsetText(TextField sawsetText) {
            Main.sawsetText = sawsetText;
        }
    
        public static TextField getMoistureGoalText() {
            return moistureGoalText;
        }
    
        public static void setMoistureGoalText(TextField moistureGoalText) {
            Main.moistureGoalText = moistureGoalText;
        }
    
        public static TextField getTimeLeftText() {
            return timeLeftText;
        }
    
        public static void setTimeLeftText(TextField timeLeftText) {
            Main.timeLeftText = timeLeftText;
        }
    }