Example usage for javafx.scene.layout GridPane setPrefHeight

List of usage examples for javafx.scene.layout GridPane setPrefHeight

Introduction

In this page you can find the example usage for javafx.scene.layout GridPane setPrefHeight.

Prototype

public final void setPrefHeight(double value) 

Source Link

Usage

From source file:de.ifsr.adam.ImageGenerator.java

/**
 * Puts the charts in chartList into GridPanes as specified by chartsPerColumn and chartsPerRow.
 *
 * @param chartList The ArrayList with the charts.
 * @param chartsPerColumn Number of charts that are in one column.
 * @param chartsPerRow Number of charts that are in one row.
 * @return The list of GridPanes that were generated.
 *///from   w w  w.j a v a2 s .com
private ArrayList<GridPane> makeLayout(ArrayList<Chart> chartList, Integer chartsPerColumn,
        Integer chartsPerRow) {
    ArrayList<GridPane> gridPaneList = new ArrayList<>();
    GridPane gridPane = new GridPane();
    int rowIndex = 0, columnIndex = 0;
    Iterator<Chart> iter = chartList.iterator();

    //int i = 0;//TODO: Remove 
    while (iter.hasNext()) {
        //System.out.println("Run: "+ i + " columnIndex: " + columnIndex + " rowIndex: " + rowIndex);//TODO: Remove 
        //i++;//TODO: Remove 

        Chart chart = iter.next();
        calculateChartSize(chart, chartsPerColumn, chartsPerRow);
        gridPane.add(chart, columnIndex, rowIndex);

        columnIndex++;

        //Case: Row is full go to next row
        if (columnIndex >= chartsPerRow) {
            columnIndex = 0;
            rowIndex++;
        }

        //Case: Page is full start a new GridPane
        if (rowIndex >= chartsPerColumn) {
            //The Layout for the gridPane
            gridPane.setHgap(imageWidth * 0.10);
            gridPane.setAlignment(Pos.CENTER);
            gridPane.setPrefWidth(imageWidth);
            gridPane.setPrefHeight(imageHeight);

            gridPaneList.add(gridPane);
            gridPane = new GridPane();
            rowIndex = 0;
        }
    }

    //This needs to be check, or the last page can be empty
    if (rowIndex != 0 || columnIndex != 0) {
        gridPaneList.add(gridPane);
    }

    return gridPaneList;
}