Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Component


    @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

    @Override
    public int getBaseline(int width, int height) {
        ScrollPane scrollPane = (ScrollPane)getComponent();

        Component view = scrollPane.getView();
        Component rowHeader = scrollPane.getRowHeader();
        Component columnHeader = scrollPane.getColumnHeader();

        int baseline = -1;

        int clientWidth = width;
        int clientHeight = height;

        int rowHeaderWidth = 0;
        if (rowHeader != null) {
            rowHeaderWidth = rowHeader.getPreferredWidth(-1);
            clientWidth -= rowHeaderWidth;
        }

        int columnHeaderHeight = 0;
        if (columnHeader != null) {
            columnHeaderHeight = columnHeader.getPreferredHeight(-1);
            clientHeight -= columnHeaderHeight;

            baseline = columnHeader.getBaseline(clientWidth, columnHeaderHeight);
        }

        if (baseline == -1
            && rowHeader != null) {
            baseline = rowHeader.getBaseline(rowHeaderWidth, clientHeight);
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
            // pressed 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

            fillHeightToCapacity = true;
        }

        layoutHelper(horizontalPolicy, verticalPolicy);

        Component view = scrollPane.getView();
        if (view != null && (fillWidthToCapacity || fillHeightToCapacity)) {
            // We assumed AUTO. Now we check our assumption to see if we
            // need to adjust it to use FILL
            boolean adjustWidth = false, adjustHeight = false;

            if (fillWidthToCapacity) {
                Component rowHeader = scrollPane.getRowHeader();
                int rowHeaderWidth = rowHeader != null ? rowHeader.getWidth() : 0;

                int verticalScrollBarWidth = verticalScrollBar.isVisible() ?
                    verticalScrollBar.getWidth() : 0;
                int minViewWidth = getWidth() - rowHeaderWidth - verticalScrollBarWidth;

                if (view.getWidth() < minViewWidth) {
                    horizontalPolicy = ScrollBarPolicy.FILL;
                    adjustWidth = true;
                }
            }

            if (fillHeightToCapacity) {
                Component columnHeader = scrollPane.getColumnHeader();
                int columnHeaderHeight = columnHeader != null ?
                    columnHeader.getHeight() : 0;

                int horizontalScrollBarHeight = horizontalScrollBar.isVisible() ?
                    horizontalScrollBar.getHeight() : 0;
                int minViewHeight = getHeight() - columnHeaderHeight -
                    horizontalScrollBarHeight;
View Full Code Here

        int height = getHeight();

        boolean constrainWidth = (horizontalPolicy == ScrollBarPolicy.FILL);
        boolean constrainHeight = (verticalPolicy == ScrollBarPolicy.FILL);

        Component view = scrollPane.getView();
        Component columnHeader = scrollPane.getColumnHeader();
        Component rowHeader = scrollPane.getRowHeader();
        Component corner = scrollPane.getCorner();

        int rowHeaderWidth = 0;
        if (rowHeader != null) {
            rowHeaderWidth = rowHeader.getPreferredWidth(-1);
        }

        int columnHeaderHeight = 0;
        if (columnHeader != null) {
            columnHeaderHeight = columnHeader.getPreferredHeight(-1);
        }

        int previousViewWidth, viewWidth = 0;
        int previousViewHeight, viewHeight = 0;
        int previousHorizontalScrollBarHeight, horizontalScrollBarHeight = cachedHorizontalScrollBarHeight;
        int previousVerticalScrollBarWidth, verticalScrollBarWidth = cachedVerticalScrollBarWidth;
        int i = 0;

        do {
            previousViewWidth = viewWidth;
            previousViewHeight = viewHeight;
            previousHorizontalScrollBarHeight = horizontalScrollBarHeight;
            previousVerticalScrollBarWidth = verticalScrollBarWidth;

            if (view != null) {
                if (constrainWidth && constrainHeight) {
                    viewWidth = Math.max
                        (width - rowHeaderWidth - verticalScrollBarWidth, 0);
                    viewHeight = Math.max
                        (height - columnHeaderHeight - horizontalScrollBarHeight, 0);
                } else if (constrainWidth) {
                    viewWidth = Math.max
                        (width - rowHeaderWidth - verticalScrollBarWidth, 0);
                    viewHeight = view.getPreferredHeight(viewWidth);
                } else if (constrainHeight) {
                    viewHeight = Math.max
                        (height - columnHeaderHeight - horizontalScrollBarHeight, 0);
                    viewWidth = view.getPreferredWidth(viewHeight);
                } else {
                    Dimensions viewPreferredSize = view.getPreferredSize();
                    viewWidth = viewPreferredSize.width;
                    viewHeight = viewPreferredSize.height;
                }
            }

            if (horizontalPolicy == ScrollBarPolicy.ALWAYS
                || (horizontalPolicy == ScrollBarPolicy.AUTO
                && viewWidth > width - rowHeaderWidth - verticalScrollBarWidth)) {
                horizontalScrollBarHeight = horizontalScrollBar.getPreferredHeight(-1);
            } else {
                horizontalScrollBarHeight = 0;
            }

            if (verticalPolicy == ScrollBarPolicy.ALWAYS
                || (verticalPolicy == ScrollBarPolicy.AUTO
                && viewHeight > height - columnHeaderHeight - horizontalScrollBarHeight)) {
                verticalScrollBarWidth = verticalScrollBar.getPreferredWidth(-1);
            } else {
                verticalScrollBarWidth = 0;
            }

            if (++i > 4) {
                // Infinite loop protection
                System.err.println("Breaking out of potential infinite loop");
                break;
            }
        } while (viewWidth != previousViewWidth
            || viewHeight != previousViewHeight
            || horizontalScrollBarHeight != previousHorizontalScrollBarHeight
            || verticalScrollBarWidth != previousVerticalScrollBarWidth);

        int scrollTop = scrollPane.getScrollTop();
        int scrollLeft = scrollPane.getScrollLeft();

        if (view != null) {
            view.setSize(viewWidth, viewHeight);
            view.setLocation(rowHeaderWidth - scrollLeft, columnHeaderHeight - scrollTop);
        }

        if (columnHeader != null) {
            columnHeader.setSize(viewWidth, columnHeaderHeight);
            columnHeader.setLocation(rowHeaderWidth - scrollLeft, 0);
        }

        if (rowHeader != null) {
            rowHeader.setSize(rowHeaderWidth, viewHeight);
            rowHeader.setLocation(0, columnHeaderHeight - scrollTop);
        }

        if (horizontalScrollBarHeight > 0) {
            horizontalScrollBar.setVisible(true);

            int horizontalScrollBarWidth = Math.max
               (width - rowHeaderWidth - verticalScrollBarWidth, 0);
            horizontalScrollBar.setSize(horizontalScrollBarWidth,
                horizontalScrollBarHeight);
            horizontalScrollBar.setLocation(rowHeaderWidth,
                height - horizontalScrollBarHeight);
        } else {
            horizontalScrollBar.setVisible(false);
        }

        if (verticalScrollBarWidth > 0) {
            verticalScrollBar.setVisible(true);

            int verticalScrollBarHeight = Math.max
               (height - columnHeaderHeight - horizontalScrollBarHeight, 0);
            verticalScrollBar.setSize(verticalScrollBarWidth,
                verticalScrollBarHeight);
            verticalScrollBar.setLocation(width - verticalScrollBarWidth,
                columnHeaderHeight);
        } else {
            verticalScrollBar.setVisible(false);
        }

        // Handle corner components

        if (columnHeaderHeight > 0
            && rowHeaderWidth > 0) {
            if (corner != null) {
                corner.setVisible(true);
                corner.setSize(rowHeaderWidth, columnHeaderHeight);
                corner.setLocation(0, 0);

                topLeftCorner.setVisible(false);
            } else {
                topLeftCorner.setVisible(true);
                topLeftCorner.setSize(rowHeaderWidth, columnHeaderHeight);
                topLeftCorner.setLocation(0, 0);
            }
        } else {
            if (corner != null) {
                corner.setVisible(false);
            }

            topLeftCorner.setVisible(false);
        }
View Full Code Here

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

        ScrollPane scrollPane = (ScrollPane)getComponent();

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

            x += rowHeaderWidth;
            width -= rowHeaderWidth;
        }

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

            y += columnHeaderHeight;
            height -= columnHeaderHeight;
        }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Component

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.