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

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

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

Node.getScene介绍

暂无

代码示例

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

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();
  }
}

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

public static EventHandler<ActionEvent> newCloseHandler() {
  return event -> {
    final Node source = (Node) event.getSource();
    final Stage stage = (Stage) source.getScene().getWindow();
    stage.close();
  };
}

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

/**
 * 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());
  }
}

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

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);
    }
  }
}

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

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();
  }
}

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

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();
    }
  }
}

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

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();
 }
}

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

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);
      }
    }
  });
}

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

Object source = event.getSource();
Node node = (Node) source ;
Scene scene = node.getScene();
Window window = scene.getWindow();
Stage stage = (Stage) window ;

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

@Override public void invalidated(Observable o) {
    if (target.getScene() != null) {
      target.sceneProperty().removeListener(this);
      sceneConsumer.accept(target.getScene());
    }
  }
};

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

/**
 *
 * @param node
 * @return The Y screen coordinate of the node.
 */
static public double screenY(Node node) {
  return sceneY(node) + node.getScene().getWindow().getY();
}

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

/**
 *
 * @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();
}

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

/**
 *
 * @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();
}

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

/**
 *
 * @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();
}

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

/**
*
* @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();
}

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

/**
*
* @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();
}

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

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() );
}

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

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());
}

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

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());
}

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

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();
      }));
}

相关文章

微信公众号

最新文章

更多

Node类方法