Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.BoxPane$BoxPaneListenerList


        titleBarTablePane.getStyles().put("horizontalSpacing", 3);

        TablePane.Row titleRow = new TablePane.Row(-1);
        titleBarTablePane.getRows().add(titleRow);

        titleBoxPane = new BoxPane(Orientation.HORIZONTAL);
        titleBoxPane.getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);

        buttonBoxPane = new BoxPane(Orientation.HORIZONTAL);
        buttonBoxPane.getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);
        buttonBoxPane.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);

        titleRow.add(titleBoxPane);
        titleRow.add(buttonBoxPane);
View Full Code Here


    @Override
    public void install(Component component) {
        super.install(component);

        BoxPane boxPane = (BoxPane)component;
        boxPane.getBoxPaneListeners().add(this);
    }
View Full Code Here

        boxPane.getBoxPaneListeners().add(this);
    }

    @Override
    public int getPreferredWidth(int height) {
        BoxPane boxPane = (BoxPane)getComponent();

        int preferredWidth = 0;

        Orientation orientation = boxPane.getOrientation();
        if (orientation == Orientation.HORIZONTAL) {
            int heightUpdated = height;
            // Include padding in constraint
            if (heightUpdated != -1) {
                heightUpdated = Math.max(heightUpdated - (padding.top + padding.bottom), 0);
            }

            // Preferred width is the sum of the preferred widths of all components
            int j = 0;
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredWidth += component.getPreferredWidth(fill ? heightUpdated : -1);
                    j++;
                }
            }

            // Include spacing
            if (j > 1) {
                preferredWidth += spacing * (j - 1);
            }
        } else {
            // Preferred width is the maximum preferred width of all components
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredWidth = Math.max(preferredWidth,
                        component.getPreferredWidth());
                }
View Full Code Here

        return preferredWidth;
    }

    @Override
    public int getPreferredHeight(int width) {
        BoxPane boxPane = (BoxPane)getComponent();

        int preferredHeight = 0;

        Orientation orientation = boxPane.getOrientation();
        if (orientation == Orientation.HORIZONTAL) {
            // Preferred height is the maximum preferred height of all components
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredHeight = Math.max(preferredHeight,
                        component.getPreferredHeight());
                }
            }
        } else {
            int widthUpdated = width;
            // Include padding in constraint
            if (widthUpdated != -1) {
                widthUpdated = Math.max(widthUpdated - (padding.left + padding.right), 0);
            }

            // Preferred height is the sum of the preferred heights of all components
            int j = 0;
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredHeight += component.getPreferredHeight(fill ? widthUpdated : -1);
                    j++;
                }
View Full Code Here

        return preferredHeight;
    }

    @Override
    public Dimensions getPreferredSize() {
        BoxPane boxPane = (BoxPane)getComponent();

        int preferredWidth = 0;
        int preferredHeight = 0;

        switch (boxPane.getOrientation()) {
            case HORIZONTAL: {
                // Preferred width is the sum of the preferred widths of all components
                int j = 0;
                for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                    Component component = boxPane.get(i);

                    if (component.isVisible()) {
                        Dimensions preferredSize = component.getPreferredSize();
                        preferredWidth += preferredSize.width;
                        preferredHeight = Math.max(preferredSize.height, preferredHeight);
                        j++;
                    }
                }

                // Include spacing
                if (j > 1) {
                    preferredWidth += spacing * (j - 1);
                }

                break;
            }

            case VERTICAL: {
                // Preferred height is the sum of the preferred heights of all components
                int j = 0;
                for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                    Component component = boxPane.get(i);

                    if (component.isVisible()) {
                        Dimensions preferredSize = component.getPreferredSize();
                        preferredWidth = Math.max(preferredSize.width, preferredWidth);
                        preferredHeight += preferredSize.height;
View Full Code Here

        return new Dimensions(preferredWidth, preferredHeight);
    }

    @Override
    public int getBaseline(int width, int height) {
        BoxPane boxPane = (BoxPane)getComponent();

        int baseline = -1;
        int contentHeight = 0;

        switch (boxPane.getOrientation()) {
            case HORIZONTAL: {
                if (fill) {
                    int clientHeight = Math.max(height - (padding.top + padding.bottom), 0);

                    for (Component component : boxPane) {
View Full Code Here

        return baseline;
    }

    @Override
    public void layout() {
        BoxPane boxPane = (BoxPane)getComponent();
        int n = boxPane.getLength();

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

        Orientation orientation = boxPane.getOrientation();
        if (orientation == Orientation.HORIZONTAL) {
            int preferredWidth = getPreferredWidth(fill ? height : -1);

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

            switch (horizontalAlignment) {
                case CENTER: {
                    x = (width - preferredWidth) / 2;
                    break;
                }
                case RIGHT: {
                    x = width - preferredWidth;
                    break;
                }
                case LEFT: {
                    break;
                }
                default: {
                    break;
                }
            }

            x += padding.left;

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

                if (component.isVisible()) {
                    int componentWidth = 0;
                    int componentHeight = 0;
                    int y = 0;

                    if (fill) {
                        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: {
                            y = padding.top;
                            break;
                        }

                        case CENTER: {
                            y = (height - componentHeight) / 2;
                            break;
                        }

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

                        default: {
                            break;
                        }
                    }

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

                    // Increment the x-coordinate
                    x += componentWidth + spacing;
                }
            }
        } else {
            int preferredHeight = getPreferredHeight(fill ? width : -1);

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

            switch (verticalAlignment) {
                case CENTER: {
                    y = (height - preferredHeight) / 2;
                    break;
                }

                case BOTTOM: {
                    y = height - preferredHeight;
                    break;
                }
                case TOP:
                    break;

                default: {
                    break;
                }
            }

            y += padding.top;

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

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

    @Override
    public void install(Component component) {
        super.install(component);

        BoxPane boxPane = (BoxPane)component;
        boxPane.getBoxPaneListeners().add(this);
    }
View Full Code Here

        boxPane.getBoxPaneListeners().add(this);
    }

    @Override
    public int getPreferredWidth(int height) {
        BoxPane boxPane = (BoxPane)getComponent();

        int preferredWidth = 0;

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

            // Preferred width is the sum of the preferred widths of all components
            int j = 0;
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredWidth += component.getPreferredWidth(fill ? height : -1);
                    j++;
                }
            }

            // Include spacing
            if (j > 1) {
                preferredWidth += spacing * (j - 1);
            }
        } else {
            // Preferred width is the maximum preferred width of all components
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredWidth = Math.max(preferredWidth,
                        component.getPreferredWidth());
                }
View Full Code Here

        return preferredWidth;
    }

    @Override
    public int getPreferredHeight(int width) {
        BoxPane boxPane = (BoxPane)getComponent();

        int preferredHeight = 0;

        Orientation orientation = boxPane.getOrientation();
        if (orientation == Orientation.HORIZONTAL) {
            // Preferred height is the maximum preferred height of all components
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

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

            // Preferred height is the sum of the preferred heights of all components
            int j = 0;
            for (int i = 0, n = boxPane.getLength(); i < n; i++) {
                Component component = boxPane.get(i);

                if (component.isVisible()) {
                    preferredHeight += component.getPreferredHeight(fill ? width : -1);
                    j++;
                }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.BoxPane$BoxPaneListenerList

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.