Ejemplo n.º 1
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {

    super.draw(canvas, mapView, shadow);

    if (shadow) {
      return;
    }

    Projection projection = mapView.getProjection();
    Path path = new Path();
    boolean isFirst = true;

    for (int i = 0; i < pointsSize; i++) {
      GeoPoint gPoint = points.get(i);
      Point pixelPoint = pixelPoints[i];

      projection.toPixels(gPoint, pixelPoint);

      if (isFirst) {
        path.moveTo(pixelPoint.x, pixelPoint.y);
        isFirst = false;
      } else {
        path.lineTo(pixelPoint.x, pixelPoint.y);
      }
    }

    canvas.drawPath(path, mPaint);
  }
  @Override
  protected void drawMyLocation(
      Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {
    if (!bugged) {
      try {
        super.drawMyLocation(canvas, mapView, lastFix, myLocation, when);
      } catch (Exception e) {
        // we found a buggy phone, draw the location icons ourselves
        bugged = true;
      }
    }

    if (bugged) {
      if (drawable == null) {

        accuracyPaint = new Paint();
        accuracyPaint.setAntiAlias(true);
        accuracyPaint.setStrokeWidth(2.0f);

        drawable =
            mapView
                .getContext()
                .getResources()
                .getDrawable(R.drawable.ic_maps_indicator_current_position);
        width = drawable.getIntrinsicWidth();
        height = drawable.getIntrinsicHeight();
        center = new Point();
        left = new Point();
      }

      Projection projection = mapView.getProjection();
      double latitude = lastFix.getLatitude();
      double longitude = lastFix.getLongitude();
      float accuracy = lastFix.getAccuracy();

      float[] result = new float[1];

      Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result);
      float longitudeLineDistance = result[0];

      GeoPoint leftGeo =
          new GeoPoint(
              (int) (latitude * 1e6), (int) ((longitude - accuracy / longitudeLineDistance) * 1e6));
      projection.toPixels(leftGeo, left);
      projection.toPixels(myLocation, center);
      int radius = center.x - left.x;

      accuracyPaint.setColor(0xff6666ff);
      accuracyPaint.setStyle(Style.STROKE);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      accuracyPaint.setColor(0x186666ff);
      accuracyPaint.setStyle(Style.FILL);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      drawable.setBounds(
          center.x - width / 2, center.y - height / 2, center.x + width / 2, center.y + height / 2);
      drawable.draw(canvas);
    }
  }
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    Projection projection = mapView.getProjection();

    if (shadow == false) {
      // Get the current location
      Double latitude = 0.0, longitude = 0.0;
      if (location != null) {
        latitude = location.getLatitude() * 1E6;
        longitude = location.getLongitude() * 1E6;
      }
      GeoPoint geoPoint = new GeoPoint(latitude.intValue(), longitude.intValue());
      // Convert the location to screen pixles
      Point point = new Point();
      projection.toPixels(geoPoint, point);
      // Start Drawing
      Paint paint = new Paint();
      paint.setAntiAlias(true);
      paint.setARGB(150, 238, 17, 100);
      canvas.drawCircle(point.x, point.y, mRadius + 4, paint);
      paint.setARGB(255, 255, 255, 0);
      canvas.drawCircle(point.x, point.y, mRadius + 2, paint);
      paint.setARGB(250, 255, 0, 0);
      canvas.drawCircle(point.x, point.y, mRadius, paint);
    }
    super.draw(canvas, mapView, shadow);
  }
