1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javafx.scene.transform; 27 28 import com.sun.javafx.geom.transform.Affine3D; 29 import com.sun.javafx.geom.transform.BaseTransform; 30 31 public class TransformShim { 32 33 public static boolean computeIs2D(Transform t) { 34 return t.computeIs2D(); 35 } 36 37 public static void clearInverseCache(Transform t) { 38 t.clearInverseCache(); 39 } 40 41 public static class ImmutableTransformShim extends Transform.ImmutableTransform { 42 43 } 44 45 public static Transform getImmutableTransform(Transform transform) { 46 return new Transform.ImmutableTransform(transform); 47 } 48 49 public static Transform getImmutableTransform( 50 double mxx, double mxy, double mxz, double tx, 51 double myx, double myy, double myz, double ty, 52 double mzx, double mzy, double mzz, double tz) { 53 return new Transform.ImmutableTransform( 54 mxx, mxy, mxz, tx, 55 myx, myy, myz, ty, 56 mzx, mzy, mzz, tz); 57 } 58 59 public static int getImmutableState2d(Transform t) { 60 return ((Transform.ImmutableTransform) t).getState2d(); 61 } 62 63 public static int getImmutableState3d(Transform t) { 64 return ((Transform.ImmutableTransform) t).getState3d(); 65 } 66 67 /** 68 * Creates a raw transformation to test the Transform class. 69 */ 70 public static Transform createRawTransform( 71 double mxx, double mxy, double mxz, double tx, 72 double myx, double myy, double myz, double ty, 73 double mzx, double mzy, double mzz, double tz) { 74 return new RawTransform( 75 mxx, mxy, mxz, tx, 76 myx, myy, myz, ty, 77 mzx, mzy, mzz, tz); 78 } 79 80 private static class RawTransform extends Transform { 81 82 private final double mxx, mxy, mxz, tx; 83 private final double myx, myy, myz, ty; 84 private final double mzx, mzy, mzz, tz; 85 86 public RawTransform( 87 double mxx, double mxy, double mxz, double tx, 88 double myx, double myy, double myz, double ty, 89 double mzx, double mzy, double mzz, double tz) { 90 this.mxx = mxx; 91 this.mxy = mxy; 92 this.mxz = mxz; 93 this.tx = tx; 94 this.myx = myx; 95 this.myy = myy; 96 this.myz = myz; 97 this.ty = ty; 98 this.mzx = mzx; 99 this.mzy = mzy; 100 this.mzz = mzz; 101 this.tz = tz; 102 } 103 104 @Override 105 public double getMxx() { 106 return mxx; 107 } 108 109 @Override 110 public double getMxy() { 111 return mxy; 112 } 113 114 @Override 115 public double getMxz() { 116 return mxz; 117 } 118 119 @Override 120 public double getTx() { 121 return tx; 122 } 123 124 @Override 125 public double getMyx() { 126 return myx; 127 } 128 129 @Override 130 public double getMyy() { 131 return myy; 132 } 133 134 @Override 135 public double getMyz() { 136 return myz; 137 } 138 139 @Override 140 public double getTy() { 141 return ty; 142 } 143 144 @Override 145 public double getMzx() { 146 return mzx; 147 } 148 149 @Override 150 public double getMzy() { 151 return mzy; 152 } 153 154 @Override 155 public double getMzz() { 156 return mzz; 157 } 158 159 @Override 160 public double getTz() { 161 return tz; 162 } 163 164 @Override 165 void apply(Affine3D t) { 166 t.concatenate( 167 getMxx(), getMxy(), getMxz(), getTx(), 168 getMyx(), getMyy(), getMyz(), getTy(), 169 getMzx(), getMzy(), getMzz(), getTz()); 170 } 171 172 @Override 173 BaseTransform derive(BaseTransform t) { 174 return t.deriveWithConcatenation( 175 getMxx(), getMxy(), getMxz(), getTx(), 176 getMyx(), getMyy(), getMyz(), getTy(), 177 getMzx(), getMzy(), getMzz(), getTz()); 178 } 179 } 180 }