Search in sources :

Example 1 with StackPane

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

the class StackPaneSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    StackPane stackPane = (StackPane) getComponent();
    for (Component component : stackPane) {
        preferredHeight = Math.max(preferredHeight, component.getPreferredHeight(width));
    }
    preferredHeight += padding.getHeight();
    return preferredHeight;
}
Also used : Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 2 with StackPane

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

the class StackPaneSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    int preferredWidth = 0;
    StackPane stackPane = (StackPane) getComponent();
    for (Component component : stackPane) {
        preferredWidth = Math.max(preferredWidth, component.getPreferredWidth(height));
    }
    preferredWidth += padding.getWidth();
    return preferredWidth;
}
Also used : Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 3 with StackPane

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

the class StackPaneSkin method layout.

@Override
public void layout() {
    // Set the size of all components to match the size of the stack pane,
    // minus padding
    StackPane stackPane = (StackPane) getComponent();
    int width = Math.max(getWidth() - padding.getWidth(), 0);
    int height = Math.max(getHeight() - padding.getHeight(), 0);
    for (Component component : stackPane) {
        component.setLocation(padding.left, padding.top);
        component.setSize(width, height);
    }
}
Also used : Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 4 with StackPane

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

the class StackPaneSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    int preferredWidth = 0;
    int preferredHeight = 0;
    StackPane stackPane = (StackPane) getComponent();
    for (Component component : stackPane) {
        Dimensions preferredCardSize = component.getPreferredSize();
        preferredWidth = Math.max(preferredWidth, preferredCardSize.width);
        preferredHeight = Math.max(preferredHeight, preferredCardSize.height);
    }
    preferredWidth += padding.getWidth();
    preferredHeight += padding.getHeight();
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 5 with StackPane

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

the class ColorPaletteTest method createCell.

private static Component createCell(int index) {
    StackPane stackPane = new StackPane();
    Border border = new Border();
    border.getStyles().put(Style.backgroundColor, index);
    stackPane.add(border);
    Label label = new Label();
    label.setText(Integer.toString(index));
    label.getStyles().put(Style.backgroundColor, Color.WHITE);
    label.getStyles().put(Style.padding, 2);
    Color themeColor = border.getStyles().getColor(Style.backgroundColor);
    Label colorLabel = new Label();
    colorLabel.setText(String.format("R:%1$d,G:%2$d,B:%3$d", themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue()));
    colorLabel.getStyles().put(Style.backgroundColor, Color.WHITE);
    colorLabel.getStyles().put(Style.padding, 2);
    BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    boxPane.add(new Border(label));
    boxPane.add(new Border(colorLabel));
    stackPane.add(boxPane);
    return stackPane;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Color(java.awt.Color) Label(org.apache.pivot.wtk.Label) Border(org.apache.pivot.wtk.Border) StackPane(org.apache.pivot.wtk.StackPane)

Aggregations

StackPane (org.apache.pivot.wtk.StackPane)5 Component (org.apache.pivot.wtk.Component)4 Color (java.awt.Color)1 Border (org.apache.pivot.wtk.Border)1 BoxPane (org.apache.pivot.wtk.BoxPane)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 Label (org.apache.pivot.wtk.Label)1