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