Package pivot.wtk

Examples of pivot.wtk.Dimensions


            if (window.isDisplayable()) {
                if (window.isMaximized()) {
                    window.setLocation(0, 0);
                    window.setSize(display.getSize());
                } else {
                    Dimensions preferredSize = window.getPreferredSize();

                    if (window.getWidth() != preferredSize.width
                        || window.getHeight() != preferredSize.height) {
                        window.setSize(preferredSize.width, preferredSize.height);
                    }
View Full Code Here


    @Override
    public Dimensions getPreferredSize() {
        // TODO Optimize by performing calculations here
        int preferredWidth = getPreferredWidth(-1);
        int preferredHeight = getPreferredHeight(preferredWidth);
        return new Dimensions(preferredWidth, preferredHeight);
    }
View Full Code Here

        Rollup rollup = (Rollup)getComponent();

        Component heading = rollup.getHeading();
        Component content = rollup.getContent();

        Dimensions rollupButtonSize = rollupButton.getPreferredSize();
        rollupButton.setSize(rollupButtonSize.width, rollupButtonSize.height);

        int x = rollupButtonSize.width + buffer;
        int y = 0;
        int justifiedWidth = Math.max(getWidth() - rollupButtonSize.width - buffer, 0);

        if (heading != null) {
            int headingWidth, headingHeight;
            if (justify) {
                headingWidth = justifiedWidth;
                headingHeight = heading.getPreferredHeight(headingWidth);
            } else {
                Dimensions headingPreferredSize = heading.getPreferredSize();
                headingWidth = headingPreferredSize.width;
                headingHeight = headingPreferredSize.height;
            }

            heading.setVisible(true);
            heading.setLocation(x, y);
            heading.setSize(headingWidth, headingHeight);

            y += headingHeight + spacing;
        }

        if (content != null) {
            if (rollup.isExpanded()) {
                int contentWidth, contentHeight;
                if (justify) {
                    contentWidth = justifiedWidth;
                    contentHeight = content.getPreferredHeight(contentWidth);
                } else {
                    Dimensions contentPreferredSize = content.getPreferredSize();
                    contentWidth = contentPreferredSize.width;
                    contentHeight = contentPreferredSize.height;
                }

                content.setVisible(true);
View Full Code Here

        return preferredHeight;
    }

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

        public int getPreferredHeight(int width) {
            return 7;
        }

        public Dimensions getPreferredSize() {
            return new Dimensions(7, 7);
        }
View Full Code Here

        PushButton pushButton = (PushButton)getComponent();
        Button.DataRenderer dataRenderer = pushButton.getDataRenderer();

        dataRenderer.render(pushButton.getButtonData(), pushButton, false);

        Dimensions preferredContentSize = dataRenderer.getPreferredSize();

        int preferredWidth = preferredContentSize.width
            + padding.left + padding.right + 2;

        int preferredHeight = preferredContentSize.height
            + padding.top + padding.bottom + 2;

        // Adjust for preferred aspect ratio
        if (!Float.isNaN(preferredAspectRatio)) {
            if (preferredAspectRatio >= 1) {
                if ((float)preferredWidth / (float)preferredHeight < preferredAspectRatio) {
                    preferredWidth = (int)((float)preferredHeight * preferredAspectRatio);
                }
            } else {
                if ((float)preferredWidth / (float)preferredHeight > preferredAspectRatio) {
                    preferredHeight = (int)((float)preferredWidth / preferredAspectRatio);
                }
            }
        }

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

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

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

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

                break;
            }

            case VERTICAL: {
                // Preferred height is the sum of the preferred heights of all
                // components, plus spacing and padding
                int displayableComponentCount = 0;

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

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

                // Include spacing
                if (displayableComponentCount > 1) {
                    preferredHeight += spacing * (displayableComponentCount - 1);
                }

                break;
            }
        }

        // Include padding
        preferredWidth += padding.left + padding.right;
        preferredHeight += padding.top + padding.bottom;

        return new Dimensions(preferredWidth, preferredHeight);
    }
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 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

        int preferredWidth = 0;

        Palette palette = (Palette)getComponent();
        Component content = palette.getContent();

        Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();
        preferredWidth = preferredTitleBarSize.width;

        if (content != null
            && content.isDisplayable()) {
            if (height != -1) {
View Full Code Here

        int preferredHeight = 0;

        Palette palette = (Palette)getComponent();
        Component content = palette.getContent();

        Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();

        preferredWidth = preferredTitleBarSize.width;
        preferredHeight = preferredTitleBarSize.height;

        if (content != null
            && content.isDisplayable()) {
            Dimensions preferredContentSize = content.getPreferredSize();

            preferredWidth = Math.max(preferredWidth, preferredContentSize.width);
            preferredHeight += preferredContentSize.height;
        }

        preferredWidth += (padding.left + padding.right) + 2;
        preferredHeight += (padding.top + padding.bottom) + 4;

        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.