blob: 4c706f884fe1f973347710429e956661dbca8436 [file] [log] [blame]
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.GraphicsContext
import org.eclipse.nebula.widgets.nattable.core.layer.cell.Cell
import org.eclipse.nebula.widgets.nattable.core.layer.cell.CellPainter
class DefaultCellPainter implements CellPainter {
override paintCell(Cell cell, PixelRectangle paintBounds, GraphicsContext gc) {
val text = cell.dataValue.toString
val centerX = paintBounds.x + (paintBounds.width / 2)
val centerY = paintBounds.y + (paintBounds.height / 2)
val textWidth = gc.calculateTextWidth(text)
gc.drawText(
text,
centerX - (textWidth / 2) as int,
centerY - (gc.fontHeight / 2) as int
)
}
}