Example usage for javafx.stage Stage getHeight

List of usage examples for javafx.stage Stage getHeight

Introduction

In this page you can find the example usage for javafx.stage Stage getHeight.

Prototype

public final double getHeight() 

Source Link

Usage

From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java

/**
 * Refreshes the complete layout and returns the bounds of the given
 * Component.//from  w w w  .j  ava 2s  . c o  m
 *
 * @param comp
 *            the Component
 * @param clickOp
 *            not used
 * @return Rectangle with the Bounds
 */
private Rectangle getComponentBounds(final Object comp, ClickOptions clickOp) {

    ComponentHandler.syncStageResize();
    Rectangle bounds = null;
    if (comp instanceof Stage) {
        Stage s = (Stage) comp;
        bounds = new Rectangle(new Point(Rounding.round(s.getX()), Rounding.round(s.getY())));

        // This is not multi display compatible
        Screen screen = Screen.getPrimary();
        final Rectangle2D screenBounds = screen.getBounds();
        int displayWidth = Rounding.round(screenBounds.getWidth());
        int displayHeight = Rounding.round(screenBounds.getHeight());
        if (s.isFullScreen()) {
            bounds.width = Rounding.round(displayWidth);
            bounds.height = Rounding.round(displayHeight);
        } else if (s.isMaximized()) {
            int x = Rounding.round(s.getX());
            int y = Rounding.round(s.getY());
            // trimming the bounds to the display if necessary
            bounds.width = Rounding.round(s.getWidth());
            bounds.height = Rounding.round(s.getHeight());
            if (x < 0 || y < 0) {
                bounds.x = 0;
                bounds.y = 0;
                if (bounds.width > displayWidth) {
                    bounds.width = displayWidth;
                }
                if (bounds.height > displayHeight) {
                    bounds.height = displayHeight;
                }
            }
        } else {
            bounds.width = Rounding.round(s.getWidth());
            bounds.height = Rounding.round(s.getHeight());
        }
    } else {
        final Node node = (Node) comp;
        if (clickOp.isScrollToVisible()) {
            ensureComponentVisible(node);
        }
        bounds = EventThreadQueuerJavaFXImpl.invokeAndWait("Robot get node bounds", new Callable<Rectangle>() { //$NON-NLS-1$

            @Override
            public Rectangle call() throws Exception {
                Rectangle bs = new Rectangle(getLocation(node, new Point(0, 0)));
                Bounds b = node.getBoundsInParent();
                bs.width = Rounding.round(b.getWidth());
                bs.height = Rounding.round(b.getHeight());
                return bs;
            }
        });

    }
    return bounds;
}

From source file:org.jamocha.gui.JamochaGui.java

private void saveState(final Stage primaryStage) {
    final Preferences userPrefs = Preferences.userNodeForPackage(getClass());
    userPrefs.putDouble("stage.x", primaryStage.getX());
    userPrefs.putDouble("stage.y", primaryStage.getY());
    userPrefs.putDouble("stage.width", primaryStage.getWidth());
    userPrefs.putDouble("stage.height", primaryStage.getHeight());
}

From source file:snpviewer.SnpViewer.java

private void fixStageSize(Stage stage, boolean fix) {
    /*provides a fix for annoying bug which means that 
     * setResizable(false) causing windows to grow in size in Windows
     *//*from   w ww. j  a v  a2s .com*/
    if (fix) {
        stage.setMaxHeight(stage.getHeight());
        stage.setMinHeight(stage.getHeight());
        stage.setMaxWidth(stage.getWidth());
        stage.setMinWidth(stage.getWidth());
    } else {
        Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
        stage.setMaxHeight(primaryScreenBounds.getHeight());
        stage.setMinHeight(300);
        stage.setMaxWidth(primaryScreenBounds.getWidth());
        stage.setMinWidth(500);
    }
}