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

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

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

Node.getBoundsInParent介绍

暂无

代码示例

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

@Override
  protected boolean handleDisclosureNode(double x, double y) {
    final TreeItem<S> treeItem = getControl().getTreeTableRow().getTreeItem();
    if (!treeItem.isLeaf()) {
      final Node disclosureNode = getControl().getTreeTableRow().getDisclosureNode();
      if (disclosureNode != null) {
        if (disclosureNode.getBoundsInParent().contains(x + disclosureNode.getTranslateX(), y)) {
          if (treeItem != null) {
            treeItem.setExpanded(!treeItem.isExpanded());
          }
          return true;
        }
      }
    }
    return false;
  }
}

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

OverLayRipple() {
    super();
    setOverLayBounds(this);
    this.getStyleClass().add("jfx-rippler-overlay");
    // update initial position
    if(JFXRippler.this.getChildrenUnmodifiable().contains(control)) {
      double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
      double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
      Bounds bounds = control.getBoundsInParent();
      this.setX(bounds.getMinX() + diffMinX - snappedLeftInset());
      this.setY(bounds.getMinY() + diffMinY - snappedTopInset());
    }
    // set initial attributes
    setOpacity(0);
    setCache(true);
    setCacheHint(CacheHint.SPEED);
    setCacheShape(true);
    setManaged(false);
  }
}

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

private static Timeline createTimeline(JFXHamburger burger) {
  double burgerWidth = burger.getChildren().get(0).getLayoutBounds().getWidth();
  double burgerHeight = burger.getChildren().get(2).getBoundsInParent().getMaxY() - burger.getChildren()
    .get(0)
    .getBoundsInParent()
    .getMinY();
    2) + Math.pow(burger.getChildren()
             .get(0)
             .getBoundsInParent()
             .getWidth() / 2, 2));
  double theta = (90 - angle) + Math.toDegrees(Math.atan((burger.getChildren()
                                .getHeight()) / (burger.getChildren()
                                           .get(0)
                                           .getBoundsInParent()
                                           .getWidth() / 2)));
  double hOffset = Math.cos(Math.toRadians(theta)) * burgerDiagonal / 2;

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

private static Timeline createTimeline(JFXHamburger burger) {
  double burgerWidth = burger.getChildren().get(0).getLayoutBounds().getWidth();
  double burgerHeight = burger.getChildren().get(2).getBoundsInParent().getMaxY() - burger.getChildren()
    .get(0)
    .getBoundsInParent()
    .getMinY();
    2) + Math.pow(burger.getChildren()
    .get(0)
    .getBoundsInParent()
    .getWidth() / 2, 2));
  double theta = (90 - angle) + Math.toDegrees(Math.atan((burger.getChildren()
    .getHeight()) / (burger.getChildren()
    .get(0)
    .getBoundsInParent()
    .getWidth() / 2)));
  double hOffset = Math.cos(Math.toRadians(theta)) * burgerDiagonal / 2;

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

Bounds bounds = control.getBoundsInParent();
double width = control.getLayoutBounds().getWidth();
double height = control.getLayoutBounds().getHeight();

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

