@Override public void onRunAnimation() { final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; final int stepDuration = this.mStepDuration; final float amountStretch = this.mAmountStretch; try { int newMapCenterLatE6; int newMapCenterLonE6; for (int i = 0; i < this.mSmoothness; i++) { final double delta = (this.mYOffset + Math.cos(this.mStepIncrement * i + this.mStart)) * amountStretch; final int deltaLatitudeE6 = (int) (this.mPanTotalLatitudeE6 * delta); final int deltaLongitudeE6 = (int) (this.mPanTotalLongitudeE6 * delta); newMapCenterLatE6 = mapview.getMapCenterLatitudeE6() - deltaLatitudeE6; newMapCenterLonE6 = mapview.getMapCenterLongitudeE6() - deltaLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6); } catch (Exception e) { this.interrupt(); } }
@Override public void onRunAnimation() { final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; final int stepDuration = this.mStepDuration; try { int newMapCenterLatE6; int newMapCenterLonE6; for (int i = 0; i < this.mSmoothness; i++) { final double delta = Math.pow(0.5, i + 1); final int deltaLatitudeE6 = (int) (this.mPanTotalLatitudeE6 * delta); final int detlaLongitudeE6 = (int) (this.mPanTotalLongitudeE6 * delta); newMapCenterLatE6 = mapview.getMapCenterLatitudeE6() - deltaLatitudeE6; newMapCenterLonE6 = mapview.getMapCenterLongitudeE6() - detlaLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6); } catch (Exception e) { this.interrupt(); } }
public LinearAnimationRunner( final int aTargetLatitudeE6, final int aTargetLongitudeE6, final int aSmoothness, final int aDuration) { super(aTargetLatitudeE6, aTargetLongitudeE6, aSmoothness, aDuration); /* Get the current mapview-center. */ final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; int mapCenterLatE6 = mapview.getMapCenterLatitudeE6(); int mapCenterLonE6 = mapview.getMapCenterLongitudeE6(); this.mPanPerStepLatitudeE6 = (mapCenterLatE6 - aTargetLatitudeE6) / aSmoothness; this.mPanPerStepLongitudeE6 = (mapCenterLonE6 - aTargetLongitudeE6) / aSmoothness; this.setName("LinearAnimationRunner"); }
public AbstractAnimationRunner( final int aTargetLatitudeE6, final int aTargetLongitudeE6, final int aSmoothness, final int aDuration) { this.mTargetLatitudeE6 = aTargetLatitudeE6; this.mTargetLongitudeE6 = aTargetLongitudeE6; this.mSmoothness = aSmoothness; this.mDuration = aDuration; this.mStepDuration = aDuration / aSmoothness; /* Get the current mapview-center. */ final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; int mapCenterLatE6 = mapview.getMapCenterLatitudeE6(); int mapCenterLonE6 = mapview.getMapCenterLongitudeE6(); this.mPanTotalLatitudeE6 = (mapCenterLatE6 - aTargetLatitudeE6); this.mPanTotalLongitudeE6 = (mapCenterLonE6 - aTargetLongitudeE6); }
@Override public void onRunAnimation() { final OpenStreetMapView mapview = OpenStreetMapViewController.this.mOsmv; final int panPerStepLatitudeE6 = this.mPanPerStepLatitudeE6; final int panPerStepLongitudeE6 = this.mPanPerStepLongitudeE6; final int stepDuration = this.mStepDuration; try { int newMapCenterLatE6; int newMapCenterLonE6; for (int i = this.mSmoothness; i > 0; i--) { newMapCenterLatE6 = mapview.getMapCenterLatitudeE6() - panPerStepLatitudeE6; newMapCenterLonE6 = mapview.getMapCenterLongitudeE6() - panPerStepLongitudeE6; mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6); Thread.sleep(stepDuration); } } catch (Exception e) { this.interrupt(); } }