Refine search
double borderWidth = ripplerPane.getBorder() != null ? ripplerPane.getBorder().getInsets().getTop() : 0; Bounds bounds = control.getBoundsInParent(); double width = control.getLayoutBounds().getWidth(); double height = control.getLayoutBounds().getHeight(); double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX()); double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY()); double diffMaxX = Math.abs(control.getBoundsInLocal().getMaxX() - control.getLayoutBounds().getMaxX()); double diffMaxY = Math.abs(control.getBoundsInLocal().getMaxY() - control.getLayoutBounds().getMaxY()); Node mask; switch (getMaskType()) { case RECT: mask = new Rectangle(bounds.getMinX() + diffMinX - snappedLeftInset(), bounds.getMinY() + diffMinY - snappedTopInset(), width - 2 * borderWidth, height - 2 * borderWidth); // -0.1 to prevent resizing the anchor pane case CIRCLE: double radius = Math.min((width / 2) - 2 * borderWidth, (height / 2) - 2 * borderWidth); mask = new Circle((bounds.getMinX() + diffMinX + bounds.getMaxX() - diffMaxX) / 2 - snappedLeftInset(), (bounds.getMinY() + diffMinY + bounds.getMaxY() - diffMaxY) / 2 - snappedTopInset(), radius, Color.BLUE); mask.relocate(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY); break; default: mask = new Rectangle(bounds.getMinX() + diffMinX - snappedLeftInset(), bounds.getMinY() + diffMinY - snappedTopInset(), width - 2 * borderWidth,
/** * compute the ripple radius * @return the ripple radius size */ protected double computeRippleRadius() { double width2 = control.getLayoutBounds().getWidth() * control.getLayoutBounds().getWidth(); double height2 = control.getLayoutBounds().getHeight() * control.getLayoutBounds().getHeight(); return Math.min(Math.sqrt(width2 + height2), RIPPLE_MAX_RADIUS) * 1.1 + 5; }
@Override public void init() { nextPage.setOpacity(0); wizard.getChildren().add(tempPage); wizard.getChildren().add(nextPage); newX = colorPane1.localToScene(colorPane1.getBoundsInLocal()).getMinX(); newY = colorPane1.localToScene(colorPane1.getBoundsInLocal()).getMinY(); tempPage.getChildren().add(colorPane1); colorPane1.setTranslateX(newX); colorPane1.setTranslateY(newY); }
double hChange = startEndX / (contentBounds.getWidth() - viewBounds.getWidth()); double vChange = startEndY / (contentBounds.getHeight() - viewBounds.getHeight()); mapScroll.setHvalue(mapScroll.getHvalue() + hChange); mapScroll.setVvalue(mapScroll.getVvalue() + vChange); }); primaryStage.setScene(scene); primaryStage.show();
@Override public void changed(ObservableValue<? extends Bounds> observable, Bounds oldValue, Bounds newValue) { if (oldHeight != newValue.getHeight()) { System.out.println("newValue = " + newValue.getHeight()); oldHeight = newValue.getHeight(); textArea.setPrefHeight(textHolder.getLayoutBounds().getHeight() + 20); // +20 is for paddings primaryStage.setScene(scene); primaryStage.show();
Bounds elementBounds = text.getLayoutBounds(); double scale = Math.min(rootBounds.getWidth() / elementBounds.getWidth(), rootBounds.getHeight() / elementBounds.getHeight()); text.setScaleX(scale); text.setScaleY(scale); double cx = (elementBounds.getMinX() + elementBounds.getMaxX()) / 2; double cy = (elementBounds.getMinY() + elementBounds.getMaxY()) / 2; text.setTranslateX(rootBounds.getWidth() / 2 - cx + text.getTranslateX()); text.setTranslateY(rootBounds.getHeight() / 2 - cy + text.getTranslateY()); primaryStage.setScene(scene); primaryStage.show();
Button btnMain = new Button("show"); btnMain.setOnAction(evt -> { Stage stage = new Stage(); Button btn = new Button("Close"); btn.setOnAction((ActionEvent event) -> { root.getChildren().add(btn); Bounds mainBounds = primaryStage.getScene().getRoot().getLayoutBounds(); Scene scene = new Scene(root, 400, 400); stage.setX(primaryStage.getX() + (mainBounds.getWidth() - rootBounds.getWidth()) / 2); stage.setY(primaryStage.getY() + (mainBounds.getHeight() - rootBounds.getHeight()) / 2); stage.showAndWait(); System.out.println("done");
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(); .getHeight() / 2, 2) + Math.pow(burgerWidth / 2, 2)); double angle = Math.toDegrees(Math.asin((burgerHeight / 2 - burger.getChildren() .get(0) .getLayoutBounds() .getHeight() / 2) / hypotenuse)); double burgerDiagonal = Math.sqrt(Math.pow(burger.getChildren().get(0).getLayoutBounds().getHeight(), 2) + Math.pow(burger.getChildren() .get(0) .getBoundsInParent() .getWidth() / 2, 2)); double theta = (90 - angle) + Math.toDegrees(Math.atan((burger.getChildren() .get(0) .getLayoutBounds() .getHeight()) / (burger.getChildren() .get(0) .getBoundsInParent() .getWidth() / 2))); double hOffset = Math.cos(Math.toRadians(theta)) * burgerDiagonal / 2; double transY = burger.getChildren().get(0).getLayoutBounds().getHeight() / 2 + burger.getSpacing() - hOffset; double transX = burgerWidth / 2 - Math.sin(Math.toRadians(theta)) * (burgerDiagonal / 2);
public void setPosition(TransformablePoint3d position) { positionDecoupled.set(position); Bounds boundsInLocal = text3dMesh.getBoundsInLocal(); text3dMesh.setTranslateX(((boundsInLocal.getMinX() - boundsInLocal.getMaxX()) / 2.0) - boundsInLocal.getMinX() + positionDecoupled.getX()); text3dMesh.setTranslateY(((boundsInLocal.getMaxY() - boundsInLocal.getMinY()) / 2.0) - boundsInLocal.getMaxY() + positionDecoupled.getY()); text3dMesh.setTranslateZ(((boundsInLocal.getMinZ() - boundsInLocal.getMaxZ()) / 2.0) - boundsInLocal.getMinZ() + positionDecoupled.getZ()); }
public static void smoothScrolling(ScrollPane scrollPane) { customScrolling(scrollPane, scrollPane.vvalueProperty(), bounds -> bounds.getHeight()); }
public static void smoothHScrolling(ScrollPane scrollPane) { customScrolling(scrollPane, scrollPane.hvalueProperty(), bounds -> bounds.getWidth()); }
private void displayLabelForData(XYChart.Data<String, Number> data) { final Node node = data.getNode(); final Text dataText = new Text(data.getYValue() + ""); node.parentProperty().addListener(new ChangeListener<Parent>() { @Override public void changed(ObservableValue<? extends Parent> ov, Parent oldParent, Parent parent) { Group parentGroup = (Group) parent; parentGroup.getChildren().add(dataText); } }); node.boundsInParentProperty().addListener(new ChangeListener<Bounds>() { @Override public void changed(ObservableValue<? extends Bounds> ov, Bounds oldBounds, Bounds bounds) { dataText.setLayoutX( Math.round( bounds.getMinX() + bounds.getWidth() / 2 - dataText.prefWidth(-1) / 2 ) ); dataText.setLayoutY( Math.round( bounds.getMinY() - dataText.prefHeight(-1) * 0.5 ) ); } }); }
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()); }
private void showAutocompletePopup(int insertionIndex, String input) { CompletionResultSource suggestionMaker = mySuggestionProvider.get(); List<MenuItem> suggestions = suggestionMaker.getSortedMatches(input, 5) .map(result -> { Label entryLabel = new Label(); entryLabel.setGraphic(result.getTextFlow()); entryLabel.setPrefHeight(5); CustomMenuItem item = new CustomMenuItem(entryLabel, true); item.setUserData(result); item.setOnAction(e -> applySuggestion(insertionIndex, input, result.getNodeName())); return item; }) .collect(Collectors.toList()); autoCompletePopup.getItems().setAll(suggestions); myCodeArea.getCharacterBoundsOnScreen(insertionIndex, insertionIndex + input.length()) .ifPresent(bounds -> autoCompletePopup.show(myCodeArea, bounds.getMinX(), bounds.getMaxY())); Skin<?> skin = autoCompletePopup.getSkin(); if (skin != null) { Node fstItem = skin.getNode().lookup(".menu-item"); if (fstItem != null) { fstItem.requestFocus(); } } }
Bounds userTextFieldBounds = userTextField.getBoundsInLocal(); Point2D popupLocation = userTextField.localToScene(userTextFieldBounds.getMaxX(), userTextFieldBounds.getMinY()); popup.show(userTextField, popupLocation.getX()+scene.getX()+primaryStage.getX(), popupLocation.getY()+scene.getY()+primaryStage.getY());