| package org.eclipse.nebula.widgets.nattable.renderer.javafx |
| |
| import javafx.geometry.Bounds |
| import javafx.scene.canvas.GraphicsContext |
| import javafx.scene.paint.Color |
| import org.eclipse.nebula.widgets.nattable.core.layer.Layer |
| |
| import static extension org.eclipse.nebula.widgets.nattable.core.layer.LayerInvariants.* |
| import javafx.scene.text.Font |
| import com.sun.javafx.tk.Toolkit |
| |
| class DefaultLayerRenderer implements JavaFXLayerRenderer { |
| |
| override renderLayer(GraphicsContext gc, Bounds bounds, Layer layer) { |
| gc.clearRect(0, 0, bounds.width, bounds.height) |
| |
| gc.stroke = Color::BLUE |
| |
| for (columnPosition : 0 .. layer.columnCount) { |
| for (rowPosition : 0 .. layer.rowCount) { |
| val cellPixelBounds = layer.getCellPixelBounds(columnPosition, rowPosition) |
| gc.strokeRect(cellPixelBounds.x, cellPixelBounds.y, cellPixelBounds.pixelWidth, cellPixelBounds.pixelHeight) |
| |
| // gc.font = new Font() |
| // val fontMetrics = Toolkit::toolkit.fontLoader.getFontMetrics(gc.font) |
| // fontMetrics.computeStringWidth("") |
| |
| gc.strokeText( |
| layer.getCellDataValue(columnPosition, rowPosition).toString, |
| cellPixelBounds.x + (cellPixelBounds.pixelWidth/2), |
| cellPixelBounds.y + (cellPixelBounds.pixelHeight/2) |
| ) |
| } |
| } |
| } |
| |
| } |