예제 #1
0
  @Override
  public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
    long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel);
    long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel);
    long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel);
    long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel);

    int tileSize = this.displayModel.getTileSize();
    int pixelX1 = (int) (MercatorProjection.tileToPixel(tileLeft, tileSize) - topLeftPoint.x);
    int pixelY1 = (int) (MercatorProjection.tileToPixel(tileTop, tileSize) - topLeftPoint.y);
    int pixelX2 =
        (int) (MercatorProjection.tileToPixel(tileRight, tileSize) - topLeftPoint.x + tileSize);
    int pixelY2 =
        (int) (MercatorProjection.tileToPixel(tileBottom, tileSize) - topLeftPoint.y + tileSize);

    for (int lineX = pixelX1; lineX <= pixelX2 + 1; lineX += tileSize) {
      canvas.drawLine(lineX, pixelY1, lineX, pixelY2, this.paintBack);
    }

    for (int lineY = pixelY1; lineY <= pixelY2 + 1; lineY += tileSize) {
      canvas.drawLine(pixelX1, lineY, pixelX2, lineY, this.paintBack);
    }

    for (int lineX = pixelX1; lineX <= pixelX2 + 1; lineX += tileSize) {
      canvas.drawLine(lineX, pixelY1, lineX, pixelY2, this.paintFront);
    }

    for (int lineY = pixelY1; lineY <= pixelY2 + 1; lineY += tileSize) {
      canvas.drawLine(pixelX1, lineY, pixelX2, lineY, this.paintFront);
    }
  }
예제 #2
0
  public void draw(Canvas canvas, Point origin, Matrix matrix) {
    Point adjustedStart = xy.offset(-origin.x, -origin.y);
    Point adjustedEnd = end.offset(-origin.x, -origin.y);

    if (this.paintBack != null) {
      canvas.drawTextRotated(
          text,
          (int) (adjustedStart.x),
          (int) (adjustedStart.y),
          (int) (adjustedEnd.x),
          (int) (adjustedEnd.y),
          this.paintBack);
    }
    canvas.drawTextRotated(
        text,
        (int) (adjustedStart.x),
        (int) (adjustedStart.y),
        (int) (adjustedEnd.x),
        (int) (adjustedEnd.y),
        this.paintFront);
  }