Ejemplo n.º 4
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {

    super.draw(canvas, mapView, shadow);

    Projection projection = mapView.getProjection();

    int latSpan = mapView.getLatitudeSpan();
    int lngSpan = mapView.getLongitudeSpan();
    GeoPoint mapCenter = mapView.getMapCenter();
    int mapLeftGeo = mapCenter.getLongitudeE6() - (lngSpan / 2);
    int mapRightGeo = mapCenter.getLongitudeE6() + (lngSpan / 2);

    int mapTopGeo = mapCenter.getLatitudeE6() - (latSpan / 2);
    int mapBottomGeo = mapCenter.getLatitudeE6() + (latSpan / 2);

    GeoPoint geoPoint = this.getSampleLocation();

    if ((geoPoint.getLatitudeE6() > mapTopGeo && geoPoint.getLatitudeE6() < mapBottomGeo)
        && (geoPoint.getLongitudeE6() > mapLeftGeo && geoPoint.getLongitudeE6() < mapRightGeo)) {
      Point myPoint = new Point();
      projection.toPixels(geoPoint, myPoint);
      Bitmap marker =
          BitmapFactory.decodeResource(mapView.getContext().getResources(), R.drawable.markerblue);
      canvas.drawBitmap(marker, myPoint.x - 15, myPoint.y - 30, null);
    }
  }
    @Override
    protected HttpResult<Iterable<Region>> doInBackground(Void... voids) {
      Projection projection = mapView.getProjection();

      // We want to download data that's off screen so the user can see something while panning
      GeoPoint northWest = projection.fromPixels(-mapView.getWidth(), -mapView.getHeight());
      GeoPoint southEast = projection.fromPixels(2 * mapView.getWidth(), 2 * mapView.getHeight());

      Location northWestLoc = LocationConversionHelper.location(northWest);
      Location southEastLoc = LocationConversionHelper.location(southEast);

      int size = min(mapView.getWidth(), mapView.getHeight()) / settingsHelper.getHeatMapDensity();
      if (size < 1) size = 1;

      int gridSizeX = MAP_BUFFER_SIZE * mapView.getWidth() / size;
      int gridSizeY = MAP_BUFFER_SIZE * mapView.getHeight() / size;

      return averagesDriver.index(
          sensorManager.getVisibleSensor(),
          northWestLoc.getLongitude(),
          northWestLoc.getLatitude(),
          southEastLoc.getLongitude(),
          southEastLoc.getLatitude(),
          gridSizeX,
          gridSizeY);
    }
Ejemplo n.º 6
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (!this.visible) return;

    // long start = System.currentTimeMillis();

    Projection projection = mapView.getProjection();
    Path p = new Path();
    Paint polygonPaint = new Paint();
    polygonPaint.setStrokeWidth(this.style.width);
    polygonPaint.setColor(this.style.color);
    polygonPaint.setStyle(Paint.Style.STROKE);
    polygonPaint.setAntiAlias(true);

    for (int i = 0; i < path.size(); i++) {
      if (i == path.size() - 1) {
        break;
      }
      Point from = new Point();
      Point to = new Point();
      projection.toPixels(path.get(i), from);
      projection.toPixels(path.get(i + 1), to);
      if (i == 0) {
        p.moveTo(from.x, from.y);
      }
      p.lineTo(to.x, to.y);
    }

    canvas.drawPath(p, polygonPaint);

    // Log.d("Tracker", "Path drawing complete in " + String.valueOf(System.currentTimeMillis() -
    // start) + "ms");
  }
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    // Get the map projection to convert lat/long to screen coordinates
    Projection projection = mapView.getProjection();

    Point lPoint = new Point();
    projection.toPixels(locationPoint, lPoint);

    // Draw the overlay
    if (shadow == false) {
      if (friendLocations.size() > 0) {
        Iterator<String> e = friendLocations.keySet().iterator();
        do {
          // Get the name and location of each contact
          String name = e.next();
          Location location = friendLocations.get(name);

          // Convert the lat / long to a Geopoint
          Double latitude = location.getLatitude() * 1E6;
          Double longitude = location.getLongitude() * 1E6;
          GeoPoint geopoint = new GeoPoint(latitude.intValue(), longitude.intValue());

          // Ensure each contact is within 10km
          float dist = location.distanceTo(getLocation());
          if (dist < 10000) {
            Point point = new Point();
            projection.toPixels(geopoint, point);

            // Draw a line connecting the contact to your current location.
            canvas.drawLine(lPoint.x, lPoint.y, point.x, point.y, paint);

            // Draw a marker at the contact's location.
            RectF oval =
                new RectF(
                    point.x - markerRadius,
                    point.y - markerRadius,
                    point.x + markerRadius,
                    point.y + markerRadius);

            canvas.drawOval(oval, backPaint);
            oval.inset(2, 2);
            canvas.drawOval(oval, paint);

            // Draw the contact's name next to their position.
            float textWidth = paint.measureText(name);
            float textHeight = paint.getTextSize();
            RectF textRect =
                new RectF(
                    point.x + markerRadius,
                    point.y - textHeight,
                    point.x + markerRadius + 8 + textWidth,
                    point.y + 4);
            canvas.drawRoundRect(textRect, 3, 3, backPaint);
            canvas.drawText(name, point.x + markerRadius + 4, point.y, paint);
          }
        } while (e.hasNext());
      }
    }
    super.draw(canvas, mapView, shadow);
  }
