/** * Copyright (c) 2013 Nokia Corporation. All rights reserved. * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. * Oracle and Java are trademarks or registered trademarks of Oracle and/or its * affiliates. Other product and company names mentioned herein may be trademarks * or trade names of their respective owners. * See LICENSE.TXT for license information. */ package com.nokia.example.statusshout.animations; /** * Implements the out-in-quad easing curve. */ public class OutInQuadEasingCurve extends EasingCurve { public boolean calculate(int first, int last, int duration) { _duration = duration; _steps = _duration / IntAnimation.UPDATE_INTERVAL; if (_steps < 3) { _values = null; return false; } _values = new int[_steps]; _currentStepIndex = 0; _values[0] = first; _values[_steps - 1] = last; final int interval = last - first; final int intervalHalved = interval / 2; float x = (float)(intervalHalved * intervalHalved) / ((float)(_steps - 2) / 2); System.out.println("x is " + x); final int sign = first > last ? -1 : 1; int value = 0; for (int i = 1; i < _steps - 1; ++i) { if (i < _steps / 2) { value = sign * (int)Math.sqrt(x * i); _values[i] = first + value; } else { value = sign * (int)Math.sqrt(x * ((_steps - 1) - i)); _values[i] = last - value; } } System.out.print("OutInQuadEasingCurve.calculate(): Duration is " + _duration + " ms. The animation has "+ _steps + " steps: { "); for (int i = 0; i < _steps; ++i) { System.out.print(_values[i]); if (i < _steps - 1) System.out.print(", "); } System.out.println(" }"); return true; } }