Examples of ScrollPane


Examples of org.apache.pivot.wtk.ScrollPane

     * The maximum scrollTop value
     */
    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()) {
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

     * The maximum scrollLeft value
     */
    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()) {
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

        return maxScrollLeft;
    }

    @Override
    public void layout() {
        ScrollPane scrollPane = (ScrollPane)getComponent();

        ScrollBarPolicy horizontalPolicy = scrollPane.getHorizontalScrollBarPolicy();
        ScrollBarPolicy verticalPolicy = scrollPane.getVerticalScrollBarPolicy();

        boolean fillWidthToCapacity = false;
        boolean fillHeightToCapacity = false;

        // The FILL_TO_CAPACITY policy means that we try to use AUTO, and only
        // if it ends up not being wide or tall enough do we use FILL

        if (horizontalPolicy == ScrollBarPolicy.FILL_TO_CAPACITY) {
            horizontalPolicy = ScrollBarPolicy.AUTO;
            fillWidthToCapacity = true;
        }

        if (verticalPolicy == ScrollBarPolicy.FILL_TO_CAPACITY) {
            verticalPolicy = ScrollBarPolicy.AUTO;
            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;
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

     * @param verticalPolicy
     * The assumed vertical scroll policy; musn't be <tt>FILL_TO_CAPACITY</tt>
     */
    private void layoutHelper(ScrollBarPolicy horizontalPolicy,
        ScrollBarPolicy verticalPolicy) {
        ScrollPane scrollPane = (ScrollPane)getComponent();

        int width = getWidth();
        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);
        }

        if (rowHeaderWidth > 0
            && horizontalScrollBarHeight > 0) {
            bottomLeftCorner.setVisible(true);
            bottomLeftCorner.setSize(rowHeaderWidth, horizontalScrollBarHeight);
            bottomLeftCorner.setLocation(0, height - horizontalScrollBarHeight);
        } else {
            bottomLeftCorner.setVisible(false);
        }

        if (verticalScrollBarWidth > 0
            && horizontalScrollBarHeight > 0) {
            bottomRightCorner.setVisible(true);
            bottomRightCorner.setSize(verticalScrollBarWidth, horizontalScrollBarHeight);
            bottomRightCorner.setLocation(width - verticalScrollBarWidth,
                height - horizontalScrollBarHeight);
        } else {
            bottomRightCorner.setVisible(false);
        }

        if (columnHeaderHeight > 0
            && verticalScrollBarWidth > 0) {
            topRightCorner.setVisible(true);
            topRightCorner.setSize(verticalScrollBarWidth, columnHeaderHeight);
            topRightCorner.setLocation(width - verticalScrollBarWidth, 0);
        } else {
            topRightCorner.setVisible(false);
        }

        // Perform bounds checking on the scrollTop and scrollLeft values,
        // and adjust them as necessary. Make sure to do this after we've laid
        // everything out, since our ViewPortListener methods rely on valid
        // sizes from our components.

        int maxScrollTop = getMaxScrollTop();
        if (scrollTop > maxScrollTop) {
            scrollPane.setScrollTop(maxScrollTop);
        }

        int maxScrollLeft = getMaxScrollLeft();
        if (scrollLeft > maxScrollLeft) {
            scrollPane.setScrollLeft(maxScrollLeft);
        }

        // Adjust the structure of our scroll bars. Make sure to do this after
        // we adjust the scrollTop and scrollLeft values; otherwise we might
        // try to set structure values that are out of bounds.
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

            // Due to Sun bug #4033851, we cannot call copyArea if the display
            // host is obscured. For a full description of why this is the case,
            // see http://people.apache.org/~tvolkert/tests/scrolling/

            ScrollPane scrollPane = (ScrollPane)getComponent();
            ApplicationContext.DisplayHost displayHost = scrollPane.getDisplay().getDisplayHost();

            optimizeScrollingLocal = (displayHost.getScale() == 1
                && (DesktopApplicationContext.isActive()
                && displayHost.isDisplayable()));
        }
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

        int x = 0;
        int y = 0;
        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