Ejemplo n.º 8
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    Point current = new Point();
    Path path = new Path();
    Projection projection = mapView.getProjection();
    Iterator<GeoPoint> iterator = pointList.iterator();

    if (iterator.hasNext()) {
      projection.toPixels(iterator.next(), current);
      path.moveTo((float) current.x, (float) current.y);
    } else return;

    while (iterator.hasNext()) {
      projection.toPixels(iterator.next(), current);
      path.lineTo((float) current.x, (float) current.y);
    }

    Paint pathPaint = new Paint();
    pathPaint.setAntiAlias(true);
    pathPaint.setDither(true);
    pathPaint.setStrokeWidth(3.5f);
    pathPaint.setColor(Color.rgb(15, 200, 2));
    pathPaint.setStyle(Style.STROKE);
    canvas.drawPath(path, pathPaint);
  }
Ejemplo n.º 9
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (!shadow) {

      // Make sure to give mMarker bounds so it will draw in the overlay
      final int intrinsicWidth = mMarker.getIntrinsicWidth();
      final int intrinsicHeight = mMarker.getIntrinsicHeight();
      mMarker.setBounds(0, 0, intrinsicWidth, intrinsicHeight);

      mMarkerXOffset = -(intrinsicWidth / 2);
      mMarkerYOffset = -(intrinsicHeight / 2);

      Paint paint = new Paint();
      paint.setARGB(250, 0, 0, 0);
      paint.setAntiAlias(true);
      paint.setFakeBoldText(true);

      Point point2 = new Point();
      Projection p = mapView.getProjection();
      p.toPixels(mGeoPoint, point2);

      canvas.drawText(text, point2.x - intrinsicWidth, point2.y + intrinsicHeight, paint);
      super.draw(canvas, mapView, shadow);
      drawAt(canvas, mMarker, point2.x + mMarkerXOffset, point2.y + mMarkerYOffset, shadow);
    }
  }
Ejemplo n.º 10
0
  public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
    Projection projection = mapView.getProjection();
    // if (shadow == false && _points != null) {
    for (ArrayList<GeoPoint> pair : pathCoords) {
      Path path = new Path();
      // We are creating the path
      GeoPoint gPointA = null;
      GeoPoint gPointB = null;
      for (int i = 0; i < 2; i++) {
        gPointA = pair.get(i);
        Point pointA = new Point();
        pointA = projection.toPixels(gPointA, pointA);
        if (i == 0) { // This is the start point
          gPointB = pair.get(i);
          path.moveTo(pointA.x, pointA.y);
        } else {
          path.lineTo(pointA.x, pointA.y);
        }
      }

      Paint paint = new Paint();
      paint.setAntiAlias(true);
      paint.setColor(_pathColor);
      paint.setStyle(Paint.Style.STROKE);
      paint.setStrokeWidth(5);
      paint.setAlpha(90);
      if ((!path.isEmpty()) && (isCurrentLocationVisible(gPointB, gPointA, mapView)))
        canvas.drawPath(path, paint);
    }
    // }
    return super.draw(canvas, mapView, shadow, when);
  }
Ejemplo n.º 11
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    // TODO Auto-generated method stub
    super.draw(canvas, mapView, shadow);

    GeoPoint centerGp = mapView.getMapCenter();
    Projection projection = mapView.getProjection();
    Point centerPoint = projection.toPixels(centerGp, null);

    drawCircle(canvas, centerPoint, mapView);
  }
