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.geom.AffineTransform;
17 import org.simantics.scenegraph.g2d.G2DParentNode;
18 import org.simantics.scenegraph.g2d.IdentityAffineTransform;
20 public class TransformNode extends G2DParentNode {
22 private static final long serialVersionUID = -3722167807691239528L;
24 @SyncField("transform")
25 public void rotate(double theta) {
26 if (transform == IdentityAffineTransform.INSTANCE)
27 transform = AffineTransform.getRotateInstance(theta);
29 transform.rotate(theta);
32 @SyncField("transform")
33 public void translate(double x, double y) {
34 if (transform == IdentityAffineTransform.INSTANCE)
35 transform = AffineTransform.getTranslateInstance(x, y);
37 transform.translate(x, y);
40 @SyncField("transform")
41 public void scale(double x, double y) {
42 if (transform == IdentityAffineTransform.INSTANCE)
43 transform = AffineTransform.getScaleInstance(x, y);
45 transform.scale(x, y);
49 public void render(Graphics2D g2d) {
54 public String toString() {
55 return super.toString();