--- /dev/null
+/*******************************************************************************\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.elementclass;\r
+\r
+import java.awt.Color;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.FillColorImpl;\r
+import org.simantics.g2d.element.handler.impl.Resizeable;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+\r
+/**\r
+ * Transparent film\r
+ * \r
+ * @author Toni Kalajainen\r
+ */\r
+public class FilmClass {\r
+\r
+ public static final Color FILM_COLOR =\r
+ new Color(0.f, 0.f, 0.f, 0.5f);\r
+ \r
+ public static final ElementClass FILM_CLASS =\r
+ ElementClass.compile(\r
+ DefaultTransform.INSTANCE,\r
+ Resizeable.UNCONSTRICTED,\r
+ //HandleMouseEvent.EVENT_CONSUMER,\r
+ FillColorImpl.handlerOf(FILM_COLOR), \r
+ new FilmSGNode()\r
+ );\r
+ \r
+ static class FilmSGNode implements SceneGraph {\r
+ /**\r
+ * \r
+ */\r
+ private static final long serialVersionUID = -7763377402727204557L;\r
+ private ShapeNode node = null;\r
+ \r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ if(node != null) {\r
+ node.remove();\r
+ }\r
+ node = null;\r
+ }\r
+\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ if(node == null) {\r
+ node = parent.addNode(ShapeNode.class);\r
+ }\r
+ Color fillColor = ElementUtils.getFillColor(e); \r
+ Rectangle2D rect = ElementUtils.getElementBounds(e); \r
+ \r
+ node.setColor(fillColor);\r
+ node.setFill(true);\r
+ node.setShape(rect);\r
+ } \r
+ }\r
+ \r
+}\r