use of org.eclipse.swt.graphics.Rectangle in project dbeaver by serge-rider.
the class GridColumn method isOverSortArrow.
public boolean isOverSortArrow(int x, int y) {
if (!isSortable()) {
return false;
}
Rectangle bounds = getBounds();
if (y < bounds.y || y > bounds.y + bounds.height) {
return false;
}
int arrowEnd = bounds.width - rightMargin;
Rectangle sortBounds = GridColumnRenderer.getSortControlBounds();
int arrowBegin = arrowEnd - sortBounds.width;
return x >= arrowBegin && x <= arrowEnd && y < bounds.y + sortBounds.height;
}
use of org.eclipse.swt.graphics.Rectangle in project dbeaver by serge-rider.
the class GridColumn method computeCellWidth.
private int computeCellWidth(Object col, Object row) {
int x = 0;
x += leftMargin;
String cellText = grid.getCellText(col, row);
int state = grid.getContentProvider().getCellState(col, row, cellText);
Rectangle imageBounds;
if (GridCellRenderer.isLinkState(state)) {
imageBounds = GridCellRenderer.LINK_IMAGE_BOUNDS;
} else {
DBPImage image = grid.getContentProvider().getCellImage(col, row);
imageBounds = image == null ? null : DBeaverIcons.getImage(image).getBounds();
}
if (imageBounds != null) {
x += imageBounds.width + insideMargin;
}
x += grid.sizingGC.textExtent(cellText).x + rightMargin;
return x;
}
use of org.eclipse.swt.graphics.Rectangle in project dbeaver by serge-rider.
the class TabbedFolderComposite method shiftPane.
private void shiftPane(FolderPane curPane, int shift) {
// Set current height to heightHint
for (FolderPane pane : folderPanes) {
Rectangle bounds = pane.editorPane.getBounds();
GridData gd = (GridData) pane.editorPane.getLayoutData();
gd.heightHint = bounds.height;
}
FolderPane nextPane = getNextFolderPane(curPane);
((GridData) curPane.editorPane.getLayoutData()).heightHint += shift;
((GridData) nextPane.editorPane.getLayoutData()).heightHint -= shift;
compositePane.layout();
/*
if (shift < 0) {
// Decrease self size and increase next pane's
//nextPane.editorPane.
} else {
// Increase self size and decrease next pane's
}
*/
}
use of org.eclipse.swt.graphics.Rectangle in project dbeaver by serge-rider.
the class ImageViewCanvas method paint.
/* Paint function */
private void paint(GC gc) {
Rectangle clientRect = getClientArea();
/* Canvas' painting area */
if (sourceImage != null) {
Rectangle imageRect = ImageViewUtil.inverseTransformRect(transform, clientRect);
int gap = 2;
/* find a better start point to render */
imageRect.x -= gap;
imageRect.y -= gap;
imageRect.width += 2 * gap;
imageRect.height += 2 * gap;
Rectangle imageBound = sourceImage.getBounds();
imageRect = imageRect.intersection(imageBound);
Rectangle destRect = ImageViewUtil.transformRect(transform, imageRect);
if (screenImage != null)
screenImage.dispose();
screenImage = new Image(getDisplay(), clientRect.width, clientRect.height);
GC newGC = new GC(screenImage);
newGC.setClipping(clientRect);
newGC.drawImage(sourceImage, imageRect.x, imageRect.y, imageRect.width, imageRect.height, destRect.x, destRect.y, destRect.width, destRect.height);
newGC.dispose();
gc.drawImage(screenImage, 0, 0);
} else {
gc.setClipping(clientRect);
gc.fillRectangle(clientRect);
initScrollBars();
}
}
use of org.eclipse.swt.graphics.Rectangle in project dbeaver by serge-rider.
the class ImageViewCanvas method syncScrollBars.
/**
* Synchronize the scrollbar with the image. If the transform is out
* of range, it will correct it. This function considers only following
* factors :<b> transform, image size, client area</b>.
*/
public void syncScrollBars() {
if (sourceImage == null) {
redraw();
return;
}
AffineTransform af = transform;
double sx = af.getScaleX(), sy = af.getScaleY();
double tx = af.getTranslateX(), ty = af.getTranslateY();
if (tx > 0)
tx = 0;
if (ty > 0)
ty = 0;
ScrollBar horizontal = getHorizontalBar();
horizontal.setIncrement(getClientArea().width / 100);
horizontal.setPageIncrement(getClientArea().width);
Rectangle imageBound = sourceImage.getBounds();
int cw = getClientArea().width, ch = getClientArea().height;
if (imageBound.width * sx > cw) {
/* image is wider than client area */
horizontal.setMaximum((int) (imageBound.width * sx));
horizontal.setEnabled(true);
if (((int) -tx) > horizontal.getMaximum() - cw)
tx = -horizontal.getMaximum() + cw;
} else {
/* image is narrower than client area */
horizontal.setEnabled(false);
//center if too small.
tx = (cw - imageBound.width * sx) / 2;
}
horizontal.setSelection((int) (-tx));
horizontal.setThumb(getClientArea().width);
ScrollBar vertical = getVerticalBar();
vertical.setIncrement(getClientArea().height / 100);
vertical.setPageIncrement(getClientArea().height);
if (imageBound.height * sy > ch) {
/* image is higher than client area */
vertical.setMaximum((int) (imageBound.height * sy));
vertical.setEnabled(true);
if (((int) -ty) > vertical.getMaximum() - ch)
ty = -vertical.getMaximum() + ch;
} else {
/* image is less higher than client area */
vertical.setEnabled(false);
//center if too small.
ty = (ch - imageBound.height * sy) / 2;
}
vertical.setSelection((int) (-ty));
vertical.setThumb(getClientArea().height);
/* update transform. */
af = AffineTransform.getScaleInstance(sx, sy);
af.preConcatenate(AffineTransform.getTranslateInstance(tx, ty));
transform = af;
redraw();
}
Aggregations