private static Timeline createTimeline(JFXHamburger burger) {
  double burgerWidth = burger.getChildren().get(0).getLayoutBounds().getWidth();
  double burgerHeight = burger.getChildren().get(2).getBoundsInParent().getMaxY() - burger.getChildren()
    .get(0)
    .getBoundsInParent()
    .getMinY();

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

private static Timeline createTimeline(JFXHamburger burger) {
  double burgerWidth = burger.getChildren().get(0).getLayoutBounds().getWidth();
  double burgerHeight = burger.getChildren().get(2).getBoundsInParent().getMaxY() - burger.getChildren()
    .get(0)
    .getBoundsInParent()
    .getMinY();

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

public void centerNodeInScrollPane(ScrollPane scrollPane, Node node) {
  double h = scrollPane.getContent().getBoundsInLocal().getHeight();
  double y = (node.getBoundsInParent().getMaxY() + 
        node.getBoundsInParent().getMinY()) / 2.0;
  double v = scrollPane.getViewportBounds().getHeight();
  scrollPane.setVvalue(scrollPane.getVmax() * ((y - 0.5 * v) / (h - v)));
}

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

calcCenter(node.getBoundsInParent());
node.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
  @Override public void changed(

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

@Override
protected double computeMinWidth(double h) {
  double minX = Double.MAX_VALUE;
  double maxX = Double.MIN_VALUE;
  for (Node n : getManagedChildren()) {
    minX = Math.min(minX, n.getBoundsInParent().getMinX());
    maxX = Math.max(maxX, n.getBoundsInParent().getMaxX());
  }
  
  return maxX;
}

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

@Override
protected double computeMinHeight(double w) {
  double minY = Double.MAX_VALUE;
  double maxY = Double.MIN_VALUE;
  for (Node n : getManagedChildren()) {
    minY = Math.min(minY, n.getBoundsInParent().getMinY());
    maxY = Math.max(maxY, n.getBoundsInParent().getMaxY());
  }
  return maxY;
}

代码示例来源:origin: org.fxmisc.richtext/richtextfx

public <T extends Node & Caret> Bounds getCaretBounds(T caret) {
  layout(); // ensure layout, is a no-op if not dirty
  checkWithinParagraph(caret);
  return caret.getBoundsInParent();
}

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

/**
 * Resizes the specified rectangle to the specified node's {@link Node#boundsInParentProperty() boundsInParent}.
 * 
 * @param rectangle
 *            the {@link Rectangle} which will be resized
 * @param node
 *            the {@link Node} to whose bounds the {@code rectangle} will be resized
 */
private static void resizeRectangleToNodeBounds(Rectangle rectangle, Node node) {
  if (node == null) {
    resizeRectangleToZero(rectangle);
  } else {
    resizeRectangleToBounds(rectangle, node.getBoundsInParent());
  }
}

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

public Collection<? extends HoverTarget> findHoverTargets(Point2D localLocation) {
  return this.usedNodes.entrySet().stream()
    .filter(e->e.getValue().getBoundsInParent().contains(localLocation))
    .map(e->{
      TextAnnotation annotation = e.getKey();
      Bounds bounds = e.getValue().getBoundsInLocal();
      Point2D anchor = new Point2D(bounds.getMinX(), bounds.getMaxY());
      HoverTarget annotationTarget = new HoverTarget(annotation, toGlobal(annotation.getRange()), e.getValue().localToScreen(anchor), e.getValue().localToScreen(bounds));
      return annotationTarget;
    })
    .collect(Collectors.toList());
}

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

private static void ensureVisible(ScrollPane pane, Node node) {
  Bounds viewport = pane.getViewportBounds();
  double contentHeight = pane.getContent().getBoundsInLocal().getHeight();
  double nodeMinY = node.getBoundsInParent().getMinY();
  double nodeMaxY = node.getBoundsInParent().getMaxY();
  double viewportMinY = (contentHeight - viewport.getHeight()) * pane.getVvalue();
  double viewportMaxY = viewportMinY + viewport.getHeight();
  if (nodeMinY < viewportMinY) {
    pane.setVvalue(nodeMinY / (contentHeight - viewport.getHeight()));
  } else if (nodeMaxY > viewportMaxY) {
    pane.setVvalue((nodeMaxY - viewport.getHeight()) / (contentHeight - viewport.getHeight()));
  }
}

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

/**
 * To bounds X.
 *
 * @param aTranslateX the translate X
 * @param aSprite the sprite
 * @return the double
 */
private double toBoundsX( double aTranslateX, Node aSprite ) {
  return toBounds( aTranslateX, aSprite.getBoundsInParent().getWidth(), _scene.getWidth() );
}

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

/**
 * To bounds Y.
 *
 * @param aTranslateY the translate Y
 * @param aSprite the sprite
 * @return the double
 */
private double toBoundsY( double aTranslateY, Node aSprite ) {
  return toBounds( aTranslateY, aSprite.getBoundsInParent().getHeight(), _scene.getHeight() );
}

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

/**
 * To snap X.
 *
 * @param aTranslateX the translate X
 * @param aSprite the sprite
 * @return the double
 */
private double toSnapX( double aTranslateX, Node aSprite ) {
  return toSnap( aTranslateX, aSprite.getBoundsInParent().getWidth(), getFieldWidth(), _scene.getWidth() );
}

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

/**
 * To snap Y.
 *
 * @param aTranslateY the translate Y
 * @param aSprite the sprite
 * @return the double
 */
private double toSnapY( double aTranslateY, Node aSprite ) {
  return toSnap( aTranslateY, aSprite.getBoundsInParent().getHeight(), getFieldHeight(), _scene.getHeight() );
}

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

/**
 * Resizes the current {@link SnapshotView#selectionProperty() selection} from the control's to the node's
 * bounds
 */
private void resizeSelectionFromControlToNode() {
  if (getNode() == null) {
    setSelection(null);
  } else {
    // transform the selection from the control's to the node's bounds
    Rectangle2D controlBounds = new Rectangle2D(0, 0, getWidth(), getHeight());
    Rectangle2D nodeBounds = Rectangles2D.fromBounds(getNode().getBoundsInParent());
    resizeSelectionToNewBounds(controlBounds, nodeBounds);
  }
}

相关文章

微信公众号

最新文章

更多

Node类方法