blob: f12bb1f7ed2f0cc4bfb764f7e49ca9adec6c1968 [file] [log] [blame]
package org.eclipse.nebula.widgets.nattable.core.layer.cell.impl
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, GraphicsContext gc) {
val text = cell.dataValue.toString
val clipBounds = gc.clipBounds
val centerX = clipBounds.x + (clipBounds.width / 2)
val centerY = clipBounds.y + (clipBounds.height / 2)
val textWidth = gc.calculateTextWidth(text)
gc.drawText(
text,
centerX - (textWidth / 2) as int,
centerY
)
}
}