public void show(Node node){ 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(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + ((Region)node).getHeight()); ((JFXAutoCompletePopupSkin<T>)getSkin()).animate(); } }
public void show(Node node) { if (text == null) { text = (Text) node.lookup(".text"); } node = text; 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(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + node.getLayoutBounds().getHeight() + shift); ((JFXAutoCompletePopupSkin<T>) getSkin()).animate(); } else { // if already showing update location if needed Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + node.getLayoutBounds().getHeight() + shift); } } }
/** * 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()); } }
Node chartArea = chart.lookup(".chart-plot-background"); Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());
Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());
Set<Node> tabs = tabPane.lookupAll(".tab"); for (Node node : tabs) { System.out.println("Coordinates relatively to Scene: " + node.localToScene(node.getBoundsInLocal())); }
private List<Node> getVisibleElements(ScrollPane pane) { List<Node> visibleNodes = new ArrayList<Node>(); Bounds paneBounds = pane.localToScene(pane.getBoundsInParent()); if (pane.getContent() instanceof Parent) { for (Node n : ((Parent) pane.getContent()).getChildrenUnmodifiable()) { Bounds nodeBounds = n.localToScene(n.getBoundsInLocal()); if (paneBounds.intersects(nodeBounds)) { visibleNodes.add(n); } } } return visibleNodes; }
/** * * @param node * @return The Y scene coordinate of the node. */ static public double sceneY(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY(); }
/** * * @param node * @return The X scene coordinate of the node. */ static public double sceneX(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinX() + node.getScene().getX(); }
private static TableCell<?, ?> getTableCellAt(TableView<?> tableView, Point2D point) { point = tableView.localToScene(point); Set<Node> lookupAll = getTableCells(tableView); TableCell<?, ?> selected = null; for (Node cellNode : lookupAll) { Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true); if (boundsInScene.contains(point)) { selected = (TableCell<?, ?>) cellNode; break; } } return selected; }
public static boolean isNodeWithinSceneBounds(Node node) { Scene scene = node.getScene(); Bounds nodeBounds = node.localToScene( node.getBoundsInLocal() ); return nodeBounds.intersects( 0, 0, scene.getWidth(), scene.getHeight() ); }
/** * * @param node * @return The Y screen coordinate of the node. */ static public double screenY(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY() + node.getScene().getWindow().getY(); }
/** * * @param node * @return The X screen coordinate of the node. */ static public double screenX(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinX() + node.getScene().getX() + node.getScene().getWindow().getX(); }
/** * * @param node * @return The Y screen coordinate of the node. */ static public double screenY(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY() + node.getScene().getWindow().getY(); }
/** * * @param node * @return The X screen coordinate of the node. */ static public double screenX(Node node) { return node.localToScene(node.getBoundsInLocal()).getMinX() + node.getScene().getX() + node.getScene().getWindow().getX(); }
public void show(Node node){ 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(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + ((Region)node).getHeight()); ((JFXAutoCompletePopupSkin<T>)getSkin()).animate(); } }
/** * Show this popup right below the given Node * * @param node */ public void show(Node node) { if (node.getScene() == null || node.getScene().getWindow() == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } // $NON-NLS-1$ if (isShowing()) { return; } final Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + control.getHeight()); }
/** * Show this popup right below the given Node * @param node */ public void show(Node node){ if(node.getScene() == null || node.getScene().getWindow() == null) throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); //$NON-NLS-1$ if(isShowing()){ return; } Window parent = node.getScene().getWindow(); this.show( parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + TITLE_HEIGHT); }
@Override public void handle(MouseEvent event) { Point2D scenePoint = chart.localToScene(event.getSceneX(), event.getSceneY()); Point2D position = chartWrap.sceneToLocal(scenePoint.getX(), scenePoint.getY()); Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal()); valueMarker.setStartY(0); valueMarker.setEndY(chartWrap.sceneToLocal(chartAreaBounds).getMaxY() - chartWrap.sceneToLocal(chartAreaBounds).getMinY()); valueMarker.setStartX(0); valueMarker.setEndX(0); valueMarker.setTranslateX(position.getX() - chartWrap.getWidth() / 2); double ydelta = chartArea.localToScene(0, 0).getY() - chartWrap.localToScene(0, 0).getY(); valueMarker.setTranslateY(-ydelta * 2); } });
private void updateArrowLinePositions() { double left = arrowButton.localToScene(0, 0).getX() - arrowButtonContainer.localToScene(0, 0).getX(); arrowButtonLeftLine.setLayoutX(left-1); arrowButtonLeftLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight()); arrowButtonRightLine.setLayoutX(left + arrowButton.getLayoutBounds().getWidth()); arrowButtonRightLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight()); double arrowLeft = arrow.localToScene(0, 0).getX() - arrowButtonContainer.localToScene(0, 0).getX(); arrowLeftLine.setLayoutX(arrowLeft-1); arrowLeftLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight()); arrowRightLine.setLayoutX(arrowLeft + arrow.getLayoutBounds().getWidth()); arrowRightLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight()); } }