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 static EventHandler<ActionEvent> newCloseHandler() { return event -> { final Node source = (Node) event.getSource(); final Stage stage = (Stage) source.getScene().getWindow(); stage.close(); }; }
/** * 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()); } }
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); } } }
public void addAnimatedKeyValue(Node node, List<JFXDrawerKeyValue<?>> values) { Collection<JFXKeyValue<?>> modifiedValues = new ArrayList<>(); for (JFXDrawerKeyValue value : values) { JFXKeyValue modifiedValue = JFXKeyValue.builder() .setEndValueSupplier(() -> currentValue.get(value.getTarget()).get()) .setAnimateCondition(() -> node.getScene() != null && value.isValid()) .setTargetSupplier(() -> value.getTarget()) .setInterpolator(value.getInterpolator()).build(); modifiedValues.add(modifiedValue); currentValue.put(value.getTarget(), isClosed() ? value.getCloseValueSupplier() : value.getOpenValueSupplier()); initValues.put(value.getTarget(), value); } animatedValues.addAll(modifiedValues); final JFXKeyFrame keyFrame = new JFXKeyFrame(Duration.millis(450), modifiedValues.toArray(new JFXKeyValue[0])); try { translateTimer.addKeyFrame(keyFrame); } catch (Exception e) { e.printStackTrace(); } }
private void updateDisclosureNode() { Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode(); if (disclosureNode != null) { TreeItem<S> item = getSkinnable().getTreeTableRow().getTreeItem(); final S value = item == null ? null : item.getValue(); boolean disclosureVisible = value != null && !item.isLeaf() && value instanceof RecursiveTreeObject && ((RecursiveTreeObject) value).getGroupedColumn() == getSkinnable().getTableColumn(); disclosureNode.setVisible(disclosureVisible); if (!disclosureVisible) { getChildren().remove(disclosureNode); } else if (disclosureNode.getParent() == null) { getChildren().add(disclosureNode); disclosureNode.toFront(); } else { disclosureNode.toBack(); } if (disclosureNode.getScene() != null) { disclosureNode.applyCss(); } } }
new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { // take some action ... // close the dialog. Node source = (Node) actionEvent.getSource(); Stage stage = (Stage) source.getScene().getWindow(); stage.close(); } }
private void addDraggableNode(final Node node) { node.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { if (me.getButton() != MouseButton.MIDDLE) { initialX = me.getSceneX(); initialY = me.getSceneY(); } } }); node.setOnMouseDragged(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { if (me.getButton() != MouseButton.MIDDLE) { node.getScene().getWindow().setX(me.getScreenX() - initialX); node.getScene().getWindow().setY(me.getScreenY() - initialY); } } }); }
Object source = event.getSource(); Node node = (Node) source ; Scene scene = node.getScene(); Window window = scene.getWindow(); Stage stage = (Stage) window ;
/** * * @param node * @return The Y screen coordinate of the node. */ static public double screenY(Node node) { return sceneY(node) + node.getScene().getWindow().getY(); }
/** * * @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(); }
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() ); }
public void updateFeedback(Consumer<StackPane> consumer) { consumer.accept((StackPane) this.popupWindow.getScene().getRoot()); this.popupWindow.sizeToScene(); this.popupWindow.setX(this.screenX - this.popupWindow.getWidth() / 2); this.popupWindow.setY(this.screenY + 20); this.popupWindow.show(n.getScene().getWindow()); }
public void updateFeedback(Consumer<StackPane> consumer) { consumer.accept((StackPane) this.popupWindow.getScene().getRoot()); this.popupWindow.sizeToScene(); this.popupWindow.setX(this.screenX - this.popupWindow.getWidth() / 2); this.popupWindow.setY(this.screenY + 20); this.popupWindow.show(n.getScene().getWindow()); }
private void updateEngineSettings(RepositoryDTO repositoryDTO) { this.engineSettingsManager.fetchAvailableEngineSettings(repositoryDTO, engineSettings -> Platform.runLater(() -> this.engineSettings = engineSettings), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Loading engine tools failed.")) .withException(e) .withOwner(this.containersView.getContent().getScene().getWindow()) .build(); errorDialog.showAndWait(); })); }