示例#1
0
    @Override
    public void onRunAnimation() {
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();
      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 = mapCenter.getLatitudeE6() - deltaLatitudeE6;
          newMapCenterLonE6 = mapCenter.getLongitudeE6() - deltaLongitudeE6;
          mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6);

          Thread.sleep(stepDuration);
        }
        mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6);
      } catch (final Exception e) {
        this.interrupt();
      }
    }
示例#2
0
    @Override
    public void onRunAnimation() {
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();
      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 = mapCenter.getLatitudeE6() - deltaLatitudeE6;
          newMapCenterLonE6 = mapCenter.getLongitudeE6() - detlaLongitudeE6;
          mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6);

          Thread.sleep(stepDuration);
        }
        mapview.setMapCenter(super.mTargetLatitudeE6, super.mTargetLongitudeE6);
      } catch (final Exception e) {
        this.interrupt();
      }
    }
示例#3
0
    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 MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();

      this.mPanPerStepLatitudeE6 = (mapCenter.getLatitudeE6() - aTargetLatitudeE6) / aSmoothness;
      this.mPanPerStepLongitudeE6 = (mapCenter.getLongitudeE6() - aTargetLongitudeE6) / aSmoothness;

      this.setName("LinearAnimationRunner");
    }
示例#4
0
    public AbstractAnimationRunner(
        final int aTargetLatitudeE6,
        final int aTargetLongitudeE6,
        final int aSmoothness,
        final int aDuration) {
      this.mTargetLatitudeE6 = aTargetLatitudeE6;
      this.mTargetLongitudeE6 = aTargetLongitudeE6;
      this.mSmoothness = aSmoothness;
      this.mStepDuration = aDuration / aSmoothness;

      /* Get the current mapview-center. */
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();

      this.mPanTotalLatitudeE6 = mapCenter.getLatitudeE6() - aTargetLatitudeE6;
      this.mPanTotalLongitudeE6 = mapCenter.getLongitudeE6() - aTargetLongitudeE6;
    }
示例#5
0
    @Override
    public void onRunAnimation() {
      final MapView mapview = MapController.this.mOsmv;
      final IGeoPoint mapCenter = mapview.getMapCenter();
      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 = mapCenter.getLatitudeE6() - panPerStepLatitudeE6;
          newMapCenterLonE6 = mapCenter.getLongitudeE6() - panPerStepLongitudeE6;
          mapview.setMapCenter(newMapCenterLatE6, newMapCenterLonE6);

          Thread.sleep(stepDuration);
        }
      } catch (final Exception e) {
        this.interrupt();
      }
    }