Package javafx.geometry

Examples of javafx.geometry.Rectangle2D


            savedBounds = null;
            maximized = false;
        } else {
            ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            Screen screen = screensForRectangle.get(0);
            Rectangle2D visualBounds = screen.getVisualBounds();

            savedBounds = new BoundingBox(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());

            undecorator.setShadow(false);

            stage.setX(visualBounds.getMinX());
            stage.setY(visualBounds.getMinY());
            stage.setWidth(visualBounds.getWidth());
            stage.setHeight(visualBounds.getHeight());
            maximized = true;
        }
    }
View Full Code Here


    void setStageY(Stage stage, double y) {
        try {
            ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            if (screensForRectangle.size() > 0) {
                Screen screen = screensForRectangle.get(0);
                Rectangle2D visualBounds = screen.getVisualBounds();
                if (y < visualBounds.getHeight() - 30 && y + SHADOW_WIDTH >= visualBounds.getMinY()) {
                    stage.setY(y);
                }
            }
        } catch (Exception e) {
            Undecorator.LOGGER.log(Level.SEVERE, "setStageY issue", e);
View Full Code Here

            if (lastDocked == DOCK_LEFT) {
                return;
            }
            ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            Screen screen = screensForRectangle.get(0);
            Rectangle2D visualBounds = screen.getVisualBounds();
            // Dock Left
            double x = visualBounds.getMinX();
            double y = visualBounds.getMinY();
            double width = visualBounds.getWidth() / 2;
            double height = visualBounds.getHeight();

            undecorator.setDockFeedbackVisible(x, y, width, height);
            lastDocked = DOCK_LEFT;
        } // Dock Right
        else if (dockSide == DOCK_RIGHT) {
            if (lastDocked == DOCK_RIGHT) {
                return;
            }
            ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            Screen screen = screensForRectangle.get(0);
            Rectangle2D visualBounds = screen.getVisualBounds();
            // Dock Right (visualBounds = (javafx.geometry.Rectangle2D) Rectangle2D [minX = 1440.0, minY=300.0, maxX=3360.0, maxY=1500.0, width=1920.0, height=1200.0])
            double x = visualBounds.getMinX() + visualBounds.getWidth() / 2;
            double y = visualBounds.getMinY();
            double width = visualBounds.getWidth() / 2;
            double height = visualBounds.getHeight();

            undecorator.setDockFeedbackVisible(x, y, width, height);
            lastDocked = DOCK_RIGHT;
        } // Dock top
        else if (dockSide == DOCK_TOP) {
            if (lastDocked == DOCK_TOP) {
                return;
            }
            ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            Screen screen = screensForRectangle.get(0);
            Rectangle2D visualBounds = screen.getVisualBounds();
            // Dock Left
            double x = visualBounds.getMinX();
            double y = visualBounds.getMinY();
            double width = visualBounds.getWidth();
            double height = visualBounds.getHeight();
            undecorator.setDockFeedbackVisible(x, y, width, height);
            lastDocked = DOCK_TOP;
        } else {
            undecorator.setDockFeedbackInvisible();
            lastDocked = DOCK_NONE;
View Full Code Here

        double maxY = 0;

        // Get "big" screen bounds
        ObservableList<Screen> screens = Screen.getScreens();
        for (Screen screen : screens) {
            Rectangle2D visualBounds = screen.getVisualBounds();
            minX = Math.min(minX, visualBounds.getMinX());
            minY = Math.min(minY, visualBounds.getMinY());
            maxX = Math.max(maxX, visualBounds.getMaxX());
            maxY = Math.max(maxY, visualBounds.getMaxY());
        }
        // Dock Left
        if (mouseEvent.getScreenX() == minX) {
            return DOCK_LEFT;
        } else if (mouseEvent.getScreenX() >= maxX - 1) { // MaxX returns the width? Not width -1 ?!
View Full Code Here

     * (Humble) Simulation of Windows behavior on screen's edges Actions
     */
    void dockActions(Stage stage, MouseEvent mouseEvent) {
        ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
        Screen screen = screensForRectangle.get(0);
        Rectangle2D visualBounds = screen.getVisualBounds();
        // Dock Left
        if (mouseEvent.getScreenX() == visualBounds.getMinX()) {
            savedBounds = new BoundingBox(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());

            stage.setX(visualBounds.getMinX());
            stage.setY(visualBounds.getMinY());
            // Respect Stage Max size
            double width = visualBounds.getWidth() / 2;
            if (stage.getMaxWidth() < width) {
                width = stage.getMaxWidth();
            }

            stage.setWidth(width);

            double height = visualBounds.getHeight();
            if (stage.getMaxHeight() < height) {
                height = stage.getMaxHeight();
            }

            stage.setHeight(height);
            undecorator.setShadow(false);
        } // Dock Right (visualBounds = [minX = 1440.0, minY=300.0, maxX=3360.0, maxY=1500.0, width=1920.0, height=1200.0])
        else if (mouseEvent.getScreenX() >= visualBounds.getMaxX() - 1) { // MaxX returns the width? Not width -1 ?!
            savedBounds = new BoundingBox(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());

            stage.setX(visualBounds.getWidth() / 2 + visualBounds.getMinX());
            stage.setY(visualBounds.getMinY());
            // Respect Stage Max size
            double width = visualBounds.getWidth() / 2;
            if (stage.getMaxWidth() < width) {
                width = stage.getMaxWidth();
            }

            stage.setWidth(width);

            double height = visualBounds.getHeight();
            if (stage.getMaxHeight() < height) {
                height = stage.getMaxHeight();
            }

            stage.setHeight(height);
            undecorator.setShadow(false);
        } else if (mouseEvent.getScreenY() <= visualBounds.getMinY()) { // Mac menu bar
            undecorator.maximizeProperty.set(true);
        }

    }
View Full Code Here

        });

        snapShotButton.setOnAction((ActionEvent event) -> {
            //take snapshot
            final SnapshotParameters snapshotParameters = new SnapshotParameters();
            snapshotParameters.setViewport(new Rectangle2D(visualization.getBoundsInParent().getMinX(), visualization.getBoundsInParent().getMinY(),
                                                           visualization.getBoundsInParent().getWidth(),
                                                           contextPane.getLayoutBounds().getHeight() + visualization.getLayoutBounds().getHeight() + partPane.getLayoutBounds().getHeight()
            ));
            WritableImage snapshot = this.snapshot(snapshotParameters, null);
            //pass snapshot to save action
View Full Code Here

  @FXML
  public void handleMax(ActionEvent event) {
    Stage stage = getStage();
    final double stageY = stage.getY();
        final Screen screen = Screen.getScreensForRectangle(stage.getX(), stageY, 1, 1).get(0);
        Rectangle2D bounds = screen.getVisualBounds();
        if (bounds.getMinX() == stage.getX() && bounds.getMinY() == stageY &&
                bounds.getWidth() == stage.getWidth() && bounds.getHeight() == stage.getHeight()) {
            if (backupWindowBounds != null) {
                stage.setX(backupWindowBounds.getMinX());
                stage.setY(backupWindowBounds.getMinY());
                stage.setWidth(backupWindowBounds.getWidth());
                stage.setHeight(backupWindowBounds.getHeight());
            }
        } else {
            backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            final double newStageY = screen.getVisualBounds().getMinY();
            stage.setX(screen.getVisualBounds().getMinX());
            stage.setY(newStageY);
            stage.setWidth(screen.getVisualBounds().getWidth());
            stage.setHeight(screen.getVisualBounds().getHeight());
View Full Code Here

 
  public void handleMax(ActionEvent event) {
    Stage stage = getStage();
    final double stageY = stage.getY();
        final Screen screen = Screen.getScreensForRectangle(stage.getX(), stageY, 1, 1).get(0);
        Rectangle2D bounds = screen.getVisualBounds();
        if (bounds.getMinX() == stage.getX() && bounds.getMinY() == stageY &&
                bounds.getWidth() == stage.getWidth() && bounds.getHeight() == stage.getHeight()) {
            if (backupWindowBounds != null) {
                stage.setX(backupWindowBounds.getMinX());
                stage.setY(backupWindowBounds.getMinY());
                stage.setWidth(backupWindowBounds.getWidth());
                stage.setHeight(backupWindowBounds.getHeight());
            }
        } else {
            backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
            final double newStageY = screen.getVisualBounds().getMinY();
            stage.setX(screen.getVisualBounds().getMinX());
            stage.setY(newStageY);
            stage.setWidth(screen.getVisualBounds().getWidth());
            stage.setHeight(screen.getVisualBounds().getHeight());
View Full Code Here

  public void handleMax(ActionEvent event) {
    Stage stage = getStage();
    final double stageY = stage.getY();
    final Screen screen = Screen.getScreensForRectangle(stage.getX(), stageY, 1, 1).get(0);
    Rectangle2D bounds = screen.getVisualBounds();
    if (bounds.getMinX() == stage.getX() && bounds.getMinY() == stageY && bounds.getWidth() == stage.getWidth()
        && bounds.getHeight() == stage.getHeight()) {
      if (backupWindowBounds != null) {
        stage.setX(backupWindowBounds.getMinX());
        stage.setY(backupWindowBounds.getMinY());
        stage.setWidth(backupWindowBounds.getWidth());
        stage.setHeight(backupWindowBounds.getHeight());
      }
    } else {
      backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
      final double newStageY = screen.getVisualBounds().getMinY();
      stage.setX(screen.getVisualBounds().getMinX());
      stage.setY(newStageY);
      stage.setWidth(screen.getVisualBounds().getWidth());
      stage.setHeight(screen.getVisualBounds().getHeight());
View Full Code Here

                      screen = Screen.getScreensForRectangle(stage.getX(), stage.getY(), 1, 1).get(0);
                  }
                  else {
                      screen = Screen.getScreensForRectangle(0,0,1,1).get(0);
                  }
                  Rectangle2D visualBounds = screen.getVisualBounds();            
                  double maxX = Math.min(visualBounds.getMaxX(), e.getScreenX() + dragOffsetX);
                  double maxY = Math.min(visualBounds.getMaxY(), e.getScreenY() - dragOffsetY);
                  stage.setWidth(Math.max(stageMinimumWidth, maxX - stage.getX()));
                  stage.setHeight(Math.max(stageMinimumHeight, maxY - stage.getY()));
                  e.consume();
              }
          });
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.