use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class TextPaneSkinTextNodeView method getCharacterBounds.
@Override
public Bounds getCharacterBounds(int offset) {
Bounds characterBounds = null;
if (textLayout != null) {
// If the offest == length, then use the right hand edge of the previous
// offset instead -- this is for positioning the caret at the end of the text
int length = textLayout.getCharacterCount();
int ix = (offset == length) ? offset - 1 : offset;
Shape glyphShape = textLayout.getLogicalHighlightShape(ix, ix + 1);
Rectangle2D glyphBounds2D = glyphShape.getBounds2D();
if (offset == length) {
characterBounds = new Bounds((int) Math.ceil(glyphBounds2D.getX() + glyphBounds2D.getWidth()), 0, 1, getHeight());
} else {
characterBounds = new Bounds((int) Math.floor(glyphBounds2D.getX()), 0, (int) Math.ceil(glyphBounds2D.getWidth()), getHeight());
}
}
return characterBounds;
}
use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class TranslationDecorator method prepare.
@Override
public Graphics2D prepare(Component component, Graphics2D graphics) {
if (clip) {
Bounds decoratedBounds = component.getDecoratedBounds();
graphics.clipRect(decoratedBounds.x - component.getX(), decoratedBounds.y - component.getY(), decoratedBounds.width, decoratedBounds.height);
}
graphics.translate(x, y);
return graphics;
}
use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class TerraTableViewHeaderSkin method mouseDown.
@Override
public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
boolean consumed = super.mouseDown(component, button, x, y);
if (button == Mouse.Button.LEFT) {
TableViewHeader tableViewHeader = (TableViewHeader) getComponent();
TableView tableView = tableViewHeader.getTableView();
if (tableView != null) {
int headerIndex = getHeaderAt(x);
if (headerIndex != -1) {
Bounds headerBounds = getHeaderBounds(headerIndex);
TableView.Column column = tableView.getColumns().get(headerIndex);
if (columnsResizable && !column.isRelative() && column.getWidth() != -1 && x > headerBounds.x + headerBounds.width - RESIZE_HANDLE_SIZE) {
resizeHeaderIndex = headerIndex;
} else if (headersPressable) {
pressedHeaderIndex = headerIndex;
repaintComponent(headerBounds);
}
}
}
}
return consumed;
}
use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class TerraTableViewHeaderSkin method getHeaderBounds.
@Override
public Bounds getHeaderBounds(int headerIndex) {
Bounds headerBounds = null;
TableViewHeader tableViewHeader = (TableViewHeader) getComponent();
TableView tableView = tableViewHeader.getTableView();
if (tableView != null) {
Utils.checkZeroBasedIndex(headerIndex, headerWidths.getLength());
int cellX = 0;
for (int i = 0; i < headerIndex; i++) {
cellX += (headerWidths.get(i).intValue() + 1);
}
headerBounds = new Bounds(cellX, 0, headerWidths.get(headerIndex).intValue(), getHeight() - 1);
}
return headerBounds;
}
use of org.apache.pivot.wtk.Bounds in project pivot by apache.
the class TerraTableViewHeaderSkin method mouseMove.
@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
TableViewHeader tableViewHeader = (TableViewHeader) getComponent();
TableView tableView = tableViewHeader.getTableView();
if (tableView != null) {
if (resizeHeaderIndex != -1 && Mouse.getCapturer() != tableViewHeader) {
Mouse.capture(tableViewHeader);
}
if (Mouse.getCapturer() == tableViewHeader) {
TableView.Column column = tableView.getColumns().get(resizeHeaderIndex);
Bounds headerBounds = getHeaderBounds(resizeHeaderIndex);
int columnWidth = Math.max(x - headerBounds.x, MINIMUM_COLUMN_WIDTH);
column.setWidth(columnWidth, false);
} else {
int headerIndex = getHeaderAt(x);
if (headerIndex != -1 && columnsResizable) {
Bounds headerBounds = getHeaderBounds(headerIndex);
TableView.Column column = tableView.getColumns().get(headerIndex);
if (!column.isRelative() && column.getWidth() != -1 && x > headerBounds.x + headerBounds.width - RESIZE_HANDLE_SIZE) {
tableViewHeader.setCursor(Cursor.RESIZE_EAST);
} else {
tableViewHeader.setCursor((Cursor) null);
}
} else {
tableViewHeader.setCursor((Cursor) null);
}
}
}
return consumed;
}
Aggregations