paint bounds
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/geometry/PixelArea.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/geometry/PixelArea.xtend
new file mode 100644
index 0000000..40d6d3b
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/geometry/PixelArea.xtend
@@ -0,0 +1,9 @@
+package org.eclipse.nebula.widgets.nattable.core.geometry
+
+@Data
+class PixelArea {
+
+ int width
+ int height
+
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerPainter.xtend
index 64ec2b7..076523d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LayerPainter.xtend
@@ -7,9 +7,9 @@
/**
* @param layer The layer to render.
- * @param paintBounds The rectangular pixel area to paint into.
+ * @param layerPaintBounds The rectangular pixel area to paint into. The coordinates of this rectangle are relative to this layer itself.
* @param gc The graphics context to render into.
*/
- def void paintLayer(T layer, PixelRectangle paintBounds, GraphicsContext gc)
+ def void paintLayer(T layer, PixelRectangle layerPaintBounds, GraphicsContext gc)
}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/CellPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/CellPainter.xtend
index 7d29d7b..706caa5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/CellPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/CellPainter.xtend
@@ -7,9 +7,9 @@
/**
* @param cell The cell to paint.
- * @param paintBounds The rectangular pixel area to paint into.
+ * @param cellPaintBounds The rectangular pixel area to paint into. The coordinates of this rectangle are relative to this cell itself.
* @param gc The graphics context to paint into.
*/
- def void paintCell(Cell cell, PixelRectangle paintBounds, GraphicsContext gc)
+ def void paintCell(Cell cell, PixelRectangle cellPaintBounds, GraphicsContext gc)
}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/TextCellPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/TextCellPainter.xtend
index 59c6f89..f8ae497 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/TextCellPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/impl/TextCellPainter.xtend
@@ -1,17 +1,21 @@
package org.eclipse.nebula.widgets.nattable.core.layer.cell.impl
import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
+import org.eclipse.nebula.widgets.nattable.core.graphics.Color
import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext
import org.eclipse.nebula.widgets.nattable.core.layer.cell.Cell
import org.eclipse.nebula.widgets.nattable.core.layer.cell.CellPainter
class TextCellPainter implements CellPainter {
- override paintCell(Cell cell, PixelRectangle paintBounds, GraphicsContext gc) {
+ override paintCell(Cell cell, PixelRectangle cellPaintBounds, GraphicsContext gc) {
+ gc.backgroundColor = new Color(255, 0, 0)
+ gc.fillRectangle(new PixelRectangle(1, 1, cellPaintBounds.width - 2, cellPaintBounds.height - 2))
+
val text = cell.dataValue.toString
- val centerX = paintBounds.x + (paintBounds.width / 2)
- val centerY = paintBounds.y + (paintBounds.height / 2)
+ val centerX = cellPaintBounds.width / 2
+ val centerY = cellPaintBounds.height / 2
val textWidth = gc.calculateTextWidth(text)
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 69869bc..38a0de7 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
@@ -19,7 +19,7 @@
// LayerPainter interface
- override paintLayer(Layer layer, PixelRectangle paintBounds, GraphicsContext gc) {
+ override paintLayer(Layer layer, PixelRectangle layerPaintBounds, GraphicsContext gc) {
val clipBounds = gc.clipBounds
val fromColumnPosition = max(layer.getColumnPositionOfXPixel(clipBounds.x), 0)
@@ -35,10 +35,10 @@
gc.pushState
- 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)
+ val cellPixelBounds = cell.adjustedPixelBounds
+ gc.clipBounds = cellPixelBounds.intersect(new PixelRectangle(0, 0, layerPaintBounds.width, layerPaintBounds.height))
+ gc.translate(cellPixelBounds.x, cellPixelBounds.y)
+ val localCellPaintBounds = new PixelRectangle(0, 0, cellPixelBounds.width, cellPixelBounds.height)
cellPainter.paintCell(cell, localCellPaintBounds, gc)
gc.popState
@@ -47,7 +47,7 @@
//
- protected def getPaintBounds(Cell cell) {
+ protected def getAdjustedPixelBounds(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 fca6bac..88f868a 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
@@ -14,9 +14,9 @@
// LayerPainter interface
- override paintLayer(Layer layer, PixelRectangle paintBounds, GraphicsContext gc) {
+ override paintLayer(Layer layer, PixelRectangle layerPaintBounds, GraphicsContext gc) {
// Draw cells
- super.paintLayer(layer, paintBounds, gc)
+ super.paintLayer(layer, layerPaintBounds, gc)
// Draw grid lines
drawGridLines(layer, gc)
@@ -24,14 +24,14 @@
// CellLayerPainter methods
- override protected getPaintBounds(Cell cell) {
- val cellBounds = super.getPaintBounds(cell)
+ override protected getAdjustedPixelBounds(Cell cell) {
+ val pixelBounds = super.getAdjustedPixelBounds(cell)
new PixelRectangle(
- cellBounds.x,
- cellBounds.y,
- cellBounds.width - 1,
- cellBounds.height - 1
+ pixelBounds.x,
+ pixelBounds.y,
+ pixelBounds.width - 1,
+ pixelBounds.height - 1
)
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainter.xtend b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainter.xtend
index 6216376..fef68da 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainter.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/impl/composite/CompositeLayerPainter.xtend
@@ -12,7 +12,7 @@
@Inject extension PainterFactory
- override paintLayer(CompositeLayer compositeLayer, PixelRectangle paintBounds, GraphicsContext gc) {
+ override paintLayer(CompositeLayer compositeLayer, PixelRectangle layerPaintBounds, GraphicsContext gc) {
var yOffset = 0
for (compositeRowPosition : 0 ..< compositeLayer.rows.size) {
val compositeRow = compositeLayer.rows.get(compositeRowPosition)
@@ -26,12 +26,12 @@
gc.pushState
gc.translate(xOffset, yOffset)
- val pixelWidth = if (isLastCompositeColumn) paintBounds.x + paintBounds.width - xOffset else childLayer.pixelWidth
- val pixelHeight = if (isLastCompositeRow) paintBounds.y + paintBounds.height - yOffset else childLayer.pixelHeight
- val childPaintBounds = new PixelRectangle(0, 0, pixelWidth, pixelHeight)
+ val pixelWidth = if (isLastCompositeColumn) layerPaintBounds.x + layerPaintBounds.width - xOffset else childLayer.pixelWidth
+ val pixelHeight = if (isLastCompositeRow) layerPaintBounds.y + layerPaintBounds.height - yOffset else childLayer.pixelHeight
+ val childLayerPaintBounds = new PixelRectangle(0, 0, pixelWidth, pixelHeight)
- gc.clipBounds = childPaintBounds
- childLayer.layerPainter.paintLayer(childLayer, childPaintBounds, gc)
+ gc.clipBounds = childLayerPaintBounds
+ childLayer.layerPainter.paintLayer(childLayer, childLayerPaintBounds, gc)
gc.popState
xOffset = xOffset + childLayer.pixelWidth
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt.test/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend b/org.eclipse.nebula.widgets.nattable.renderer.swt.test/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend
index c5a09b7..2deaadd 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt.test/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt.test/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTExample.xtend
@@ -22,7 +22,7 @@
class SWTExample {
- def static void main(String[] args) {
+ static def void main(String[] args) {
new SWTExample().run(400, 300)
}
@@ -55,18 +55,18 @@
def createNatTable(Shell shell) {
val bodyLayer = new ViewportLayer(new DummyLayer(
// Horizontal axis
- new ReorderAxis(
- new AxisImpl(4, 200) => [ setPixelSizeOfSegmentPosition(100, 0) ]
- ) => [ reorderSegmentPosition(0, 2) ],
+// new ReorderAxis(
+ new AxisImpl(10, 200)// => [ setPixelSizeOfSegmentPosition(100, 0) ]
+// ) => [ reorderSegmentPosition(0, 2) ]
+,
// Vertical axis
- new HideShowAxis(
- new AxisImpl(4, 100) => [ setPixelSizeOfSegmentPosition(200, 2) ]
- ) => [ hideSegmentId(0) ]
+// new HideShowAxis(
+ new AxisImpl(10, 100)// => [ setPixelSizeOfSegmentPosition(200, 2) ]
+// ) => [ hideSegmentId(0) ]
))
- val String[] columnHeaders = #[ "A", "B", "C", "D" ]
- val columnHeaderLayer = new ColumnHeaderLayer(bodyLayer.horizontalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | columnHeaders.get(columnId as Integer) ]))
+ val columnHeaderLayer = new ColumnHeaderLayer(bodyLayer.horizontalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | columnId ]))
val rowHeaderLayer = new RowHeaderLayer(bodyLayer.verticalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | rowId ]))
val cornerLayer = new DimensionallyDependentLayer(rowHeaderLayer.horizontalAxis, columnHeaderLayer.verticalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | "" ]))