Search in sources :

Example 31 with Component

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

the class TablePaneSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    TablePane tablePane = (TablePane) getComponent();
    TablePane.RowSequence rows = tablePane.getRows();
    TablePane.ColumnSequence columns = tablePane.getColumns();
    int rowCount = rows.getLength();
    int columnCount = columns.getLength();
    int[] columnWidthsLocal = getColumnWidths(width);
    int[] rowHeightsLocal = getRowHeights(height, columnWidthsLocal);
    boolean[][] occupiedCells = getOccupiedCells();
    int baseline = -1;
    int rowY = padding.top;
    for (int i = 0; i < rowCount && baseline == -1; i++) {
        TablePane.Row row = rows.get(i);
        boolean rowVisible = false;
        for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) {
            Component component = row.get(j);
            if (component != null && component.isVisible()) {
                int columnSpan = Math.min(TablePane.getColumnSpan(component), columnCount - j);
                int componentWidth = (columnSpan - 1) * horizontalSpacing;
                for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
                    componentWidth += columnWidthsLocal[j + k];
                }
                int rowSpan = Math.min(TablePane.getRowSpan(component), rowCount - i);
                int componentHeight = (rowSpan - 1) * verticalSpacing;
                for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
                    componentHeight += rowHeightsLocal[i + k];
                }
                baseline = component.getBaseline(Math.max(componentWidth, 0), Math.max(componentHeight, 0));
                if (baseline != -1) {
                    baseline += rowY;
                }
            }
            rowVisible |= occupiedCells[i][j];
        }
        if (rowVisible) {
            rowY += (rowHeightsLocal[i] + verticalSpacing);
        }
    }
    return baseline;
}
Also used : Component(org.apache.pivot.wtk.Component) TablePane(org.apache.pivot.wtk.TablePane)

Example 32 with Component

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

the class TextPaneSkinComponentNodeView method getBaseline.

@Override
public int getBaseline() {
    ComponentNode componentNode = (ComponentNode) getNode();
    Component component = componentNode.getComponent();
    int baseline = -1;
    if (component != null) {
        baseline = component.getBaseline();
    }
    return baseline;
}
Also used : Component(org.apache.pivot.wtk.Component) ComponentNode(org.apache.pivot.wtk.text.ComponentNode)

Example 33 with Component

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

the class TextPaneSkinComponentNodeView method attach.

@Override
protected void attach() {
    super.attach();
    ComponentNode componentNode = (ComponentNode) getNode();
    componentNode.getComponentNodeListeners().add(this);
    Component component = componentNode.getComponent();
    if (component != null) {
        component.getComponentListeners().add(myComponentListener);
    }
}
Also used : Component(org.apache.pivot.wtk.Component) ComponentNode(org.apache.pivot.wtk.text.ComponentNode)

Example 34 with Component

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

the class TextPaneSkinComponentNodeView method componentChanged.

@Override
public void componentChanged(ComponentNode componentNode, Component previousComponent) {
    invalidateUpTree();
    Component component = componentNode.getComponent();
    if (component != null) {
        component.getComponentListeners().add(myComponentListener);
    }
    if (previousComponent != null) {
        previousComponent.getComponentListeners().remove(myComponentListener);
    }
}
Also used : Component(org.apache.pivot.wtk.Component)

Example 35 with Component

use of org.apache.pivot.wtk.Component 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)

Aggregations

Component (org.apache.pivot.wtk.Component)209 Dimensions (org.apache.pivot.wtk.Dimensions)40 Point (org.apache.pivot.wtk.Point)38 GradientPaint (java.awt.GradientPaint)33 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)24 TextInput (org.apache.pivot.wtk.TextInput)21 Label (org.apache.pivot.wtk.Label)20 BoxPane (org.apache.pivot.wtk.BoxPane)18 Paint (java.awt.Paint)17 Button (org.apache.pivot.wtk.Button)15 PushButton (org.apache.pivot.wtk.PushButton)14 ScrollPane (org.apache.pivot.wtk.ScrollPane)14 TablePane (org.apache.pivot.wtk.TablePane)14 Window (org.apache.pivot.wtk.Window)14 IOException (java.io.IOException)13 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)13 Frame (org.apache.pivot.wtk.Frame)13 FlowPane (org.apache.pivot.wtk.FlowPane)12 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)11 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)10