Exemple #1
0
    @Override
    public void handleMessage(Message msg) {
      mapBitmap = bmLow;
      minRate = MapCommonUtil.getScreenWidth(getContext()) / MapView.this.startWidth;
      imgMatrix.setScale(minRate, minRate);
      float[] values = new float[9];
      imgMatrix.getValues(values);
      float y = (MapCommonUtil.getScreenHeight(getContext()) - startHeight * values[4]) / 2;
      imgMatrix.postTranslate(0, y);

      isNaviMode = false;
      isNaviRefresh = false;

      isCompleted = true;
      postInvalidate();
      if (onMapLoadCompletedListener != null) {
        onMapLoadCompletedListener.onMapLoadCompleted(map);
      }
    }
Exemple #2
0
 public void moveToCenter(Point point, int from) {
   int sWidth = MapCommonUtil.getScreenWidth(getContext()) / 2;
   int sHeight = MapCommonUtil.getScreenHeight(getContext()) / 2;
   // float scale = MapCommonUtil.getMapScale(this);
   float[] values = new float[9];
   imgMatrix.getValues(values);
   float startx = (point.getX() * values[0] + point.getY() * values[1]) + values[2];
   float starty = (point.getX() * values[3] + point.getY() * values[4]) + values[5];
   float x = sWidth - startx;
   float y = sHeight - starty;
   float dx = x / 10;
   float dy = y / 10;
   if (Math.abs(x) < 3 && Math.abs(y) < 3) {
     if (null != onInvalidataListener) {
       onInvalidataListener.onInvalidataEnd(from);
       return;
     }
   }
   translate(x, y, dx, dy, from);
 }
Exemple #3
0
  @SuppressLint("DrawAllocation")
  @Override
  protected void onDraw(Canvas canvas) {
    if (isCompleted) {
      canvas.drawBitmap(mapBitmap, imgMatrix, paint);
      canvas.setDrawFilter(pfdf);
      if (isInvalidate) {
        if (isRotate) {}
        if (isScale) {
          float curScale = MapCommonUtil.getMapScale(this);
          if (scaleStep > 0) {
            if (curScale * (1 + scaleStep) > scale) {
              isScale = false;
              isInvalidate = false;
              imgMatrix.postScale(scale / curScale, scale / curScale, scaleDx, scaleDy);
              if (onInvalidataListener != null) {
                onInvalidataListener.onInvalidataEnd(-1);
              }
            }
          } else {
            if (curScale * (1 + scaleStep) < scale) {
              isScale = false;
              isInvalidate = false;
              imgMatrix.postScale(scale / curScale, scale / curScale, scaleDx, scaleDy);
              if (onInvalidataListener != null) {
                onInvalidataListener.onInvalidataEnd(-1);
              }
            }
          }
          if (isScale) {
            imgMatrix.postScale(1 + scaleStep, 1 + scaleStep, scaleDx, scaleDy);
          }
        }

        if (isTranslate) {
          sumX += translateStepX;
          sumY += translateStepY;
          if (Math.abs(sumX) > Math.abs(translateX) && Math.abs(sumY) > Math.abs(translateY)) {
            isTranslate = false;
            isInvalidate = false;
            if (onInvalidataListener != null) {
              onInvalidataListener.onInvalidataEnd(translateFrom);
            }
          }
          if (isTranslate) {
            imgMatrix.postTranslate(translateStepX, translateStepY);
          }
        }
        if (onInvalidataListener != null) {
          onInvalidataListener.onInvalidata();
        }
        invalidate();
      }
      if (isNaviRefresh && !isInvalidate) {
        PathEffect pe1 = new CornerPathEffect(10);
        PathEffect pe2 =
            new PathDashPathEffect(
                makePathDash(), 60 * scale, phase, PathDashPathEffect.Style.ROTATE);
        PathEffect pe = new ComposePathEffect(pe2, pe1);
        paint1.setPathEffect(pe);
        paint1.setStrokeWidth(10f * scale);
        paint2.setPathEffect(pe1);
        paint2.setStrokeWidth(15f * scale);
        if (routeAlpha <= 255 && isNaviMode) {
          paint1.setAlpha(routeAlpha);
          paint2.setAlpha(routeAlpha);
          routeAlpha += 5;
        } else if (!isNaviMode) {
          if (routeAlpha > 0) {
            paint1.setAlpha(routeAlpha);
            paint2.setAlpha(routeAlpha);
            routeAlpha -= 5;
          } else {
            isNaviRefresh = false;
          }
        }
        canvas.drawPath(p1, paint2);
        canvas.drawPath(p1, paint1);
        canvas.save();
        phase = phase - 0.5f * scale;
        invalidate();
      }
    }

    super.onDraw(canvas);
  }