@Test public void drawTest() { for (int tileSize : TILE_SIZES) { Circle circle = new Circle(null, 0, null, null); circle.setDisplayModel(new FixedTileSizeDisplayModel(tileSize)); BoundingBox boundingBox = new BoundingBox(-1, -1, 1, 1); Canvas canvas = GRAPHIC_FACTORY.createCanvas(); canvas.setBitmap(GRAPHIC_FACTORY.createBitmap(tileSize, tileSize)); Point point = new Point(0, 0); circle.draw(boundingBox, (byte) 0, canvas, point); circle.setLatLong(new LatLong(0, 0)); circle.draw(boundingBox, (byte) 0, canvas, point); circle.setRadius(1); circle.draw(boundingBox, (byte) 0, canvas, point); circle.setPaintFill(GRAPHIC_FACTORY.createPaint()); circle.draw(boundingBox, (byte) 0, canvas, point); circle.setPaintStroke(GRAPHIC_FACTORY.createPaint()); circle.draw(boundingBox, (byte) 0, canvas, point); } }
@Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLong == null || (this.paintStroke == null && this.paintFill == null)) { return; } double latitude = this.latLong.latitude; double longitude = this.latLong.longitude; int tileSize = displayModel.getTileSize(); int pixelX = (int) (MercatorProjection.longitudeToPixelX(longitude, zoomLevel, tileSize) - topLeftPoint.x); int pixelY = (int) (MercatorProjection.latitudeToPixelY(latitude, zoomLevel, tileSize) - topLeftPoint.y); int radiusInPixel = getRadiusInPixels(latitude, zoomLevel); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight()); if (!canvasRectangle.intersectsCircle(pixelX, pixelY, radiusInPixel)) { return; } if (this.paintStroke != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintStroke); } if (this.paintFill != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintFill); } }
Circle extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLong == null || (this.paintStroke == null && this.paintFill == null)) { return; } double latitude = this.latLong.latitude; double longitude = this.latLong.longitude; int tileSize = displayModel.getTileSize(); int pixelX = (int) (MercatorProjection.longitudeToPixelX(longitude, zoomLevel, tileSize) - topLeftPoint.x); int pixelY = (int) (MercatorProjection.latitudeToPixelY(latitude, zoomLevel, tileSize) - topLeftPoint.y); int radiusInPixel = getRadiusInPixels(latitude, zoomLevel); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight()); if (!canvasRectangle.intersectsCircle(pixelX, pixelY, radiusInPixel)) { return; } if (this.paintStroke != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintStroke); } if (this.paintFill != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintFill); } } }
Circle extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLong == null || (this.paintStroke == null && this.paintFill == null)) { return; } double latitude = this.latLong.latitude; double longitude = this.latLong.longitude; int tileSize = displayModel.getTileSize(); int pixelX = (int) (MercatorProjection.longitudeToPixelX(longitude, zoomLevel, tileSize) - topLeftPoint.x); int pixelY = (int) (MercatorProjection.latitudeToPixelY(latitude, zoomLevel, tileSize) - topLeftPoint.y); int radiusInPixel = getRadiusInPixels(latitude, zoomLevel); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight()); if (!canvasRectangle.intersectsCircle(pixelX, pixelY, radiusInPixel)) { return; } if (this.paintStroke != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintStroke); } if (this.paintFill != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintFill); } } Circle(LatLong latLong, float radius, Paint paintFill, Paint paintStroke); }
Circle extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLong == null || (this.paintStroke == null && this.paintFill == null)) { return; } double latitude = this.latLong.latitude; double longitude = this.latLong.longitude; int tileSize = displayModel.getTileSize(); int pixelX = (int) (MercatorProjection.longitudeToPixelX(longitude, zoomLevel, tileSize) - topLeftPoint.x); int pixelY = (int) (MercatorProjection.latitudeToPixelY(latitude, zoomLevel, tileSize) - topLeftPoint.y); int radiusInPixel = getRadiusInPixels(latitude, zoomLevel); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight()); if (!canvasRectangle.intersectsCircle(pixelX, pixelY, radiusInPixel)) { return; } if (this.paintStroke != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintStroke); } if (this.paintFill != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintFill); } } Circle(LatLong latLong, float radius, Paint paintFill, Paint paintStroke); @Override synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint); synchronized Paint getPaintFill(); synchronized Paint getPaintStroke(); @Override synchronized LatLong getPosition(); synchronized float getRadius(); synchronized void setLatLong(LatLong latLong); synchronized void setPaintFill(Paint paintFill); synchronized void setPaintStroke(Paint paintStroke); synchronized void setRadius(float radius); }
Circle extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLong == null || (this.paintStroke == null && this.paintFill == null)) { return; } double latitude = this.latLong.latitude; double longitude = this.latLong.longitude; int tileSize = displayModel.getTileSize(); int pixelX = (int) (MercatorProjection.longitudeToPixelX(longitude, zoomLevel, tileSize) - topLeftPoint.x); int pixelY = (int) (MercatorProjection.latitudeToPixelY(latitude, zoomLevel, tileSize) - topLeftPoint.y); int radiusInPixel = getRadiusInPixels(latitude, zoomLevel); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight()); if (!canvasRectangle.intersectsCircle(pixelX, pixelY, radiusInPixel)) { return; } if (this.paintStroke != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintStroke); } if (this.paintFill != null) { canvas.drawCircle(pixelX, pixelY, radiusInPixel, this.paintFill); } } Circle(LatLong latLong, float radius, Paint paintFill, Paint paintStroke); @Override synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint); synchronized Paint getPaintFill(); synchronized Paint getPaintStroke(); @Override synchronized LatLong getPosition(); synchronized float getRadius(); synchronized void setLatLong(LatLong latLong); synchronized void setPaintFill(Paint paintFill); synchronized void setPaintStroke(Paint paintStroke); synchronized void setRadius(float radius);  }