use of io.github.vocabhunter.gui.common.Placement in project VocabHunter by VocabHunter.
the class VocabHunterGui method start.
public void start(final Stage stage) {
Parent root = ViewFxml.MAIN.loadNode(mainLoader);
initialise(stage);
Scene scene = new Scene(root);
scene.setOnKeyPressed(this::handleKeyEvent);
stage.setOnCloseRequest(mainController.getCloseRequestHandler());
Placement placement = placementManager.getMainWindow();
stage.setScene(scene);
stage.setWidth(placement.getWidth());
stage.setHeight(placement.getHeight());
if (placement.isPositioned()) {
stage.setX(placement.getX());
stage.setY(placement.getY());
}
stage.show();
LOG.info("User interface started");
// We delay starting the async filtering to allow the GUI to start quickly
filterSettingsTool.beginAsyncFiltering();
}
use of io.github.vocabhunter.gui.common.Placement in project VocabHunter by VocabHunter.
the class GuiTest method setUp.
@BeforeEach
public void setUp() throws Exception {
when(environmentManager.useSystemMenuBar()).thenReturn(false);
when(environmentManager.isExitOptionShown()).thenReturn(true);
when(placementManager.getMainWindow()).thenReturn(new Placement(WINDOW_WIDTH, WINDOW_HEIGHT));
manager = new TestFileManager(getClass());
Path settingsFile = manager.addFile(SettingsManagerImpl.SETTINGS_JSON);
SettingsManager settingsManager = new SettingsManagerImpl(settingsFile);
Path fileListManagerFile = manager.addFile(FileListManagerImpl.SETTINGS_JSON);
FileListManager fileListManager = new FileListManagerImpl(fileListManagerFile);
CoreGuiModule coreModule = new CoreGuiModule();
Module testModule = new AbstractModule() {
@Override
protected void configure() {
bind(SettingsManager.class).toInstance(settingsManager);
bind(FileListManager.class).toInstance(fileListManager);
bind(FileDialogueFactory.class).toInstance(fileDialogueFactory);
bind(EnvironmentManager.class).toInstance(environmentManager);
bind(PlacementManager.class).toInstance(placementManager);
bind(WebPageTool.class).toInstance(webPageTool);
bind(GuiTaskHandler.class).to(GuiTaskHandlerForTesting.class);
}
};
VocabHunterGuiExecutable.setModules(coreModule, testModule, new StandardEventSourceModule());
setupApplication(VocabHunterGuiExecutable.class);
}
use of io.github.vocabhunter.gui.common.Placement in project VocabHunter by VocabHunter.
the class PlacementManagerTest method testVisibleSettings.
@Test
public void testVisibleSettings() {
when(environmentManager.isVisible(any(Placement.class))).thenReturn(true);
when(settingsManager.getWindowSettings()).thenReturn(Optional.of(windowSettings));
Placement result = target.getMainWindow();
assertEquals(result, new Placement(1, 2, 3, 4), "Visible settings");
}
use of io.github.vocabhunter.gui.common.Placement in project VocabHunter by VocabHunter.
the class PlacementManagerImpl method defaultWindowPlacement.
private Placement defaultWindowPlacement() {
Placement screenSize = environmentManager.getScreenSize();
double width = screenSize.getWidth() * WINDOW_SIZE_FACTOR;
double height = screenSize.getHeight() * WINDOW_SIZE_FACTOR;
return new Placement(width, height);
}
use of io.github.vocabhunter.gui.common.Placement in project VocabHunter by VocabHunter.
the class PlacementManagerTest method testUnspecifiedSettings.
@Test
public void testUnspecifiedSettings() {
when(settingsManager.getWindowSettings()).thenReturn(Optional.empty());
Placement result = target.getMainWindow();
assertEquals(result, DEFAULT_WINDOW_SIZE, "Unspecified settings");
}
Aggregations