Package pivot.wtk

Examples of pivot.wtk.FlowPane$FlowPaneListenerList


    private Window window = null;
    private PushButton helloButton = null;

    public void startup(Display display, Dictionary<String, String> properties)
        throws Exception {
        FlowPane flowPane = new FlowPane();
        flowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);

        helloButton = new PushButton("Say Hello");
        flowPane.add(helloButton);

        helloButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                BrowserApplicationContext.eval("sayHello(\"Hello from Java!\")", DOMTest.this);
            }
View Full Code Here


        Label messageLabel = (Label)wtkxSerializer.getObjectByName("messageLabel");
        String message = alert.getMessage();
        messageLabel.setText(message);

        // Set the body
        FlowPane messageFlowPane = (FlowPane)wtkxSerializer.getObjectByName("messageFlowPane");
        Component body = alert.getBody();
        if (body != null) {
            messageFlowPane.add(body);
        }

        // Add the option buttons
        FlowPane buttonFlowPane = (FlowPane)wtkxSerializer.getObjectByName("buttonFlowPane");

        for (int i = 0, n = alert.getOptionCount(); i < n; i++) {
            Object option = alert.getOption(i);

            PushButton optionButton = new PushButton(option);
            HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
            optionButtonStyles.put("color", theme.getColor(4));
            optionButtonStyles.put("backgroundColor", theme.getColor(16));
            optionButtonStyles.put("borderColor", theme.getColor(13));

            optionButton.setStyles(optionButtonStyles);
            optionButton.getStyles().put("preferredAspectRatio", 3);

            optionButton.getButtonPressListeners().add(new ButtonPressListener() {
                public void buttonPressed(Button button) {
                    int optionIndex = optionButtons.indexOf(button);

                    if (optionIndex >= 0) {
                        Alert alert = (Alert)getComponent();
                        alert.setSelectedOption(optionIndex);
                        alert.close(true);
                    }
                }
            });

            buttonFlowPane.add(optionButton);
            optionButtons.add(optionButton);
        }
    }
View Full Code Here

        yearSpinner.getComponentMouseButtonListeners().add(spinnerMouseButtonListener);

        TablePane.Row row;

        // Add the month/year flow pane
        FlowPane monthYearFlowPane = new FlowPane();
        monthYearFlowPane.getStyles().put("padding", 3);
        monthYearFlowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.JUSTIFY);

        monthYearFlowPane.add(monthSpinner);
        monthYearFlowPane.add(yearSpinner);

        row = new TablePane.Row();
        row.add(monthYearFlowPane);
        tablePane.getRows().add(row);
View Full Code Here

        Label messageLabel = (Label)wtkxSerializer.getObjectByName("messageLabel");
        String message = prompt.getMessage();
        messageLabel.setText(message);

        // Set the body
        FlowPane messageFlowPane = (FlowPane)wtkxSerializer.getObjectByName("messageFlowPane");
        Component body = prompt.getBody();
        if (body != null) {
            messageFlowPane.add(body);
        }

        // Add the option buttons
        FlowPane buttonFlowPane = (FlowPane)wtkxSerializer.getObjectByName("buttonFlowPane");

        for (int i = 0, n = prompt.getOptionCount(); i < n; i++) {
            Object option = prompt.getOption(i);

            PushButton optionButton = new PushButton(option);
            HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
            optionButtonStyles.put("color", theme.getColor(4));
            optionButtonStyles.put("backgroundColor", theme.getColor(16));
            optionButtonStyles.put("borderColor", theme.getColor(13));

            optionButton.setStyles(optionButtonStyles);
            optionButton.getStyles().put("preferredAspectRatio", 3);

            optionButton.getButtonPressListeners().add(new ButtonPressListener() {
                public void buttonPressed(Button button) {
                    int optionIndex = optionButtons.indexOf(button);

                    if (optionIndex >= 0) {
                        Prompt prompt = (Prompt)getComponent();
                        prompt.setSelectedOption(optionIndex);
                        prompt.close(true);
                    }
                }
            });

            buttonFlowPane.add(optionButton);
            optionButtons.add(optionButton);
        }
    }
