use of net.sf.latexdraw.model.api.shape.Drawing in project latexdraw by arnobl.
the class LaTeXDraw method start.
@Override
public void start(final Stage stage) {
final Task<Void> task = new Task<>() {
@Override
protected Void call() throws IOException {
updateProgress(0.1, 1d);
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> {
mainStage = new Stage(StageStyle.DECORATED);
mainStage.setIconified(true);
injector = new LatexdrawInjector(LaTeXDraw.this);
latch.countDown();
});
// We need to wait for the javafx thread to perform its job before loading the UI (because of the injector).
try {
latch.await();
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
throw new RuntimeException(ex);
}
final PreferencesService prefs = injector.getInstance(PreferencesService.class);
prefs.readPreferences();
final Parent root = // NON-NLS
FXMLLoader.load(// NON-NLS
getClass().getResource("/fxml/UI.fxml"), // NON-NLS
prefs.getBundle(), injector.getInstance(BuilderFactory.class), cl -> injector.getInstance(cl));
updateProgress(0.6, 1d);
final Scene scene = new Scene(root);
updateProgress(0.7, 1d);
// NON-NLS
scene.getStylesheets().add("css/style.css");
// Binding the title of the app on the title of the drawing.
mainStage.titleProperty().bind(injector.getInstance(Drawing.class).titleProperty().concat(" -- " + LABEL_APP));
updateProgress(0.8, 1d);
Platform.runLater(() -> {
mainStage.setScene(scene);
updateProgress(0.9, 1d);
setModified(false);
mainStage.show();
registerScene(scene);
// Preventing the stage to close automatically.
mainStage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, WindowEvent::consume);
// NON-NLS
mainStage.getIcons().add(new Image("/res/LaTeXDrawIcon.png"));
mainStage.centerOnScreen();
injector.getInstance(TabSelector.class).centreViewport();
injector.getInstance(Canvas.class).requestFocus();
// Checking a new version if required.
if (VersionChecker.WITH_UPDATE && injector.getInstance(PreferencesSetter.class).isVersionCheckEnable()) {
new Thread(new VersionChecker(injector.getInstance(StatusBarController.class), prefs.getBundle())).start();
}
setModified(false);
});
return null;
}
};
task.setOnFailed(BadaboomCollector.INSTANCE);
showSplash(stage, task);
new Thread(task).start();
}
use of net.sf.latexdraw.model.api.shape.Drawing in project latexdraw by arnobl.
the class TestMetaShapeCustomiser method testActivatedOnSelectionRemoval.
@Test
public void testActivatedOnSelectionRemoval() {
Mockito.when(injector.getInstance(Hand.class).isActivated()).thenReturn(true);
meta.initialize(null, null);
final Drawing dr = injector.getInstance(Drawing.class);
dr.getSelection().addShape(ShapeFactory.INST.createRectangle());
dr.getSelection().removeShape(0);
assertFalse(meta.isActivated());
}
Aggregations