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;
}
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;
}
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);
}
}
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);
}
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;
}