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