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.scenegraph.g2d.nodes;
\r
14 import java.awt.Graphics2D;
\r
15 import java.awt.Shape;
\r
16 import java.awt.geom.Rectangle2D;
\r
18 import org.simantics.scenegraph.g2d.G2DParentNode;
\r
21 * @author Tuukka Lehtonen
\r
23 public class ClippingNode extends G2DParentNode {
\r
25 private static final long serialVersionUID = -1064240485806430485L;
\r
27 protected Shape clipShape;
\r
29 @SyncField({"clipShape"})
\r
30 public void setClip(Shape shape) {
\r
31 this.clipShape = shape;
\r
34 public Shape getClip() {
\r
39 public void render(Graphics2D g2d) {
\r
40 Shape prevClip = g2d.getClip();
\r
42 g2d.setClip(clipShape);
\r
45 g2d.setClip(prevClip);
\r
50 public String toString() {
\r
51 return super.toString() + "[clip shape=" + clipShape + "]";
\r
55 public Rectangle2D getBoundsInLocal() {
\r
56 if (clipShape == null)
\r
58 return clipShape.getBounds2D();
\r