Ejemplo n.º 12
0
 public void draw(Canvas canvas, MapView mapview, boolean flag) {
   Projection projection = mapview.getProjection();
   Paint paint = new Paint();
   Point point = new Point();
   projection.toPixels(gp1, point);
   paint.setColor(color);
   Point point1 = new Point();
   projection.toPixels(gp2, point1);
   paint.setStrokeWidth(5F);
   paint.setAlpha(120);
   canvas.drawLine(point.x, point.y, point1.x, point1.y, paint);
   super.draw(canvas, mapview, flag);
 }
Ejemplo n.º 13
0
  private void transformSegmentToCanvasDots() {
    Cursor trackCursor = null;
    GeoPoint geoPoint;
    mCalculatedPoints = 0;
    setStepSize();
    step = 0;

    try {
      trackCursor =
          this.mResolver.query(
              this.mSegmentUri,
              new String[] {Waypoints.LATITUDE, Waypoints.LONGITUDE, Waypoints.ACCURACY},
              null,
              null,
              null);
      if (trackCursor.moveToFirst()) {
        // Start point of the segments, possible a dot
        this.mStartPoint = extractGeoPoint(trackCursor);
        moveToGeoPoint(this.mStartPoint);

        Paint radiusPaint = new Paint();
        radiusPaint.setColor(Color.YELLOW);
        radiusPaint.setAlpha(100);

        do {
          geoPoint = extractGeoPoint(trackCursor);
          Point out = new Point();
          mProjection.toPixels(geoPoint, out);
          mCalculatedPoints++;
          Bitmap bitmap =
              BitmapFactory.decodeResource(this.mContext.getResources(), R.drawable.stip2);
          this.mCanvas.drawBitmap(bitmap, out.x - 8, out.y - 8, new Paint());
          float radius = mProjection.metersToEquatorPixels(trackCursor.getFloat(2));
          if (radius > 8f) {
            this.mCanvas.drawCircle(out.x, out.y, radius, radiusPaint);
          }
          this.mPrevScreenPoint.x = this.mScreenPoint.x;
          this.mPrevScreenPoint.y = this.mScreenPoint.y;
        } while (moveToNextWayPoint(trackCursor));

        // End point of the segments, possible a dot
        this.mEndPoint = extractGeoPoint(trackCursor);
      }
    } finally {
      if (trackCursor != null) {
        trackCursor.close();
      }
    }

    //      Log.d( TAG, "transformSegmentToPath stop: points "+mCalculatedPoints );
  }
Ejemplo n.º 14
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {

    Projection projection = mapView.getProjection();
    projection.toPixels(geopoint, point);

    circle.setColor(Color.parseColor("#EB5475"));
    circle.setAlpha(100);

    myCircleRadius =
        metersToRadius(CIRCLERADIUS, mapView, (double) geopoint.getLatitudeE6() / 1000000);

    canvas.drawCircle(point.x, point.y, myCircleRadius, circle);
  }
Ejemplo n.º 15
0
  /**
   * @param canvas
   * @param mapView
   * @param shadow
   * @see TrackingOverlay#draw(Canvas, MapView, boolean)
   */
  private void drawDots(Canvas canvas, MapView mapView, boolean shadow) {
    this.mCanvas = canvas;
    this.mScreenPoint = new Point();
    this.mPrevScreenPoint = new Point();
    mProjection = mapView.getProjection();
    mTopLeft = mProjection.fromPixels(0, 0);
    mBottumRight = mProjection.fromPixels(this.mCanvas.getWidth(), this.mCanvas.getHeight());

    transformSegmentToCanvasDots();

    drawStartStopCircles();

    super.draw(this.mCanvas, mapView, shadow);
    this.mCanvas = null;
  }
  @Override
  public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
    Projection projection = mapView.getProjection();
    if (shadow == false) {

      Paint paint = new Paint();
      paint.setAntiAlias(true);
      Point point = new Point();
      projection.toPixels(gp1, point);
      paint.setColor(Color.BLUE);
      Point point2 = new Point();
      projection.toPixels(gp2, point2);
      paint.setStrokeWidth(2);
      canvas.drawLine((float) point.x, (float) point.y, (float) point2.x, (float) point2.y, paint);
    }
    return super.draw(canvas, mapView, shadow, when);
  }
