Newer
Older
package org.josast.UVSQsatDecoder;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Logger;
/**
* JavaFX App
*/
public class App extends Application {
private static Scene scene;
private static FXMLLoader fxmlLoader;
private static Logger logger = Logger.getLogger("AmsatLogger");
@Override
public void start(Stage stage) throws IOException {
System.setProperty("glass.accessible.force", "false");
scene = new Scene(loadFXML("UVSQsat"), 800, 600);
stage.setScene(scene);
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
Platform.exit();
System.exit(0);
}
});
Controler ctrl = fxmlLoader.getController();
ctrl.setPrimaryStage(stage);
scene.getStylesheets().add(this.getClass().getResource("boot.css").toExternalForm());
stage.setTitle("UVSQsat Decoder - "+ctrl.getversion());
stage.getIcons().add(new Image(App.class.getResourceAsStream("OIP.jpg")));
ctrl.initMMI();
stage.show();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
logger.info("class "+App.class.getResource(fxml + ".fxml").getFile().toString());
public static void main(String[] args) {
// initialisation du systéme de log en premier
try {
String path = System.getProperty("user.dir") + "/log";
File apath = new File(path);
if (!apath.exists()) {
if (apath.mkdir() == false) {
logger.severe("fail to create " + path);
}
}
FileHandler fh = new FileHandler(path + "/" + "UVSQsat.log");
logger.setUseParentHandlers(false);
Handler[] handlers = logger.getHandlers();
for (Handler handler : handlers) {
logger.removeHandler(handler);
}
logger.addHandler(fh);
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
launch();
}
}