private static Circle createCircle(LatLong latLong, float radius, Paint paintFill, Paint paintStroke) { return new Circle(latLong, radius, paintFill, paintStroke); }
@Test public void constructorTest() { LatLong latLong = new LatLong(0, 0); int radius = 3; Paint paintFill = GRAPHIC_FACTORY.createPaint(); Paint paintStroke = GRAPHIC_FACTORY.createPaint(); Circle circle = new Circle(latLong, radius, paintFill, paintStroke); Assert.assertEquals(latLong, circle.getPosition()); Assert.assertEquals(radius, circle.getRadius(), 0); Assert.assertEquals(paintFill, circle.getPaintFill()); Assert.assertEquals(paintStroke, circle.getPaintStroke()); verifyInvalidRadius(latLong, -1, paintFill, paintStroke); verifyInvalidRadius(latLong, Float.NaN, paintFill, paintStroke); }
@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); } }
final Circle circle = new Circle(point, CIRCLE_WIFI_CATALOG_WIDTH, mPaintCatalogFill, mPaintCatalogStroke); mCatalogObjects.add(circle);
@Test public void setterTest() { LatLong latLong = new LatLong(1, 2); Paint paintFill = GRAPHIC_FACTORY.createPaint(); Paint paintStroke = GRAPHIC_FACTORY.createPaint(); Circle circle = new Circle(null, 0, null, null); Assert.assertNull(circle.getPosition()); Assert.assertEquals(0, circle.getRadius(), 0); Assert.assertNull(circle.getPaintFill()); Assert.assertNull(circle.getPaintStroke()); circle.setLatLong(latLong); Assert.assertEquals(latLong, circle.getPosition()); circle.setRadius(1); Assert.assertEquals(1, circle.getRadius(), 0); circle.setPaintFill(paintFill); Assert.assertEquals(paintFill, circle.getPaintFill()); circle.setPaintStroke(paintStroke); Assert.assertEquals(paintStroke, circle.getPaintStroke()); } }
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override protected void createLayers() { super.createLayers(); // marker to show at the location Drawable drawable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDrawable(R.drawable.ic_maps_indicator_current_position) : getResources().getDrawable(R.drawable.ic_maps_indicator_current_position); Marker marker = new Marker(null, AndroidGraphicFactory.convertToBitmap(drawable), 0, 0); // circle to show the location accuracy (optional) Circle circle = new Circle(null, 0, getPaint(AndroidGraphicFactory.INSTANCE.createColor(48, 0, 0, 255), 0, Style.FILL), getPaint(AndroidGraphicFactory.INSTANCE.createColor(160, 0, 0, 255), 2, Style.STROKE)); // create the overlay this.myLocationOverlay = new MyLocationOverlay(marker, circle); this.mapView.getLayerManager().getLayers().add(this.myLocationOverlay); }
protected void onLongPress(LatLong position) { if (this.mapRequest == null) this.mapRequest = new MapRequest(); this.mapRequest.setNorth(position.latitude); this.mapRequest.setEast(position.longitude); showAddress(position); Layers layers = mapView.getLayerManager().getLayers(); //this.mapViews.get(0).getLayerManager().getLayers() if (index >= 0) layers.remove(index); float circleSize = 8 * this.mapView.getModel().displayModel.getScaleFactor(); Paint GREEN = Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.GREEN), 0, Style.FILL); Circle circle = new Circle(position, circleSize, GREEN, null); layers.add(circle); index = layers.size() - 1; circle.requestRedraw(); }