Ejemplo n.º 17
0
  /** Either the Path or the Dots are calculated based on he current track coloring method */
  private synchronized void calculateTrackAsync() {
    GeoPoint oldTopLeft = mGeoTopLeft;
    GeoPoint oldBottumRight = mGeoBottumRight;
    mGeoTopLeft = mProjection.fromPixels(0, 0);
    mGeoBottumRight = mProjection.fromPixels(mWidth, mHeight);

    if (mRequeryFlag
        || oldTopLeft == null
        || oldBottumRight == null
        || mGeoTopLeft.getLatitudeE6() / 100 != oldTopLeft.getLatitudeE6() / 100
        || mGeoTopLeft.getLongitudeE6() / 100 != oldTopLeft.getLongitudeE6() / 100
        || mGeoBottumRight.getLatitudeE6() / 100 != oldBottumRight.getLatitudeE6() / 100
        || mGeoBottumRight.getLongitudeE6() / 100 != oldBottumRight.getLongitudeE6() / 100) {
      calculateStepSize();

      mScreenPoint.x = -1;
      mScreenPoint.y = -1;
      this.mPrevDrawnScreenPoint.x = -1;
      this.mPrevDrawnScreenPoint.y = -1;

      switch (mTrackColoringMethod) {
        case (DRAW_CALCULATED):
        case (DRAW_MEASURED):
        case (DRAW_RED):
        case (DRAW_GREEN):
          calculatePath();
          synchronized (mPath) // Switch the fresh path with the old Path object
          {
            Path oldPath = mPath;
            mPath = mPathCalculation;
            mPathCalculation = oldPath;
          }
          break;
        case (DRAW_DOTS):
          calculateDots();
          synchronized (mDotPath) // Switch the fresh path with the old Path object
          {
            Vector<DotVO> oldDotPath = mDotPath;
            mDotPath = mDotPathCalculation;
            mDotPathCalculation = oldDotPath;
          }
          break;
      }
      mLoggerMap.onDateOverlayChanged();
    }
  }
Ejemplo n.º 18
0
	/**
	 * draw icon.
	 *
	 * @param canvas  Canvas object.
	 * @param mapView MapView object.
	 * @param shadow  shadow flag.
	 */
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		cluster.onNotifyDrawFromMarker();
		Projection proj = mapView.getProjection();
		Point p = proj.toPixels(center, null);
		if (p.x < 0 || p.x > mapView.getWidth() || p.y < 0 || p.y > mapView.getHeight()) {
			return;
		}
		MarkerBitmap mkrBmp = markerIconBmps.get(markerTypes);
		Bitmap bmp = selected ? mkrBmp.getBitmapSelect() : mkrBmp.getBitmapNormal();
		Point grid = mkrBmp.getGrid();
		Point gridReal = new Point((int) (grid.x * screenDensity + 0.5f), (int) (grid.y * screenDensity + 0.5f));
		canvas.drawBitmap(bmp, p.x - gridReal.x, p.y - gridReal.y, paint);
		String caption = String.valueOf(geoItems.size());
		int x = p.x;
		int y = p.y - txtHeightOffset;
		canvas.drawText(caption, x, y, paint);
	}
  @Override
  protected void drawMyLocation(
      Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {

    accuracyPaint = new Paint();
    accuracyPaint.setAntiAlias(true);
    accuracyPaint.setStrokeWidth(2.0f);
    center = new Point();
    left = new Point();

    Projection projection = mapView.getProjection();
    double latitude = lastFix.getLatitude();
    double longitude = lastFix.getLongitude();
    float accuracy = lastFix.getAccuracy();

    float[] result = new float[1];

    Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result);
    float longitudeLineDistance = result[0];

    GeoPoint leftGeo =
        new GeoPoint(
            (int) (latitude * 1e6), (int) ((longitude - accuracy / longitudeLineDistance) * 1e6));
    projection.toPixels(leftGeo, left);
    projection.toPixels(myLocation, center);
    int radius = center.x - left.x;

    accuracyPaint.setColor(0xff6666ff);
    accuracyPaint.setStyle(Style.STROKE);
    canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

    accuracyPaint.setColor(0x186666ff);
    accuracyPaint.setStyle(Style.FILL);
    canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

    mapView.getProjection().toPixels(myLocation, point);
    rect.left = point.x - slips[currSlip].getIntrinsicWidth() / 2;
    rect.top = point.y - slips[currSlip].getIntrinsicHeight() / 2;
    rect.right = point.x + slips[currSlip].getIntrinsicWidth() / 2;
    rect.bottom = point.y + slips[currSlip].getIntrinsicHeight() / 2;
    slips[currSlip].setBounds(rect);
    slips[currSlip].draw(canvas);
  }