View Full Code Here

        // Include padding in constraint
        if (height != -1) {
            height = Math.max(height - (padding.top + padding.bottom), 0);
        }

        FlowPane flowPane = (FlowPane)getComponent();
        int n = flowPane.getLength();

        Orientation orientation = flowPane.getOrientation();
        if (orientation == Orientation.HORIZONTAL) {
            // Preferred width is the sum of the preferred widths of all
            // components, plus spacing
            int displayableComponentCount = 0;

            for (int i = 0; i < n; i++) {
                Component component = flowPane.get(i);

                if (component.isDisplayable()) {
                    preferredWidth += component.getPreferredWidth(height);
                    displayableComponentCount++;
                }
            }

            if (displayableComponentCount > 1) {
                preferredWidth += spacing * (displayableComponentCount - 1);
            }
        } else {
            // Preferred width is the maximum preferred width of all components
            int maxComponentWidth = 0;

            // Determine the fixed and total preferred heights, if necessary
            int totalSpacing = 0;
            int totalPreferredHeight = 0;

            if (horizontalAlignment == HorizontalAlignment.JUSTIFY
                && height != -1) {
                int displayableComponentCount = 0;
                for (int i = 0; i < n; i++) {
                    Component component = flowPane.get(i);

                    if (component.isDisplayable()) {
                        totalPreferredHeight += component.getPreferredHeight(-1);
                        displayableComponentCount++;
                    }
                }

                if (displayableComponentCount > 1) {
                    totalSpacing = spacing * (displayableComponentCount - 1);
                }
            }

            for (int i = 0; i < n; i++) {
                Component component = flowPane.get(i);

                if (component.isDisplayable()) {
                    int componentHeight = -1;

                    if (verticalAlignment == VerticalAlignment.JUSTIFY
View Full Code Here

        // Include padding in constraint
        if (width != -1) {
            width = Math.max(width - (padding.left + padding.right), 0);
        }

        FlowPane flowPane = (FlowPane)getComponent();
        int n = flowPane.getLength();

        Orientation orientation = flowPane.getOrientation();
        if (orientation == Orientation.VERTICAL) {
            // Preferred height is the sum of the preferred heights of all
            // components, plus padding and spacing
            int displayableComponentCount = 0;

            for (int i = 0; i < n; i++) {
                Component component = flowPane.get(i);

                if (component.isDisplayable()) {
                    preferredHeight += component.getPreferredHeight(width);
                    displayableComponentCount++;
                }
            }

            if (displayableComponentCount > 1) {
                preferredHeight += spacing * (displayableComponentCount - 1);
            }
        } else {
            // Preferred height is the maximum preferred height of all
            // components, plus padding
            int maxComponentHeight = 0;

            // Determine the fixed and total preferred widths, if necessary
            int totalSpacing = 0;
            int totalPreferredWidth = 0;

            if (horizontalAlignment == HorizontalAlignment.JUSTIFY
                && width != -1) {
                int displayableComponentCount = 0;

                for (int i = 0; i < n; i++) {
                    Component component = flowPane.get(i);

                    if (component.isDisplayable()) {
                        totalPreferredWidth += component.getPreferredWidth(-1);
                        displayableComponentCount++;
                    }
                }

                if (displayableComponentCount > 1) {
                    totalSpacing = spacing * (displayableComponentCount - 1);
                }
            }

            for (int i = 0; i < n; i++) {
                Component component = flowPane.get(i);

                if (component.isDisplayable()) {
                    int componentWidth = -1;

                    if (horizontalAlignment == HorizontalAlignment.JUSTIFY
View Full Code Here

        // TODO Optimize by performing calculations here?
        return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
    }

    public void layout() {
        FlowPane flowPane = (FlowPane)getComponent();
        int n = flowPane.getLength();

        int width = getWidth();
        int height = getHeight();

        Orientation orientation = flowPane.getOrientation();
        if (orientation == Orientation.HORIZONTAL) {
            int preferredWidth = getPreferredWidth(height);

            // Determine the fixed width (used in scaling components
            // when justified horizontally)
            int fixedWidth = 0;
            if (horizontalAlignment == HorizontalAlignment.JUSTIFY) {
                fixedWidth = padding.left + padding.right;

                int displayableComponentCount = 0;

                for (int i = 0; i < n; i++) {
                    Component component = flowPane.get(i);

                    if (component.isDisplayable()) {
                        displayableComponentCount++;
                    }
                }

                if (displayableComponentCount > 1) {
                    fixedWidth += spacing * (displayableComponentCount - 1);
                }
            }

            // Determine the starting x-coordinate
            int componentX = 0;

            switch (horizontalAlignment) {
                case CENTER: {
                    componentX = (int)Math.round((double)(width - preferredWidth) / 2);
                    break;
                }

                case RIGHT: {
                    componentX = width - preferredWidth;
                    break;
                }
            }

            componentX += padding.left;

            // Lay out the components
            for (int i = 0; i < n; i++) {
                Component component = flowPane.get(i);

                if (component.isDisplayable()) {
                    int componentWidth = 0;
                    int componentHeight = 0;
                    int componentY = 0;

                    // If the contents are horizontally justified, scale the
                    // component's width to match the available space
                    if (horizontalAlignment == HorizontalAlignment.JUSTIFY) {
                        if (width > fixedWidth
                            && preferredWidth > fixedWidth) {
                            double widthScale = ((double)(width - fixedWidth)
                                / (double)(preferredWidth - fixedWidth));

                            componentWidth = (int)Math.max(Math.round((double)component.getPreferredWidth(-1)
                                * widthScale), 0);

                            if (verticalAlignment == VerticalAlignment.JUSTIFY) {
                                componentY = padding.top;
                                componentHeight = Math.max(height - (padding.top
                                    + padding.bottom), 0);
                            } else {
                                componentHeight = component.getPreferredHeight(componentWidth);
                            }
                        }
                    } else {
                        if (verticalAlignment == VerticalAlignment.JUSTIFY) {
                            componentY = padding.top;
                            componentHeight = Math.max(height - (padding.top
                                + padding.bottom), 0);
                            componentWidth = component.getPreferredWidth(componentHeight);
                        } else {
                            Dimensions preferredComponentSize = component.getPreferredSize();
                            componentWidth = preferredComponentSize.width;
                            componentHeight = preferredComponentSize.height;
                        }
                    }

                    switch (verticalAlignment) {
                        case TOP: {
                            componentY = padding.top;
                            break;
                        }

                        case CENTER: {
                            componentY = (int)Math.round((double)(height - componentHeight) / 2);
                            break;
                        }

                        case BOTTOM: {
                            componentY = height - padding.bottom
                                - componentHeight;
                            break;
                        }
                    }

                    // Set the component's size and position
                    component.setSize(componentWidth, componentHeight);
                    component.setLocation(componentX, componentY);

                    // Ensure that the component is visible
                    component.setVisible(true);

                    // Increment the x-coordinate
                    componentX += componentWidth + spacing;
                } else {
                    // Hide the component
                    component.setVisible(false);
                }
            }
        } else {
            int preferredHeight = getPreferredHeight(width);

            // Determine the fixed height (used in scaling components
            // when justified vertically)
            int fixedHeight = 0;
            if (verticalAlignment == VerticalAlignment.JUSTIFY) {
                fixedHeight = padding.top + padding.bottom;

                int displayableComponentCount = 0;

                for (int i = 0; i < n; i++) {
                    Component component = flowPane.get(i);

                    if (component.isDisplayable()) {
                        displayableComponentCount++;
                    }
                }

                if (displayableComponentCount > 1) {
                    fixedHeight += spacing * (displayableComponentCount - 1);
                }
            }

            // Determine the starting y-coordinate
            int componentY = 0;

            switch (verticalAlignment) {
                case CENTER: {
                    componentY = (int)Math.round((double)(height - preferredHeight) / 2);
                    break;
                }

                case BOTTOM: {
                    componentY = height - preferredHeight;
                    break;
                }
            }

            componentY += padding.top;

            // Lay out the components
            for (int i = 0; i < n; i++) {
                Component component = flowPane.get(i);

                if (component.isDisplayable()) {
                    int componentWidth = 0;
                    int componentHeight = 0;
                    int componentX = 0;
View Full Code Here

        padding = new Insets(4);

        // Set the derived colors
        titleBarBevelColor = TerraTheme.brighten(titleBarBackgroundColor);

        titleBarFlowPane = new FlowPane(Orientation.HORIZONTAL);
        titleBarFlowPane.getComponentMouseButtonListeners().add(titleBarMouseHandler);

        titleBarFlowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.JUSTIFY);
        titleBarFlowPane.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
        titleBarFlowPane.getStyles().put("padding", new Insets(3));
        titleBarFlowPane.getStyles().put("spacing", 3);

        titleFlowPane = new FlowPane(Orientation.HORIZONTAL);
        titleFlowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);

        buttonFlowPane = new FlowPane(Orientation.HORIZONTAL);
        buttonFlowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);

        titleBarFlowPane.add(titleFlowPane);
        titleBarFlowPane.add(buttonFlowPane);
View Full Code Here

    private Sheet sheet = null;
    private CardPane cardPane = null;

    public void startup(Display display, Dictionary<String, String> properties)
        throws Exception {
      Frame frame = new Frame(new FlowPane());
      frame.getStyles().put("padding", 0);
      frame.setTitle("Card Pane Test");
      frame.setPreferredSize(800, 600);
      frame.setLocation(20, 20);
View Full Code Here

        frame1.setTitle("File Browser Test");
        frame1.setPreferredSize(480, 640);
        frame1.open(display);

        FlowPane flowPane2 = new FlowPane();
        flowPane2.add(new TextInput());
        frame2 = new Frame(flowPane2);
        frame2.setTitle("Frame 2");
        frame2.setPreferredSize(240, 80);
        frame2.open(display);

        FlowPane flowPane3 = new FlowPane();
        flowPane3.add(new TextInput());
        frame3 = new Frame(flowPane3);
        frame3.setTitle("Frame 3");
        frame3.setPreferredSize(240, 80);
        frame3.open(display);
    }
View Full Code Here

TOP

Related Classes of pivot.wtk.FlowPane$FlowPaneListenerList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.