cell clipping
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/geometry/PixelRectangleInvariants.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/geometry/PixelRectangleInvariants.xtend
new file mode 100644
index 0000000..4de3334
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/geometry/PixelRectangleInvariants.xtend
@@ -0,0 +1,13 @@
+package org.eclipse.nebula.widgets.nattable.core.geometry
+
+class PixelRectangleInvariants {
+
+ static def PixelRectangle intersect(PixelRectangle rect1, PixelRectangle rect2) {
+ val startX = Math::max(rect1.x, rect2.x)
+ val startY = Math::max(rect1.y, rect2.y)
+ val endX = Math::min(rect1.x + rect1.width, rect2.x + rect2.width)
+ val endY = Math::min(rect1.y + rect1.height, rect2.y + rect2.height)
+ new PixelRectangle(startX, startY, endX - startX, endY - startY)
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainter.xtend
index 30b2368..c5fea48 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/CellLayerPainter.xtend
@@ -7,6 +7,7 @@
import org.eclipse.nebula.widgets.nattable.core.layer.cell.Cell
import org.eclipse.nebula.widgets.nattable.core.layer.cell.impl.DefaultCellPainter
+import static extension org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangleInvariants.*
import static extension org.eclipse.nebula.widgets.nattable.core.layer.LayerInvariants.*
import static extension org.eclipse.nebula.widgets.nattable.core.layer.cell.CellInvariants.*
@@ -22,15 +23,22 @@
for (columnPosition : 0 ..< layer.getColumnCount)
for (rowPosition : 0 ..< layer.getRowCount) {
val cell = layer.getCell(columnPosition, rowPosition)
+
gc.pushState
- cellPainter.paintCell(cell, cell.paintRegion, gc)
+
+ val cellPaintBounds = cell.paintBounds
+ gc.clipBounds = cellPaintBounds.intersect(paintBounds)
+ gc.translate(cellPaintBounds.x, cellPaintBounds.y)
+ val localCellPaintBounds = new PixelRectangle(0, 0, cellPaintBounds.width, cellPaintBounds.height)
+ cellPainter.paintCell(cell, localCellPaintBounds, gc)
+
gc.popState
}
}
//
- protected def getPaintRegion(Cell cell) {
+ protected def getPaintBounds(Cell cell) {
cell.pixelBounds
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainter.xtend
index 07382fb..bf4b5c0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/GridLineCellLayerPainter.xtend
@@ -22,8 +22,8 @@
// CellLayerPainter methods
- override protected getPaintRegion(Cell cell) {
- val cellBounds = super.getPaintRegion(cell)
+ override protected getPaintBounds(Cell cell) {
+ val cellBounds = super.getPaintBounds(cell)
new PixelRectangle(
cellBounds.x,