Search in sources :

Example 11 with Border

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

Example 12 with Border

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);
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Window(org.apache.pivot.wtk.Window) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) PushButton(org.apache.pivot.wtk.PushButton) Border(org.apache.pivot.wtk.Border)

Example 13 with Border

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;
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) FontRenderContext(java.awt.font.FontRenderContext) Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border) Paint(java.awt.Paint)

Aggregations

Border (org.apache.pivot.wtk.Border)13 Paint (java.awt.Paint)6 Component (org.apache.pivot.wtk.Component)6 BoxPane (org.apache.pivot.wtk.BoxPane)4 Window (org.apache.pivot.wtk.Window)4 FontRenderContext (java.awt.font.FontRenderContext)3 Rectangle2D (java.awt.geom.Rectangle2D)3 RoundRectangle2D (java.awt.geom.RoundRectangle2D)3 Button (org.apache.pivot.wtk.Button)2 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)2 Label (org.apache.pivot.wtk.Label)2 PushButton (org.apache.pivot.wtk.PushButton)2 Theme (org.apache.pivot.wtk.Theme)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Area (java.awt.geom.Area)1 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 Button (org.apache.pivot.wtk.Mouse.Button)1 StackPane (org.apache.pivot.wtk.StackPane)1