1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.elementclass;
\r
14 import java.awt.Color;
\r
15 import java.awt.geom.Rectangle2D;
\r
17 import org.simantics.g2d.element.ElementClass;
\r
18 import org.simantics.g2d.element.ElementUtils;
\r
19 import org.simantics.g2d.element.IElement;
\r
20 import org.simantics.g2d.element.handler.SceneGraph;
\r
21 import org.simantics.g2d.element.handler.impl.DefaultTransform;
\r
22 import org.simantics.g2d.element.handler.impl.FillColorImpl;
\r
23 import org.simantics.g2d.element.handler.impl.Resizeable;
\r
24 import org.simantics.scenegraph.g2d.G2DParentNode;
\r
25 import org.simantics.scenegraph.g2d.nodes.ShapeNode;
\r
30 * @author Toni Kalajainen
\r
32 public class FilmClass {
\r
34 public static final Color FILM_COLOR =
\r
35 new Color(0.f, 0.f, 0.f, 0.5f);
\r
37 public static final ElementClass FILM_CLASS =
\r
38 ElementClass.compile(
\r
39 DefaultTransform.INSTANCE,
\r
40 Resizeable.UNCONSTRICTED,
\r
41 //HandleMouseEvent.EVENT_CONSUMER,
\r
42 FillColorImpl.handlerOf(FILM_COLOR),
\r
46 static class FilmSGNode implements SceneGraph {
\r
50 private static final long serialVersionUID = -7763377402727204557L;
\r
51 private ShapeNode node = null;
\r
54 public void cleanup(IElement e) {
\r
62 public void init(IElement e, G2DParentNode parent) {
\r
64 node = parent.addNode(ShapeNode.class);
\r
66 Color fillColor = ElementUtils.getFillColor(e);
\r
67 Rectangle2D rect = ElementUtils.getElementBounds(e);
\r
69 node.setColor(fillColor);
\r
71 node.setShape(rect);
\r