Java Code Examples for javafx.scene.layout.RowConstraints#setPercentHeight()

The following examples show how to use javafx.scene.layout.RowConstraints#setPercentHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFXHelper.java    From Schillsaver with MIT License 6 votes vote down vote up
/**
 * Creates a GridPane with only one column, but where there are as many rows as there are controls passed
 * to the function.
 *
 * Ex:
 *      If you pass in two controls, then there will be one column with two rows where each row uses 50%
 *      of the height.
 *
 * Ex:
 *      If you pass in four controls, then there will be one column with four rows where each row uses 25%
 *      of the height.
 *
 * @param controls
 *          The controls.
 *
 * @return
 *          The pane.
 */
public static GridPane createVerticalGridPane(final Control... controls) {
    if (controls.length == 0) {
        return new GridPane();
    }

    final GridPane pane = new GridPane();
    final double sectionHeight = 100.0 / controls.length;

    for (final Control ignored : controls) {
        final RowConstraints constraints = new RowConstraints();
        constraints.setPercentHeight(sectionHeight);

        pane.getRowConstraints().add(constraints);
    }

    for (int i = 0 ; i < controls.length ; i++) {
        pane.add(controls[i], 0, i);
    }

    return pane;
}
 
Example 2
Source File: EasyGridPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
public void addRowConstraint(boolean fillHeight, VPos alignment, Priority grow, double maxHeight, double minHeight, double prefHeight, double percentHeight) {
    RowConstraints constraint = new RowConstraints();
    constraint.setFillHeight(fillHeight);
    constraint.setValignment(alignment);
    constraint.setVgrow(grow);
    constraint.setMaxHeight(maxHeight);
    constraint.setMinHeight(minHeight);
    constraint.setPrefHeight(prefHeight);

    if (percentHeight >= 0) {
        constraint.setPercentHeight(percentHeight);
    }

    getRowConstraints().add(constraint);
}
 
Example 3
Source File: ScatterPlot3DFXDemo3.java    From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Returns a panel containing the content for the demo.  This method is
 * used across all the individual demo applications to allow aggregation 
 * into a single "umbrella" demo (OrsonChartsDemo).
 * 
 * @return A panel containing the content for the demo.
 */
public static Node createDemoNode() {
    
    XYZDataset[] datasets = createDatasets();
    Chart3D chart1 = createChart(
            "Iris Dataset : Combination 1", datasets[0], "Sepal Length", 
            "Sepal Width", "Petal Length");
    chart1.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120));
    Chart3DViewer viewer1 = new Chart3DViewer(chart1);
    Chart3D chart2 = createChart(
            "Iris Dataset : Combination 2", datasets[1], 
            "Sepal Length", "Sepal Width", "Petal Width");
    chart2.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120));
    Chart3DViewer viewer2 = new Chart3DViewer(chart2);
    Chart3D chart3 = createChart(
            "Iris Dataset : Combination 3", datasets[2], 
            "Sepal Length", "Petal Width", "Petal Length");
    chart3.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120));
    Chart3DViewer viewer3 = new Chart3DViewer(chart3);
    Chart3D chart4 = createChart(
            "Iris Dataset : Combination 4", datasets[3], 
            "Sepal Width", "Petal Width", "Petal Length");
    chart4.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120));
    Chart3DViewer viewer4 = new Chart3DViewer(chart4);
    GridPane pane = new GridPane();
    ColumnConstraints c1 = new ColumnConstraints();
    c1.setPercentWidth(50);
    ColumnConstraints c2 = new ColumnConstraints();
    c2.setPercentWidth(50);
    pane.getColumnConstraints().addAll(c1, c2);
    RowConstraints r1 = new RowConstraints();
    r1.setPercentHeight(50);
    RowConstraints r2 = new RowConstraints();
    r2.setPercentHeight(50);
    pane.getRowConstraints().addAll(r1, r2);
    pane.add(viewer1, 0, 0);
    pane.add(viewer2, 0, 1);
    pane.add(viewer3, 1, 0);
    pane.add(viewer4, 1, 1);
    return pane;
}
 
Example 4
Source File: FXStockChart.java    From Rails with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a {@link RowConstraints} object with the given height factor.
 * The height factor defines, how much higher the row is compared to other columns.
 * A factor of 2 means, that the row is twice as high as a row with the factor 1
 *
 * @param factor The height factor
 * @return The created constraint
 */
private RowConstraints createRow(int factor) {
    RowConstraints constraints = new RowConstraints();

    constraints.setPercentHeight(100d / ((market.getNumberOfRows() * 2) + 1) * factor);

    return constraints;
}