Search in sources :

Example 66 with Rectangle2D

use of javafx.geometry.Rectangle2D in project loinc2hpo by monarch-initiative.

the class PopUps method adjustStagePosition.

/**
 * Ensure that popup Stage will be displayed on the same monitor as the parent Stage
 *
 * @param childStage
 * @param parentStage
 * @return
 */
private static Stage adjustStagePosition(Stage childStage, Stage parentStage) {
    ObservableList<Screen> screensForParentWindow = Screen.getScreensForRectangle(parentStage.getX(), parentStage.getY(), parentStage.getWidth(), parentStage.getHeight());
    Screen actual = screensForParentWindow.get(0);
    Rectangle2D bounds = actual.getVisualBounds();
    // set top left position to 35%/25% of screen/monitor width & height
    childStage.setX(bounds.getWidth() * 0.35);
    childStage.setY(bounds.getHeight() * 0.25);
    return childStage;
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Example 67 with Rectangle2D

use of javafx.geometry.Rectangle2D in project jphp by jphp-compiler.

the class DraggableTab method getInsertData.

private InsertData getInsertData(Point2D screenPoint) {
    for (TabPane tabPane : tabPanes) {
        Rectangle2D tabAbsolute = getAbsoluteRect(tabPane);
        if (tabAbsolute.contains(screenPoint)) {
            int tabInsertIndex = 0;
            if (!tabPane.getTabs().isEmpty()) {
                Rectangle2D firstTabRect = getAbsoluteRect(tabPane.getTabs().get(0));
                if (firstTabRect.getMaxY() + 60 < screenPoint.getY() || firstTabRect.getMinY() > screenPoint.getY()) {
                    return null;
                }
                Rectangle2D lastTabRect = getAbsoluteRect(tabPane.getTabs().get(tabPane.getTabs().size() - 1));
                if (screenPoint.getX() < (firstTabRect.getMinX() + firstTabRect.getWidth() / 2)) {
                    tabInsertIndex = 0;
                } else if (screenPoint.getX() > (lastTabRect.getMaxX() - lastTabRect.getWidth() / 2)) {
                    tabInsertIndex = tabPane.getTabs().size();
                } else {
                    for (int i = 0; i < tabPane.getTabs().size() - 1; i++) {
                        Tab leftTab = tabPane.getTabs().get(i);
                        Tab rightTab = tabPane.getTabs().get(i + 1);
                        if (leftTab instanceof DraggableTab && rightTab instanceof DraggableTab) {
                            Rectangle2D leftTabRect = getAbsoluteRect(leftTab);
                            Rectangle2D rightTabRect = getAbsoluteRect(rightTab);
                            if (betweenX(leftTabRect, rightTabRect, screenPoint.getX())) {
                                tabInsertIndex = i + 1;
                                break;
                            }
                        }
                    }
                }
            }
            return new InsertData(tabInsertIndex, tabPane);
        }
    }
    return null;
}
Also used : TabPane(javafx.scene.control.TabPane) Tab(javafx.scene.control.Tab) Rectangle2D(javafx.geometry.Rectangle2D)

Example 68 with Rectangle2D

use of javafx.geometry.Rectangle2D in project jphp by jphp-compiler.

the class CustomStage method reinit.

protected void reinit() {
    Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
    double x = screenBounds.getMinX() + screenBounds.getWidth() - ap.getPrefWidth() - horGap;
    double y = screenBounds.getMinY() + screenBounds.getHeight() - ap.getPrefHeight() - verGap;
    bottomRight = new Location(x, y);
    bottomLeft = new Location(horGap, y);
    topLeft = new Location(horGap, verGap);
    topRight = new Location(x, verGap);
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Example 69 with Rectangle2D

use of javafx.geometry.Rectangle2D in project JFoenix by jfoenixadmin.

the class MainDemo method start.

@Override
public void start(Stage stage) throws Exception {
    new Thread(() -> {
        try {
            SVGGlyphLoader.loadGlyphsFont(MainDemo.class.getResourceAsStream("/fonts/icomoon.svg"), "icomoon.svg");
        } catch (IOException ioExc) {
            ioExc.printStackTrace();
        }
    }).start();
    Flow flow = new Flow(MainController.class);
    DefaultFlowContainer container = new DefaultFlowContainer();
    flowContext = new ViewFlowContext();
    flowContext.register("Stage", stage);
    flow.createHandler(flowContext).start(container);
    JFXDecorator decorator = new JFXDecorator(stage, container.getView());
    decorator.setCustomMaximize(true);
    decorator.setGraphic(new SVGGlyph(""));
    stage.setTitle("JFoenix Demo");
    double width = 800;
    double height = 600;
    try {
        Rectangle2D bounds = Screen.getScreens().get(0).getBounds();
        width = bounds.getWidth() / 2.5;
        height = bounds.getHeight() / 1.35;
    } catch (Exception e) {
    }
    Scene scene = new Scene(decorator, width, height);
    final ObservableList<String> stylesheets = scene.getStylesheets();
    stylesheets.addAll(JFoenixResources.load("css/jfoenix-fonts.css").toExternalForm(), JFoenixResources.load("css/jfoenix-design.css").toExternalForm(), MainDemo.class.getResource("/css/jfoenix-main-demo.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
Also used : DefaultFlowContainer(io.datafx.controller.flow.container.DefaultFlowContainer) ViewFlowContext(io.datafx.controller.flow.context.ViewFlowContext) FXMLViewFlowContext(io.datafx.controller.flow.context.FXMLViewFlowContext) Rectangle2D(javafx.geometry.Rectangle2D) IOException(java.io.IOException) Scene(javafx.scene.Scene) IOException(java.io.IOException) Flow(io.datafx.controller.flow.Flow) JFXDecorator(com.jfoenix.controls.JFXDecorator) SVGGlyph(com.jfoenix.svg.SVGGlyph)

Example 70 with Rectangle2D

use of javafx.geometry.Rectangle2D in project JFoenix by jfoenixadmin.

the class JFXDecorator method maximize.

private void maximize(SVGGlyph resizeMin, SVGGlyph resizeMax) {
    if (!isCustomMaximize()) {
        primaryStage.setMaximized(!primaryStage.isMaximized());
        maximized = primaryStage.isMaximized();
        if (primaryStage.isMaximized()) {
            btnMax.setGraphic(resizeMin);
            btnMax.setTooltip(new Tooltip("Restore Down"));
        } else {
            btnMax.setGraphic(resizeMax);
            btnMax.setTooltip(new Tooltip("Maximize"));
        }
    } else {
        if (!maximized) {
            // store original bounds
            originalBox = new BoundingBox(primaryStage.getX(), primaryStage.getY(), primaryStage.getWidth(), primaryStage.getHeight());
            // get the max stage bounds
            Screen screen = Screen.getScreensForRectangle(primaryStage.getX(), primaryStage.getY(), primaryStage.getWidth(), primaryStage.getHeight()).get(0);
            Rectangle2D bounds = screen.getVisualBounds();
            maximizedBox = new BoundingBox(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
            // maximized the stage
            primaryStage.setX(maximizedBox.getMinX());
            primaryStage.setY(maximizedBox.getMinY());
            primaryStage.setWidth(maximizedBox.getWidth());
            primaryStage.setHeight(maximizedBox.getHeight());
            btnMax.setGraphic(resizeMin);
            btnMax.setTooltip(new Tooltip("Restore Down"));
        } else {
            // restore stage to its original size
            primaryStage.setX(originalBox.getMinX());
            primaryStage.setY(originalBox.getMinY());
            primaryStage.setWidth(originalBox.getWidth());
            primaryStage.setHeight(originalBox.getHeight());
            originalBox = null;
            btnMax.setGraphic(resizeMax);
            btnMax.setTooltip(new Tooltip("Maximize"));
        }
        maximized = !maximized;
    }
}
Also used : Screen(javafx.stage.Screen) Tooltip(javafx.scene.control.Tooltip) BoundingBox(javafx.geometry.BoundingBox) Rectangle2D(javafx.geometry.Rectangle2D)

Aggregations

Rectangle2D (javafx.geometry.Rectangle2D)96 Image (javafx.scene.image.Image)14 Point2D (javafx.geometry.Point2D)13 Scene (javafx.scene.Scene)11 Color (javafx.scene.paint.Color)11 Screen (javafx.stage.Screen)11 List (java.util.List)8 IOException (java.io.IOException)7 Rectangle (javafx.scene.shape.Rectangle)7 Stage (javafx.stage.Stage)7 GameApplication (com.almasb.fxgl.app.GameApplication)6 GameSettings (com.almasb.fxgl.app.GameSettings)6 FXGL (com.almasb.fxgl.dsl.FXGL)6 KeyCode (javafx.scene.input.KeyCode)6 Duration (javafx.util.Duration)6 Interpolators (com.almasb.fxgl.animation.Interpolators)4 FXGLMath (com.almasb.fxgl.core.math.FXGLMath)4 Entity (com.almasb.fxgl.entity.Entity)4 BufferedImage (java.awt.image.BufferedImage)4 Collectors (java.util.stream.Collectors)4