Back to project page salaya-tram-map.
The source code is released under:
Unless otherwise noted, this software is Copyright 2011 Pawit Pornkitprasan and is licensed under the Simplified BSD License. Copyright 2011 Pawit Pornkitprasan. All rights reserved. Red...
If you think the Android project salaya-tram-map listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.dyndns.pawitp.salayatrammap.map; // w w w . j av a 2s. co m import android.view.animation.AnimationUtils; // Inspired by Scroller public class Zoomer { private static final int DURATION = 250; private static final float DURATION_RECIPROCAL = (float) 1/DURATION; private boolean mFinished = true; private long mStartTime; private float mPivotX; private float mPivotY; private float mCurrScale; private float mStartScale; private float mDestScale; private float mDeltaScale; boolean compute() { if (mFinished == true) { return false; } int timePassed = (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime); if (timePassed < DURATION) { float x = timePassed * DURATION_RECIPROCAL; mCurrScale = mStartScale + x * mDeltaScale; } else { mCurrScale = mDestScale; mFinished = true; } return true; } float getPivotX() { return mPivotX; } float getPivotY() { return mPivotY; } float getCurrScale() { return mCurrScale; } void zoomTo(float startScale, float destScale, float pivotX, float pivotY) { mFinished = false; mStartTime = AnimationUtils.currentAnimationTimeMillis(); mStartScale = startScale; mDestScale = destScale; mDeltaScale = destScale - startScale; mPivotX = pivotX; mPivotY = pivotY; } }