use of net.sf.latexdraw.service.PreferencesService in project latexdraw by arnobl.
the class InsertPSTCodeTest method commonCanDoFixture.
@Override
protected void commonCanDoFixture() {
drawing = ShapeFactory.INST.createDrawing();
lang = new PreferencesService().getBundle();
statusBar = new Label();
}
use of net.sf.latexdraw.service.PreferencesService 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.service.PreferencesService in project latexdraw by arnobl.
the class TestMagneticGrid method setUp.
@BeforeEach
void setUp() {
prefW = new SimpleDoubleProperty(100d);
prefH = new SimpleDoubleProperty(50d);
zoom = new SimpleDoubleProperty(1d);
canvas = Mockito.mock(Canvas.class);
Mockito.when(canvas.prefHeightProperty()).thenReturn(prefH);
Mockito.when(canvas.prefWidthProperty()).thenReturn(prefW);
Mockito.when(canvas.getPrefHeight()).thenReturn(50d);
Mockito.when(canvas.getPrefWidth()).thenReturn(100d);
Mockito.when(canvas.getPPCDrawing()).thenReturn(50);
Mockito.when(canvas.zoomProperty()).thenReturn(zoom);
Mockito.when(canvas.getZoom()).thenAnswer(inv -> zoom.get());
prefs = new PreferencesService();
grid = new MagneticGrid(canvas, prefs);
prefs.gridStyleProperty().set(GridStyle.STANDARD);
}
use of net.sf.latexdraw.service.PreferencesService in project latexdraw by arnobl.
the class TestVersionChecker method testCheckVersionNoNewVersion.
@Test
public void testCheckVersionNoNewVersion() throws InterruptedException {
final StatusBarController controller = mock(StatusBarController.class);
final FutureTask<Void> future = new FutureTask<>(new VersionChecker(controller, new PreferencesService().getBundle()), null);
final ExecutorService taskExecutor = Executors.newFixedThreadPool(1);
taskExecutor.execute(future);
taskExecutor.shutdown();
taskExecutor.awaitTermination(5L, TimeUnit.SECONDS);
}
use of net.sf.latexdraw.service.PreferencesService in project latexdraw by arnobl.
the class TestArcStyle method testGetLabel.
@ParameterizedTest
@EnumSource
void testGetLabel(final ArcStyle style) {
final ResourceBundle bundle = new PreferencesService().getBundle();
assertNotNull(style.getLabel(bundle));
assertFalse(style.getLabel(bundle).isEmpty());
}
Aggregations