]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/AffineTransformFunctions.java
G2DParentNode handles "undefined" child bounds separately
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / AffineTransformFunctions.java
1 /*******************************************************************************
2  * Copyright (c) 2017 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.scenegraph.g2d;
13
14 import java.awt.geom.AffineTransform;
15 import java.awt.geom.NoninvertibleTransformException;
16 import java.awt.geom.Point2D;
17
18 import org.simantics.scl.runtime.tuple.Tuple2;
19
20 /**
21  * @author Antti Villberg
22  * @since 1.29.0
23  */
24 public class AffineTransformFunctions {
25
26         public static Tuple2 transform(AffineTransform transform, Tuple2 point) {
27                 Point2D result = new Point2D.Double((Double) point.c0, (Double) point.c1);
28                 transform.transform(result, result);
29                 return new Tuple2(result.getX(), result.getY());
30         }
31
32         public static Tuple2 inverseTransform(AffineTransform transform, Tuple2 point) throws NoninvertibleTransformException {
33                 Point2D result = new Point2D.Double((Double)point.c0, (Double)point.c1);
34                 transform.inverseTransform(result, result);
35                 return new Tuple2(result.getX(), result.getY());
36         }
37
38 }