Search in sources :

Example 6 with Border

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

the class BorderSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    Border border = (Border) getComponent();
    Component content = border.getContent();
    if (content != null) {
        int widthUpdated = width;
        if (widthUpdated != -1) {
            widthUpdated = Math.max(widthUpdated - paddingThicknessWidth(), 0);
        }
        preferredHeight = content.getPreferredHeight(widthUpdated);
    }
    preferredHeight += paddingThicknessHeight();
    return preferredHeight;
}
Also used : Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border) Paint(java.awt.Paint)

Example 7 with Border

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

the class ColorSchemeBuilderWindow method createColorPaletteCell.

private static Component createColorPaletteCell(int index) {
    Border border = new Border();
    border.getStyles().put(Style.backgroundColor, index);
    Theme theme = Theme.getTheme();
    Label label = new Label();
    label.setText(Integer.toString(index));
    label.getStyles().put(Style.font, "{size:'80%'}");
    label.getStyles().put(Style.backgroundColor, 4);
    label.getStyles().put(Style.padding, 1);
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.padding, 2);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    boxPane.add(new Border(label));
    border.setContent(boxPane);
    return border;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label) Theme(org.apache.pivot.wtk.Theme) Border(org.apache.pivot.wtk.Border)

Example 8 with Border

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

the class ColorPaletteTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    Theme theme = Theme.getTheme();
    TablePane tablePane = new TablePane();
    new TablePane.Column(tablePane, 1, true);
    new TablePane.Column(tablePane, 1, true);
    new TablePane.Column(tablePane, 1, true);
    int numberOfPaletteColors = theme.getNumberOfPaletteColors();
    // ArrayList<String> colors = new ArrayList<>(numberOfPaletteColors);
    for (int i = 0; i < numberOfPaletteColors; i++) {
        TablePane.Row row = new TablePane.Row(tablePane, 1, true);
        row.add(createCell(i * 3));
        row.add(createCell(i * 3 + 1));
        row.add(createCell(i * 3 + 2));
    }
    tablePane.getStyles().put(Style.horizontalSpacing, 4);
    tablePane.getStyles().put(Style.verticalSpacing, 4);
    Border border = new Border(tablePane);
    border.getStyles().put(Style.padding, 6);
    this.window = new Window(border);
    this.window.setTitle("Color Palette");
    this.window.setMaximized(true);
    this.window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Theme(org.apache.pivot.wtk.Theme) Border(org.apache.pivot.wtk.Border) TablePane(org.apache.pivot.wtk.TablePane)

Example 9 with Border

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

the class PromptTest 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);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.BOTTOM);
    helloButton = new PushButton("Say Hello");
    boxPane.add(helloButton);
    helloButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            String text = button.getButtonData().toString();
            if (window.isBlocked()) {
                System.out.println("I'm already saying \"" + text + "\" !");
            } else {
                Prompt.prompt(text, window);
            }
        }
    });
    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 10 with Border

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

the class Pivot951 method startup.

@Override
public void startup(Display display, Map<String, String> properties) {
    window = new Window();
    Border brd = new Border();
    brd.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {

        @Override
        public boolean mouseClick(Component component, Button button, int x, int y, int count) {
            if (count == 1) {
                System.out.println("Click!");
            } else {
                System.out.println("Double Click!");
            }
            return true;
        }
    });
    window.setContent(brd);
    window.setTitle("Pivot951: Cannot click twice");
    window.setMaximized(true);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Button(org.apache.pivot.wtk.Mouse.Button) ComponentMouseButtonListener(org.apache.pivot.wtk.ComponentMouseButtonListener) Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border)

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