void setCanvasBitmap(Bitmap bitmap) { this.canvas.setBitmap(bitmap); }
public MapScaleBar(IMapViewPosition mapViewPosition, MapViewDimension mapViewDimension, DisplayModel displayModel, GraphicFactory graphicFactory, int width, int height) { this.mapViewPosition = mapViewPosition; this.mapViewDimension = mapViewDimension; this.displayModel = displayModel; this.graphicFactory = graphicFactory; this.mapScaleBitmap = graphicFactory.createBitmap(width, height); this.scaleBarPosition = DEFAULT_SCALE_BAR_POSITION; this.mapScaleCanvas = graphicFactory.createCanvas(); this.mapScaleCanvas.setBitmap(this.mapScaleBitmap); this.distanceUnitAdapter = MetricUnitAdapter.INSTANCE; this.visible = true; this.redrawNeeded = true; }
static void mergeSameSized(HillshadingBitmap center, HillshadingBitmap neighbor, HillshadingBitmap.Border border, int padding, Canvas copyCanvas) { HillshadingBitmap sink; HillshadingBitmap source; if (border == HillshadingBitmap.Border.EAST) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(sink.getWidth() - padding, padding, padding, sink.getHeight() - 2 * padding); copyCanvas.drawBitmap(source, (source.getWidth() - 2 * padding), 0); } else if (border == HillshadingBitmap.Border.WEST) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(0, padding, padding, sink.getHeight() - 2 * padding); copyCanvas.drawBitmap(source, 2 * padding - (source.getWidth()), 0); } else if (border == HillshadingBitmap.Border.NORTH) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(padding, 0, sink.getWidth() - 2 * padding, padding); copyCanvas.drawBitmap(source, 0, 2 * padding - (source.getHeight())); } else if (border == HillshadingBitmap.Border.SOUTH) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(padding, sink.getHeight() - padding, sink.getWidth() - 2 * padding, padding); copyCanvas.drawBitmap(source, 0, (source.getHeight() - 2 * padding)); } }
void setCanvasBitmap(Bitmap bitmap) { this.canvas.setBitmap(bitmap); }
Bitmap bitmap = frameBuffer.getDrawingBitmap(); if (bitmap != null) { this.drawingCanvas.setBitmap(bitmap);
@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); } }
@Test public void drawTest() { for (int tileSize : TILE_SIZES) { Polygon polygon = new Polygon(null, null, GRAPHIC_FACTORY); polygon.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); polygon.draw(boundingBox, (byte) 0, canvas, point); List<LatLong> latLongs = new ArrayList<>(); latLongs.add(new LatLong(0, 0)); latLongs.add(new LatLong(1, 1)); polygon.setPoints(latLongs); polygon.draw(boundingBox, (byte) 0, canvas, point); polygon.setPaintFill(GRAPHIC_FACTORY.createPaint()); polygon.setPaintStroke(GRAPHIC_FACTORY.createPaint()); polygon.draw(boundingBox, (byte) 0, canvas, point); } }
public MapScaleBar(IMapViewPosition mapViewPosition, MapViewDimension mapViewDimension, DisplayModel displayModel, GraphicFactory graphicFactory, int width, int height) { this.mapViewPosition = mapViewPosition; this.mapViewDimension = mapViewDimension; this.displayModel = displayModel; this.graphicFactory = graphicFactory; this.mapScaleBitmap = graphicFactory.createBitmap(width, height); this.scaleBarPosition = DEFAULT_SCALE_BAR_POSITION; this.mapScaleCanvas = graphicFactory.createCanvas(); this.mapScaleCanvas.setBitmap(this.mapScaleBitmap); this.distanceUnitAdapter = MetricUnitAdapter.INSTANCE; this.visible = true; this.redrawNeeded = true; }
@Test public void drawTest() { for (int tileSize : TILE_SIZES) { Marker marker = new Marker(null, null, 0, 0); marker.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); marker.draw(boundingBox, (byte) 0, canvas, point); marker.setLatLong(new LatLong(0, 0)); marker.draw(boundingBox, (byte) 0, canvas, point); marker.setBitmap(GRAPHIC_FACTORY.createBitmap(10, 20)); marker.draw(boundingBox, (byte) 0, canvas, point); } }
@Test public void getTopLeftPointTest() { for (int tileSize : TILE_SIZES) { MapPosition mapPosition = new MapPosition(new LatLong(0, 0), (byte) 0); Canvas canvas = GRAPHIC_FACTORY.createCanvas(); canvas.setBitmap(GRAPHIC_FACTORY.createBitmap(tileSize, tileSize)); Point expectedPoint = new Point(0, 0); Assert.assertEquals(expectedPoint, MapPositionUtil.getTopLeftPoint(mapPosition, canvas.getDimension(), tileSize)); mapPosition = new MapPosition(new LatLong(0, 90), (byte) 1); expectedPoint = new Point(tileSize, (float) tileSize / 2); Assert.assertEquals(expectedPoint, MapPositionUtil.getTopLeftPoint(mapPosition, canvas.getDimension(), tileSize)); } } }
@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); } }
@Test public void getBoundingBoxTest() { for (int tileSize : TILE_SIZES) { MapPosition mapPosition = new MapPosition(new LatLong(0, 0), (byte) 0); Canvas canvas = GRAPHIC_FACTORY.createCanvas(); canvas.setBitmap(GRAPHIC_FACTORY.createBitmap(tileSize, tileSize)); double latitudeMin = MercatorProjection.LATITUDE_MIN; double latitudeMax = MercatorProjection.LATITUDE_MAX; BoundingBox expectedBoundingBox = new BoundingBox(latitudeMin, -180, latitudeMax, 180); Assert.assertEquals(expectedBoundingBox, MapPositionUtil.getBoundingBox(mapPosition, canvas.getDimension(), tileSize)); mapPosition = new MapPosition(new LatLong(0, 90), (byte) 0); expectedBoundingBox = new BoundingBox(latitudeMin, -90, latitudeMax, 180); Assert.assertEquals(expectedBoundingBox, MapPositionUtil.getBoundingBox(mapPosition, canvas.getDimension(), tileSize)); mapPosition = new MapPosition(new LatLong(90, -180), (byte) 0); expectedBoundingBox = new BoundingBox(0, -180, latitudeMax, 0); Assert.assertEquals(expectedBoundingBox, MapPositionUtil.getBoundingBox(mapPosition, canvas.getDimension(), tileSize)); } }
static void mergeSameSized(HillshadingBitmap center, HillshadingBitmap neighbor, HillshadingBitmap.Border border, int padding, Canvas copyCanvas) { HillshadingBitmap sink; HillshadingBitmap source; if (border == HillshadingBitmap.Border.EAST) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(sink.getWidth() - padding, padding, padding, sink.getHeight() - 2 * padding); copyCanvas.drawBitmap(source, (source.getWidth() - 2 * padding), 0); } else if (border == HillshadingBitmap.Border.WEST) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(0, padding, padding, sink.getHeight() - 2 * padding); copyCanvas.drawBitmap(source, 2 * padding - (source.getWidth()), 0); } else if (border == HillshadingBitmap.Border.NORTH) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(padding, 0, sink.getWidth() - 2 * padding, padding); copyCanvas.drawBitmap(source, 0, 2 * padding - (source.getHeight())); } else if (border == HillshadingBitmap.Border.SOUTH) { sink = center; source = neighbor; copyCanvas.setBitmap(sink); copyCanvas.setClip(padding, sink.getHeight() - padding, sink.getWidth() - 2 * padding, padding); copyCanvas.drawBitmap(source, 0, (source.getHeight() - 2 * padding)); } }
Bitmap bitmap = frameBuffer.getDrawingBitmap(); if (bitmap != null) { this.drawingCanvas.setBitmap(bitmap);