1 /*******************************************************************************
2 * Copyright (c) 2017 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 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.scenegraph.g2d;
14 import java.awt.geom.AffineTransform;
15 import java.awt.geom.NoninvertibleTransformException;
16 import java.awt.geom.Point2D;
18 import org.simantics.scl.runtime.tuple.Tuple2;
21 * @author Antti Villberg
24 public class AffineTransformFunctions {
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());
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());