Search in sources :

Example 1 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    GridPane gridPane = (GridPane) component;
    gridPane.getGridPaneListeners().add(this);
}
Also used : GridPane(org.apache.pivot.wtk.GridPane)

Example 2 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method paint.

@Override
public void paint(Graphics2D graphics) {
    super.paint(graphics);
    GridPane gridPane = (GridPane) getComponent();
    GridPane.RowSequence rows = gridPane.getRows();
    int columnCount = gridPane.getColumnCount();
    int rowCount = rows.getLength();
    int width = getWidth();
    int height = getHeight();
    Metadata metadata = new Metadata();
    if (showHorizontalGridLines && verticalSpacing > 0 && rowCount > 1) {
        graphics.setPaint(horizontalGridColor);
        int rowY = padding.top + (cellHeight + verticalSpacing);
        for (int i = 1; i < rowCount; i++) {
            if (metadata.isRowVisible(i - 1)) {
                int gridY = Math.max(rowY - (int) Math.ceil(verticalSpacing * 0.5f), 0);
                GraphicsUtilities.drawLine(graphics, 0, gridY, width, Orientation.HORIZONTAL);
                rowY += (cellHeight + verticalSpacing);
            }
        }
    }
    if (showVerticalGridLines && horizontalSpacing > 0 && columnCount > 1) {
        graphics.setPaint(verticalGridColor);
        int columnX = padding.left + (cellWidth + horizontalSpacing);
        for (int j = 1; j < columnCount; j++) {
            if (metadata.isColumnVisible(j - 1)) {
                int gridX = Math.max(columnX - (int) Math.ceil(horizontalSpacing * 0.5f), 0);
                GraphicsUtilities.drawLine(graphics, gridX, 0, height, Orientation.VERTICAL);
                columnX += (cellWidth + horizontalSpacing);
            }
        }
    }
}
Also used : GridPane(org.apache.pivot.wtk.GridPane)

Example 3 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    GridPane gridPane = (GridPane) getComponent();
    GridPane.RowSequence rows = gridPane.getRows();
    int columnCount = gridPane.getColumnCount();
    int rowCount = rows.getLength();
    Metadata metadata = new Metadata();
    int cellWidthLocal = getCellWidth(width, metadata);
    int preferredCellHeight = 0;
    for (int i = 0; i < rowCount; i++) {
        GridPane.Row row = rows.get(i);
        for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
            Component component = row.get(j);
            if (component != null && component.isVisible()) {
                preferredCellHeight = Math.max(preferredCellHeight, component.getPreferredHeight(cellWidthLocal));
            }
        }
    }
    // The preferred height of the grid pane is the sum of the row
    // heights, plus padding and spacing
    int preferredHeight = (metadata.visibleRowCount * preferredCellHeight) + padding.getHeight();
    if (metadata.visibleRowCount > 1) {
        preferredHeight += (metadata.visibleRowCount - 1) * verticalSpacing;
    }
    return preferredHeight;
}
Also used : GridPane(org.apache.pivot.wtk.GridPane) Component(org.apache.pivot.wtk.Component)

Example 4 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    GridPane gridPane = (GridPane) getComponent();
    GridPane.RowSequence rows = gridPane.getRows();
    int columnCount = gridPane.getColumnCount();
    int rowCount = rows.getLength();
    Metadata metadata = new Metadata();
    int cellWidthLocal = getCellWidth(width, metadata);
    int cellHeightLocal = getCellHeight(height, metadata);
    // Return the first available baseline by traversing cells top left to
    // bottom right
    int baseline = -1;
    int rowY = padding.top;
    for (int i = 0; i < rowCount && baseline == -1; i++) {
        if (metadata.isRowVisible(i)) {
            GridPane.Row row = rows.get(i);
            for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) {
                Component component = row.get(j);
                if (component != null && component.isVisible()) {
                    baseline = component.getBaseline(cellWidthLocal, cellHeightLocal);
                    if (baseline != -1) {
                        baseline += rowY;
                    }
                }
            }
            rowY += (cellHeightLocal + verticalSpacing);
        }
    }
    return baseline;
}
Also used : GridPane(org.apache.pivot.wtk.GridPane) Component(org.apache.pivot.wtk.Component)

Example 5 with GridPane

use of org.apache.pivot.wtk.GridPane in project pivot by apache.

the class GridPaneSkin method getRowAt.

// GridPane.Skin methods
@Override
public int getRowAt(int y) {
    GridPane gridPane = (GridPane) getComponent();
    GridPane.RowSequence rows = gridPane.getRows();
    int rowCount = rows.getLength();
    int rowIndex = -1;
    int rowY = padding.top;
    for (int i = 0; rowY <= y && i < rowCount; i++) {
        if (y < rowY + cellHeight) {
            rowIndex = i;
            break;
        }
        rowY += cellHeight + verticalSpacing;
    }
    return rowIndex;
}
Also used : GridPane(org.apache.pivot.wtk.GridPane)

Aggregations

GridPane (org.apache.pivot.wtk.GridPane)13 Component (org.apache.pivot.wtk.Component)6 Bounds (org.apache.pivot.wtk.Bounds)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 FileObject (org.apache.commons.vfs2.FileObject)1 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)1 Dictionary (org.apache.pivot.collections.Dictionary)1 Task (org.apache.pivot.util.concurrent.Task)1 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)1 TaskListener (org.apache.pivot.util.concurrent.TaskListener)1 ActivityIndicator (org.apache.pivot.wtk.ActivityIndicator)1 CardPane (org.apache.pivot.wtk.CardPane)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 Row (org.apache.pivot.wtk.GridPane.Row)1 Point (org.apache.pivot.wtk.Point)1 PushButton (org.apache.pivot.wtk.PushButton)1 SortDirection (org.apache.pivot.wtk.SortDirection)1 TableView (org.apache.pivot.wtk.TableView)1