Package pivot.wtk

Examples of pivot.wtk.Component$ComponentLayoutListenerList


        }

        @Override
        public void stop() {
          TabPane tabPane = (TabPane)getComponent();
          Component selectedTab = tabPane.getSelectedTab();
          selectedTab.getDecorators().remove(clipDecorator);

          int selectedIndex = tabPane.getSelectedIndex();
          TabButton tabButton = (TabButton)buttonFlowPane.get(selectedIndex);
          tabButton.active = false;
View Full Code Here


            // 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
                        && height != -1) {
                        int preferredHeight = component.getPreferredHeight(-1);

                        if (height > totalSpacing
                            && preferredHeight > totalSpacing) {
                            double heightScale = (double)preferredHeight
                                / (double)totalPreferredHeight;

                            componentHeight = (int)Math.round((double)(height
                                - totalSpacing) * heightScale);
                        } else {
                            componentHeight = 0;
                        }
                    }

                    maxComponentWidth = Math.max(maxComponentWidth,
                        component.getPreferredWidth(componentHeight));
                }
            }

            preferredWidth += maxComponentWidth;
        }
View Full Code Here

            // 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
                        && width != -1) {
                        int preferredWidth = component.getPreferredWidth(-1);

                        if (width > totalSpacing
                            && preferredWidth > totalSpacing) {
                            double widthScale = (double)preferredWidth
                                / (double)totalPreferredWidth;

                            componentWidth = (int)Math.round((double)(width
                                - totalSpacing) * widthScale);
                        }
                    }

                    maxComponentHeight = Math.max(maxComponentHeight,
                        component.getPreferredHeight(componentWidth));
                }
            }

            preferredHeight += maxComponentHeight;
        }
View Full Code Here

                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;

                    if (horizontalAlignment == HorizontalAlignment.JUSTIFY) {
                        componentX = padding.left;
                        componentWidth = Math.max(width - (padding.left
                            + padding.right), 0);
                        componentHeight = component.getPreferredHeight(componentWidth);
                    } else {
                    }

                    // If the contents are vertically justified, scale the
                    // component's height to match the available space
                    if (verticalAlignment == VerticalAlignment.JUSTIFY) {
                        if (height > fixedHeight
                            && preferredHeight > fixedHeight) {
                            double heightScale = (double)(height - fixedHeight)
                                / (double)(preferredHeight - fixedHeight);

                            componentHeight = (int)Math.max(Math.round((double)component.getPreferredHeight(-1)
                                * heightScale), 0);

                            if (horizontalAlignment == HorizontalAlignment.JUSTIFY) {
                                componentX = padding.left;
                                componentWidth = Math.max(width - (padding.left
                                    + padding.right), 0);
                            } else {
                                componentWidth = component.getPreferredWidth(componentHeight);
                            }
                        }
                    } else {
                        if (horizontalAlignment == HorizontalAlignment.JUSTIFY) {
                            componentX = padding.left;
                            componentWidth = Math.max(width - (padding.left
                                + padding.right), 0);
                            componentHeight = component.getPreferredHeight(componentWidth);
                        } else {
                            Dimensions preferredComponentSize = component.getPreferredSize();
                            componentWidth = preferredComponentSize.width;
                            componentHeight = preferredComponentSize.height;
                        }
                    }

                    switch (horizontalAlignment) {
                        case LEFT: {
                            componentX = padding.left;
                            break;
                        }

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

                        case RIGHT: {
                            componentX = width - padding.right
                                - componentWidth;
                            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 y-coordinate
                    componentY += componentHeight + spacing;
                } else {
                    // Hide the component
                    component.setVisible(false);
                }
            }
        }
    }
