Skip to content
Snippets Groups Projects
Main.java 7.86 KiB
Newer Older
import com.application.GUI.PopUpWindows.InputPopup;
import com.application.GUI.Panes.BottomBar;
import com.application.GUI.Panes.LogoBar;
import com.application.GUI.Panes.SideBar;
import com.application.GUI.LineChartFunctionality;
Eilert Tunheim's avatar
Eilert Tunheim committed
import com.application.GUI.PopUpWindows.LoginPopup;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.chart.LineChart;
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 BottomBar bottomBar1 = new BottomBar(this);
    private final com.application.GUI.Panes.MenuBar menuBar1 = new com.application.GUI.Panes.MenuBar(this);
    private final SideBar sideBar1 = new SideBar(this);
    private final LogoBar logoBar1 = new LogoBar();
Eilert Tunheim's avatar
Eilert Tunheim committed

    private BorderPane topBar;
    private HBox logoBar;
    private VBox sideBar;
    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 {
    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.bottomBar = new HBox();
     * Sets the primaryStage and sets the scene for the window.
Eilert Tunheim's avatar
Eilert Tunheim committed
     *
     * @param primaryStage
     * @throws Exception
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        // Create panes for root
        BorderPane root = new BorderPane();
        this.menuBar = menuBar1.createMenuBar();
        this.sideBar = sideBar1.createSideBar();
        this.logoBar = logoBar1.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 = bottomBar1.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);

        this.topBar.setCenter(logoBar);

        // Sets alignment for the panes to the parent root
        root.setTop(this.topBar);
        root.setLeft(this.sideBar);
        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
Eilert Tunheim's avatar
Eilert Tunheim committed
        LoginPopup.login();
    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;
    }