content: //******************************************************************************
  // SCICHART® Copyright SciChart Ltd. 2011-2017. All rights reserved.
  //
  // Web: http://www.scichart.com
  // Support: support@scichart.com
  // Sales:   sales@scichart.com
  //
  // FlipAnimation.java is part of the SCICHART® Examples. Permission is hereby granted
  // to modify, create derivative works, distribute and publish any part of this source
  // code whether for commercial, private or personal use.
  //
  // The SCICHART® examples are distributed in the hope that they will be useful, but
  // without any warranty. It is provided "AS IS" without warranty of any kind, either
  // expressed or implied.
  //******************************************************************************
  
  package com.scichart.examples.components.SideMenuAnimations;
  
  import android.graphics.Camera;
  import android.graphics.Matrix;
  import android.view.animation.Animation;
  import android.view.animation.Transformation;
  
  public class FlipAnimation extends Animation {
      private final float fromDegrees;
      private final float toDegrees;
      private final float centerX;
      private final float centerY;
      private Camera mCamera;
  
      public FlipAnimation(float fromDegrees, float toDegrees, float centerX, float centerY) {
          this.fromDegrees = fromDegrees;
          this.toDegrees = toDegrees;
          this.centerX = centerX;
          this.centerY = centerY;
      }
  
      @Override
      public void initialize(int width, int height, int parentWidth, int parentHeight) {
          super.initialize(width, height, parentWidth, parentHeight);
          mCamera = new Camera();
      }
  
      @Override
      protected void applyTransformation(float interpolatedTime, Transformation t) {
          float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
          final Matrix matrix = t.getMatrix();
  
          final Camera camera = mCamera;
          camera.save();
  
          camera.rotateY(degrees);
          camera.getMatrix(matrix);
  
          camera.restore();
  
          matrix.preTranslate(-centerX, -centerY);
          matrix.postTranslate(centerX, centerY);
      }
  }