X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felementclass%2Fcanvas%2FCanvasPainter.java;fp=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felementclass%2Fcanvas%2FCanvasPainter.java;h=d6fddb81c90ef2c363442e3d8ddbe52adc237b0d;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=5d2aaa3f4a9d20131cf1f2015192676b133ccbbf;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/canvas/CanvasPainter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/canvas/CanvasPainter.java index 5d2aaa3f4..d6fddb81c 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/canvas/CanvasPainter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/canvas/CanvasPainter.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * 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.canvas; - -import java.awt.geom.Rectangle2D; - -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.element.ElementUtils; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.SceneGraphNodeKey; -import org.simantics.g2d.element.handler.SceneGraph; -import org.simantics.scenegraph.Node; -import org.simantics.scenegraph.g2d.G2DParentNode; -import org.simantics.scenegraph.g2d.nodes.ClippingNode; -import org.simantics.utils.datastructures.hints.IHintContext.Key; - -/** - * An element handler that "paints" a canvas bound to an element. - * - * Keys: CanvasClass.KEY_CANVAS - * - * @author Toni Kalajainen - */ -public class CanvasPainter implements SceneGraph { - - private static final long serialVersionUID = -182067379834789790L; - - public static final CanvasPainter INSTANCE = new CanvasPainter(); - - public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE"); - - @Override - public void cleanup(IElement e) { - ElementUtils.removePossibleNode(e, SG_NODE); - } - - @Override - public void init(IElement e, G2DParentNode parent) { - ICanvasContext ctx = e.getHint(CanvasClass.KEY_CANVAS); - if (ctx == null) { - ElementUtils.removePossibleNode(e, SG_NODE); - return; - } - - ClippingNode node = ElementUtils.getOrCreateNode(e, parent, SG_NODE, ClippingNode.class); - - Rectangle2D bounds = ElementUtils.getElementBounds(e); - node.setClip(bounds); - } - -} +/******************************************************************************* + * 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.canvas; + +import java.awt.geom.Rectangle2D; + +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.g2d.element.ElementUtils; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.SceneGraphNodeKey; +import org.simantics.g2d.element.handler.SceneGraph; +import org.simantics.scenegraph.Node; +import org.simantics.scenegraph.g2d.G2DParentNode; +import org.simantics.scenegraph.g2d.nodes.ClippingNode; +import org.simantics.utils.datastructures.hints.IHintContext.Key; + +/** + * An element handler that "paints" a canvas bound to an element. + * + * Keys: CanvasClass.KEY_CANVAS + * + * @author Toni Kalajainen + */ +public class CanvasPainter implements SceneGraph { + + private static final long serialVersionUID = -182067379834789790L; + + public static final CanvasPainter INSTANCE = new CanvasPainter(); + + public static final Key SG_NODE = new SceneGraphNodeKey(Node.class, "SUB_SG_NODE"); + + @Override + public void cleanup(IElement e) { + ElementUtils.removePossibleNode(e, SG_NODE); + } + + @Override + public void init(IElement e, G2DParentNode parent) { + ICanvasContext ctx = e.getHint(CanvasClass.KEY_CANVAS); + if (ctx == null) { + ElementUtils.removePossibleNode(e, SG_NODE); + return; + } + + ClippingNode node = ElementUtils.getOrCreateNode(e, parent, SG_NODE, ClippingNode.class); + + Rectangle2D bounds = ElementUtils.getElementBounds(e); + node.setClip(bounds); + } + +}