content: /*
   * Copyright (C) 2012 CyberAgent
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package com.mitakeran.magicfilter.utils;
  
  public enum Rotation {
      NORMAL, ROTATION_90, ROTATION_180, ROTATION_270;
  
      /**
       * Retrieves the int representation of the Rotation.
       *
       * @return 0, 90, 180 or 270
       */
      public int asInt() {
          switch (this) {
              case NORMAL: return 0;
              case ROTATION_90: return 90;
              case ROTATION_180: return 180;
              case ROTATION_270: return 270;
              default: throw new IllegalStateException("Unknown Rotation!");
          }
      }
  
      /**
       * Create a Rotation from an integer. Needs to be either 0, 90, 180 or 270.
       *
       * @param rotation 0, 90, 180 or 270
       * @return Rotation object
       */
      public static Rotation fromInt(int rotation) {
          switch (rotation) {
              case 0: return NORMAL;
              case 90: return ROTATION_90;
              case 180: return ROTATION_180;
              case 270: return ROTATION_270;
              case 360: return NORMAL;
              default: throw new IllegalStateException(
                      rotation + " is an unknown rotation. Needs to be either 0, 90, 180 or 270!");
          }
      }
  }
  