Ejemplo n.º 20
0
 private void drawStartStopCircles() {
   Bitmap bitmap;
   if ((this.mPlacement == FIRST_SEGMENT || this.mPlacement == FIRST_SEGMENT + LAST_SEGMENT)
       && this.mStartPoint != null) {
     Point out = new Point();
     mProjection.toPixels(this.mStartPoint, out);
     mCalculatedPoints++;
     bitmap = BitmapFactory.decodeResource(this.mContext.getResources(), R.drawable.stip2);
     this.mCanvas.drawBitmap(bitmap, out.x - 8, out.y - 8, new Paint());
   }
   if ((this.mPlacement == LAST_SEGMENT || this.mPlacement == FIRST_SEGMENT + LAST_SEGMENT)
       && this.mEndPoint != null) {
     Point out = new Point();
     mProjection.toPixels(this.mEndPoint, out);
     mCalculatedPoints++;
     bitmap = BitmapFactory.decodeResource(this.mContext.getResources(), R.drawable.stip);
     this.mCanvas.drawBitmap(bitmap, out.x - 5, out.y - 5, new Paint());
   }
 }
Ejemplo n.º 21
0
  @Override
  public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
    Projection projection = mapView.getProjection();
    if (shadow == false) {
      Paint paint = new Paint();
      paint.setAntiAlias(true);
      Point point = new Point();
      projection.toPixels(gp1, point);
      // mode=1&#65306;start
      if (mode == 1) {
        if (defaultColor == 999) paint.setColor(Color.BLUE);
        else paint.setColor(defaultColor);
        // start point
      }
      // mode=2&#65306;path
      else if (mode == 2) {
        if (defaultColor == 999) paint.setColor(Color.RED);
        else paint.setColor(defaultColor);
        Point point2 = new Point();
        projection.toPixels(gp2, point2);
        paint.setStrokeWidth(5);
        paint.setAlpha(120);
        canvas.drawLine(point.x, point.y, point2.x, point2.y, paint);

      }
      /* mode=3&#65306;end */
      else if (mode == 3) {
        /* the last path */

        if (defaultColor == 999) paint.setColor(Color.GREEN);
        else paint.setColor(defaultColor);
        Point point2 = new Point();
        projection.toPixels(gp2, point2);
        paint.setStrokeWidth(5);
        paint.setAlpha(120);
        canvas.drawLine(point.x, point.y, point2.x, point2.y, paint);
        /* end point */

      }
    }
    return super.draw(canvas, mapView, shadow, when);
  }
Ejemplo n.º 22
0
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (shadow == false) {
      Projection projection = mapView.getProjection();

      int length = pathGeoPoints.length;
      projectedPoints = new float[length * 4]; // Make room for from.x, from.y, to.x, to.y
      for (int g = 0, p = 1; g < length; g++, p += 2) {
        pathPoints[g] = projection.toPixels(pathGeoPoints[g], null);

        if (g % 2 != 0) {
          projectedPoints[p] = pathPoints[g].y;
          projectedPoints[p - 1] = pathPoints[g].x;
          projectedPoints[p - 2] = pathPoints[g - 1].y;
          projectedPoints[p - 3] = pathPoints[g - 1].x;
        }
      }

      canvas.drawLines(projectedPoints, paint);
    }
  }
