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