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