Package pivot.wtk

Examples of pivot.wtk.Dimensions


        public Dimensions getSize(boolean validate) {
            if (validate) {
                validate();
            }

            return new Dimensions(width, height);
        }
View Full Code Here


        return preferredHeight;
    }

    public Dimensions getPreferredSize() {
        // TODO Optimize
        return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
    }
View Full Code Here

        int tabHeight = 0;

        Component selectedTab = tabPane.getSelectedTab();
        Component corner = tabPane.getCorner();

        Dimensions buttonPanoramaSize;
        if (expandTransition == null) {
          buttonPanoramaSize = buttonPanorama.getPreferredSize();
        } else {
          buttonPanoramaSize = buttonPanorama.getSize();
        }
View Full Code Here

            TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();

            Button.DataRenderer dataRenderer = tabButton.getDataRenderer();
            dataRenderer.render(tabButton.getButtonData(), tabButton, false);

            Dimensions preferredContentSize = dataRenderer.getPreferredSize();

            int preferredWidth = 0;
            int preferredHeight = 0;
            switch (tabPane.getTabOrientation()) {
                case HORIZONTAL: {
                    preferredWidth = preferredContentSize.width
                        + buttonPadding.left + buttonPadding.right + 2;

                    preferredHeight = preferredContentSize.height
                        + buttonPadding.top + buttonPadding.bottom + 2;

                    break;
                }

                case VERTICAL: {
                    preferredWidth = preferredContentSize.height
                        + buttonPadding.top + buttonPadding.bottom + 2;

                    preferredHeight = preferredContentSize.width
                        + buttonPadding.left + buttonPadding.right + 2;

                    break;
                }
            }

            return new Dimensions(preferredWidth, preferredHeight);
        }
View Full Code Here

        return preferredHeight;
    }

    public Dimensions getPreferredSize() {
        // TODO Optimize by performing calculations here?
        return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
    }
View Full Code Here

                            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;
                        }
                    }

View Full Code Here

        public int getHeight() {
            return 4;
        }

        public Dimensions getPreferredSize() {
            return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
        }
View Full Code Here

            ScrollBarPolicy verticalPolicy = scrollPane.getVerticalScrollBarPolicy();

            if (verticalPolicy != ScrollBarPolicy.FILL) {
                // Get the unconstrained preferred size of the view
                Dimensions preferredViewSize = view.getPreferredSize();

                // If the policy is FILL_TO_CAPACITY, and the sum of the
                // unconstrained preferred heights of the view and the column
                // header is less than the height constraint, apply the FILL
                // policy; otherwise, apply the AUTO policy
View Full Code Here

            ScrollBarPolicy horizontalPolicy = scrollPane.getHorizontalScrollBarPolicy();

            if (horizontalPolicy != ScrollBarPolicy.FILL) {
                // Get the unconstrained preferred size of the view
                Dimensions preferredViewSize = view.getPreferredSize();

                // If the policy is FILL_TO_CAPACITY, and the sum of the
                // unconstrained preferred widths of the view and the row
                // header is less than the width constraint, apply the FILL
                // policy; otherwise, apply the AUTO policy
View Full Code Here

        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);
            }

            if (scrollPane.getVerticalScrollBarPolicy() == ScrollBarPolicy.ALWAYS) {
                preferredWidth += verticalScrollBar.getPreferredWidth(-1);
            }
        }

        return new Dimensions(preferredWidth, preferredHeight);
    }
View Full Code Here

TOP

Related Classes of pivot.wtk.Dimensions

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.