protected void paintCell(ILayerCell cell, GC gc,
IConfigRegistry configRegistry) {
ILayer layer = cell.getLayer();
int columnPosition = cell.getColumnPosition();
int rowPosition = cell.getRowPosition();
ICellPainter cellPainter = layer.getCellPainter(columnPosition,
rowPosition, cell, configRegistry);
Rectangle adjustedCellBounds = layer.getLayerPainter()
.adjustCellBounds(columnPosition, rowPosition,
cell.getBounds());
if (cellPainter != null) {
Rectangle originalClipping = gc.getClipping();
int startX = getStartXOfColumnPosition(columnPosition);
int startY = getStartYOfRowPosition(rowPosition);
int endX = getStartXOfColumnPosition(cell
.getOriginColumnPosition() + cell.getColumnSpan());
int endY = getStartYOfRowPosition(cell
.getOriginRowPosition() + cell.getRowSpan());
// correct position of first column in right region
// find the last visible column in left region
int viewportBorderX = bodyLayer.getViewportLayerLeft()
.getClientAreaWidth() + rowHeaderLayer.getWidth();
if (isClipLeft(columnPosition) && startX < viewportBorderX) {
startX = viewportBorderX;
}
if (!isClipLeft(columnPosition - 1)
&& startX > viewportBorderX) {
startX = viewportBorderX;
}
if (isClipLeft(cell.getOriginColumnPosition()
+ cell.getColumnSpan())
&& endX < viewportBorderX) {
endX = viewportBorderX;
}
Rectangle cellClipBounds = originalClipping
.intersection(new Rectangle(startX, startY, endX
- startX, endY - startY));
gc.setClipping(cellClipBounds
.intersection(adjustedCellBounds));
cellPainter.paintCell(cell, gc, adjustedCellBounds,
configRegistry);
gc.setClipping(originalClipping);
}
}