use of org.apache.pivot.wtk.Border 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;
}
use of org.apache.pivot.wtk.Border in project pivot by apache.
the class DOMInteractionDemo method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
helloButton = new PushButton("Say Hello");
boxPane.add(helloButton);
helloButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
BrowserApplicationContext.eval("sayHello(\"Hello from Pivot!\")", DOMInteractionDemo.this);
}
});
Border border = new Border(boxPane);
border.getStyles().put(Style.color, 7);
border.getStyles().put(Style.padding, 5);
window = new Window(border);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.Border in project pivot by apache.
the class BorderSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
int preferredWidth = 0;
Border border = (Border) getComponent();
String title = border.getTitle();
if (title != null && title.length() > 0) {
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
Rectangle2D headingBounds = font.getStringBounds(title, fontRenderContext);
preferredWidth = (int) Math.ceil(headingBounds.getWidth());
}
Component content = border.getContent();
if (content != null) {
int heightUpdated = height;
if (heightUpdated != -1) {
heightUpdated = Math.max(heightUpdated - paddingThicknessHeight(), 0);
}
preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(heightUpdated));
}
preferredWidth += paddingThicknessWidth();
return preferredWidth;
}
Aggregations