Search in sources :

Example 66 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraSheetSkin method mouseDown.

@Override
public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
    Sheet sheet = (Sheet) container;
    if (!sheet.isTopMost()) {
        Window owner = sheet.getOwner();
        owner.moveToFront();
    }
    boolean consumed = super.mouseDown(container, button, x, y);
    if (resizable && button == Mouse.Button.LEFT) {
        Bounds resizeHandleBounds = resizeHandle.getBounds();
        if (resizeHandleBounds.contains(x, y)) {
            resizeOffset = new Point(getWidth() - x, getHeight() - y);
            Mouse.capture(container);
        }
    }
    return consumed;
}
Also used : Window(org.apache.pivot.wtk.Window) Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point) Sheet(org.apache.pivot.wtk.Sheet)

Example 67 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraTabPaneSkin method paint.

@Override
public void paint(Graphics2D graphics) {
    TabPane tabPane = (TabPane) getComponent();
    Bounds tabPaneBounds = tabPane.getBounds();
    // Call the base class to paint the background
    super.paint(graphics);
    // Paint the content background and border
    int x = 0;
    int y = 0;
    int width = 0;
    int height = 0;
    switch(tabOrientation) {
        case HORIZONTAL:
            {
                x = 0;
                y = Math.max(tabButtonPanorama.getY() + tabButtonPanorama.getHeight() - 1, 0);
                width = tabPaneBounds.width;
                height = Math.max(tabPaneBounds.height - y, 0);
                break;
            }
        case VERTICAL:
            {
                x = Math.max(tabButtonPanorama.getX() + tabButtonPanorama.getWidth() - 1, 0);
                y = 0;
                width = Math.max(tabPaneBounds.width - x, 0);
                height = tabPaneBounds.height;
                break;
            }
        default:
            {
                break;
            }
    }
    TabButton activeTabButton;
    if (selectionChangeTransition == null) {
        activeTabButton = (TabButton) tabButtonGroup.getSelection();
    } else {
        activeTabButton = (TabButton) tabButtonBoxPane.get(selectionChangeTransition.index);
    }
    if (activeTabButton != null) {
        Bounds contentBounds = new Bounds(x, y, width, height);
        GraphicsUtilities.setAntialiasingOn(graphics);
        // Paint the background
        graphics.setPaint(activeTabColor);
        graphics.fillRect(contentBounds.x, contentBounds.y, contentBounds.width, contentBounds.height);
        if (!themeIsFlat()) {
            // Draw the border
            double top = contentBounds.y + 0.5;
            double left = contentBounds.x + 0.5;
            double bottom = top + contentBounds.height - 1;
            double right = left + contentBounds.width - 1;
            graphics.setPaint(borderColor);
            // Draw the right and bottom borders
            graphics.draw(new Line2D.Double(right, top, right, bottom));
            graphics.draw(new Line2D.Double(left, bottom, right, bottom));
            // Draw the left and top borders
            switch(tabOrientation) {
                case HORIZONTAL:
                    {
                        graphics.draw(new Line2D.Double(left, top, left, bottom));
                        Point selectedTabButtonLocation = activeTabButton.mapPointToAncestor(tabPane, 0, 0);
                        graphics.draw(new Line2D.Double(left, top, selectedTabButtonLocation.x + 0.5, top));
                        graphics.draw(new Line2D.Double(selectedTabButtonLocation.x + activeTabButton.getWidth() - 0.5, top, right, top));
                        break;
                    }
                case VERTICAL:
                    {
                        graphics.draw(new Line2D.Double(left, top, right, top));
                        Point selectedTabButtonLocation = activeTabButton.mapPointToAncestor(tabPane, 0, 0);
                        graphics.draw(new Line2D.Double(left, top, left, selectedTabButtonLocation.y + 0.5));
                        graphics.draw(new Line2D.Double(left, selectedTabButtonLocation.y + activeTabButton.getHeight() - 0.5, left, bottom));
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
        }
    }
}
Also used : TabPane(org.apache.pivot.wtk.TabPane) Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point) Line2D(java.awt.geom.Line2D) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 68 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraListViewSkin method getCheckboxBounds.

private Bounds getCheckboxBounds(int itemIndex) {
    Bounds itemBounds = getItemBounds(itemIndex);
    int checkboxHeight = CHECKBOX.getHeight();
    return new Bounds(checkboxPadding.left, itemBounds.y + (itemBounds.height - checkboxHeight) / 2, CHECKBOX.getWidth(), checkboxHeight);
}
Also used : Bounds(org.apache.pivot.wtk.Bounds)

Example 69 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraListViewSkin method selectedRangesChanged.

@Override
public void selectedRangesChanged(ListView listView, Sequence<Span> previousSelectedRanges) {
    if (previousSelectedRanges != null && previousSelectedRanges != listView.getSelectedRanges()) {
        if (listView.isValid()) {
            // Repaint the area occupied by the previous selection
            if (previousSelectedRanges.getLength() > 0) {
                int rangeStart = previousSelectedRanges.get(0).start;
                int rangeEnd = previousSelectedRanges.get(previousSelectedRanges.getLength() - 1).end;
                Bounds previousSelectionBounds = getItemBounds(rangeStart);
                previousSelectionBounds = previousSelectionBounds.union(getItemBounds(rangeEnd));
                repaintComponent(previousSelectionBounds);
            }
            // Repaint the area occupied by the current selection
            Sequence<Span> selectedRanges = listView.getSelectedRanges();
            if (selectedRanges.getLength() > 0) {
                int rangeStart = selectedRanges.get(0).start;
                int rangeEnd = selectedRanges.get(selectedRanges.getLength() - 1).end;
                Bounds selectionBounds = getItemBounds(rangeStart);
                selectionBounds = selectionBounds.union(getItemBounds(rangeEnd));
                repaintComponent(selectionBounds);
                // Ensure that the selection is visible
                Bounds visibleSelectionBounds = listView.getVisibleArea(selectionBounds);
                if (visibleSelectionBounds != null && visibleSelectionBounds.height < selectionBounds.height) {
                    // Repainting the entire component is a workaround for PIVOT-490
                    repaintComponent();
                    listView.scrollAreaToVisible(selectionBounds);
                }
            }
        } else {
            validateSelection = true;
        }
    }
}
Also used : Bounds(org.apache.pivot.wtk.Bounds) Span(org.apache.pivot.wtk.Span)

Example 70 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraListViewSkin method mouseWheel.

@Override
public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y) {
    ListView listView = (ListView) getComponent();
    if (highlightIndex != -1) {
        Bounds itemBounds = getItemBounds(highlightIndex);
        highlightIndex = -1;
        if (listView.getSelectMode() != ListView.SelectMode.NONE && showHighlight) {
            repaintComponent(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height, true);
        }
    }
    return super.mouseWheel(component, scrollType, scrollAmount, wheelRotation, x, y);
}
Also used : ListView(org.apache.pivot.wtk.ListView) Bounds(org.apache.pivot.wtk.Bounds)

Aggregations

Bounds (org.apache.pivot.wtk.Bounds)77 Point (org.apache.pivot.wtk.Point)21 GradientPaint (java.awt.GradientPaint)15 Color (java.awt.Color)10 Graphics2D (java.awt.Graphics2D)9 Rectangle (java.awt.Rectangle)7 TableView (org.apache.pivot.wtk.TableView)7 BasicStroke (java.awt.BasicStroke)6 GeneralPath (java.awt.geom.GeneralPath)5 Button (org.apache.pivot.wtk.Button)5 Component (org.apache.pivot.wtk.Component)5 Span (org.apache.pivot.wtk.Span)5 TextArea (org.apache.pivot.wtk.TextArea)5 TextPane (org.apache.pivot.wtk.TextPane)5 FontRenderContext (java.awt.font.FontRenderContext)4 LineMetrics (java.awt.font.LineMetrics)4 Area (java.awt.geom.Area)4 RoundRectangle2D (java.awt.geom.RoundRectangle2D)4 ArrayList (org.apache.pivot.collections.ArrayList)4 ScrollPane (org.apache.pivot.wtk.ScrollPane)4