1 /*
2 * Copyright (c) 1996, 2017, 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
1327 m12 = ty + m12;
1328 if (m02 == 0.0 && m12 == 0.0) {
1329 state = APPLY_IDENTITY;
1330 type = TYPE_IDENTITY;
1331 }
1332 return;
1333 case (APPLY_IDENTITY):
1334 m02 = tx;
1335 m12 = ty;
1336 if (tx != 0.0 || ty != 0.0) {
1337 state = APPLY_TRANSLATE;
1338 type = TYPE_TRANSLATION;
1339 }
1340 return;
1341 }
1342 }
1343
1344 // Utility methods to optimize rotate methods.
1345 // These tables translate the flags during predictable quadrant
1346 // rotations where the shear and scale values are swapped and negated.
1347 private static final int rot90conversion[] = {
1348 /* IDENTITY => */ APPLY_SHEAR,
1349 /* TRANSLATE (TR) => */ APPLY_SHEAR | APPLY_TRANSLATE,
1350 /* SCALE (SC) => */ APPLY_SHEAR,
1351 /* SC | TR => */ APPLY_SHEAR | APPLY_TRANSLATE,
1352 /* SHEAR (SH) => */ APPLY_SCALE,
1353 /* SH | TR => */ APPLY_SCALE | APPLY_TRANSLATE,
1354 /* SH | SC => */ APPLY_SHEAR | APPLY_SCALE,
1355 /* SH | SC | TR => */ APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE,
1356 };
1357 private void rotate90() {
1358 double M0 = m00;
1359 m00 = m01;
1360 m01 = -M0;
1361 M0 = m10;
1362 m10 = m11;
1363 m11 = -M0;
1364 int state = rot90conversion[this.state];
1365 if ((state & (APPLY_SHEAR | APPLY_SCALE)) == APPLY_SCALE &&
1366 m00 == 1.0 && m11 == 1.0)
1367 {
|
1 /*
2 * Copyright (c) 1996, 2018, 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
1327 m12 = ty + m12;
1328 if (m02 == 0.0 && m12 == 0.0) {
1329 state = APPLY_IDENTITY;
1330 type = TYPE_IDENTITY;
1331 }
1332 return;
1333 case (APPLY_IDENTITY):
1334 m02 = tx;
1335 m12 = ty;
1336 if (tx != 0.0 || ty != 0.0) {
1337 state = APPLY_TRANSLATE;
1338 type = TYPE_TRANSLATION;
1339 }
1340 return;
1341 }
1342 }
1343
1344 // Utility methods to optimize rotate methods.
1345 // These tables translate the flags during predictable quadrant
1346 // rotations where the shear and scale values are swapped and negated.
1347 private static final int[] rot90conversion = {
1348 /* IDENTITY => */ APPLY_SHEAR,
1349 /* TRANSLATE (TR) => */ APPLY_SHEAR | APPLY_TRANSLATE,
1350 /* SCALE (SC) => */ APPLY_SHEAR,
1351 /* SC | TR => */ APPLY_SHEAR | APPLY_TRANSLATE,
1352 /* SHEAR (SH) => */ APPLY_SCALE,
1353 /* SH | TR => */ APPLY_SCALE | APPLY_TRANSLATE,
1354 /* SH | SC => */ APPLY_SHEAR | APPLY_SCALE,
1355 /* SH | SC | TR => */ APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE,
1356 };
1357 private void rotate90() {
1358 double M0 = m00;
1359 m00 = m01;
1360 m01 = -M0;
1361 M0 = m10;
1362 m10 = m11;
1363 m11 = -M0;
1364 int state = rot90conversion[this.state];
1365 if ((state & (APPLY_SHEAR | APPLY_SCALE)) == APPLY_SCALE &&
1366 m00 == 1.0 && m11 == 1.0)
1367 {
|