Search in sources :

Example 1 with Window

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

the class Pivot964Pivot method startup.

@Override
public void startup(Display display, Map<String, String> properties) {
    // force dimensions for host frame
    display.getHostWindow().setSize(1028, 600);
    window = new Window();
    prepareSVG();
    final ImageView image = new ImageView(new Drawing(diagram));
    BoxPane bp = new BoxPane();
    TablePane tp = new TablePane();
    setStyles(tp, "{padding: 4}");
    TablePane.Column c1 = new TablePane.Column(-1);
    TablePane.Column c2 = new TablePane.Column(-1);
    tp.getColumns().add(c1);
    tp.getColumns().add(c2);
    TablePane.Row r1 = new TablePane.Row(-1);
    TablePane.Row r2 = new TablePane.Row(-1);
    TablePane.Row r3 = new TablePane.Row(-1);
    PushButton pb1 = new PushButton("Visible");
    PushButton pb2 = new PushButton("Invisible (bug)");
    r1.add(pb1);
    r1.add(pb2);
    final Spinner sp1 = new Spinner(new ListAdapter<>(spinnerData));
    sp1.setPreferredWidth(80);
    sp1.setSelectedIndex(0);
    final Spinner sp2 = new Spinner(new ListAdapter<>(spinnerData));
    sp2.setPreferredWidth(80);
    sp2.setSelectedIndex(0);
    BoxPane bp1 = new BoxPane();
    setStyles(bp1, "{verticalAlignment:'center', padding: 4, spacing: 2}");
    bp1.add(new Label("X:"));
    bp1.add(sp1);
    r2.add(bp1);
    BoxPane bp2 = new BoxPane();
    setStyles(bp2, "{verticalAlignment:'center', padding: 4, spacing: 2}");
    bp2.add(new Label("Y:"));
    bp2.add(sp2);
    r2.add(bp2);
    tp.getRows().add(r1);
    tp.getRows().add(r2);
    r3.add(new Label("   Max X=507"));
    r3.add(new Label("   Max Y=269"));
    tp.getRows().add(r3);
    bp.add(image);
    bp.add(tp);
    pb1.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button arg0) {
            try {
                root.setAttribute("viewBox", AnimationElement.AT_XML, "0 0 2368 1652");
                root.updateTime(0f);
                image.repaint();
            } catch (SVGElementException e) {
                e.printStackTrace();
            } catch (SVGException e) {
                e.printStackTrace();
            }
        }
    });
    pb2.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button arg0) {
            try {
                String xOffset = (String) sp1.getSelectedItem();
                String yOffset = (String) sp2.getSelectedItem();
                String viewBox = String.format("%1$s %2$s 2368 1652", xOffset, yOffset);
                root.setAttribute("viewBox", AnimationElement.AT_XML, viewBox);
                root.updateTime(0f);
                image.repaint();
            } catch (SVGElementException e) {
                e.printStackTrace();
            } catch (SVGException e) {
                e.printStackTrace();
            }
        }
    });
    window.setContent(bp);
    window.setMaximized(true);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Drawing(org.apache.pivot.wtk.media.Drawing) Spinner(org.apache.pivot.wtk.Spinner) SVGException(com.kitfox.svg.SVGException) Label(org.apache.pivot.wtk.Label) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ImageView(org.apache.pivot.wtk.ImageView) SVGElementException(com.kitfox.svg.SVGElementException) PushButton(org.apache.pivot.wtk.PushButton) TablePane(org.apache.pivot.wtk.TablePane)

Example 2 with Window

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

the class Pivot765 method startup.

@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
    final MenuButton button = new MenuButton();
    button.setButtonData("Populate menu and open!");
    Window window = new Window(button);
    button.getListPopup().getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public Vote previewWindowOpen(Window windowArgument) {
            Menu menu = new Menu();
            Menu.Section section = new Menu.Section();
            menu.getSections().add(section);
            section.add(new Menu.Item("A dynamically added menu item"));
            button.setMenu(menu);
            menuPopulated = true;
            return Vote.APPROVE;
        }

        @Override
        public void windowOpened(Window windowArgument) {
            if (!menuPopulated) {
                Alert.alert("Window was opened before the menu was populated." + "Either previewWindowOpen threw an exception, or it wasn't called before the Window was opened.", windowArgument);
            }
        }

        @Override
        public void windowClosed(Window windowArgument, Display displayArgument, Window owner) {
            // Remove menu for subsequent open attempt
            button.setMenu(null);
            menuPopulated = false;
        }
    });
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Vote(org.apache.pivot.util.Vote) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) MenuButton(org.apache.pivot.wtk.MenuButton) Menu(org.apache.pivot.wtk.Menu) Display(org.apache.pivot.wtk.Display)

Example 3 with Window

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

the class Pivot838 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    // TODO: empty currently ...
    Window window = new Window();
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window)

Example 4 with Window

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

the class Pivot841 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    TextArea textArea = new TextArea();
    textArea.setText("abcxyz");
    final ParagraphListener paragraphListener = new ParagraphListener.Adapter() {

        @Override
        public void textInserted(Paragraph paragraph, int index, int count) {
            System.out.println("Text inserted\n\tparagraph content: '" + paragraph.getCharacters() + "" + "'\n\tindex: " + index + "\n\tcount: " + count);
        }

        @Override
        public void textRemoved(Paragraph paragraph, int index, int count) {
            System.out.println("Text removed\n\tparagraph content: '" + paragraph.getCharacters() + "'\n\tindex: " + index + "\n\tcount: " + count);
        }
    };
    textArea.getParagraphs().get(0).getParagraphListeners().add(paragraphListener);
    textArea.getTextAreaContentListeners().add(new TextAreaContentListener() {

        @Override
        public void paragraphInserted(TextArea textAreaArgument, int index) {
            Paragraph paragraph = textAreaArgument.getParagraphs().get(index);
            System.out.println("Paragraph inserted\n\tparagraph content: '" + paragraph.getCharacters() + "'\n\tindex: " + index);
            paragraph.getParagraphListeners().add(paragraphListener);
        }
    });
    Window window = new Window(textArea);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) TextArea(org.apache.pivot.wtk.TextArea) TextAreaContentListener(org.apache.pivot.wtk.TextAreaContentListener) ParagraphListener(org.apache.pivot.wtk.TextArea.ParagraphListener) Paragraph(org.apache.pivot.wtk.TextArea.Paragraph)

Example 5 with Window

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

the class WindowSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    Window window = (Window) getComponent();
    Component content = window.getContent();
    return (content != null) ? content.getPreferredWidth(height) : 0;
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component)

Aggregations

Window (org.apache.pivot.wtk.Window)45 Component (org.apache.pivot.wtk.Component)14 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)13 PushButton (org.apache.pivot.wtk.PushButton)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Button (org.apache.pivot.wtk.Button)7 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)6 Display (org.apache.pivot.wtk.Display)5 Border (org.apache.pivot.wtk.Border)4 Label (org.apache.pivot.wtk.Label)4 Sheet (org.apache.pivot.wtk.Sheet)4 TablePane (org.apache.pivot.wtk.TablePane)4 File (java.io.File)3 Bounds (org.apache.pivot.wtk.Bounds)3 Point (org.apache.pivot.wtk.Point)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 SerializationException (org.apache.pivot.serialization.SerializationException)2 Vote (org.apache.pivot.util.Vote)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2