Package javafx.geometry

Examples of javafx.geometry.Rectangle2D


        return scene;
    }

    public void centerOnScreen() {
        Screen primary = Screen.getPrimary();
        Rectangle2D bounds = primary.getVisualBounds();
        double width = getScene().getStage().getWidth();
        double height = getScene().getStage().getHeight();
        double x = bounds.getMinX() + (bounds.getWidth() - width) / 2d;
        double y = bounds.getMinY() + (bounds.getHeight() - height) / 2d;

        getScene().getWindow().setX(x);
        getScene().getWindow().setY(y);
    }
View Full Code Here


            maxX = Math.max(maxX, screen.getVisualBounds().getMaxX());
            maxY = Math.max(maxY, screen.getVisualBounds().getMaxY());
        }

        Rectangle2D bounds = getScreenBounds(primaryMoveNode);
        Rectangle2D valid = bounds;
        if (!isValidBounds(bounds)) {
            if (bounds.getMinY() < minY || bounds.getMaxY() > maxY) {
                int dir = 1;
                if (bounds.getMaxY() > maxY) {
                    dir = -1;
                }
                for (double y = minX; y <= maxY && y >= minY; y += dir) {
                    Rectangle2D test = cloneRect(bounds, null, y, null, null);
                    if (isValidBounds(test)) {
                        valid = test;
                    }
                }
            }
View Full Code Here

        ObservableList<Screen> screens = Screen.getScreensForRectangle(bounds);
        if (screens.size() == 0) {
            return false;
        }
        for (Screen screen : Screen.getScreensForRectangle(bounds)) {
            Rectangle2D vis = screen.getVisualBounds();
            if (bounds.getMinY() < vis.getMinY() || bounds.getMaxY() > vis.getMaxY()) {
                return false;
            }
        }
        return true;
    }
View Full Code Here

        Point2D scenepos = node.localToScene(0, 0);

        windowX += scenepos.getX();
        windowY += scenepos.getY();

        return new Rectangle2D(windowX, windowY, node.getLayoutBounds().getWidth(), node.getLayoutBounds().getHeight());
    }
View Full Code Here

        return new Rectangle2D(windowX, windowY, node.getLayoutBounds().getWidth(), node.getLayoutBounds().getHeight());
    }

    private static Rectangle2D cloneRect(Rectangle2D c, Double x, Double y, Double width, Double height) {
        return new Rectangle2D(x != null ? x : c.getMinX(), y != null ? y : c.getMinY(), width != null ? width : c.getWidth(), height != null ? height : c.getHeight());
    }
View Full Code Here

                double stageY = getScene().getWindow().getY();

                stageX += delta.getX();
                stageY += delta.getY();

                Rectangle2D newBounds = new Rectangle2D(stageX, stageY, getScene().getWindow().getWidth(), getScene().getWindow().getHeight());

                // check screen bounds
                for (Screen screen : Screen.getScreensForRectangle(newBounds)) {
                    // Limit dragging over menu bar
                    if (screen.getVisualBounds().equals(Screen.getPrimary().getVisualBounds())
View Full Code Here

        decorateStage(initialStage);

        Scene splashScene = new Scene(splashLayout);
        initialStage.initStyle(StageStyle.UNDECORATED);
        final Rectangle2D bounds = Screen.getPrimary().getBounds();
        initialStage.setScene(splashScene);
        initialStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2);
        initialStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2);
        initialStage.show();
    }
View Full Code Here

    @FXML
    private void maximize(Event event) {

        // Change stage properties
        Rectangle2D bounds = Screen.getPrimary().getVisualBounds();

        if (bounds.getHeight() == stage.getHeight() && bounds.getWidth() == stage.getWidth()) {
            stage.setX(50);
            stage.setY(50);
            stage.setWidth(bounds.getWidth() * 0.8);
            stage.setHeight(bounds.getHeight() * 0.8);
        } else {
            stage.setX(bounds.getMinX());
            stage.setY(bounds.getMinY());
            stage.setWidth(bounds.getWidth());
            stage.setHeight(bounds.getHeight());
        }
    }
View Full Code Here

        }
    }

    public static void setFullscreen(Stage stage) {
        Screen screen = Screen.getPrimary();
        Rectangle2D bounds = screen.getVisualBounds();

        stage.setX(bounds.getMinX());
        stage.setY(bounds.getMinY());
        stage.setWidth(bounds.getWidth());
        stage.setHeight(bounds.getHeight());
    }
View Full Code Here

        if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
            scene.setCursor(Cursor.NONE);
        }

        Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
        double factor = Math.min(visualBounds.getWidth() / (gameBounds.getWidth() + MARGIN),
                visualBounds.getHeight() / (gameBounds.getHeight() + MARGIN));
        primaryStage.setTitle("2048FX");
        primaryStage.setScene(scene);
        primaryStage.setMinWidth(gameBounds.getWidth() / 2d);
        primaryStage.setMinHeight(gameBounds.getHeight() / 2d);
        primaryStage.setWidth((gameBounds.getWidth() + MARGIN) * factor);
 
View Full Code Here

TOP

Related Classes of javafx.geometry.Rectangle2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.