List of usage examples for javafx.scene Node getBoundsInParent
public final Bounds getBoundsInParent()
From source file:com.github.vatbub.tictactoe.view.Main.java
private void updateMenuHeight(boolean includeAILevelSlider) { double toHeight = 0; int effectiveChildCount = 0; for (Node child : menuSubBox.getChildren()) { if (child.isVisible() && child != aiLevelTitleLabel && child != aiLevelSlider && child != aiLevelLabelPane) { toHeight = toHeight + child.getBoundsInParent().getHeight(); effectiveChildCount = effectiveChildCount + 1; }/* w w w. ja va 2 s. c om*/ } if (includeAILevelSlider) { toHeight = toHeight + aiLevelLabelPane.getPrefHeight(); toHeight = toHeight + aiLevelSlider.getPrefHeight(); toHeight = toHeight + aiLevelTitleLabel.getPrefHeight(); effectiveChildCount = effectiveChildCount + 3; } toHeight = toHeight + menuSubBox.getSpacing() * (effectiveChildCount - 1); if (updateMenuHeightTimeline != null && updateMenuHeightTimeline.getStatus() == Animation.Status.RUNNING) { updateMenuHeightTimeline.stop(); } updateMenuHeightTimeline = new Timeline(); KeyValue keyValue0 = new KeyValue(menuSubBox.prefHeightProperty(), toHeight, Interpolator.EASE_BOTH); KeyFrame keyFrame0 = new KeyFrame(Duration.seconds(animationSpeed), keyValue0); updateMenuHeightTimeline.getKeyFrames().add(keyFrame0); updateMenuHeightTimeline.play(); }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * Gets a location inside the component. If <code>offset</code> is * <code>null</code>, it returns the middle of the component otherwise it * adds the offset to the upper left corner. * * @param comp/* w w w .j a v a2 s . com*/ * the component to get the location for * @param offset * the offset * @throws IllegalArgumentException * if <code>component</code> is null * @return the <b>global </b> coordinates of <code>component</code> */ private Point getLocation(Node comp, final Point offset) throws IllegalArgumentException { Validate.notNull(comp, "component must not be null"); //$NON-NLS-1$ Scene s = comp.getScene(); s.getRoot().layout(); Point2D pos = comp.localToScreen(0, 0); double x = pos.getX(); double y = pos.getY(); if (offset == null) { final Bounds boundsInParent = comp.getBoundsInParent(); x += boundsInParent.getWidth() / 2; y += boundsInParent.getHeight() / 2; } else { x += offset.x; y += offset.y; } return new Point(Rounding.round(x), Rounding.round(y)); }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * Refreshes the complete layout and returns the bounds of the given * Component./*from w w w . ja v a2 s . com*/ * * @param comp * the Component * @param clickOp * not used * @return Rectangle with the Bounds */ private Rectangle getComponentBounds(final Object comp, ClickOptions clickOp) { ComponentHandler.syncStageResize(); Rectangle bounds = null; if (comp instanceof Stage) { Stage s = (Stage) comp; bounds = new Rectangle(new Point(Rounding.round(s.getX()), Rounding.round(s.getY()))); // This is not multi display compatible Screen screen = Screen.getPrimary(); final Rectangle2D screenBounds = screen.getBounds(); int displayWidth = Rounding.round(screenBounds.getWidth()); int displayHeight = Rounding.round(screenBounds.getHeight()); if (s.isFullScreen()) { bounds.width = Rounding.round(displayWidth); bounds.height = Rounding.round(displayHeight); } else if (s.isMaximized()) { int x = Rounding.round(s.getX()); int y = Rounding.round(s.getY()); // trimming the bounds to the display if necessary bounds.width = Rounding.round(s.getWidth()); bounds.height = Rounding.round(s.getHeight()); if (x < 0 || y < 0) { bounds.x = 0; bounds.y = 0; if (bounds.width > displayWidth) { bounds.width = displayWidth; } if (bounds.height > displayHeight) { bounds.height = displayHeight; } } } else { bounds.width = Rounding.round(s.getWidth()); bounds.height = Rounding.round(s.getHeight()); } } else { final Node node = (Node) comp; if (clickOp.isScrollToVisible()) { ensureComponentVisible(node); } bounds = EventThreadQueuerJavaFXImpl.invokeAndWait("Robot get node bounds", new Callable<Rectangle>() { //$NON-NLS-1$ @Override public Rectangle call() throws Exception { Rectangle bs = new Rectangle(getLocation(node, new Point(0, 0))); Bounds b = node.getBoundsInParent(); bs.width = Rounding.round(b.getWidth()); bs.height = Rounding.round(b.getHeight()); return bs; } }); } return bounds; }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractTimelineChart.java
/** * Add a Text Node to the specific label container for the decluttered axis * labels.//w ww. j a v a 2 s .c o m * * @param labelText The String to add. * @param labelWidth The width, in pixels, of the space available for the * text. * @param labelX The horizontal position, in pixels, in the specificPane * of the text. * @param bold True if the text should be bold, false otherwise. */ private synchronized void addSpecificLabel(String labelText, double labelWidth, double labelX, boolean bold) { Text label = new Text(" " + labelText + " "); //NON-NLS label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(null, bold ? FontWeight.BOLD : FontWeight.NORMAL, 10)); //position label accounting for width label.relocate(labelX + labelWidth / 2 - label.getBoundsInLocal().getWidth() / 2, 0); label.autosize(); if (specificLabelPane.getChildren().isEmpty()) { //just add first label specificLabelPane.getChildren().add(label); } else { //otherwise don't actually add the label if it would intersect with previous label final Node lastLabel = specificLabelPane.getChildren().get(specificLabelPane.getChildren().size() - 1); if (false == lastLabel.getBoundsInParent().intersects(label.getBoundsInParent())) { specificLabelPane.getChildren().add(label); } } }