Esempio n. 1
0
 private void refreshMapInternal(DrawSettings drawSettings) {
   handler.removeMessages(MAP_REFRESH_MESSAGE);
   SurfaceHolder holder = getHolder();
   long ms = SystemClock.elapsedRealtime();
   synchronized (holder) {
     Canvas canvas = holder.lockCanvas();
     if (canvas != null) {
       try {
         final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.8f : 0.5f;
         final int cy = (int) (ratioy * getHeight());
         if (currentViewport.getPixWidth() != getWidth()
             || currentViewport.getPixHeight() != getHeight()
             || currentViewport.getCenterPixelY() != cy) {
           currentViewport.setPixelDimensions(getWidth(), getHeight(), 0.5f, ratioy);
           refreshBufferImage(drawSettings);
         }
         // make copy to avoid concurrency
         RotatedTileBox viewportToDraw = currentViewport.copy();
         fillCanvas(canvas, drawSettings);
         drawOverMap(canvas, viewportToDraw, drawSettings);
       } finally {
         holder.unlockCanvasAndPost(canvas);
       }
     }
     if (MEASURE_FPS) {
       main.calculateFPS(ms, SystemClock.elapsedRealtime());
     }
   }
 }
Esempio n. 2
0
    private void changeZoomPosition(float dz, float angle) {
      final QuadPoint cp = initialViewport.getCenterPixelPoint();
      float dx = cp.x - initialMultiTouchCenterPoint.x;
      float dy = cp.y - initialMultiTouchCenterPoint.y;
      final RotatedTileBox calc = initialViewport.copy();
      calc.setLatLonCenter(initialCenterLatLon.getLatitude(), initialCenterLatLon.getLongitude());

      float calcZoom = initialViewport.getZoom() + dz + initialViewport.getZoomScale();
      float calcRotate = calc.getRotate() + angle;
      calc.setRotate(calcRotate);
      calc.setZoomAnimation(dz);
      final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy);
      setLatLon(r.getLatitude(), r.getLongitude());
      zoomToAnimate(calcZoom, true);
      rotateToAnimate(calcRotate);
    }
Esempio n. 3
0
  private void drawBasemap(Canvas canvas) {
    if (bufferImgLoc != null) {
      float rot = -bufferImgLoc.getRotate();
      canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
      final RotatedTileBox calc = currentViewport.copy();
      calc.setRotate(bufferImgLoc.getRotate());

      int cz = getZoom();
      QuadPoint lt = bufferImgLoc.getLeftTopTile(cz);
      QuadPoint rb = bufferImgLoc.getRightBottomTile(cz);
      final float x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
      final float x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
      final float y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
      final float y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
      if (!bufferBitmap.isRecycled()) {
        canvas.drawBitmap(bufferBitmap, null, new RectF(x1, y1, x2, y2), paintImg);
      }
      canvas.rotate(-rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
    }
  }