View Full Code Here

    @Override
    public int getPreferredWidth(int height) {
        int preferredWidth = 0;

        ScrollPane scrollPane = (ScrollPane)getComponent();
        Component view = scrollPane.getView();

        if (view != null) {
            int preferredRowHeaderWidth = 0;
            Component rowHeader = scrollPane.getRowHeader();
            if (rowHeader != null) {
                preferredRowHeaderWidth = rowHeader.getPreferredWidth(-1);
            }

            int preferredColumnHeaderHeight = 0;
            Component columnHeader = scrollPane.getColumnHeader();
            if (columnHeader != null) {
                preferredColumnHeaderHeight = columnHeader.getPreferredHeight(-1);
            }

            ScrollBarPolicy verticalPolicy = scrollPane.getVerticalScrollBarPolicy();

            if (verticalPolicy != ScrollBarPolicy.FILL) {
View Full Code Here

    @Override
    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        ScrollPane scrollPane = (ScrollPane)getComponent();
        Component view = scrollPane.getView();

        if (view != null) {
            int preferredRowHeaderWidth = 0;
            Component rowHeader = scrollPane.getRowHeader();
            if (rowHeader != null) {
                preferredRowHeaderWidth = rowHeader.getPreferredWidth(-1);
            }

            int preferredColumnHeaderHeight = 0;
            Component columnHeader = scrollPane.getColumnHeader();
            if (columnHeader != null) {
                preferredColumnHeaderHeight = columnHeader.getPreferredHeight(-1);
            }

            ScrollBarPolicy horizontalPolicy = scrollPane.getHorizontalScrollBarPolicy();

            if (horizontalPolicy != ScrollBarPolicy.FILL) {
View Full Code Here

        ScrollPane scrollPane = (ScrollPane)getComponent();

        int preferredWidth = 0;
        int preferredHeight = 0;

        Component view = scrollPane.getView();
        if (view != null) {
            Dimensions preferredViewSize = view.getPreferredSize();

            preferredWidth += preferredViewSize.width;
            preferredHeight += preferredViewSize.height;

            Component rowHeader = scrollPane.getRowHeader();
            if (rowHeader != null) {
                preferredWidth += rowHeader.getPreferredWidth(-1);
            }

            Component columnHeader = scrollPane.getColumnHeader();
            if (columnHeader != null) {
                preferredHeight += columnHeader.getPreferredHeight(-1);
            }

            if (scrollPane.getHorizontalScrollBarPolicy() == ScrollBarPolicy.ALWAYS) {
                preferredHeight += horizontalScrollBar.getPreferredHeight(-1);
            }
View Full Code Here

    public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount,
        int wheelRotation, int x, int y) {
        boolean consumed = false;

        ScrollPane scrollPane = (ScrollPane)getComponent();
        Component view = scrollPane.getView();

        if (view != null) {
            // The scroll orientation is tied to whether the shift key was
            // presssed while the mouse wheel was scrolled
            if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
View Full Code Here

     */
    private int getMaxScrollTop() {
        int maxScrollTop = 0;

        ScrollPane scrollPane = (ScrollPane)getComponent();
        Component view = scrollPane.getView();

        if (view != null) {
            int viewHeight = view.getHeight();
            int columnHeaderHeight = 0;
            int horizontalScrollBarHeight = 0;
            int height = getHeight();

            Component columnHeader = scrollPane.getColumnHeader();
            if (columnHeader != null) {
                columnHeaderHeight = columnHeader.getHeight();
            }

            if (horizontalScrollBar.isVisible()) {
                horizontalScrollBarHeight = horizontalScrollBar.getHeight();
            }
View Full Code Here

     */
    private int getMaxScrollLeft() {
        int maxScrollLeft = 0;

        ScrollPane scrollPane = (ScrollPane)getComponent();
        Component view = scrollPane.getView();

        if (view != null) {
            int viewWidth = view.getWidth();
            int rowHeaderWidth = 0;
            int verticalScrollBarWidth = 0;
            int width = getWidth();

            Component rowHeader = scrollPane.getRowHeader();
            if (rowHeader != null) {
                rowHeaderWidth = rowHeader.getWidth();
            }

            if (verticalScrollBar.isVisible()) {
                verticalScrollBarWidth = verticalScrollBar.getWidth();
            }
View Full Code Here

TOP

Related Classes of pivot.wtk.Component$ComponentLayoutListenerList

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.