Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.ScrollPane$Corner


        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


    @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

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

            scrollPane.repaint(rowHeaderWidth + (deltaScrollLeft > 0 ? blitWidth : 0), blitY,
                Math.abs(deltaScrollLeft), blitHeight, true);
        } else {
            if (view != null) {
                view.setLocation(rowHeaderWidth - scrollLeft, view.getY());
            }
View Full Code Here

    // 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

    @Override
    public void install(Component component) {
        super.install(component);

        ScrollPane scrollPane = (ScrollPane)component;
        scrollPane.getViewportListeners().add(this);
        scrollPane.getScrollPaneListeners().add(this);

        scrollPane.add(horizontalScrollBar);
        scrollPane.add(verticalScrollBar);

        scrollPane.add(topLeftCorner);
        scrollPane.add(bottomLeftCorner);
        scrollPane.add(bottomRightCorner);
        scrollPane.add(topRightCorner);

        horizontalScrollBar.getScrollBarValueListeners().add(this);
        verticalScrollBar.getScrollBarValueListeners().add(this);
    }
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) {
                // Get the unconstrained preferred size of the view
                Dimensions preferredViewSize = view.getPreferredSize();
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) {
                // Get the unconstrained preferred size of the view
                Dimensions preferredViewSize = view.getPreferredSize();
View Full Code Here

        return preferredHeight;
    }

    @Override
    public Dimensions getPreferredSize() {
        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);
            }

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

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

        return new Dimensions(preferredWidth, preferredHeight);
    }

    @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;
View Full Code Here

    @Override
    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)) {
                // Treat the mouse wheel as a horizontal scroll event
                int previousScrollLeft = scrollPane.getScrollLeft();
                int newScrollLeft = previousScrollLeft + (scrollAmount * wheelRotation *
                    horizontalScrollBar.getUnitIncrement());

                if (wheelRotation > 0) {
                    int maxScrollLeft = getMaxScrollLeft();
                    newScrollLeft = Math.min(newScrollLeft, maxScrollLeft);

                    if (previousScrollLeft < maxScrollLeft) {
                        consumed = true;
                    }
                } else {
                    newScrollLeft = Math.max(newScrollLeft, 0);

                    if (previousScrollLeft > 0) {
                        consumed = true;
                    }
                }

                scrollPane.setScrollLeft(newScrollLeft);
            } else {
                // Treat the mouse wheel as a vertical scroll event
                int previousScrollTop = scrollPane.getScrollTop();
                int newScrollTop = previousScrollTop + (scrollAmount * wheelRotation *
                    verticalScrollBar.getUnitIncrement());

                if (wheelRotation > 0) {
                    int maxScrollTop = getMaxScrollTop();
                    newScrollTop = Math.min(newScrollTop, maxScrollTop);

                    if (previousScrollTop < maxScrollTop) {
                        consumed = true;
                    }
                } else {
                    newScrollTop = Math.max(newScrollTop, 0);

                    if (previousScrollTop > 0) {
                        consumed = true;
                    }
                }

                scrollPane.setScrollTop(newScrollTop);
            }
        }

        return consumed;
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.ScrollPane$Corner

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.