Java Code Examples for javafx.stage.Window#getX()
The following examples show how to use
javafx.stage.Window#getX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DockTools.java From FxDock with Apache License 2.0 | 6 votes |
public static boolean contains(Window w, double screenx, double screeny) { double x = w.getX(); if(screenx < x) { return false; } else if(screenx > (x + w.getWidth())) { return false; } double y = w.getY(); if(screeny < y) { return false; } else if(screeny > (y + w.getHeight())) { return false; } return true; }
Example 2
Source File: JFXPopup.java From JFoenix with Apache License 2.0 | 6 votes |
/** * show the popup according to the specified position with a certain offset * * @param vAlign can be TOP/BOTTOM * @param hAlign can be LEFT/RIGHT * @param initOffsetX on the x axis * @param initOffsetY on the y axis */ public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { if (!isShowing()) { if (node.getScene() == null || node.getScene().getWindow() == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = node.getScene().getWindow(); final Point2D origin = node.localToScene(0, 0); final double anchorX = parent.getX() + origin.getX() + node.getScene().getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0); final double anchorY = parent.getY() + origin.getY() + node.getScene() .getY() + (vAlign == PopupVPosition.BOTTOM ? ((Region) node).getHeight() : 0); this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); } }
Example 3
Source File: DataViewWindow.java From chart-fx with Apache License 2.0 | 5 votes |
private void dragFinish(final MouseEvent mevt) { if (isMinimised() || getParentView() == null || getParentView().getMinimisedChildren().contains(this)) { return; } if (!mouseFilter.test(mevt)) { return; } uninstallCursor(); if (!isDetachableWindow()) { return; } // detach only if window is dragged outside Scene if (getScene() == null) { return; } final Point2D mouseLoc = new Point2D(mevt.getScreenX(), mevt.getScreenY()); final Window window = getScene().getWindow(); final Bounds sceneBounds = new BoundingBox(window.getX(), window.getY(), window.getWidth(), window.getHeight()); final Bounds screenBounds = localToScreen(WindowDecoration.FRAME.equals(getWindowDecoration()) ? this.getBoundsInLocal() : getWindowDecorationBar().getBoundsInLocal()); if (MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, mouseLoc) > MIN_DRAG_BORDER_WIDTH && MouseUtils.mouseOutsideBoundaryBoxDistance(sceneBounds, mouseLoc) > MIN_DRAG_BORDER_WIDTH) { // mouse move outside window and surrounding stage detected -- launch dialog if (!dialog.isShowing()) { dialog.show(this, mevt); return; } dialog.setX(mevt.getScreenX() - xOffset); dialog.setY(mevt.getScreenY() - yOffset); return; } if (!dialog.isShowing()) { return; } dialog.setX(mevt.getScreenX() - xOffset); dialog.setY(mevt.getScreenY() - yOffset); }
Example 4
Source File: LoadDialog.java From Animu-Downloaderu with MIT License | 5 votes |
public static void showDialog(Window owner, String title, Message message) { alert = new Alert(AlertType.NONE); alert.initOwner(owner); alert.setTitle(title); ObservableMap<String, String> messages = message.getMessages(); StringBuilder msg = new StringBuilder(); messages.forEach((key, value) -> msg.append(String.format("%s\t: %s%n", key, value))); alert.getDialogPane().setMinHeight(messages.size() * 30d); alert.setContentText(msg.toString()); // Run with small delay on each change messages.addListener((Change<? extends String, ? extends String> change) -> Platform.runLater(() -> { StringBuilder msgChange = new StringBuilder(); messages.forEach((key, value) -> msgChange.append(String.format("%s\t: %s%n", key, value))); alert.setContentText(msgChange.toString()); if (messages.values().stream().allMatch(val -> val.startsWith(Message.processed))) { stopDialog(); message.clearMessages(); } })); alert.initModality(Modality.APPLICATION_MODAL); alert.getDialogPane().getStylesheets() .add(LoadDialog.class.getResource("/css/application.css").toExternalForm()); // Calculate the center position of the parent Stage double centerXPosition = owner.getX() + owner.getWidth() / 2d; double centerYPosition = owner.getY() + owner.getHeight() / 2d; alert.setOnShowing(e -> { alert.setX(centerXPosition - alert.getDialogPane().getWidth() / 2d); alert.setY(centerYPosition - alert.getDialogPane().getHeight() / 2d); }); alert.show(); }
Example 5
Source File: FX.java From FxDock with Apache License 2.0 | 5 votes |
/** * returns margin between the node and its containing window. * WARNING: does not check if window is indeed a right one. */ public static Insets getInsetsInWindow(Window w, Node n) { Bounds b = n.localToScreen(n.getBoundsInLocal()); double left = b.getMinX() - w.getX(); double top = b.getMinY() - w.getY(); double right = w.getX() + w.getWidth() - b.getMaxX(); double bottom = w.getY() + w.getHeight() - b.getMaxY(); return new Insets(top, right, bottom, left); }
Example 6
Source File: FxDialog.java From FxDock with Apache License 2.0 | 5 votes |
public FxDialog(Object owner, String name) { super(name); initModality(Modality.APPLICATION_MODAL); Window win = FX.getParentWindow(owner); initOwner(win); // TODO center around parent window, but not outside of the current device double x = win.getX(); double y = win.getY(); double w = win.getWidth(); double h = win.getHeight(); }
Example 7
Source File: JFXPopup.java From JFoenix with Apache License 2.0 | 5 votes |
public void show(Window window, double x, double y, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { if (!isShowing()) { if (window == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = window; final double anchorX = parent.getX() + x + initOffsetX; final double anchorY = parent.getY() + y + initOffsetY; this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); } }
Example 8
Source File: DockItemRepresentation.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@Override public ToolkitRepresentation<Parent, Node> openNewWindow(final DisplayModel model, final Consumer<DisplayModel> close_handler) { // If a display has already been opened, reuse it by bringing it to the front. DockItemWithInput existing = DockStage.getDockItemWithInput(DisplayRuntimeApplication.NAME, DisplayInfo.forModel(model).toURI()); if(existing != null){ DisplayRuntimeInstance instance = existing.getApplication(); instance.raise(); return instance.getRepresentation(); } // Open new Stage final Stage new_stage = new Stage(); // Configure for docking, i.e. with DockPane DockStage.configureStage(new_stage); // Use location and size from model for the window double x = model.propX().getValue(); double y = model.propY().getValue(); if (x <= 0.0 && y <= 0.0) { // .. unless that's (0, 0), i.e. very likely nobody bothered to set it. // In that case, open new window close to the current window final DockPane parent = app_instance.getDockItem().getDockPane(); if (parent != null && parent.getScene() != null && parent.getScene().getWindow() != null) { Window window = parent.getScene().getWindow(); x = window.getX(); y = window.getY(); } } new_stage.setX(x); new_stage.setY(y); // Size needs to account for the border and toolbar. // Using fixed numbers, exact size of border and toolbar unknown // at this time in the code new_stage.setWidth(model.propWidth().getValue() + 20); new_stage.setHeight(model.propHeight().getValue() + 70); new_stage.show(); // New DockPane is now the 'active' one, // model will be opened in it. return representModelInNewDockItem(model); }
Example 9
Source File: DockStation.java From AnchorFX with GNU Lesser General Public License v3.0 | 4 votes |
public boolean isInnerPosition(double x, double y) { Window window = getStationWindow(); Rectangle bounds = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight()); return bounds.contains(x, y); }
Example 10
Source File: CaptureController.java From logbook-kai with MIT License | 4 votes |
private GraphicsConfiguration currentGraphicsConfiguration() { Window window = this.getWindow(); int x = (int) window.getX(); int y = (int) window.getY(); return ScreenCapture.detectScreenDevice(x, y); }
Example 11
Source File: JFXTooltip.java From JFoenix with Apache License 2.0 | 2 votes |
/** * @param ownerNode * @param sceneBounds is the owner node scene Bounds * @return anchorX that represents the local minX of owner node */ private double ownerX(Node ownerNode, Bounds sceneBounds) { Window parent = ownerNode.getScene().getWindow(); return parent.getX() + sceneBounds.getMinX() + ownerNode.getScene().getX(); }