-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g2d.image.impl;\r
-\r
-import java.awt.Color;\r
-import java.awt.Paint;\r
-import java.awt.Shape;\r
-import java.awt.Stroke;\r
-import java.awt.geom.Rectangle2D;\r
-import java.util.EnumSet;\r
-\r
-import org.simantics.g2d.image.Image;\r
-import org.simantics.scenegraph.Node;\r
-import org.simantics.scenegraph.g2d.G2DParentNode;\r
-import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ShapeImage extends AbstractImage implements Image {\r
-\r
- private static final EnumSet<Feature> defaultFeats = VECTOR;\r
-\r
- Shape shape;\r
- Paint paint;\r
- Stroke stroke;\r
- EnumSet<Feature> feats;\r
- boolean scaleStroke = false;\r
-\r
- public ShapeImage(Shape shape, Paint fill, Stroke stroke) {\r
- this(shape, fill, stroke, defaultFeats);\r
- }\r
-\r
- public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke) {\r
- this(shape, fill, stroke, scaleStroke, defaultFeats);\r
- }\r
-\r
- public ShapeImage(Shape shape, Paint fill, Stroke stroke, EnumSet<Feature> features) {\r
- this(shape, fill, stroke, false, features);\r
- }\r
-\r
- public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke, EnumSet<Feature> features) {\r
- this.shape = shape;\r
- this.paint = fill;\r
- this.stroke = stroke;\r
- this.scaleStroke = scaleStroke;\r
- this.feats = features;\r
- }\r
-\r
- @Override\r
- public Rectangle2D getBounds() {\r
- return shape.getBounds2D();\r
- }\r
-\r
- @Override\r
- public EnumSet<Feature> getFeatures() {\r
- return feats;\r
- }\r
-\r
- @Override\r
- public Shape getOutline() {\r
- return shape;\r
- }\r
-\r
- @Override\r
- public Node init(G2DParentNode parent) {\r
- ShapeNode shapeNode = parent.getOrCreateNode("ShapeImage", ShapeNode.class);\r
- shapeNode.setShape(shape);\r
- shapeNode.setStroke(stroke);\r
- shapeNode.setFill(paint != null);\r
- shapeNode.setColor(paint != null ? paint : Color.BLACK);\r
- shapeNode.setScaleStroke(scaleStroke);\r
- return shapeNode;\r
- }\r
-\r
-};\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.image.impl;
+
+import java.awt.Color;
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.Rectangle2D;
+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;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ShapeImage extends AbstractImage implements Image {
+
+ private static final EnumSet<Feature> defaultFeats = VECTOR;
+
+ Shape shape;
+ Paint paint;
+ Stroke stroke;
+ EnumSet<Feature> feats;
+ boolean scaleStroke = false;
+
+ public ShapeImage(Shape shape, Paint fill, Stroke stroke) {
+ this(shape, fill, stroke, defaultFeats);
+ }
+
+ public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke) {
+ this(shape, fill, stroke, scaleStroke, defaultFeats);
+ }
+
+ public ShapeImage(Shape shape, Paint fill, Stroke stroke, EnumSet<Feature> features) {
+ this(shape, fill, stroke, false, features);
+ }
+
+ public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke, EnumSet<Feature> features) {
+ this.shape = shape;
+ this.paint = fill;
+ this.stroke = stroke;
+ this.scaleStroke = scaleStroke;
+ this.feats = features;
+ }
+
+ @Override
+ public Rectangle2D getBounds() {
+ return shape.getBounds2D();
+ }
+
+ @Override
+ public EnumSet<Feature> getFeatures() {
+ return feats;
+ }
+
+ @Override
+ public Shape getOutline() {
+ return shape;
+ }
+
+ @Override
+ public Node init(G2DParentNode parent) {
+ ShapeNode shapeNode = parent.getOrCreateNode("ShapeImage", ShapeNode.class);
+ shapeNode.setShape(shape);
+ shapeNode.setStroke(stroke);
+ shapeNode.setFill(paint != null);
+ shapeNode.setColor(paint != null ? paint : Color.BLACK);
+ shapeNode.setScaleStroke(scaleStroke);
+ return shapeNode;
+ }
+
+};