if (bounds == null || image == null || image.isDisposed()) {
//System.out.println(row.getIndex() + " nb");
return;
}
Table table = getTable();
// System.out.println("doPnt#" + row.getIndex()+": " +
// ((gc == null) ? "GC NULL" : String.valueOf(gc.getClipping())) +
// "ta="+table.getClientArea()+";bounds="+bounds);
Rectangle imageBounds = image.getBounds();
if (imageBounds.width <= 0 || imageBounds.height <= 0 || bounds.width <= 0
|| bounds.height <= 0) {
//System.out.println(row.getIndex() + " < 0");
return;
}
Rectangle tableBounds = table.getClientArea();
if (bounds.y + bounds.height - tableBounds.y < table.getHeaderHeight()
|| bounds.y > tableBounds.height) {
// System.out.println("doPnt#" + row.getIndex() + ": "
// + (bounds.y + bounds.height - tableBounds.y) + "<" + tableBounds.y
// + " || " + bounds.y + " > " + tableBounds.height);
return;
}
if (orientation == SWT.FILL) {
if (imageBounds.width != bounds.width
|| imageBounds.height != bounds.height) {
//System.out.println("doPaint() sizewrong #"+row.getIndex()+ ". Image="+imageBounds +";us="+bounds);
/**/
// Enable this for semi-fast visual update with some flicker
boolean ourGC = (gc == null);
if (ourGC)
gc = new GC(table);
if (gc != null) {
int iAdj = VerticalAligner.getTableAdjustVerticalBy(table);
bounds.y += iAdj;
iAdj = VerticalAligner.getTableAdjustHorizontallyBy(table);
bounds.x += iAdj;
gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height,
bounds.x, bounds.y, bounds.width, bounds.height);
if (ourGC)
gc.dispose();
}
// _OR_ enable refresh() for slower visual update with lots of flicker
//refresh();
// OR, disable both and image will be updated on next graphic bar update
// TODO: make config option to choose
/**/
invalidate();
return;
}
} else {
if (imageBounds.width < bounds.width) {
if (orientation == SWT.CENTER)
bounds.x += (bounds.width - imageBounds.width) / 2;
else if (orientation == SWT.RIGHT)
bounds.x = (bounds.x + bounds.width) - imageBounds.width;
}
if (imageBounds.height < bounds.height) {
bounds.y += (bounds.height - imageBounds.height) / 2;
}
}
Rectangle clipping = new Rectangle(bounds.x, bounds.y,
bounds.width,
bounds.height);
int iMinY = table.getHeaderHeight() + tableBounds.y;
if (clipping.y < iMinY) {
clipping.height -= iMinY - clipping.y;
clipping.y = iMinY;
}
int iMaxY = tableBounds.height + tableBounds.y;