Ejemplo n.º 23
0
  @Override
  public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
    Projection projection = mapView.getProjection();
    if (shadow == false) {
      GeoPoint gp = new GeoPoint((int) this.geoLatitude, (int) this.geoLongitude);
      /* 将Location转成Point对象 */
      Point point = new Point();
      projection.toPixels(gp, point);

      /* 设定笔刷 */
      Paint paint = new Paint();
      paint.setAntiAlias(true);

      /* 绘制Overlay */
      // canvas.drawOval(oval, paint);
      Bitmap bm = BitmapFactory.decodeResource(mapView.getResources(), this.drawableID);
      canvas.drawBitmap(bm, point.x, point.y, paint);
    }
    return super.draw(canvas, mapView, shadow, when);
  }
Ejemplo n.º 24
0
 @Override
 public void draw(Canvas canvas, MapView mapView, boolean shadow) {
   super.draw(canvas, mapView, shadow);
   Point locationPoint = new Point();
   Projection projection = mapView.getProjection();
   projection.toPixels(getGeopoint(), locationPoint);
   Paint containerPaint = new Paint();
   containerPaint.setAntiAlias(true);
   int containerX = locationPoint.x;
   int containerY = locationPoint.y;
   if (shadow) {
     containerX += CONTAINER_SHADOW_OFFSET;
     containerY += CONTAINER_SHADOW_OFFSET;
     containerPaint.setARGB(90, 0, 0, 0);
     canvas.drawCircle(containerX, containerY, CONTAINER_RADIUS, containerPaint);
   } else {
     containerPaint.setColor(Color.RED);
     canvas.drawCircle(containerX, containerY, CONTAINER_RADIUS, containerPaint);
   }
 }
Ejemplo n.º 25
0
  private boolean commonOnTap(GeoPoint tappedGeoPoint) {
    List<Uri> tappedUri = new Vector<Uri>();

    Point tappedPoint = new Point();
    mProjection.toPixels(tappedGeoPoint, tappedPoint);
    for (MediaVO media : mMediaPath) {
      if (media.x < tappedPoint.x
          && tappedPoint.x < media.x + media.w
          && media.y < tappedPoint.y
          && tappedPoint.y < media.y + media.h) {
        // Log.d( TAG, String.format( "Tapped at a (x,y) (%d,%d)", tappedPoint.x, tappedPoint.y ) );
        tappedUri.add(media.uri);
      }
    }
    if (tappedUri.size() > 0) {
      return handleMediaTapList(tappedUri);
    } else {
      if (mTrackColoringMethod == DRAW_DOTS) {
        DotVO tapped = null;
        synchronized (mDotPath) // Switch the fresh path with the old Path object
        {
          int w = 25;
          for (DotVO dot : mDotPath) {
            //                  Log.d( TAG, "Compare ("+dot.x+","+dot.y+") with tap
            // ("+tappedPoint.x+","+tappedPoint.y+")" );
            if (dot.x - w < tappedPoint.x
                && tappedPoint.x < dot.x + w
                && dot.y - w < tappedPoint.y
                && tappedPoint.y < dot.y + w) {
              if (tapped == null) {
                tapped = dot;
              } else {
                tapped =
                    dot.distanceTo(tappedPoint) < tapped.distanceTo(tappedPoint) ? dot : tapped;
              }
            }
          }
        }
        if (tapped != null) {
          DateFormat timeFormat =
              android.text.format.DateFormat.getTimeFormat(mLoggerMap.getApplicationContext());
          String timetxt = timeFormat.format(new Date(tapped.time));
          UnitsI18n units = new UnitsI18n(mLoggerMap, null);
          double speed = units.conversionFromMetersPerSecond(tapped.speed);
          String speedtxt = String.format("%.1f %s", speed, units.getSpeedUnit());
          String text = mLoggerMap.getString(R.string.time_and_speed, timetxt, speedtxt);
          Toast toast = Toast.makeText(mLoggerMap, text, Toast.LENGTH_SHORT);
          toast.show();
        }
      }
      return false;
    }
  }
Ejemplo n.º 26
0
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    Projection projection = mapView.getProjection();

    // Create and setup your paint brush
    Paint paint = new Paint();
    paint.setARGB(250, 255, 0, 0);
    paint.setAntiAlias(true);
    paint.setFakeBoldText(true);

    if (shadow == false) {
      for (GeoPoint point : quakeLocations) {
        Point myPoint = new Point();
        projection.toPixels(point, myPoint);

        RectF oval = new RectF(myPoint.x - rad, myPoint.y - rad, myPoint.x + rad, myPoint.y + rad);

        canvas.drawOval(oval, paint);
      }
    }
  }