Examples of org.apache.pivot.wtk.ScrollPane

    @Override
    public void scrollTopChanged(Viewport viewport, int previousScrollTop) {
        // NOTE we don't invalidate the component here because we need only
        // reposition the view and row header. Invalidating would yield
        // the correct positioning, but it would do much more work than needed.
        ScrollPane scrollPane = (ScrollPane)viewport;

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

        int columnHeaderHeight = 0;
        if (columnHeader != null) {
            columnHeaderHeight = columnHeader.getHeight();
        }

        int scrollTop = scrollPane.getScrollTop();

        if (view != null
            && view.isShowing()
            && isOptimizeScrolling()) {
            Bounds blitArea = view.getVisibleArea();

            int blitX = blitArea.x + view.getX();
            int blitY = blitArea.y + view.getY();
            int blitWidth = blitArea.width;
            int blitHeight = blitArea.height;

            if (rowHeader != null) {
                // Blit the row header as well
                int rowHeaderWidth = rowHeader.getWidth();
                blitX -= rowHeaderWidth;
                blitWidth += rowHeaderWidth;
            }

            int deltaScrollTop = scrollTop - previousScrollTop;
            blitY += Math.max(deltaScrollTop, 0);
            blitHeight -= Math.abs(deltaScrollTop);

            Graphics2D graphics = scrollPane.getGraphics();
            graphics.copyArea(blitX, blitY, blitWidth, blitHeight, 0, -deltaScrollTop);

            scrollPane.setConsumeRepaint(true);

            try {
                view.setLocation(view.getX(), columnHeaderHeight - scrollTop);

                if (rowHeader != null) {
                    rowHeader.setLocation(0, columnHeaderHeight - scrollTop);
                }
            } finally {
                scrollPane.setConsumeRepaint(false);
            }

            boolean repaintAllViewport = scrollPane.isRepaintAllViewport();
            if (!repaintAllViewport) {
                scrollPane.repaint(blitX, (columnHeaderHeight + (deltaScrollTop > 0 ? blitHeight : 0)),
                    blitWidth, Math.abs(deltaScrollTop), true);
            } else {
                Bounds viewportBounds = getViewportBounds();
                scrollPane.repaint(viewportBounds.x, viewportBounds.y,
                    viewportBounds.width, viewportBounds.height, true);
            }

        } else {
            if (view != null) {
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

    @Override
    public void scrollLeftChanged(Viewport viewport, int previousScrollLeft) {
        // NOTE we don't invalidate the component here because we need only
        // reposition the view and column header. Invalidating would yield
        // the correct positioning, but it would do much more work than needed.
        ScrollPane scrollPane = (ScrollPane)viewport;

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

        int rowHeaderWidth = 0;
        if (rowHeader != null) {
            rowHeaderWidth = rowHeader.getWidth();
        }

        int scrollLeft = scrollPane.getScrollLeft();

        if (view != null
            && view.isShowing()
            && isOptimizeScrolling()) {
            Bounds blitArea = view.getVisibleArea();

            int blitX = blitArea.x + view.getX();
            int blitY = blitArea.y + view.getY();
            int blitWidth = blitArea.width;
            int blitHeight = blitArea.height;

            if (columnHeader != null) {
                // Blit the column header as well
                int columnHeaderHeight = columnHeader.getHeight();
                blitY -= columnHeaderHeight;
                blitHeight += columnHeaderHeight;
            }

            int deltaScrollLeft = scrollLeft - previousScrollLeft;
            blitX += Math.max(deltaScrollLeft, 0);
            blitWidth -= Math.abs(deltaScrollLeft);

            Graphics2D graphics = scrollPane.getGraphics();
            graphics.copyArea(blitX, blitY, blitWidth, blitHeight, -deltaScrollLeft, 0);

            scrollPane.setConsumeRepaint(true);
            try {
                view.setLocation(rowHeaderWidth - scrollLeft, view.getY());

                if (columnHeader != null) {
                    columnHeader.setLocation(rowHeaderWidth - scrollLeft, 0);
                }
            } finally {
                scrollPane.setConsumeRepaint(false);
            }

            boolean repaintAllViewport = scrollPane.isRepaintAllViewport();
            if (!repaintAllViewport) {
                scrollPane.repaint(rowHeaderWidth + (deltaScrollLeft > 0 ? blitWidth : 0), blitY,
                    Math.abs(deltaScrollLeft), blitHeight, true);
            } else {
                Bounds viewportBounds = getViewportBounds();
                scrollPane.repaint(viewportBounds.x, viewportBounds.y,
                    viewportBounds.width, viewportBounds.height, true);
            }
        } else {
            if (view != null) {
                view.setLocation(rowHeaderWidth - scrollLeft, view.getY());
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

    // ScrollBarValueListener methods

    @Override
    public void valueChanged(ScrollBar scrollBar, int previousValue) {
        ScrollPane scrollPane = (ScrollPane)getComponent();

        int value = scrollBar.getValue();

        if (scrollBar == horizontalScrollBar) {
            scrollPane.setScrollLeft(value);
        } else {
            scrollPane.setScrollTop(value);
        }
    }
View Full Code Here

Examples of org.apache.pivot.wtk.ScrollPane

                beanDictionary = new BeanDictionary(tableRow);
                rowData = beanDictionary;
            }

            // Set up the editor component hierarchy
            scrollPane = new ScrollPane(ScrollPane.ScrollBarPolicy.NEVER,
                ScrollPane.ScrollBarPolicy.FILL);
            setContent(scrollPane);

            cardPane = new CardPane();
            scrollPane.setView(cardPane);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.