Package org.apache.isis.viewer.dnd.drawing

Examples of org.apache.isis.viewer.dnd.drawing.Bounds


    @Override
    public void draw(final Canvas canvas) {
        super.draw(canvas);

        final Bounds b = getButtonBounds();
        canvas.drawRoundedRectangle(b.getX(), b.getY(), b.getWidth(), b.getHeight(), 6, 6, Toolkit.getColor(0xfff));
    }
View Full Code Here


        }
    }

    private Bounds getButtonBounds() {
        final int x = getSize().getWidth() - 28;
        return new Bounds(x, 8, 20, 16);
    }
View Full Code Here

    private int adjust(final ContentDrag drag) {
        return adjust(drag.getTargetLocation());
    }

    private int adjust(final Location location) {
        final Bounds contentArea = viewportArea();
        final Offset offset = offset();
        final int yOffset = offset.getDeltaY();
        final int xOffset = offset.getDeltaX();
        if (contentArea.contains(location)) {
            location.subtract(left, top);
            location.add(xOffset, yOffset);
            return CENTER;
        } else {
            final int x = location.getX();
            final int y = location.getY();

            if (x > contentArea.getX2() && y >= contentArea.getY() && y <= contentArea.getY2()) {
                // vertical scrollbar
                location.subtract(0, contentArea.getY());
                return EAST;
            } else if (y > contentArea.getY2() && x >= contentArea.getX() && x <= contentArea.getX2()) {
                // horzontal scrollbar
                location.subtract(contentArea.getX(), 0);
                return SOUTH;
            } else if (y < contentArea.getY() && x >= contentArea.getX() && x <= contentArea.getX2()) {
                // top border
                location.subtract(left, 0);
                location.add(xOffset, 0);
                return NORTH;
            } else if (x < contentArea.getX() && y >= contentArea.getY() && y <= contentArea.getY2()) {
                // left border
                location.subtract(0, top);
                location.add(0, yOffset);
                return WEST;
            } else {
View Full Code Here

        }

    }

    protected Bounds viewportArea() {
        return new Bounds(left, top, getSize().getWidth() - left - right, getSize().getHeight() - top - bottom);
    }
View Full Code Here

        return adjust(drag.getLocation());
    }

    @Override
    public void draw(final Canvas canvas) {
        final Bounds contents = viewportArea();
        final Offset offset = offset();
        final int x = offset.getDeltaX();
        final int y = offset.getDeltaY();

        final int contentWidth = contents.getWidth();
        final int contentHeight = contents.getHeight();

        final Canvas headerCanvasLeft = canvas.createSubcanvas(0, top, left, contentHeight);
        headerCanvasLeft.offset(0, -y);
        leftHeader.draw(headerCanvasLeft);

        final Canvas headerCanvasRight = canvas.createSubcanvas(left, 0, contentWidth, top);
        headerCanvasRight.offset(-x, 0);
        topHeader.draw(headerCanvasRight);

        final Color thumbColor = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY2);
        drawVerticalScrollBar(canvas, contentWidth, contentHeight, thumbColor);
        drawHorizontalScrollBar(canvas, contentWidth, contentHeight, thumbColor);

        final Canvas contentCanvas = canvas.createSubcanvas(left, top, contentWidth, contentHeight);
        contentCanvas.offset(-x, -y);

        if (Toolkit.debug) {
            canvas.drawRectangle(contents.getX(), contents.getY(), contents.getWidth(), contents.getHeight(), Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_DRAW));
        }

        // drawContent(canvas, contentWidth, contentHeight);
        wrappedView.draw(contentCanvas);
View Full Code Here

        return location;
    }

    @Override
    public Bounds getBounds() {
        return new Bounds(getLocation(), getSize());
    }
View Full Code Here

            break;
        }
    }

    private Offset offset() {
        final Bounds contents = viewportArea();
        final int width = contents.getWidth();
        final int x = width == 0 ? 0 : horizontalScrollBar.getPosition() * wrappedView.getRequiredSize(Size.createMax()).getWidth() / width;
        final int height = contents.getHeight();
        final int y = height == 0 ? 0 : verticalScrollBar.getPosition() * wrappedView.getRequiredSize(Size.createMax()).getHeight() / height;
        return new Offset(x, y);
    }
View Full Code Here

        final int availableWidth2 = size.getWidth() - left;
        final int contentWidth2 = contentSize.getWidth();
        bottom = availableWidth2 >= contentWidth2 ? 0 : SCROLLBAR_WIDTH;

        final Bounds viewport = viewportArea();

        final int viewportHeight = viewport.getHeight();
        final int maxContentHeight = Math.max(viewportHeight, contentSize.getHeight());

        verticalScrollBar.setSize(viewportHeight, maxContentHeight);
        if (leftHeader != null) {
            leftHeader.setSize(new Size(left, maxContentHeight));
        }

        final int viewportWidth = viewport.getWidth();
        final int maxContentWidth = Math.max(viewportWidth, contentSize.getWidth());

        horizontalScrollBar.setSize(viewportWidth, maxContentWidth);
        if (topHeader != null) {
            topHeader.setSize(new Size(maxContentWidth, top));
View Full Code Here

    @Override
    public void draw(final Canvas canvas) {
        final View views[] = getSubviews();
        for (final View subview : views) {
            final Bounds bounds = subview.getBounds();
            if (Toolkit.debug) {
                LOG.debug("compare: " + bounds + "  " + canvas);
            }
            if (canvas.overlaps(bounds)) {
                // Canvas subCanvas = canvas.createSubcanvas();
                final Canvas subCanvas = canvas.createSubcanvas(bounds.getX(), bounds.getY(), bounds.getWidth() - 0, bounds.getSize().getHeight());
                // subCanvas.offset(subview.getBounds().getX(),
                // subview.getBounds().getY());
                if (Toolkit.debug) {
                    LOG.debug("-- repainting " + subview);
                    LOG.debug("subcanvas " + subCanvas);
View Full Code Here

    /**
     * Clears the background of this view to the given color (call from the
     * {@link #draw(Canvas)} method.
     */
    protected void clearBackground(final Canvas canvas, final Color color) {
        final Bounds bounds = getBounds();
        canvas.drawSolidRectangle(0, 0, bounds.getWidth(), bounds.getHeight(), color);
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.dnd.drawing.Bounds

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.