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

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

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

Node.localToScene介绍

暂无

代码示例

代码示例来源: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: 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. /**
  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: stackoverflow.com

  1. Node chartArea = chart.lookup(".chart-plot-background");
  2. Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());

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

  1. Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());

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

  1. Set<Node> tabs = tabPane.lookupAll(".tab");
  2. for (Node node : tabs) {
  3. System.out.println("Coordinates relatively to Scene: " + node.localToScene(node.getBoundsInLocal()));
  4. }

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

  1. private List<Node> getVisibleElements(ScrollPane pane) {
  2. List<Node> visibleNodes = new ArrayList<Node>();
  3. Bounds paneBounds = pane.localToScene(pane.getBoundsInParent());
  4. if (pane.getContent() instanceof Parent) {
  5. for (Node n : ((Parent) pane.getContent()).getChildrenUnmodifiable()) {
  6. Bounds nodeBounds = n.localToScene(n.getBoundsInLocal());
  7. if (paneBounds.intersects(nodeBounds)) {
  8. visibleNodes.add(n);
  9. }
  10. }
  11. }
  12. return visibleNodes;
  13. }

代码示例来源: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: com.nexitia.emaginplatform/emagin-jfxcore-engine

  1. private static TableCell<?, ?> getTableCellAt(TableView<?> tableView, Point2D point) {
  2. point = tableView.localToScene(point);
  3. Set<Node> lookupAll = getTableCells(tableView);
  4. TableCell<?, ?> selected = null;
  5. for (Node cellNode : lookupAll) {
  6. Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
  7. if (boundsInScene.contains(point)) {
  8. selected = (TableCell<?, ?>) cellNode;
  9. break;
  10. }
  11. }
  12. return selected;
  13. }

代码示例来源: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: 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: 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() + node.getScene().getX() + node.getScene().getWindow().getX();
  8. }

代码示例来源:origin: com.jfoenix/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: com.nexitia.emaginplatform/emagin-jfxcore-engine

  1. /**
  2. * Show this popup right below the given Node
  3. *
  4. * @param node
  5. */
  6. public void show(Node node) {
  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. } // $NON-NLS-1$
  10. if (isShowing()) {
  11. return;
  12. }
  13. final Window parent = node.getScene().getWindow();
  14. 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());
  15. }

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

  1. /**
  2. * Show this popup right below the given Node
  3. * @param node
  4. */
  5. public void show(Node node){
  6. if(node.getScene() == null || node.getScene().getWindow() == null)
  7. throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); //$NON-NLS-1$
  8. if(isShowing()){
  9. return;
  10. }
  11. Window parent = node.getScene().getWindow();
  12. this.show(
  13. parent,
  14. parent.getX() + node.localToScene(0, 0).getX() +
  15. node.getScene().getX(),
  16. parent.getY() + node.localToScene(0, 0).getY() +
  17. node.getScene().getY() + TITLE_HEIGHT);
  18. }

代码示例来源:origin: org.copper-engine/copper-monitoring-client

  1. @Override
  2. public void handle(MouseEvent event) {
  3. Point2D scenePoint = chart.localToScene(event.getSceneX(), event.getSceneY());
  4. Point2D position = chartWrap.sceneToLocal(scenePoint.getX(), scenePoint.getY());
  5. Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());
  6. valueMarker.setStartY(0);
  7. valueMarker.setEndY(chartWrap.sceneToLocal(chartAreaBounds).getMaxY() - chartWrap.sceneToLocal(chartAreaBounds).getMinY());
  8. valueMarker.setStartX(0);
  9. valueMarker.setEndX(0);
  10. valueMarker.setTranslateX(position.getX() - chartWrap.getWidth() / 2);
  11. double ydelta = chartArea.localToScene(0, 0).getY() - chartWrap.localToScene(0, 0).getY();
  12. valueMarker.setTranslateY(-ydelta * 2);
  13. }
  14. });

代码示例来源:origin: com.aquafx-project/aquafx

  1. private void updateArrowLinePositions() {
  2. double left = arrowButton.localToScene(0, 0).getX() - arrowButtonContainer.localToScene(0, 0).getX();
  3. arrowButtonLeftLine.setLayoutX(left-1);
  4. arrowButtonLeftLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight());
  5. arrowButtonRightLine.setLayoutX(left + arrowButton.getLayoutBounds().getWidth());
  6. arrowButtonRightLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight());
  7. double arrowLeft = arrow.localToScene(0, 0).getX() - arrowButtonContainer.localToScene(0, 0).getX();
  8. arrowLeftLine.setLayoutX(arrowLeft-1);
  9. arrowLeftLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight());
  10. arrowRightLine.setLayoutX(arrowLeft + arrow.getLayoutBounds().getWidth());
  11. arrowRightLine.setPrefHeight(arrowButtonContainer.getLayoutBounds().getHeight());
  12. }
  13. }

相关文章

Node类方法