/*
* Copyright 2015 Sudipto Chandra.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sandsoft.cymric;
import org.sandsoft.cymric.model.CymricCore;
import org.sandsoft.cymric.startup.StartupWizard;
import org.sandsoft.cymric.util.Resources;
import org.sandsoft.cymric.view.RootLayout;
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
* Main entry point of the application.
*
* @author Sudipto Chandra
*/
public class Launcher extends Application {
/**
* Start point of the application.
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
//private controls
private CymricCore mCore;
/**
* constructor of the class. gets called before start()
*/
public Launcher() {
initializeGlobals();
}
/**
* Initializes some global or static values
*/
private void initializeGlobals() {
}
//this is called after the constructor
@Override
public void start(Stage stage) throws Exception {
//create core objects
mCore = new CymricCore(stage);
//create a new scene
Parent node = getParentNode();
Scene scene = new Scene(node,
node.prefWidth(Cymric.DEFAULT_WIDTH),
node.prefHeight(Cymric.DEFAULT_HEIGHT));
//set theme
scene.getStylesheets().add(Resources.getDefaultTheme());
//show stage
stage.setScene(scene);
stage.setTitle(Cymric.WINDOW_TITLE);
stage.getIcons().add(Resources.getMainIcon(Cymric.WINDOW_ICON_SIZE));
stage.centerOnScreen();
stage.show();
}
/**
* Gets the node that should be used as a parent.
*
* @return the parent node.
*/
private Parent getParentNode() {
if (mCore.getAppSettings().getWorkingPath() != null) {
return RootLayout.createNew(mCore);
} else {
return StartupWizard.createNew(mCore);
}
}
}