Merge branch 'master' of ssh://git.eclipse.org/gitroot/nattable/org.eclipse.nebula.widgets.nattable.experimental
diff --git a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/MultiViewportExample.xtend b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/MultiViewportExample.xtend
index e6b3d7e..e680db1 100644
--- a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/MultiViewportExample.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/MultiViewportExample.xtend
@@ -12,17 +12,17 @@
 class MultiViewportExample extends AbstractNatExample {
 	
 	override createLayer() {
-		val regionA = new ViewportLayer(new DummyLayer(
-			new AxisImpl(4, 150),  // Horizontal axis
-			new AxisImpl(10, 100)  // Vertical axis
-		))
-		val regionB = new ViewportLayer(new DummyLayer(
-			new AxisImpl(10, 150),  // Horizontal axis
-			new AxisImpl(10, 100)  // Vertical axis
-		))
-		
 		val bodyLayer = new CompositeLayer => [
-			addRow(regionA, regionB)
+			addRow(
+				new ViewportLayer(new DummyLayer(
+					new AxisImpl(4, 150),  // Horizontal axis
+					new AxisImpl(10, 100)  // Vertical axis
+				)),
+				new ViewportLayer(new DummyLayer(
+					new AxisImpl(10, 150),  // Horizontal axis
+					new AxisImpl(10, 100)  // Vertical axis
+				))
+			)
 		]
 
 		val columnHeaderLayer = new ColumnHeaderLayer(bodyLayer.horizontalAxis, new LayerDataAccessorImpl([ layer, columnId, rowId | columnId ]))
diff --git a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SimpleLayerExample.xtend b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SimpleLayerExample.xtend
new file mode 100644
index 0000000..6ec0d9c
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SimpleLayerExample.xtend
@@ -0,0 +1,21 @@
+package org.eclipse.nebula.widgets.nattable.core.example.impl
+
+import org.eclipse.nebula.widgets.nattable.core.layer.axis.impl.AxisImpl
+import org.eclipse.nebula.widgets.nattable.core.layer.impl.DummyLayer
+
+class SimpleLayerExample extends AbstractNatExample {
+	
+	override getDescription() {
+		'''
+		A single layer with 4 columns and 4 rows
+		'''
+	}
+	
+	override createLayer() {
+		new DummyLayer(
+			new AxisImpl(4, 200),  // Horizontal axis
+			new AxisImpl(4, 100)  // Vertical axis
+		)
+	}
+	
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SmallLayerExample.xtend b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SmallGridLayerExample.xtend
similarity index 96%
rename from org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SmallLayerExample.xtend
rename to org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SmallGridLayerExample.xtend
index ce76964..9709ddb 100644
--- a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SmallLayerExample.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/SmallGridLayerExample.xtend
@@ -10,7 +10,7 @@
 import org.eclipse.nebula.widgets.nattable.core.layer.impl.header.RowHeaderLayer
 import org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport.ViewportLayer
 
-class SmallLayerExample extends AbstractNatExample {
+class SmallGridLayerExample extends AbstractNatExample {
 	
 	override getDescription() {
 		'''
diff --git a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/BigLayerExample.xtend b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/BigGridLayerExample.xtend
similarity index 97%
rename from org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/BigLayerExample.xtend
rename to org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/BigGridLayerExample.xtend
index 6c66d17..9715803 100644
--- a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/BigLayerExample.xtend
+++ b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/BigGridLayerExample.xtend
@@ -12,7 +12,7 @@
 import org.eclipse.nebula.widgets.nattable.core.layer.impl.header.RowHeaderLayer
 import org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport.ViewportLayer
 
-class BigLayerExample extends AbstractNatExample {
+class BigGridLayerExample extends AbstractNatExample {
 
 	val static MILLION = 1000 * 1000L
 	val static BILLION = 1000 * MILLION
diff --git a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/index.properties b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/index.properties
index a48fc8c..a1f90b1 100644
--- a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/index.properties
+++ b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/big/index.properties
@@ -1 +1 @@
-BigLayerExample=org.eclipse.nebula.widgets.nattable.core.example.impl.big.BigLayerExample
+BigGridLayerExample=org.eclipse.nebula.widgets.nattable.core.example.impl.big.BigGridLayerExample
diff --git a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/index.properties b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/index.properties
index ee60f0c..3728d26 100644
--- a/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/index.properties
+++ b/org.eclipse.nebula.widgets.nattable.core.example/src/org/eclipse/nebula/widgets/nattable/core/example/impl/index.properties
@@ -1,4 +1,5 @@
+SimpleLayerExample=org.eclipse.nebula.widgets.nattable.core.example.impl.SimpleLayerExample
+SmallGridLayerExample=org.eclipse.nebula.widgets.nattable.core.example.impl.SmallGridLayerExample
 GridLayerExample=org.eclipse.nebula.widgets.nattable.core.example.impl.GridLayerExample
-MultiViewportExample=org.eclipse.nebula.widgets.nattable.core.example.impl.MultiViewportExample
-SmallLayerExample=org.eclipse.nebula.widgets.nattable.core.example.impl.SmallLayerExample|A little example
 big=|Huge examples
+MultiViewportExample=org.eclipse.nebula.widgets.nattable.core.example.impl.MultiViewportExample
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx.example/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/example/JavaFXNatExamplesRunner.xtend b/org.eclipse.nebula.widgets.nattable.renderer.javafx.example/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/example/JavaFXNatExamplesRunner.xtend
index 0e1d7bd..a786452 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.javafx.example/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/example/JavaFXNatExamplesRunner.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx.example/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/example/JavaFXNatExamplesRunner.xtend
@@ -42,21 +42,21 @@
 	
 	override start(Stage primaryStage) throws Exception {
         primaryStage.title = "NatTable -> JavaFX"
-        val grid = new BorderPane
+        val borderPane = new BorderPane
         
         // Nav tree
         val indexNode = NatExamplesIndex::rootNode
         indexNode.createTreeItem(rootTreeItem)
-	    grid.left = new TreeView<IndexNode>(rootTreeItem) => [
+	    borderPane.left = new TreeView<IndexNode>(rootTreeItem) => [
 	    	showRoot = false
         	editable = true
         	cellFactory = [ treeView | new NavTreeCell(this) as TreeCell<IndexNode> ]
        	]
 		
 		// Example pane
-	    grid.center = tabPane
+	    borderPane.center = tabPane
         
-        val scene = new Scene(grid, 1000, 600)
+        val scene = new Scene(borderPane, 1000, 600)
         scene.stylesheets += "style.css"
         primaryStage.scene = scene
         primaryStage.show
@@ -87,11 +87,8 @@
 			content = new BorderPane => [
 				// Create example control
 				center = new StackPane => [
-					val centerPane = it
 					children += getInstance(typeof(JavaFXNatTable)) => [
 						layer = node.natExample.createLayer
-				        widthProperty.bind(centerPane.widthProperty)
-				        heightProperty.bind(centerPane.heightProperty)
 			        ]
 				]
 				
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/JavaFXNatTable.xtend b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/JavaFXNatTable.xtend
index fedd2ba..42078e2 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/JavaFXNatTable.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/JavaFXNatTable.xtend
@@ -1,38 +1,33 @@
 package org.eclipse.nebula.widgets.nattable.renderer.javafx
 
-import javafx.beans.value.ObservableValue
-import javafx.scene.canvas.Canvas
+import javafx.scene.control.Control
 import javax.inject.Inject
-import org.eclipse.nebula.widgets.nattable.core.geometry.PixelArea
-import org.eclipse.nebula.widgets.nattable.core.layer.Layer
-import org.eclipse.nebula.widgets.nattable.renderer.javafx.graphics.JavaFXGraphicsContext
 import org.eclipse.nebula.widgets.nattable.core.graphics.LayerPainterFactory
+import org.eclipse.nebula.widgets.nattable.core.layer.Layer
 
 /**
  * A JavaFX component that renders a NatTable Layer.
  */
-class JavaFXNatTable extends Canvas {
+class JavaFXNatTable extends Control {
 	
-	@Inject extension LayerPainterFactory
+	@Inject LayerPainterFactory layerPainterFactory
 	
 	Layer layer
 	
+	new() {
+		styleClass += "natTable"
+	}
+	
+	override protected getUserAgentStylesheet() {
+		class.getResource("natTable.css").toExternalForm
+	}
+	
 	def Layer getLayer() { layer }
 	
 	def void setLayer(Layer layer) {
 		this.layer = layer
-		
-		paintLayer
-		
-        boundsInLocalProperty.addListener([ ObservableValue<?> observable, Object oldValue, Object newValue |
-        	paintLayer
-        ])
 	}
 	
-	def private paintLayer() {
-		val paintArea = new PixelArea(boundsInLocal.width, boundsInLocal.height)
-		val gc = new JavaFXGraphicsContext(this.graphicsContext2D)
-		layer?.layerPainter?.paintLayer(layer, paintArea, gc)
-	}
+	def getLayerPainter() { layerPainterFactory.getLayerPainter(layer) }
 	
 }
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/NatTableBehavior.xtend b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/NatTableBehavior.xtend
new file mode 100644
index 0000000..bb54ca1
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/NatTableBehavior.xtend
@@ -0,0 +1,11 @@
+package org.eclipse.nebula.widgets.nattable.renderer.javafx
+
+import com.sun.javafx.scene.control.behavior.BehaviorBase
+
+class NatTableBehavior extends BehaviorBase<JavaFXNatTable> {
+	
+	new(JavaFXNatTable control) {
+		super(control)
+	}
+	
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/NatTableSkin.xtend b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/NatTableSkin.xtend
new file mode 100644
index 0000000..e957fe4
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/NatTableSkin.xtend
@@ -0,0 +1,32 @@
+package org.eclipse.nebula.widgets.nattable.renderer.javafx
+
+import com.sun.javafx.scene.control.skin.SkinBase
+import javafx.scene.canvas.Canvas
+import org.eclipse.nebula.widgets.nattable.core.geometry.PixelArea
+import org.eclipse.nebula.widgets.nattable.renderer.javafx.graphics.JavaFXGraphicsContext
+
+class NatTableSkin extends SkinBase<JavaFXNatTable, NatTableBehavior> {
+	
+	val Canvas canvas
+	
+	new(JavaFXNatTable control) {
+		super(control, new NatTableBehavior(control))
+		
+		canvas = new Canvas
+		children += canvas
+		
+		canvas.widthProperty.bind(widthProperty)
+		canvas.heightProperty.bind(heightProperty)
+	}
+	
+	override protected layoutChildren() {
+		canvas.paintLayer
+	}
+	
+	def private paintLayer(Canvas canvas) {
+		val paintArea = new PixelArea(boundsInLocal.width, boundsInLocal.height)
+		val gc = new JavaFXGraphicsContext(canvas)
+		skinnable.layerPainter?.paintLayer(skinnable.layer, paintArea, gc)
+	}
+	
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend
index b888cad..c8d55d1 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/graphics/JavaFXGraphicsContext.xtend
@@ -4,15 +4,22 @@
 import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
 import org.eclipse.nebula.widgets.nattable.core.graphics.Color
 import org.eclipse.nebula.widgets.nattable.core.graphics.GraphicsContext
+import javafx.scene.canvas.Canvas
 
 class JavaFXGraphicsContext implements GraphicsContext {
 	
+	val Canvas canvas
 	val javafx.scene.canvas.GraphicsContext gc
 	
-	new(javafx.scene.canvas.GraphicsContext gc) {
-		this.gc = gc
+	PixelRectangle clipBounds
+	
+	new(Canvas canvas) {
+		this.canvas = canvas
+		this.gc = canvas.graphicsContext2D
 	}
 	
+	def Canvas getCanvas() { canvas }
+	
 	// GraphicsContext interface
 	
 	override pushState() {
@@ -20,6 +27,10 @@
 	}
 	
 	override popState() {
+		if (clipBounds != null) {
+			gc.restore
+			clipBounds = null
+		}
 		gc.restore
 	}
 	
@@ -46,12 +57,19 @@
 	}
 	
 	override getClipBounds() {
-		val bounds = gc.canvas.boundsInLocal
-		new PixelRectangle(bounds.minX, bounds.minY, bounds.width, bounds.height)
+		clipBounds ?: {
+			val bounds = gc.canvas.boundsInLocal
+			new PixelRectangle(bounds.minX, bounds.minY, bounds.width, bounds.height)
+		}
 	}
 	
 	override setClipBounds(PixelRectangle clipBounds) {
-		println("setClipBounds(clipBounds) not implemented")
+//		if (this.clipBounds != null) gc.restore
+//		gc.save
+//		this.clipBounds = clipBounds
+//		gc.beginPath
+//		gc.rect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height)
+//		gc.clip
 	}
 	
 	override drawLine(double x1, double y1, double x2, double y2) {
@@ -71,7 +89,8 @@
 	}
 	
 	override drawText(String text, double x, double y) {
-		gc.strokeText(text, x, y)
+		val fontMetrics = Toolkit::toolkit.fontLoader.getFontMetrics(gc.font)
+		gc.strokeText(text, x, y + fontMetrics.ascent)
 	}
 	
 	override calculateTextWidth(String text) {
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/natTable.css b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/natTable.css
new file mode 100644
index 0000000..0931d23
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.renderer.javafx/src/org/eclipse/nebula/widgets/nattable/renderer/javafx/natTable.css
@@ -0,0 +1,5 @@
+.natTable {
+	-fx-skin: "org.eclipse.nebula.widgets.nattable.renderer.javafx.NatTableSkin";
+	-fx-fill-width: true;
+	-fx-fill-height: true;
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend
index c099556..8681029 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/graphics/SWTGraphicsContext.xtend
@@ -1,6 +1,5 @@
 package org.eclipse.nebula.widgets.nattable.renderer.swt.graphics
 
-import java.util.HashMap
 import java.util.Map
 import java.util.Stack
 import org.eclipse.nebula.widgets.nattable.core.geometry.PixelRectangle
@@ -57,7 +56,7 @@
 	
 	override pushState() {
 		stateStack.push(originalState)
-		originalState = new HashMap<GraphicsPropertiesEnum, Object>
+		originalState = newHashMap
 	}
 	
 	override popState() {