Search in sources :

Example 1 with Placement

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();
}
Also used : Parent(javafx.scene.Parent) Placement(io.github.vocabhunter.gui.common.Placement) Scene(javafx.scene.Scene)

Example 2 with Placement

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);
}
Also used : Path(java.nio.file.Path) WebPageTool(io.github.vocabhunter.gui.services.WebPageTool) SettingsManagerImpl(io.github.vocabhunter.gui.settings.SettingsManagerImpl) EnvironmentManager(io.github.vocabhunter.gui.services.EnvironmentManager) SettingsManager(io.github.vocabhunter.gui.settings.SettingsManager) TestFileManager(io.github.vocabhunter.test.utils.TestFileManager) FileListManagerImpl(io.github.vocabhunter.analysis.settings.FileListManagerImpl) FileDialogueFactory(io.github.vocabhunter.gui.dialogues.FileDialogueFactory) AbstractModule(com.google.inject.AbstractModule) FileListManager(io.github.vocabhunter.analysis.settings.FileListManager) PlacementManager(io.github.vocabhunter.gui.services.PlacementManager) Placement(io.github.vocabhunter.gui.common.Placement) GuiTaskHandler(io.github.vocabhunter.analysis.core.GuiTaskHandler) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Placement

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");
}
Also used : Placement(io.github.vocabhunter.gui.common.Placement) Test(org.junit.jupiter.api.Test)

Example 4 with Placement

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);
}
Also used : Placement(io.github.vocabhunter.gui.common.Placement)

Example 5 with Placement

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");
}
Also used : Placement(io.github.vocabhunter.gui.common.Placement) Test(org.junit.jupiter.api.Test)

Aggregations

Placement (io.github.vocabhunter.gui.common.Placement)6 Test (org.junit.jupiter.api.Test)3 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 GuiTaskHandler (io.github.vocabhunter.analysis.core.GuiTaskHandler)1 FileListManager (io.github.vocabhunter.analysis.settings.FileListManager)1 FileListManagerImpl (io.github.vocabhunter.analysis.settings.FileListManagerImpl)1 FileDialogueFactory (io.github.vocabhunter.gui.dialogues.FileDialogueFactory)1 EnvironmentManager (io.github.vocabhunter.gui.services.EnvironmentManager)1 PlacementManager (io.github.vocabhunter.gui.services.PlacementManager)1 WebPageTool (io.github.vocabhunter.gui.services.WebPageTool)1 SettingsManager (io.github.vocabhunter.gui.settings.SettingsManager)1 SettingsManagerImpl (io.github.vocabhunter.gui.settings.SettingsManagerImpl)1 TestFileManager (io.github.vocabhunter.test.utils.TestFileManager)1 Path (java.nio.file.Path)1 Parent (javafx.scene.Parent)1 Scene (javafx.scene.Scene)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1