Ejemplo n.º 27
0
 public List<Point> convertListGeoPointToPoint(List<GeoPoint> listGeoPoint, Projection project) {
   List<Point> listPoint = new ArrayList<Point>();
   if (listGeoPoint != null && listGeoPoint.size() > 0 && project != null) {
     listPoint.clear();
     for (GeoPoint geoPoint : listGeoPoint) {
       Point point = new Point();
       project.toPixels(geoPoint, point);
       listPoint.add(point);
     }
   }
   return listPoint;
 }
Ejemplo n.º 28
0
  /**
   * @param canvas
   * @param mapView
   * @param shadow
   * @see TrackingOverlay#draw(Canvas, MapView, boolean)
   */
  public void drawPath(Canvas canvas, MapView mapView, boolean shadow) {
    this.mCanvas = canvas;
    this.mScreenPoint = new Point();
    this.mPrevScreenPoint = new Point();
    mProjection = mapView.getProjection();
    mTopLeft = mProjection.fromPixels(0, 0);
    mBottumRight = mProjection.fromPixels(this.mCanvas.getWidth(), this.mCanvas.getHeight());

    this.mPath.rewind();
    this.mShader = null;
    transformSegmentToPath();

    // Just the rendering bits left to do
    Paint routePaint = new Paint();
    routePaint.setPathEffect(new CornerPathEffect(10));
    //      Log.d( TAG, "Drawing color is "+trackColoringMethod );
    switch (trackColoringMethod) {
      case (DRAW_CALCULATED):
      case (DRAW_MEASURED):
        routePaint.setShader(this.mShader);
        break;
      case (DRAW_RED):
        routePaint.setColor(Color.RED);
        break;
      case (DRAW_GREEN):
      default:
        routePaint.setColor(Color.GREEN);
        break;
    }
    routePaint.setStyle(Paint.Style.STROKE);
    routePaint.setStrokeWidth(8);
    routePaint.setAntiAlias(true);

    this.mCanvas.drawPath(this.mPath, routePaint);

    drawStartStopCircles();

    super.draw(this.mCanvas, mapView, shadow);
    this.mCanvas = null;
  }
Ejemplo n.º 29
0
  @Override
  public boolean onTap(GeoPoint p, MapView mapView) {
    if (isTapable()) {
      Footprint chosen = null;
      // TODO calculate tapped Footprint

      System.out.println("--------------> TAB TAB TAB TAB");
      if (activity.footprints != null) {
        iterator = activity.footprints.iterator();
      }

      while (iterator != null && iterator.hasNext()) {
        Footprint footprint = iterator.next();
        GeoPoint geoPoint = footprint.getLocation();

        Point p_foot = new Point();
        Point p_tab = new Point();

        projection.toPixels(geoPoint, p_foot);
        projection.toPixels(p, p_tab);

        if (p_tab.x >= p_foot.x
            & p_tab.y >= p_foot.y
            & p_tab.x <= (p_foot.x + 45)
            & p_tab.y <= (p_foot.y + 45)) {
          chosen = footprint;
          break;
        }
      }

      if (chosen != null) {
        activity.activateFotoView(chosen);
      }
    }
    return super.onTap(p, mapView);
  }
Ejemplo n.º 30
0
  /** ***** Overlay Overrides ****** */
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, shadow);

    final Projection projection = mapView.getProjection();

    int numPoints = points.size();

    if (numPoints > 1) {
      for (int i = 0; i < points.size() - 1; i++) {
        GeoPoint gp1 = points.get(i);
        GeoPoint gp2 = points.get(i + 1);
        Paint paint = new Paint();
        paint.setDither(true);
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeWidth(4);
        paint.setAlpha(80);

        Point p1 = new Point();
        Point p2 = new Point();

        Path path = new Path();

        projection.toPixels(gp1, p1);
        projection.toPixels(gp2, p2);

        path.moveTo(p2.x, p2.y);
        path.lineTo(p1.x, p1.y);

        canvas.drawPath(path, paint);
      }
    }
  }