@Test public void drawTest() { for (int tileSize : TILE_SIZES) { Polyline polyline = new Polyline(null, GRAPHIC_FACTORY); polyline.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); polyline.draw(boundingBox, (byte) 0, canvas, point); polyline.getLatLongs().add(new LatLong(0, 0)); polyline.getLatLongs().add(new LatLong(1, 1)); polyline.draw(boundingBox, (byte) 0, canvas, point); polyline.setPaintStroke(GRAPHIC_FACTORY.createPaint()); polyline.draw(boundingBox, (byte) 0, canvas, point); } }
@Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLongs.isEmpty() || this.paintStroke == null) { return; } Iterator<LatLong> iterator = this.latLongs.iterator(); if (!iterator.hasNext()) { return; } LatLong latLong = iterator.next(); int tileSize = displayModel.getTileSize(); float x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); float y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); Path path = this.graphicFactory.createPath(); path.moveTo(x, y); while (iterator.hasNext()) { latLong = iterator.next(); x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); path.lineTo(x, y); } canvas.drawPath(path, this.paintStroke); }
Polyline extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLongs.isEmpty() || this.paintStroke == null) { return; } Iterator<LatLong> iterator = this.latLongs.iterator(); if (!iterator.hasNext()) { return; } LatLong latLong = iterator.next(); int tileSize = displayModel.getTileSize(); float x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); float y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); Path path = this.graphicFactory.createPath(); path.moveTo(x, y); while (iterator.hasNext()) { latLong = iterator.next(); x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); path.lineTo(x, y); } canvas.drawPath(path, this.paintStroke); } }
Polyline extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLongs.isEmpty() || this.paintStroke == null) { return; } Iterator<LatLong> iterator = this.latLongs.iterator(); if (!iterator.hasNext()) { return; } LatLong latLong = iterator.next(); int tileSize = displayModel.getTileSize(); float x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); float y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); Path path = this.graphicFactory.createPath(); path.moveTo(x, y); while (iterator.hasNext()) { latLong = iterator.next(); x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); path.lineTo(x, y); } canvas.drawPath(path, this.paintStroke); } Polyline(Paint paintStroke, GraphicFactory graphicFactory); }
Polyline extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLongs.isEmpty() || this.paintStroke == null) { return; } Iterator<LatLong> iterator = this.latLongs.iterator(); if (!iterator.hasNext()) { return; } LatLong latLong = iterator.next(); int tileSize = displayModel.getTileSize(); float x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); float y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); Path path = this.graphicFactory.createPath(); path.moveTo(x, y); while (iterator.hasNext()) { latLong = iterator.next(); x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); path.lineTo(x, y); } canvas.drawPath(path, this.paintStroke); } Polyline(Paint paintStroke, GraphicFactory graphicFactory); @Override synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint); List<LatLong> getLatLongs(); synchronized Paint getPaintStroke(); synchronized void setPaintStroke(Paint paintStroke); }
Polyline extends Layer { @Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) { if (this.latLongs.isEmpty() || this.paintStroke == null) { return; } Iterator<LatLong> iterator = this.latLongs.iterator(); if (!iterator.hasNext()) { return; } LatLong latLong = iterator.next(); int tileSize = displayModel.getTileSize(); float x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); float y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); Path path = this.graphicFactory.createPath(); path.moveTo(x, y); while (iterator.hasNext()) { latLong = iterator.next(); x = (float) (MercatorProjection.longitudeToPixelX(latLong.longitude, zoomLevel, tileSize) - topLeftPoint.x); y = (float) (MercatorProjection.latitudeToPixelY(latLong.latitude, zoomLevel, tileSize) - topLeftPoint.y); path.lineTo(x, y); } canvas.drawPath(path, this.paintStroke); } Polyline(Paint paintStroke, GraphicFactory graphicFactory); @Override synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint); List<LatLong> getLatLongs(); synchronized Paint getPaintStroke(); synchronized void setPaintStroke(Paint paintStroke);  }