javafx.scene.Node.getScene()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(336)

本文整理了Java中javafx.scene.Node.getScene()方法的一些代码示例,展示了Node.getScene()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getScene()方法的具体详情如下:
包路径:javafx.scene.Node
类名称:Node
方法名:getScene

Node.getScene介绍

暂无

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

  1. public void show(Node node){
  2. if(!isShowing()){
  3. if(node.getScene() == null || node.getScene().getWindow() == null)
  4. throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
  5. Window parent = node.getScene().getWindow();
  6. this.show(parent, parent.getX() + node.localToScene(0, 0).getX() +
  7. node.getScene().getX(),
  8. parent.getY() + node.localToScene(0, 0).getY() +
  9. node.getScene().getY() + ((Region)node).getHeight());
  10. ((JFXAutoCompletePopupSkin<T>)getSkin()).animate();
  11. }
  12. }

代码示例来源:origin: speedment/speedment

  1. public static EventHandler<ActionEvent> newCloseHandler() {
  2. return event -> {
  3. final Node source = (Node) event.getSource();
  4. final Stage stage = (Stage) source.getScene().getWindow();
  5. stage.close();
  6. };
  7. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. /**
  2. * show the popup according to the specified position with a certain offset
  3. *
  4. * @param vAlign can be TOP/BOTTOM
  5. * @param hAlign can be LEFT/RIGHT
  6. * @param initOffsetX on the x axis
  7. * @param initOffsetY on the y axis
  8. */
  9. public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) {
  10. if (!isShowing()) {
  11. if (node.getScene() == null || node.getScene().getWindow() == null) {
  12. throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
  13. }
  14. Window parent = node.getScene().getWindow();
  15. final Point2D origin = node.localToScene(0, 0);
  16. final double anchorX = parent.getX() + origin.getX()
  17. + node.getScene().getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0);
  18. final double anchorY = parent.getY() + origin.getY()
  19. + node.getScene()
  20. .getY() + (vAlign == PopupVPosition.BOTTOM ? ((Region) node).getHeight() : 0);
  21. this.show(parent, anchorX, anchorY);
  22. ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY);
  23. Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate());
  24. }
  25. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. public void show(Node node) {
  2. if (text == null) {
  3. text = (Text) node.lookup(".text");
  4. }
  5. node = text;
  6. if (!isShowing()) {
  7. if (node.getScene() == null || node.getScene().getWindow() == null) {
  8. throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window.");
  9. }
  10. Window parent = node.getScene().getWindow();
  11. this.show(parent, parent.getX() +
  12. node.localToScene(0, 0).getX() +
  13. node.getScene().getX(),
  14. parent.getY() + node.localToScene(0, 0).getY() +
  15. node.getScene().getY() + node.getLayoutBounds().getHeight() + shift);
  16. ((JFXAutoCompletePopupSkin<T>) getSkin()).animate();
  17. } else {
  18. // if already showing update location if needed
  19. Window parent = node.getScene().getWindow();
  20. this.show(parent, parent.getX() +
  21. node.localToScene(0, 0).getX() +
  22. node.getScene().getX(),
  23. parent.getY() + node.localToScene(0, 0).getY() +
  24. node.getScene().getY() + node.getLayoutBounds().getHeight() + shift);
  25. }
  26. }
  27. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. public void addAnimatedKeyValue(Node node, List<JFXDrawerKeyValue<?>> values) {
  2. Collection<JFXKeyValue<?>> modifiedValues = new ArrayList<>();
  3. for (JFXDrawerKeyValue value : values) {
  4. JFXKeyValue modifiedValue = JFXKeyValue.builder()
  5. .setEndValueSupplier(() -> currentValue.get(value.getTarget()).get())
  6. .setAnimateCondition(() -> node.getScene() != null && value.isValid())
  7. .setTargetSupplier(() -> value.getTarget())
  8. .setInterpolator(value.getInterpolator()).build();
  9. modifiedValues.add(modifiedValue);
  10. currentValue.put(value.getTarget(), isClosed() ? value.getCloseValueSupplier() : value.getOpenValueSupplier());
  11. initValues.put(value.getTarget(), value);
  12. }
  13. animatedValues.addAll(modifiedValues);
  14. final JFXKeyFrame keyFrame = new JFXKeyFrame(Duration.millis(450), modifiedValues.toArray(new JFXKeyValue[0]));
  15. try {
  16. translateTimer.addKeyFrame(keyFrame);
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. }
  20. }

代码示例来源:origin: jfoenixadmin/JFoenix

  1. private void updateDisclosureNode() {
  2. Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode();
  3. if (disclosureNode != null) {
  4. TreeItem<S> item = getSkinnable().getTreeTableRow().getTreeItem();
  5. final S value = item == null ? null : item.getValue();
  6. boolean disclosureVisible = value != null
  7. && !item.isLeaf()
  8. && value instanceof RecursiveTreeObject
  9. && ((RecursiveTreeObject) value).getGroupedColumn() == getSkinnable().getTableColumn();
  10. disclosureNode.setVisible(disclosureVisible);
  11. if (!disclosureVisible) {
  12. getChildren().remove(disclosureNode);
  13. } else if (disclosureNode.getParent() == null) {
  14. getChildren().add(disclosureNode);
  15. disclosureNode.toFront();
  16. } else {
  17. disclosureNode.toBack();
  18. }
  19. if (disclosureNode.getScene() != null) {
  20. disclosureNode.applyCss();
  21. }
  22. }
  23. }

