X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felementclass%2FFilmClass.java;h=40b7fd853eb80948c1bac81252238942058d8dbc;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=ec9f1e97b64f89bcc8ad364a8d940879703cdda3;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/FilmClass.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/FilmClass.java index ec9f1e97b..40b7fd853 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/FilmClass.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/FilmClass.java @@ -1,75 +1,75 @@ -/******************************************************************************* - * 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.elementclass; - -import java.awt.Color; -import java.awt.geom.Rectangle2D; - -import org.simantics.g2d.element.ElementClass; -import org.simantics.g2d.element.ElementUtils; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.SceneGraph; -import org.simantics.g2d.element.handler.impl.DefaultTransform; -import org.simantics.g2d.element.handler.impl.FillColorImpl; -import org.simantics.g2d.element.handler.impl.Resizeable; -import org.simantics.scenegraph.g2d.G2DParentNode; -import org.simantics.scenegraph.g2d.nodes.ShapeNode; - -/** - * Transparent film - * - * @author Toni Kalajainen - */ -public class FilmClass { - - public static final Color FILM_COLOR = - new Color(0.f, 0.f, 0.f, 0.5f); - - public static final ElementClass FILM_CLASS = - ElementClass.compile( - DefaultTransform.INSTANCE, - Resizeable.UNCONSTRICTED, - //HandleMouseEvent.EVENT_CONSUMER, - FillColorImpl.handlerOf(FILM_COLOR), - new FilmSGNode() - ); - - static class FilmSGNode implements SceneGraph { - /** - * - */ - private static final long serialVersionUID = -7763377402727204557L; - private ShapeNode node = null; - - @Override - public void cleanup(IElement e) { - if(node != null) { - node.remove(); - } - node = null; - } - - @Override - public void init(IElement e, G2DParentNode parent) { - if(node == null) { - node = parent.addNode(ShapeNode.class); - } - Color fillColor = ElementUtils.getFillColor(e); - Rectangle2D rect = ElementUtils.getElementBounds(e); - - node.setColor(fillColor); - node.setFill(true); - node.setShape(rect); - } - } - -} +/******************************************************************************* + * 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.elementclass; + +import java.awt.Color; +import java.awt.geom.Rectangle2D; + +import org.simantics.g2d.element.ElementClass; +import org.simantics.g2d.element.ElementUtils; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.SceneGraph; +import org.simantics.g2d.element.handler.impl.DefaultTransform; +import org.simantics.g2d.element.handler.impl.FillColorImpl; +import org.simantics.g2d.element.handler.impl.Resizeable; +import org.simantics.scenegraph.g2d.G2DParentNode; +import org.simantics.scenegraph.g2d.nodes.ShapeNode; + +/** + * Transparent film + * + * @author Toni Kalajainen + */ +public class FilmClass { + + public static final Color FILM_COLOR = + new Color(0.f, 0.f, 0.f, 0.5f); + + public static final ElementClass FILM_CLASS = + ElementClass.compile( + DefaultTransform.INSTANCE, + Resizeable.UNCONSTRICTED, + //HandleMouseEvent.EVENT_CONSUMER, + FillColorImpl.handlerOf(FILM_COLOR), + new FilmSGNode() + ); + + static class FilmSGNode implements SceneGraph { + /** + * + */ + private static final long serialVersionUID = -7763377402727204557L; + private ShapeNode node = null; + + @Override + public void cleanup(IElement e) { + if(node != null) { + node.remove(); + } + node = null; + } + + @Override + public void init(IElement e, G2DParentNode parent) { + if(node == null) { + node = parent.addNode(ShapeNode.class); + } + Color fillColor = ElementUtils.getFillColor(e); + Rectangle2D rect = ElementUtils.getElementBounds(e); + + node.setColor(fillColor); + node.setFill(true); + node.setShape(rect); + } + } + +}