/*************************************************************************** * * Public API * * **************************************************************************/ public void registerSnackbarContainer(Pane snackbarContainer) { if (snackbarContainer != null) { if (this.snackbarContainer != null) { //since listeners are added the container should be properly registered/unregistered throw new IllegalArgumentException("Snackbar Container already set"); } this.snackbarContainer = snackbarContainer; this.snackbarContainer.getChildren().add(this); this.snackbarContainer.heightProperty().addListener(weakSizeListener); this.snackbarContainer.widthProperty().addListener(weakSizeListener); } }
public void unregisterSnackbarContainer(Pane snackbarContainer) { if (snackbarContainer != null) { if (this.snackbarContainer == null) { throw new IllegalArgumentException("Snackbar Container not set"); } this.snackbarContainer.getChildren().remove(this); this.snackbarContainer.heightProperty().removeListener(weakSizeListener); this.snackbarContainer.widthProperty().removeListener(weakSizeListener); this.snackbarContainer = null; } }
/*************************************************************************** * * Public API * * **************************************************************************/ public void registerSnackbarContainer(Pane snackbarContainer) { if (snackbarContainer != null) { if (this.snackbarContainer != null) { //since listeners are added the container should be properly registered/unregistered throw new IllegalArgumentException("Snackbar Container already set"); } this.snackbarContainer = snackbarContainer; this.snackbarContainer.getChildren().add(this); this.snackbarContainer.heightProperty().addListener(weakSizeListener); this.snackbarContainer.widthProperty().addListener(weakSizeListener); } }
/** * @param chartParentPane that should contain the {@link WebView} used by this chart controller * @param webEngineConsumer a {@link WebEngine} consumer that knows how to retrieve the content to be displayed, without relying on the value returned by {@link #createChartData()} */ public HtmlChartController(Pane chartParentPane, Consumer<WebEngine> webEngineConsumer) { this.webEngineConsumer = webEngineConsumer; chartParentPane.getChildren().add(webView); chartParentPane.widthProperty().addListener((obs, oldVal, newVal) -> {webView.setPrefWidth(newVal.doubleValue());}); chartParentPane.heightProperty().addListener((obs, oldVal, newVal) -> {webView.setPrefHeight(newVal.doubleValue());}); }
public void start(Stage stage) throws Exception { Pane root = new Pane(); int grid_x = 7; //number of rows int grid_y = 7; //number of columns for (int x = 0; x < grid_x; x++) { for (int y = 0; y < grid_y; y++) { Rectangle temp = new Rectangle(); temp.xProperty().bind(root.heightProperty().divide(grid_x).multiply(x)); temp.yProperty().bind(root.heightProperty().divide(grid_x).multiply(y)); temp.heightProperty().bind(root.heightProperty().divide(grid_x)); temp.widthProperty().bind(temp.heightProperty()); root.getChildren().add(temp); } } stage.setScene(new Scene(root, 500, 500)); stage.show(); }
//This pane is the root of the scene, and stretches with the //stage. It will hold the smileyPane. Pane rootPane = new Pane(); double smileyRadius = 50.0; //This pane is just big enough to hold the outer circle of //the smiley face. It holds all the individual pieces that //make up the face. Pane smileyPane = new Pane(); rootPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { double smileyPaneStartX = (newValue.doubleValue()/2)-(smileyRadius); smileyPane.setLayoutX(smileyPaneStartX); } }); rootPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { double smileyPaneStartY = (newValue.doubleValue()/2)-(smileyRadius); smileyPane.setLayoutY(smileyPaneStartY); } });
public void unregisterSnackbarContainer(Pane snackbarContainer) { if (snackbarContainer != null) { if (this.snackbarContainer == null) { throw new IllegalArgumentException("Snackbar Container not set"); } this.snackbarContainer.getChildren().remove(this); this.snackbarContainer.heightProperty().removeListener(weakSizeListener); this.snackbarContainer.widthProperty().removeListener(weakSizeListener); this.snackbarContainer = null; } }
Pane pane = new Pane(); Text text = new Text(250,250,"1"); pane.getChildren().add(text); double width = 150; double height = 150; Scene scene = new Scene(pane, width, height); double x = 50; double y = 50; double xRatio = x / width; //GET THE RATIO double yRatio = y / width; //GET THE RATIO text.xProperty().bind(pane.widthProperty().multiply(xRatio)); text.yProperty().bind(pane.heightProperty().multiply(yRatio)); stage.setTitle("Hello World!"); stage.setScene(scene); stage.show();
public void _doSetSecondaryheader(Node node) { secondaryHeaderStack.setVisible(true); secondaryHeaderStack.getChildren().clear(); secondaryHeaderStack.getChildren().add(node); secondaryHeaderStack.heightProperty().addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> { pushedContentWrapper.translateYProperty().set(newValue.doubleValue() + 2); rootStructureWrapper.translateYProperty().set(newValue.doubleValue() + 2); }); }
Pane root = new VBox(); //or other Pane sub-class ImageView bg = new ImageView(...); bg.setPreserveRatio(false); bg.fitWidthProperty().bind(root.widthProperty()); bg.fitHeightProperty().bind(root.heightProperty()); root.getChildren().addAll(bg);
/** * <p> Only available for sub-scene creation. </p> * Binds the sub-scene size to the pane's size. * @param pane the pane the sub-scene's size is to be bind to. */ public void bindSubSceneSizeToPaneSize(Pane pane) { if (subScene == null) return; subScene.heightProperty().bind(pane.heightProperty()); subScene.widthProperty().bind(pane.widthProperty()); }
/** * <p> Only available for sub-scene creation. </p> * Binds the sub-scene size to the pane's size. * @param pane the pane the sub-scene's size is to be bind to. */ public void bindSubSceneSizeToPaneSize(Pane pane) { if (subScene == null) return; subScene.heightProperty().bind(pane.heightProperty()); subScene.widthProperty().bind(pane.widthProperty()); } }
public void setBTop(Pane top) { Pane leftGap = (Pane) getGapNode(); Pane rightGap = (Pane) getGapNode(); leftGap.prefHeightProperty().bind(top.heightProperty()); rightGap.prefHeightProperty().bind(top.heightProperty()); HBox t = new HBox(); HBox.setHgrow(top, Priority.ALWAYS); t.getChildren().addAll(leftGap, top, rightGap); setTop(t); }
Pane pane3 = new Pane(); Circle circ3 = new Circle(); circ3.setStroke(Color.PEACHPUFF); circ3.setFill(Color.YELLOWGREEN); circ3.centerXProperty().bind(pane3.widthProperty().divide(2)); circ3.centerYProperty().bind(pane3.heightProperty().divide(2)); circ3.radiusProperty().bind(pane3.widthProperty().divide(2));
Pane testImage2(Pane pane) { Pane inner = new Pane(); inner.prefWidthProperty().bind(pane.widthProperty()); inner.prefHeightProperty().bind(pane.heightProperty()); pane.getChildren().add(inner); SVGPath texture = new SVGPath(); texture.setStroke(Color.GREEN); texture.setStrokeWidth(2.5); texture.setFill(Color.TRANSPARENT); texture.setContent("M 10 10 C 40 10 10 70 70 20"); SnapshotParameters params = new SnapshotParameters(); params.setViewport(new Rectangle2D(-5, -5, 70, 50)); Image image = texture.snapshot(params, null); Paint paint = new ImagePattern(image, 5,5, 20, 20, false); inner.setBackground(new Background(new BackgroundFill(paint, new CornerRadii(0), new Insets(inset)))); return pane; }
/** * construct me for the given gauge * * @param rgauge */ public ResetableGaugeSkin(ResetableGauge rgauge) { super(rgauge); pane = (Pane) this.getChildren().get(0); ImageButton rb = rgauge.getResetButton(); pane.getChildren().add(rb); rb.translateXProperty().set(5); rb.translateYProperty().set(0); rb.imageHeightProperty().bind(pane.heightProperty().multiply(0.225)); rb.imageWidthProperty().bind(pane.widthProperty().multiply(0.15)); }
/** * {@inheritDoc} */ @Override public void layout(IViewLayoutManageable layoutManageable) { super.layout(layoutManageable); if (topNode == null) { headerAreaSection.setVisible(false); AnchorPane.clearConstraints(anchorCenteredPane); AnchorPane.setLeftAnchor(anchorCenteredPane, 0.); AnchorPane.setRightAnchor(anchorCenteredPane, 0.); AnchorPane.setTopAnchor(anchorCenteredPane, 0.); AnchorPane.setBottomAnchor(anchorCenteredPane, 72.); } else { headerAreaSection.heightProperty().addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> { headerHeight = newValue.doubleValue(); AnchorPane.clearConstraints(anchorCenteredPane); AnchorPane.setTopAnchor(anchorCenteredPane, 0.); AnchorPane.setLeftAnchor(anchorCenteredPane, 0.); AnchorPane.setRightAnchor(anchorCenteredPane, 0.); AnchorPane.setBottomAnchor(anchorCenteredPane, 72.); }); } if(bottomNode != null) { bottomNode.visibleProperty().addListener((ChangeListener<Boolean>) (observable, oldValue, newValue) -> { updateConstraints(); }); } }
/** * Inline Edit a row inside a simple editor pane. All node in the row are wrapped in an editor which * holds the action buttons. * * @param inlineEditor */ @Override public void beginInlineEdit(IFormRowEditor inlineEditor) { beginEdition(); getChildren().clear(); getChildren().add(inlineEditor.getDisplay()); minHeightProperty().unbind(); minHeightProperty().bind(((Pane) inlineEditor.getDisplay()).heightProperty()); NodeHelper.setHgrow(inlineEditor.getDisplay()); FadeTransition tt = NodeHelper.fadeIn(inlineEditor.getDisplay(), Duration.millis(100)); EasingInterpolator ei = new EasingInterpolator(EasingMode.IN_CIRC); tt.setInterpolator(ei); tt.play(); requestLayout(); requestParentLayout(); }
lineInput.endXProperty().set(lineInput.startXProperty().get()); lineInput.startYProperty().set(0); lineInput.endYProperty().bind(animationPane.heightProperty()); animationPane.getChildren().add(lineInput); lineOutput.endXProperty().set(lineOutput.startXProperty().get()); lineOutput.startYProperty().set(0); lineOutput.endYProperty().bind(animationPane.heightProperty()); animationPane.getChildren().add(lineOutput);
public static void startValueSetAnimation(final Pane parent) { final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle(); Insets margin = BorderPane.getMargin(parent); if (margin == null) { margin = new Insets(0); } rectangle.widthProperty().bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight())); rectangle.heightProperty().bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom())); rectangle.setFill(Color.rgb(0, 150, 201)); parent.getChildren().add(rectangle); BoxBlur bb = new BoxBlur(); bb.setWidth(5); bb.setHeight(5); bb.setIterations(3); rectangle.setEffect(bb); FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle); ft.setFromValue(0.2); ft.setToValue(0.8); ft.setCycleCount(2); ft.setAutoReverse(true); ft.play(); ft.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { parent.getChildren().remove(rectangle); } }); }