代码示例来源:origin: stackoverflow.com

  1. new EventHandler<ActionEvent>() {
  2. @Override public void handle(ActionEvent actionEvent) {
  3. // take some action
  4. ...
  5. // close the dialog.
  6. Node source = (Node) actionEvent.getSource();
  7. Stage stage = (Stage) source.getScene().getWindow();
  8. stage.close();
  9. }
  10. }

代码示例来源:origin: stackoverflow.com

  1. private void addDraggableNode(final Node node) {
  2. node.setOnMousePressed(new EventHandler<MouseEvent>() {
  3. @Override
  4. public void handle(MouseEvent me) {
  5. if (me.getButton() != MouseButton.MIDDLE) {
  6. initialX = me.getSceneX();
  7. initialY = me.getSceneY();
  8. }
  9. }
  10. });
  11. node.setOnMouseDragged(new EventHandler<MouseEvent>() {
  12. @Override
  13. public void handle(MouseEvent me) {
  14. if (me.getButton() != MouseButton.MIDDLE) {
  15. node.getScene().getWindow().setX(me.getScreenX() - initialX);
  16. node.getScene().getWindow().setY(me.getScreenY() - initialY);
  17. }
  18. }
  19. });
  20. }

代码示例来源:origin: stackoverflow.com

  1. Object source = event.getSource();
  2. Node node = (Node) source ;
  3. Scene scene = node.getScene();
  4. Window window = scene.getWindow();
  5. Stage stage = (Stage) window ;

代码示例来源:origin: org.controlsfx/controlsfx

  1. @Override public void invalidated(Observable o) {
  2. if (target.getScene() != null) {
  3. target.sceneProperty().removeListener(this);
  4. sceneConsumer.accept(target.getScene());
  5. }
  6. }
  7. };

代码示例来源:origin: org.jfxtras/jfxtras-common

  1. /**
  2. *
  3. * @param node
  4. * @return The Y screen coordinate of the node.
  5. */
  6. static public double screenY(Node node) {
  7. return sceneY(node) + node.getScene().getWindow().getY();
  8. }

代码示例来源:origin: eu.mihosoft.vrl.workflow/vworkflows-fx

  1. /**
  2. *
  3. * @param node
  4. * @return The Y screen coordinate of the node.
  5. */
  6. static public double screenY(Node node) {
  7. return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY() + node.getScene().getWindow().getY();
  8. }

代码示例来源:origin: eu.mihosoft.vrl.workflow/vworkflows-fx

  1. /**
  2. *
  3. * @param node
  4. * @return The X screen coordinate of the node.
  5. */
  6. static public double screenX(Node node) {
  7. return node.localToScene(node.getBoundsInLocal()).getMinX()
  8. + node.getScene().getX() + node.getScene().getWindow().getX();
  9. }

代码示例来源:origin: eu.mihosoft.vrl.workflow/vworkflows-fx

  1. /**
  2. *
  3. * @param node
  4. * @return The Y screen coordinate of the node.
  5. */
  6. static public double screenY(Node node) {
  7. return node.localToScene(node.getBoundsInLocal()).getMinY()
  8. + node.getScene().getY() + node.getScene().getWindow().getY();
  9. }

代码示例来源:origin: org.jfxtras/jfxtras-common

  1. /**
  2. *
  3. * @param node
  4. * @return The Y scene coordinate of the node.
  5. */
  6. static public double sceneY(Node node) {
  7. return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY();
  8. }

代码示例来源:origin: org.jfxtras/jfxtras-common

  1. /**
  2. *
  3. * @param node
  4. * @return The X scene coordinate of the node.
  5. */
  6. static public double sceneX(Node node) {
  7. return node.localToScene(node.getBoundsInLocal()).getMinX() + node.getScene().getX();
  8. }

代码示例来源:origin: org.loadui/testFx

  1. public static boolean isNodeWithinSceneBounds(Node node)
  2. {
  3. Scene scene = node.getScene();
  4. Bounds nodeBounds = node.localToScene( node.getBoundsInLocal() );
  5. return nodeBounds.intersects( 0, 0, scene.getWidth(), scene.getHeight() );
  6. }

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.controls

  1. public void updateFeedback(Consumer<StackPane> consumer) {
  2. consumer.accept((StackPane) this.popupWindow.getScene().getRoot());
  3. this.popupWindow.sizeToScene();
  4. this.popupWindow.setX(this.screenX - this.popupWindow.getWidth() / 2);
  5. this.popupWindow.setY(this.screenY + 20);
  6. this.popupWindow.show(n.getScene().getWindow());
  7. }

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.ui.controls

  1. public void updateFeedback(Consumer<StackPane> consumer) {
  2. consumer.accept((StackPane) this.popupWindow.getScene().getRoot());
  3. this.popupWindow.sizeToScene();
  4. this.popupWindow.setX(this.screenX - this.popupWindow.getWidth() / 2);
  5. this.popupWindow.setY(this.screenY + 20);
  6. this.popupWindow.show(n.getScene().getWindow());
  7. }

代码示例来源:origin: PhoenicisOrg/phoenicis

  1. private void updateEngineSettings(RepositoryDTO repositoryDTO) {
  2. this.engineSettingsManager.fetchAvailableEngineSettings(repositoryDTO,
  3. engineSettings -> Platform.runLater(() -> this.engineSettings = engineSettings),
  4. e -> Platform.runLater(() -> {
  5. final ErrorDialog errorDialog = ErrorDialog.builder()
  6. .withMessage(tr("Loading engine tools failed."))
  7. .withException(e)
  8. .withOwner(this.containersView.getContent().getScene().getWindow())
  9. .build();
  10. errorDialog.showAndWait();
  11. }));
  12. }

相关文章

Node类方法