package nl.tudelft.dnainator.ui;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Screen;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * DNAinator's main window, from which all interaction will occur.
 * <p>
 * The {@link #start(Stage) start} method will automatically load
 * the required fxml files, which in turn instantiates all controllers.
 * </p>
 */
public class DNAinator extends Application {
	private static final String DNAINATOR = "DNAinator";
	private static final String FXML = "/ui/fxml/dnainator.fxml";
	private static final String ICON = "/ui/dnainator.iconset/icon_512x512.png";

	private static final int MIN_WIDTH = 300;
	private static final int MIN_HEIGHT = 150;

	@Override
	public void start(Stage primaryStage) throws Exception {
		primaryStage.setTitle(DNAINATOR);
		primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(ICON)));
		setDimensions(primaryStage);

		try {
			BorderPane rootLayout = FXMLLoader.load(getClass().getResource(FXML));
			Scene scene = new Scene(rootLayout);
			primaryStage.setScene(scene);
		} catch (IOException e) {
			e.printStackTrace();
		}
		primaryStage.show();
	}

	private void setDimensions(Stage stage) {
		Rectangle2D bounds = Screen.getPrimary().getVisualBounds();

		stage.setMinHeight(MIN_HEIGHT);
		stage.setMinWidth(MIN_WIDTH);
		stage.setWidth(bounds.getWidth());
		stage.setHeight(bounds.getHeight());
		/* Add this for better Windows LAF. */
		stage.setMaximized(true);
	}
}

@@ -1062,39 +1062,8 @@
 )));
-%0A%09%09setDimensions(primaryStage);
 %0A%0A%09%09
@@ -1179,16 +1179,53 @@
 otLayout
+, getScreenWidth(), getScreenHeight()
 );%0A%09%09%09pr
@@ -1348,244 +1348,130 @@
 ate 
-void setDimensions(Stage stage) %7B%0A%09%09Rectangle2D bounds = Screen.getPrimary().getVisualBounds();%0A%0A%09%09stage.setMinHeight(MIN_HEIGHT);%0A%09%09stage.setMinWidth(MIN_WIDTH);%0A%09%09stage.setWidth(bounds.getWidth());%0A%09%09stage.setHeight(bounds.get
+double getScreenWidth() %7B%0A%09%09return Screen.getPrimary().getVisualBounds().getWidth();%0A%09%7D%0A%0A%09private double getScreen
 Height()
 );%0A%09
@@ -1470,81 +1470,73 @@
 ht()
-);%0A%09%09/* Add this for better Windows LAF. */%0A%09%09stage.setMaximized(true
+ %7B%0A%09%09return Screen.getPrimary().getVisualBounds().getHeight(
 );%0A%09%7D%0A
+%0A
 %7D%0A

Fix OSX bug that minimizes screen on startup