Esempio n. 1
0
  /**
   * method used to draw a polygon on map
   *
   * @param advancedStyle
   */
  public void drawPolygons(AdvancedStyle advancedStyle) {
    Paint stroke = StyleManager.getStrokePaint4Style(advancedStyle);
    Paint fill = StyleManager.getFillPaint4Style(advancedStyle);

    if (stroke == null && fill == null) {
      // Can't draw
      return;
    }

    ShapeWriter wr = new ShapeWriter(pointTransformer);
    wr.setRemoveDuplicatePoints(true);
    wr.setDecimation(style4Table.decimationFactor);
    while (geometryIterator.hasNext()) {

      Geometry geom = geometryIterator.next();
      if (geom != null) {
        DrawableShape shape = wr.toShape(geom);
        if (fill != null) {
          shape.fill(canvas, fill);
        }
        if (stroke != null) {
          shape.draw(canvas, stroke);
        }
      }
    }
  }
Esempio n. 2
0
  /**
   * Method used to draw a line on map.
   *
   * @param advancedStyle
   * @param currentZoomLevel the current zoom level of the map view
   */
  public void drawLines(AdvancedStyle advancedStyle, byte currentZoomLevel) {
    Paint stroke = StyleManager.getStrokePaint4Style(advancedStyle);
    Paint textStroke = StyleManager.getTextStrokePaint4Style(advancedStyle);
    ShapeWriter wr = new ShapeWriter(pointTransformer);
    wr.setRemoveDuplicatePoints(true);
    wr.setDecimation(style4Table.decimationFactor);
    if (stroke == null && textStroke == null) {
      // Can't draw
      return;
    }

    while (geometryIterator.hasNext()) {
      Geometry geom = geometryIterator.next();
      DrawableShape shape = wr.toShape(geom);
      if (stroke != null) {
        shape.draw(canvas, stroke);
      }

      // draw labels if zoom level fits and data is available
      if (currentZoomLevel >= advancedStyle.label_minZoom
          && textStroke != null
          && shape instanceof PathShape
          && geom.getUserData() != null) {

        Object userData = geom.getUserData();

        canvas.drawTextOnPath(
            userData.toString(),
            ((PathShape) shape).getPath(),
            LABEL_H_OFFSET,
            LABEL_V_OFFSET,
            textStroke);
      }
    }
  }
Esempio n. 3
0
  /**
   * Method used to draw a point on map.
   *
   * @param fill
   * @param stroke
   */
  public void drawPoints(Paint fill, Paint stroke) {
    ShapeWriter wr = new ShapeWriter(pointTransformer, style4Table.shape, style4Table.size);
    wr.setRemoveDuplicatePoints(true);
    wr.setDecimation(style4Table.decimationFactor);
    while (geometryIterator.hasNext()) {
      Geometry geom = geometryIterator.next();
      geom.getCoordinate();
      DrawableShape shape = wr.toShape(geom);

      if (fill != null) {
        shape.fill(canvas, fill);
      }
      if (stroke != null) {
        shape.draw(canvas, stroke);
      }
    }
  }
Esempio n. 4
0
  public void onToolDraw(Canvas canvas) {
    if (startP.x == 0 && startP.y == 0) return;
    canvas.drawCircle(startP.x, startP.y, 15, drawingPaintFill);
    canvas.drawPath(drawingPath, drawingPaintStroke);
    canvas.drawCircle(endP.x, endP.y, 15, drawingPaintFill);

    if (previewGeometry != null) {
      Projection projection = editingViewProjection;

      byte zoomLevelBeforeDraw;
      synchronized (mapView) {
        zoomLevelBeforeDraw = mapView.getMapPosition().getZoomLevel();
        positionBeforeDraw =
            projection.toPoint(
                mapView.getMapPosition().getMapCenter(), positionBeforeDraw, zoomLevelBeforeDraw);
      }

      // calculate the top-left point of the visible rectangle
      point.x = positionBeforeDraw.x - (canvas.getWidth() >> 1);
      point.y = positionBeforeDraw.y - (canvas.getHeight() >> 1);

      MapViewPosition mapPosition = mapView.getMapPosition();
      byte zoomLevel = mapPosition.getZoomLevel();

      PointTransformation pointTransformer =
          new MapsforgePointTransformation(projection, point, zoomLevel);
      ShapeWriter shapeWriter = new ShapeWriter(pointTransformer);
      shapeWriter.setRemoveDuplicatePoints(true);

      FeatureUtilities.drawGeometry(
          previewGeometry,
          canvas,
          shapeWriter,
          selectedPreviewGeometryPaintFill,
          selectedPreviewGeometryPaintStroke);
    }
  }