Example usage for javafx.geometry Rectangle2D getMinX

List of usage examples for javafx.geometry Rectangle2D getMinX

Introduction

In this page you can find the example usage for javafx.geometry Rectangle2D getMinX.

Prototype

public double getMinX() 

Source Link

Document

The x coordinate of the upper-left corner of this Rectangle2D .

Usage

From source file:org.jevis.jeconfig.JEConfig.java

/**
 * maximized the given stage/*from w  ww .  ja v a 2 s  .  c o  m*/
 *
 * @param primaryStage
 */
public static void maximize(Stage primaryStage) {
    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);//from   w  w w  .  j  a  v  a2s . c om

    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();

    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());

    stage.show();

}

From source file:wpdisplaytest.WPDisplayTest.java

private void moveToSecondaryIfExists(Stage stage) {
    Screen secondary;/*from  w  ww  . j ava  2  s . c  o m*/
    try {
        secondary = Screen.getScreens().stream().filter(E -> {
            return !E.equals(Screen.getPrimary());
        }).findFirst().get();
        Rectangle2D bounds = secondary.getVisualBounds();
        stage.setX(bounds.getMinX());
        stage.setY(bounds.getMinY());
        stage.centerOnScreen();
    } catch (NoSuchElementException ex) {
        //There is no secondary viewport, fail silently
    }

}

From source file:qupath.lib.gui.plots.ScatterPlot.java

public void drawPlot(GraphicsContext g, Rectangle2D region, int maxPoints) {

    g.save();/*from ww w .jav  a 2s .c  o m*/

    g.beginPath();
    g.moveTo(region.getMinX(), region.getMinY());
    g.lineTo(region.getMaxX(), region.getMinY());
    g.lineTo(region.getMaxX(), region.getMaxY());
    g.lineTo(region.getMinX(), region.getMaxY());
    g.closePath();
    g.clip();

    //      int pad = 10;
    double scaleX = region.getWidth() / (maxX - minX);
    double scaleY = region.getHeight() / (maxY - minY);

    g.setLineWidth(1.5f);

    //      g.setStroke(javafx.scene.paint.Color.GRAY);
    //      g.strokeRect(region.getX(), region.getY(), region.getWidth(), region.getHeight());

    g.translate(region.getMinX(), region.getMinY());

    //      g2d.drawLine(0, 0, 0, region.height);
    //      g2d.drawLine(0, region.height, region.width, region.height);

    double increment;
    if (maxPoints < 0 || x.length <= maxPoints)
        increment = 1;
    else
        increment = (double) x.length / maxPoints;

    for (double i = 0; i < x.length; i += increment) {
        int ind = (int) i;
        double xx = x[ind];
        double yy = y[ind];
        //         // Skip if out of range
        //         if (xx < minX || xx > maxX || yy < minY || yy > maxY)
        //            continue;

        double xo = (xx - minX) * scaleX - markerSize / 2;
        double yo = region.getHeight() - (yy - minY) * scaleY - markerSize / 2;

        Color cDraw = colorDraw == null ? null : colorDraw[ind];
        if (fillMarkers) {
            Color cFill = colorFill[ind] == null ? cDraw : colorFill[ind];
            if (cFill != null) {
                g.setFill(cFill);
                g.fillOval(xo, yo, markerSize, markerSize);
                // Don't need to draw if it would be the same color anyway
                if (cFill == cDraw)
                    continue;
            }
        }
        if (cDraw != null) {
            g.setStroke(cDraw);
            g.strokeOval(xo, yo, markerSize, markerSize);
        }
    }

    g.restore();
}

From source file:de.ks.text.AsciiDocEditor.java

@FXML
void showPreviewPopup() {
    if (previewPopupStage == null) {
        String title = Localized.get("adoc.preview");

        previewPopupStage = new Stage();
        previewPopupStage.setTitle(title);
        Scene scene = new Scene(new StackPane(popupPreviewNode));
        scene.setOnKeyReleased(e -> {
            if (e.getCode() == KeyCode.ESCAPE) {
                previewPopupStage.close();
            }//from w  ww.j  a va 2 s .  c o m
        });
        previewPopupStage.setScene(scene);

        Rectangle2D bounds = new ScreenResolver().getScreenToShow().getBounds();
        previewPopupStage.setX(bounds.getMinX());
        previewPopupStage.setY(bounds.getMinY());
        previewPopupStage.setWidth(bounds.getWidth());
        previewPopupStage.setHeight(bounds.getHeight());

        previewPopupStage.initModality(Modality.NONE);
        previewPopupStage.setOnShowing(e -> {
            popupPreview.showDirect(getText());
        });
        previewPopupStage.setOnCloseRequest(e -> this.previewPopupStage = null);
        previewPopupStage.show();
    }
}

From source file:Main.java

@Override
public void start(Stage stage) {
    BorderPane root = new BorderPane();

    Pane parentContainer = new Pane();
    parentContainer.setPrefSize(500, 500);
    parentContainer.setPickOnBounds(false);

    //Pane parent = new Pane();
    Group parent = new Group();
    boundsLayoutNode = parent;//from   w ww  . jav  a  2  s  .com
    //parent.setPrefSize(300, 200);
    parent.setLayoutX(200);
    parent.setLayoutY(200);
    parent.setStyle("-fx-background-color:white;");
    parent.getChildren().addAll(new Group(localXAxisGroup, localYAxisGroup),
            new Group(parentXAxisGroup, parentYAxisGroup),
            new Group(parentBoundsRect, PARENT_BOUNDS_PATH_CIRCLE),
            new Group(localBoundsRect, LOCAL_BOUNDS_PATH_CIRCLE),
            new Group(layoutBoundsRect, LAYOUT_BOUNDS_PATH_CIRCLE), new Group(mainRect));

    parentContainer.getChildren().addAll(parent);

    VBox transformsControls = getTransformationControls();
    VBox resultsControls = getResultsControls();

    BorderPane nestedPane = new BorderPane();
    nestedPane.setCenter(parentContainer);
    nestedPane.setBottom(resultsControls);
    //nestedPane.setTop(printDataTextArea);
    //printDataTextArea.setPrefColumnCount(40);
    //printDataTextArea.setPrefRowCount(3);
    root.setCenter(nestedPane);

    root.setRight(transformsControls);
    //root.setBottom(resultsControls);
    //root.setCenter(parentContainer);

    // Attach event handlers
    attachEventHandlers();

    Scene scene = new Scene(root); //, 600, 400);
    stage.setScene(scene);
    stage.setTitle("Bounds of a Node");
    Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(visualBounds.getMinX());
    stage.setY(visualBounds.getMinY());
    stage.setWidth(visualBounds.getWidth());
    stage.setHeight(visualBounds.getHeight());
    stage.show();

    // Make sure everything is in sync
    relayout();
}