blob: 59c6f89a089234ef7a869d0ed377bd216f5e7cf0 [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 TextCellPainter 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
)
}
}