@Test public void setterTest() { LatLong latLong = new LatLong(0, 0); Paint paintStroke = GRAPHIC_FACTORY.createPaint(); Polyline polyline = new Polyline(null, GRAPHIC_FACTORY); Assert.assertTrue(polyline.getLatLongs().isEmpty()); Assert.assertNull(polyline.getPaintStroke()); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(latLong); polyline.setPoints(latLongs); Assert.assertEquals(Arrays.asList(latLong), polyline.getLatLongs()); polyline.setPaintStroke(paintStroke); Assert.assertEquals(paintStroke, polyline.getPaintStroke()); } }
@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); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(new LatLong(0, 0)); latLongs.add(new LatLong(1, 1)); polyline.setPoints(latLongs); polyline.draw(boundingBox, (byte) 0, canvas, point); polyline.setPaintStroke(GRAPHIC_FACTORY.createPaint()); polyline.draw(boundingBox, (byte) 0, canvas, point); } }
@Override protected void addOverlayLayers(Layers layers) { Polyline polyline = new Polyline(Utils.createPaint( AndroidGraphicFactory.INSTANCE.createColor(Color.BLUE), 8, Style.STROKE), AndroidGraphicFactory.INSTANCE); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(latLong2); latLongs.add(latLong3); polyline.setPoints(latLongs); layers.add(polyline); }
@Override protected void setCenter() { super.setCenter(); BoundingBox bbox = DualOverviewMapViewer.this.mapView.getBoundingBox(); Paint paintStroke = Utils.createPaint( AndroidGraphicFactory.INSTANCE.createColor(Color.RED), 2, Style.STROKE); Polyline polygon = new Polyline(paintStroke, AndroidGraphicFactory.INSTANCE); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(new LatLong(bbox.minLatitude, bbox.minLongitude)); latLongs.add(new LatLong(bbox.minLatitude, bbox.maxLongitude)); latLongs.add(new LatLong(bbox.maxLatitude, bbox.maxLongitude)); latLongs.add(new LatLong(bbox.maxLatitude, bbox.minLongitude)); latLongs.add(new LatLong(bbox.minLatitude, bbox.minLongitude)); polygon.setPoints(latLongs); if (this.lastLine != null) { DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers() .remove(this.lastLine); } DualOverviewMapViewer.this.mapView2.getLayerManager() .getLayers().add(polygon); this.lastLine = polygon; }