1 /*
2 * Copyright (c) 2011, 2013, 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
5685 state2d = (APPLY_SHEAR | APPLY_TRANSLATE);
5686 }
5687 } else {
5688 if (getTx() == 0.0 && getTy() == 0.0) {
5689 state2d = (APPLY_SHEAR | APPLY_SCALE);
5690 } else {
5691 state2d = (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE);
5692 }
5693 }
5694 }
5695 }
5696
5697 /**
5698 * Convenience method used internally to throw exceptions when
5699 * a case was forgotten in a switch statement.
5700 */
5701 private static void stateError() {
5702 throw new InternalError("missing case in a switch");
5703 }
5704
5705 /**
5706 * @treatAsPrivate implementation detail
5707 * @deprecated This is an internal API that is not intended for use and will be removed in the next version
5708 */
5709 @Deprecated
5710 @Override
5711 public void impl_apply(final Affine3D trans) {
5712 trans.concatenate(getMxx(), getMxy(), getMxz(), getTx(),
5713 getMyx(), getMyy(), getMyz(), getTy(),
5714 getMzx(), getMzy(), getMzz(), getTz());
5715 }
5716
5717 /**
5718 * @treatAsPrivate implementation detail
5719 * @deprecated This is an internal API that is not intended for use and will be removed in the next version
5720 */
5721 @Deprecated
5722 @Override
5723 public BaseTransform impl_derive(final BaseTransform trans) {
5724 switch(state3d) {
5725 default:
5726 stateError();
5727 // cannot reach
5728 case APPLY_NON_3D:
5729 switch(state2d) {
5730 case APPLY_IDENTITY:
5731 return trans;
5732 case APPLY_TRANSLATE:
5733 return trans.deriveWithTranslation(getTx(), getTy());
5734 case APPLY_SCALE:
5735 return trans.deriveWithScale(getMxx(), getMyy(), 1.0);
5736 case APPLY_SCALE | APPLY_TRANSLATE:
5737 // fall through
5738 default:
5739 return trans.deriveWithConcatenation(
5740 getMxx(), getMyx(),
5741 getMxy(), getMyy(),
5742 getTx(), getTy());
5743 }
|
1 /*
2 * Copyright (c) 2011, 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
5685 state2d = (APPLY_SHEAR | APPLY_TRANSLATE);
5686 }
5687 } else {
5688 if (getTx() == 0.0 && getTy() == 0.0) {
5689 state2d = (APPLY_SHEAR | APPLY_SCALE);
5690 } else {
5691 state2d = (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE);
5692 }
5693 }
5694 }
5695 }
5696
5697 /**
5698 * Convenience method used internally to throw exceptions when
5699 * a case was forgotten in a switch statement.
5700 */
5701 private static void stateError() {
5702 throw new InternalError("missing case in a switch");
5703 }
5704
5705 @Override
5706 void apply(final Affine3D trans) {
5707 trans.concatenate(getMxx(), getMxy(), getMxz(), getTx(),
5708 getMyx(), getMyy(), getMyz(), getTy(),
5709 getMzx(), getMzy(), getMzz(), getTz());
5710 }
5711
5712 @Override
5713 BaseTransform derive(final BaseTransform trans) {
5714 switch(state3d) {
5715 default:
5716 stateError();
5717 // cannot reach
5718 case APPLY_NON_3D:
5719 switch(state2d) {
5720 case APPLY_IDENTITY:
5721 return trans;
5722 case APPLY_TRANSLATE:
5723 return trans.deriveWithTranslation(getTx(), getTy());
5724 case APPLY_SCALE:
5725 return trans.deriveWithScale(getMxx(), getMyy(), 1.0);
5726 case APPLY_SCALE | APPLY_TRANSLATE:
5727 // fall through
5728 default:
5729 return trans.deriveWithConcatenation(
5730 getMxx(), getMyx(),
5731 getMxy(), getMyy(),
5732 getTx(), getTy());
5733 }
|