@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); } }
public void setPosition(double latitude, double longitude, float accuracy) { synchronized (this) { LatLong latLong = new LatLong(latitude, longitude); this.marker.setLatLong(latLong); if (this.circle != null) { this.circle.setLatLong(latLong); this.circle.setRadius(accuracy); } requestRedraw(); } } }
public void mouseDragged(MouseEvent e) { if (isLeftMouseButton(e)) { if (isMousePressedOnMarker()) { startDragCursor(mapView); LatLong latLong = projection.fromPixels(e.getX(), e.getY()); mousePressMarker.setLatLong(latLong); mousePressMarker.requestRedraw(); } else if (getLastMousePoint() != null) { Point point = e.getPoint(); int moveHorizontal = point.x - lastMousePressPoint.x; int moveVertical = point.y - lastMousePressPoint.y; mapView.getModel().mapViewPosition.moveCenter(moveHorizontal, moveVertical); lastMousePressPoint = point; } } }
@Test public void setterTest() { LatLong latLong = new LatLong(0, 0); Bitmap bitmap = GRAPHIC_FACTORY.createBitmap(10, 20); Marker marker = new Marker(null, null, 0, 0); Assert.assertNull(marker.getLatLong()); Assert.assertNull(marker.getBitmap()); Assert.assertEquals(0, marker.getHorizontalOffset()); Assert.assertEquals(0, marker.getVerticalOffset()); marker.setLatLong(latLong); Assert.assertEquals(latLong, marker.getLatLong()); marker.setBitmap(bitmap); Assert.assertEquals(bitmap, marker.getBitmap()); marker.setHorizontalOffset(-1); Assert.assertEquals(-1, marker.getHorizontalOffset()); marker.setVerticalOffset(-2); Assert.assertEquals(-2, marker.getVerticalOffset()); } }