Search in sources :

Example 56 with Bounds

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

the class TextPaneSkinParagraphView method paint.

@Override
public void paint(Graphics2D graphics) {
    // The default paint() method paints the document children, but because of row-splitting,
    // the children we want to paint are not the same.
    // Determine the paint bounds
    Bounds paintBounds = new Bounds(0, 0, getWidth(), getHeight());
    Rectangle clipBounds = graphics.getClipBounds();
    if (clipBounds != null) {
        paintBounds = paintBounds.intersect(clipBounds);
    }
    for (int i = 0, n = rows.getLength(); i < n; i++) {
        Row row = rows.get(i);
        for (RowSegment segment : row.rowSegments) {
            paintChild(graphics, paintBounds, segment.nodeView);
        }
    }
}
Also used : Bounds(org.apache.pivot.wtk.Bounds) Rectangle(java.awt.Rectangle)

Example 57 with Bounds

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

the class TextPaneSkinVerticalElementView method getInsertionPoint.

@Override
public int getInsertionPoint(int x, int y) {
    int offset = -1;
    for (int i = 0, n = getLength(); i < n; i++) {
        TextPaneSkinNodeView nodeView = get(i);
        Bounds nodeViewBounds = nodeView.getBounds();
        if (y >= nodeViewBounds.y && y < nodeViewBounds.y + nodeViewBounds.height) {
            offset = nodeView.getInsertionPoint(x - nodeView.getX(), y - nodeView.getY()) + nodeView.getOffset();
            break;
        }
    }
    return offset;
}
Also used : Bounds(org.apache.pivot.wtk.Bounds)

Example 58 with Bounds

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

the class TerraTableViewSkin method selectedRangeRemoved.

@Override
public void selectedRangeRemoved(TableView tableView, int rangeStart, int rangeEnd) {
    // Repaint the area containing the removed selection
    if (tableView.isValid()) {
        Bounds selectionBounds = getRowBounds(rangeStart);
        selectionBounds = selectionBounds.union(getRowBounds(rangeEnd));
        repaintComponent(selectionBounds);
    }
}
Also used : Bounds(org.apache.pivot.wtk.Bounds)

Example 59 with Bounds

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

the class TerraTableViewSkin method selectedRangesChanged.

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

Example 60 with Bounds

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

the class TerraTableViewSkin method mouseWheel.

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

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