1 /*
   2  * Copyright (c) 2012, 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
  23  * questions.
  24  */
  25 
  26 package javafx.scene.transform;
  27 
  28 /**
  29  * Specifies type of transformation matrix.
  30  * @since JavaFX 8.0
  31  */
  32 public enum MatrixType {
  33     /**
  34      * A 2D affine transformation matrix of 2 rows and 3 columns. Contains
  35      * the following values:
  36      * <pre>
  37      * mxx, mxy, tx,
  38      * myx, myy, ty
  39      * </pre>
  40      */
  41     MT_2D_2x3(2, 3),
  42 
  43     /**
  44      * A 2D transformation matrix of 3 rows and 3 columns. For affine transforms
  45      * the last line is constant, so the matrix contains the following values:
  46      * <pre>
  47      * mxx, mxy, tx,
  48      * myx, myy, ty,
  49      *   0,   0,  1
  50      * </pre>
  51      */
  52     MT_2D_3x3(3, 3),
  53 
  54     /**
  55      * A 3D affine transformation matrix of 3 rows and 4 columns. Contains
  56      * the following values:
  57      * <pre>
  58      * mxx, mxy, mxz, tx,
  59      * myx, myy, myz, ty,
  60      * mzx, mzy, mzz, tz
  61      * </pre>
  62      */
  63     MT_3D_3x4(3, 4),
  64 
  65     /**
  66      * A 3D transformation matrix of 4 rows and 4 columns. For affine transforms
  67      * the last line is constant, so the matrix contains the following values:
  68      * <pre>
  69      * mxx, mxy, mxz, tx,
  70      * myx, myy, myz, ty,
  71      * mzx, mzy, mzz, tz,
  72      *   0,   0,   0,  1
  73      * </pre>
  74      */
  75     MT_3D_4x4(4, 4);
  76 
  77     private int rows;
  78     private int cols;
  79 
  80     private MatrixType(int rows, int cols) {
  81         this.rows = rows;
  82         this.cols = cols;
  83     }
  84 
  85     /**
  86      * Returns the number of elements in the matrix of this type.
  87      * @return the number of elements in the matrix of this type
  88      */
  89     public int elements() {
  90         return rows * cols;
  91     }
  92 
  93     /**
  94      * Returns the number of rows in the matrix of this type.
  95      * @return the number of rows in the matrix of this type
  96      */
  97     public int rows() {
  98         return rows;
  99     }
 100 
 101     /**
 102      * Returns the number of columns in the matrix of this type.
 103      * @return the number of columns in the matrix of this type
 104      */
 105     public int columns() {
 106         return cols;
 107     }
 108 
 109     /**
 110      * Specifies if this is a 2D transformation matrix
 111      * @return true if this is a 2D transformation matrix, false if this
 112      *         is a 3D transformation matrix
 113      */
 114     public boolean is2D() {
 115         return this == MT_2D_2x3 || this == MT_2D_3x3;
 116     }
 117 }