package eu.simstadt.regionchooser;

import java.time.LocalDate;
import java.util.Objects;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;


public class RegionChooserFX extends Application
{
	/**
	 * Starting point of RegionChooser application. Either "Run as Java" from Eclipse or run
	 * "RegionChooser.bat/.sh/.command" from deployed SimStadt folder.
	 * 
	 * This application is basically just a scene and a browser for the RegionChooser website (HTML + Javascript frontend
	 * + Java backend). The Java part is written in RegionChooserBrowser.
	 */
	@Override
	public void start(Stage stage) {
		stage.setTitle("RegionChooser " + getApplicationVersion());
		Scene scene = new Scene(new RegionChooserBrowser(), 1024, 720, Color.web("#666970"));
		stage.setScene(scene);
		stage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}

	/**
	 * Returns application version, if it has been written in the JAR file during deployment.
	 * 
	 * e.g. "0.9.1-SNAPSHOT (rev. 73cbe48e, 2018-07-20)"
	 */
	private String getApplicationVersion() {
		Package regionChooserJar = RegionChooserFX.class.getPackage();
		return Objects.toString(regionChooserJar.getImplementationVersion(),
				String.format("development version (%s)", LocalDate.now()));
	}
}

