@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); } } }
case BOTTOM_CENTER: if (scaleBarLength2 == 0) { canvas.drawLine(Math.round((canvas.getWidth() - maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), Math.round((canvas.getWidth() + maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round((canvas.getWidth() - maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round((canvas.getWidth() - maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round((canvas.getWidth() + maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round((canvas.getWidth() + maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); } else { canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() * 0.5f), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(SCALE_BAR_MARGIN * scale), Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength1), Math.round(SCALE_BAR_MARGIN * scale), Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength1), Math.round(canvas.getHeight() * 0.5f), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength2), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength2), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); case BOTTOM_LEFT: if (scaleBarLength2 == 0) { canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); } else { canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() * 0.5f), paint);
public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { long mapSize = getMapSize(zoomLevel, tileSize); for (int i = 0; i < latLongs.size() - 1; i++) { LatLong from = latLongs.get(i); int fromX = (int) (longitudeToPixelX(from.longitude, mapSize) - topLeftPoint.x); int fromY = (int) (latitudeToPixelY(from.latitude, mapSize) - topLeftPoint.y); LatLong to = latLongs.get(i + 1); int toX = (int) (longitudeToPixelX(to.longitude, mapSize) - topLeftPoint.x); int toY = (int) (latitudeToPixelY(to.latitude, mapSize) - topLeftPoint.y); canvas.drawLine(fromX, fromY, toX, toY, paint); } } }
@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); } } }
case BOTTOM_CENTER: if (scaleBarLength2 == 0) { canvas.drawLine(Math.round((canvas.getWidth() - maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), Math.round((canvas.getWidth() + maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round((canvas.getWidth() - maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round((canvas.getWidth() - maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round((canvas.getWidth() + maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round((canvas.getWidth() + maxScaleBarLength) * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); } else { canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() * 0.5f), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(SCALE_BAR_MARGIN * scale), Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength1), Math.round(SCALE_BAR_MARGIN * scale), Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength1), Math.round(canvas.getHeight() * 0.5f), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength2), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + scaleBarLength2), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); case BOTTOM_LEFT: if (scaleBarLength2 == 0) { canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() - SCALE_BAR_MARGIN * scale), paint); } else { canvas.drawLine(Math.round(STROKE_EXTERNAL * scale * 0.5f), Math.round(canvas.getHeight() * 0.5f), Math.round(STROKE_EXTERNAL * scale * 0.5f + maxScaleBarLength), Math.round(canvas.getHeight() * 0.5f), paint);
public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { long mapSize = getMapSize(zoomLevel, tileSize); int fromX = (int) (longitudeToPixelX(from.longitude, mapSize) - topLeftPoint.x); int fromY = (int) (latitudeToPixelY(from.latitude, mapSize) - topLeftPoint.y); int toX = (int) (longitudeToPixelX(to.longitude, mapSize) - topLeftPoint.x); int toY = (int) (latitudeToPixelY(to.latitude, mapSize) - topLeftPoint.y); canvas.drawLine(fromX, fromY, toX, toY, paint); } }
canvas.drawLine(left + halfBitmapWidth, top + this.getVerticalOffset() + halfBitmapHeight, leftGroup + groupBitmapHalfWidth, topGroup + groupVOffset + groupBitmapHalfHeight, this.polyPaintStroke);