| package org.eclipse.nebula.widgets.nattable.renderer.javafx |
| |
| import javafx.beans.value.ObservableValue |
| import javafx.scene.canvas.Canvas |
| import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle |
| import org.eclipse.nebula.widgets.nattable.core.layer.Layer |
| import org.eclipse.nebula.widgets.nattable.core.layer.impl.GridLineCellLayerPainter |
| import org.eclipse.nebula.widgets.nattable.renderer.javafx.graphics.JavaFXGraphicsContext |
| |
| /** |
| * A JavaFX component that renders a NatTable Layer. |
| */ |
| class JavaFXNatTable extends Canvas { |
| |
| val static defaultLayerPainter = new GridLineCellLayerPainter |
| |
| val Layer layer |
| |
| new(Layer layer, int width, int height) { |
| super(width, height) |
| this.layer = layer |
| |
| paintLayer |
| |
| boundsInLocalProperty.addListener([ ObservableValue<?> observable, Object oldValue, Object newValue | |
| paintLayer |
| ]) |
| } |
| |
| private def paintLayer() { |
| val paintBounds = new PixelRectangle(boundsInLocal.minX as int, boundsInLocal.minY as int, boundsInLocal.width as int, boundsInLocal.height as int) |
| layer.layerPainter.paintLayer(layer, paintBounds, new JavaFXGraphicsContext(this.graphicsContext2D)) |
| } |
| |
| private def getLayerPainter(Layer layer) { |
| defaultLayerPainter |
| } |
| |
| } |