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

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

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

Node.getLayoutBounds介绍

暂无

代码示例

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

  1. /**
  2. * compute the ripple radius
  3. * @return the ripple radius size
  4. */
  5. protected double computeRippleRadius() {
  6. double width2 = control.getLayoutBounds().getWidth() * control.getLayoutBounds().getWidth();
  7. double height2 = control.getLayoutBounds().getHeight() * control.getLayoutBounds().getHeight();
  8. return Math.min(Math.sqrt(width2 + height2), RIPPLE_MAX_RADIUS) * 1.1 + 5;
  9. }

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

  1. protected void setOverLayBounds(Rectangle overlay){
  2. overlay.setWidth(control.getLayoutBounds().getWidth());
  3. overlay.setHeight(control.getLayoutBounds().getHeight());
  4. }

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

  1. @Override
  2. protected Node getMask() {
  3. Region clip = new Region();
  4. JFXNodeUtils.updateBackground(JFXListCell.this.getBackground(), clip);
  5. double width = control.getLayoutBounds().getWidth();
  6. double height = control.getLayoutBounds().getHeight();
  7. clip.resize(width, height);
  8. return clip;
  9. }

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

  1. @Override
  2. protected Node getMask() {
  3. Region clip = new Region();
  4. JFXNodeUtils.updateBackground(JFXTreeCell.this.getBackground(), clip);
  5. double width = control.getLayoutBounds().getWidth();
  6. double height = control.getLayoutBounds().getHeight();
  7. clip.resize(width, height);
  8. return clip;
  9. }

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

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateY(contentContainer.getLayoutY()
  5. + contentContainer.getLayoutBounds().getMaxY());
  6. }

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

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(-(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX()));
  6. }

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

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateX(contentContainer.getLayoutX()
  5. + contentContainer.getLayoutBounds().getMaxX());
  6. }

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

  1. @Override
  2. public void initAnimation(Node contentContainer, Node overlay) {
  3. overlay.setOpacity(0);
  4. contentContainer.setTranslateY(-(contentContainer.getLayoutY()
  5. + contentContainer.getLayoutBounds().getMaxY()));
  6. }

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

  1. /**
  2. * creates Ripple effect in the center of the control
  3. * @return a runnable to release the ripple when needed
  4. */
  5. public Runnable createManualRipple() {
  6. if(!isRipplerDisabled()) {
  7. rippler.setGeneratorCenterX(control.getLayoutBounds().getWidth() / 2);
  8. rippler.setGeneratorCenterY(control.getLayoutBounds().getHeight() / 2);
  9. rippler.createRipple();
  10. return () -> {
  11. // create fade out transition for the ripple
  12. releaseRipple();
  13. };
  14. }
  15. return () -> { };
  16. }

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

  1. OverLayRipple() {
  2. super();
  3. setOverLayBounds(this);
  4. this.getStyleClass().add("jfx-rippler-overlay");
  5. // update initial position
  6. if(JFXRippler.this.getChildrenUnmodifiable().contains(control)) {
  7. double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
  8. double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
  9. Bounds bounds = control.getBoundsInParent();
  10. this.setX(bounds.getMinX() + diffMinX - snappedLeftInset());
  11. this.setY(bounds.getMinY() + diffMinY - snappedTopInset());
  12. }
  13. // set initial attributes
  14. setOpacity(0);
  15. setCache(true);
  16. setCacheHint(CacheHint.SPEED);
  17. setCacheShape(true);
  18. setManaged(false);
  19. }
  20. }

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

  1. @Override
  2. protected void layoutChildren(double x, double y, double w, double h) {
  3. updateDisclosureNode();
  4. double disclosureWidth = 0;
  5. Node disclosureNode = ((JFXTreeTableCell<S, T>) getSkinnable()).getDisclosureNode();
  6. if (disclosureNode.isVisible()) {
  7. Pos alignment = getSkinnable().getAlignment();
  8. alignment = alignment == null ? Pos.CENTER_LEFT : alignment;
  9. layoutInArea(disclosureNode, x + 8, y, w, h, 0, Insets.EMPTY, false, false, HPos.LEFT, VPos.CENTER);
  10. disclosureWidth = disclosureNode.getLayoutBounds().getWidth() + 18;
  11. }
  12. super.layoutChildren(x + disclosureWidth, y, w - disclosureWidth, h);
  13. }
  14. }

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

  1. double borderWidth = ripplerPane.getBorder() != null ? ripplerPane.getBorder().getInsets().getTop() : 0;
  2. Bounds bounds = control.getBoundsInParent();
  3. double width = control.getLayoutBounds().getWidth();
  4. double height = control.getLayoutBounds().getHeight();
  5. double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
  6. double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
  7. double diffMaxX = Math.abs(control.getBoundsInLocal().getMaxX() - control.getLayoutBounds().getMaxX());
  8. double diffMaxY = Math.abs(control.getBoundsInLocal().getMaxY() - control.getLayoutBounds().getMaxY());
  9. Node mask;
  10. switch (getMaskType()) {

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

  1. private void updateTextPos() {
  2. double textWidth = textNode.getLayoutBounds().getWidth();
  3. final double promptWidth = promptText == null ? 0 : promptText.getLayoutBounds().getWidth();
  4. switch (getHAlignment()) {
  5. case CENTER:
  6. linesWrapper.promptTextScale.setPivotX(promptWidth / 2);
  7. double midPoint = textRight.get() / 2;
  8. double newX = midPoint - textWidth / 2;
  9. if (newX + textWidth <= textRight.get()) {
  10. textTranslateX.set(newX);
  11. }
  12. break;
  13. case LEFT:
  14. linesWrapper.promptTextScale.setPivotX(0);
  15. break;
  16. case RIGHT:
  17. linesWrapper.promptTextScale.setPivotX(promptWidth);
  18. break;
  19. }
  20. }

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

  1. private void updateTextPos() {
  2. double textWidth = textNode.getLayoutBounds().getWidth();
  3. final double promptWidth = promptText == null ? 0 : promptText.getLayoutBounds().getWidth();
  4. switch (getHAlignment()) {
  5. case CENTER:
  6. linesWrapper.promptTextScale.setPivotX(promptWidth / 2);
  7. double midPoint = textRight.get() / 2;
  8. double newX = midPoint - textWidth / 2;
  9. if (newX + textWidth <= textRight.get()) {
  10. textTranslateX.set(newX);
  11. }
  12. break;
  13. case LEFT:
  14. linesWrapper.promptTextScale.setPivotX(0);
  15. break;
  16. case RIGHT:
  17. linesWrapper.promptTextScale.setPivotX(promptWidth);
  18. break;
  19. }
  20. }

代码示例来源: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. return;
  2. double rateX = this.getWidth() / getClip().getLayoutBounds().getWidth();
  3. double rateY = this.getHeight() / getClip().getLayoutBounds().getHeight();
  4. double newRate = Math.max(rateX, rateY) * getScalingFactor();
  5. double animationRate = toggleAnimation == null ? -1 : toggleAnimation.getRate();
  6. if (toggleAnimation.getRate() == 1) {
  7. this.getClip().scaleXProperty().bind(Bindings.createDoubleBinding(() -> {
  8. double X = this.getWidth() / getClip().getLayoutBounds().getWidth();
  9. double Y = this.getHeight() / getClip().getLayoutBounds().getHeight();
  10. return Math.max(X, Y) * getScalingFactor();
  11. }, this.widthProperty(), this.heightProperty()));
  12. double X = this.getWidth() / getClip().getLayoutBounds().getWidth();
  13. double Y = this.getHeight() / getClip().getLayoutBounds().getHeight();
  14. return Math.max(X, Y) * getScalingFactor();
  15. }, this.widthProperty(), this.heightProperty()));

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

  1. public HorizontalTransition(boolean leftDirection, Node contentContainer, Node overlay) {
  2. super(contentContainer, new Timeline(
  3. new KeyFrame(Duration.ZERO,
  4. new KeyValue(contentContainer.translateXProperty(),
  5. (contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX())
  6. * (leftDirection? -1 : 1), Interpolator.LINEAR),
  7. new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH)
  8. ),
  9. new KeyFrame(Duration.millis(1000),
  10. new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH),
  11. new KeyValue(contentContainer.translateXProperty(), 0, Interpolator.EASE_OUT)
  12. )));
  13. // reduce the number to increase the shifting , increase number to reduce shifting
  14. setCycleDuration(Duration.seconds(0.4));
  15. setDelay(Duration.seconds(0));
  16. }
  17. }

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

  1. public VerticalTransition(boolean topDirection, Node contentContainer, Node overlay) {
  2. super(contentContainer, new Timeline(
  3. new KeyFrame(Duration.ZERO,
  4. new KeyValue(contentContainer.translateYProperty(),
  5. (contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY())
  6. * (topDirection? -1 : 1), Interpolator.LINEAR),
  7. new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH)
  8. ),
  9. new KeyFrame(Duration.millis(1000),
  10. new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH),
  11. new KeyValue(contentContainer.translateYProperty(), 0, Interpolator.EASE_OUT)
  12. )));
  13. // reduce the number to increase the shifting , increase number to reduce shifting
  14. setCycleDuration(Duration.seconds(0.4));
  15. setDelay(Duration.seconds(0));
  16. }
  17. }

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

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

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

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

相关文章

Node类方法