ShapeNode with separate stroke and fill paints
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / image / impl / ShapeImage.java
index 77c65cb6ee497d9883cf01ea496a81039dc5184c..90ceaa12af567f4d1f217bd35131b11c47bd6a9b 100644 (file)
@@ -21,7 +21,7 @@ import java.util.EnumSet;
 import org.simantics.g2d.image.Image;
 import org.simantics.scenegraph.Node;
 import org.simantics.scenegraph.g2d.G2DParentNode;
-import org.simantics.scenegraph.g2d.nodes.ShapeNode;
+import org.simantics.scenegraph.g2d.nodes.ShapeNode2;
 
 /**
  * @author Tuukka Lehtonen
@@ -31,7 +31,8 @@ public class ShapeImage extends AbstractImage implements Image {
     private static final EnumSet<Feature> defaultFeats = VECTOR;
 
     Shape shape;
-    Paint paint;
+    Paint fillPaint;
+    Paint strokePaint;
     Stroke stroke;
     EnumSet<Feature> feats;
     boolean scaleStroke = false;
@@ -41,16 +42,20 @@ public class ShapeImage extends AbstractImage implements Image {
     }
 
     public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke) {
-        this(shape, fill, stroke, scaleStroke, defaultFeats);
+        this(shape, fill, stroke, fill, scaleStroke, defaultFeats);
     }
 
     public ShapeImage(Shape shape, Paint fill, Stroke stroke, EnumSet<Feature> features) {
-        this(shape, fill, stroke, false, features);
+        this(shape, fill, stroke, fill, false, features);
+    }
+    public ShapeImage(Shape shape, Paint fill, Stroke stroke, Paint strokeColor, boolean scaleStroke)  {
+        this(shape, fill, stroke, strokeColor, scaleStroke, defaultFeats);
     }
 
-    public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke, EnumSet<Feature> features) {
+    public ShapeImage(Shape shape, Paint fill, Stroke stroke, Paint strokeColor, boolean scaleStroke, EnumSet<Feature> features) {
         this.shape = shape;
-        this.paint = fill;
+        this.fillPaint = fill;
+        this.strokePaint = strokeColor;
         this.stroke = stroke;
         this.scaleStroke = scaleStroke;
         this.feats = features;
@@ -73,11 +78,11 @@ public class ShapeImage extends AbstractImage implements Image {
 
     @Override
     public Node init(G2DParentNode parent) {
-        ShapeNode shapeNode = parent.getOrCreateNode("ShapeImage", ShapeNode.class);
+        ShapeNode2 shapeNode = parent.getOrCreateNode("ShapeImage", ShapeNode2.class);
         shapeNode.setShape(shape);
         shapeNode.setStroke(stroke);
-        shapeNode.setFill(paint != null);
-        shapeNode.setColor(paint != null ? paint : Color.BLACK);
+        shapeNode.setFillColor(fillPaint);
+        shapeNode.setStrokeColor(strokePaint != null ? strokePaint : Color.BLACK);
         shapeNode.setScaleStroke(scaleStroke);
         return shapeNode;
     }