Clean code.
This commit is contained in:
@@ -105,14 +105,15 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
Color color;
|
||||
|
||||
public MapViewMarkerOverlay(Marker marker, Color color) {
|
||||
super(new Layer[] { marker });
|
||||
super(new Layer[]{ marker });
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getPoint() {
|
||||
Marker marker = (Marker) super.layers[0];
|
||||
return new Point(marker.getLatLong().getLongitude(), marker.getLatLong().getLatitude());
|
||||
return new Point((float) marker.getLatLong().getLongitude(),
|
||||
(float) marker.getLatLong().getLatitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,11 +139,11 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
private class MapViewPathOverlay extends MapViewOverlay implements PathOverlay {
|
||||
|
||||
public MapViewPathOverlay(PolylineAutoScaling path, Marker origin, Marker destination) {
|
||||
super(new Layer[] { path, origin, destination });
|
||||
super(new Layer[]{ path, origin, destination });
|
||||
}
|
||||
|
||||
public MapViewPathOverlay(PolylineAutoScaling path) {
|
||||
super(new Layer[] { path });
|
||||
super(new Layer[]{ path });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -253,7 +254,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
super.paint(graphics);
|
||||
if (this.zoomControls != null) {
|
||||
this.zoomControls.setZoomLevel(this.getModel().mapViewPosition.getZoomLevel());
|
||||
this.zoomControls.draw((Graphics2D) graphics, getWidth() - this.zoomControls.getWidth() - 20,
|
||||
this.zoomControls.draw((Graphics2D) graphics,
|
||||
getWidth() - this.zoomControls.getWidth() - 20,
|
||||
this.getHeight() - this.zoomControls.getHeight() - 10, this);
|
||||
}
|
||||
|
||||
@@ -263,17 +265,19 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
return new LatLong(point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
|
||||
private TileRendererLayer createTileRendererLayer(TileCache tileCache, MapDataStore mapDataStore,
|
||||
MapViewPosition mapViewPosition, HillsRenderConfig hillsRenderConfig) {
|
||||
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore, mapViewPosition, false,
|
||||
true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
|
||||
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
|
||||
MapDataStore mapDataStore, MapViewPosition mapViewPosition,
|
||||
HillsRenderConfig hillsRenderConfig) {
|
||||
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
|
||||
mapViewPosition, false, true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
|
||||
@Override
|
||||
public boolean onTap(LatLong tapLatLong, org.mapsforge.core.model.Point layerXY,
|
||||
org.mapsforge.core.model.Point tapXY) {
|
||||
if (zoomControls.contains(new java.awt.Point((int) tapXY.x, (int) tapXY.y))) {
|
||||
return false;
|
||||
}
|
||||
Point pt = new Point(tapLatLong.getLongitude(), tapLatLong.getLatitude());
|
||||
Point pt = new Point((float) tapLatLong.getLongitude(),
|
||||
(float) tapLatLong.getLatitude());
|
||||
for (DrawingClickListener listener: MapViewDrawing.this.drawingClickListeners) {
|
||||
listener.mouseClicked(pt);
|
||||
}
|
||||
@@ -326,7 +330,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
public void drawGraph(File file) {
|
||||
|
||||
// Tile cache
|
||||
TileCache tileCache = AwtUtil.createTileCache(tileSize, getModel().frameBufferModel.getOverdrawFactor(), 1024,
|
||||
TileCache tileCache = AwtUtil.createTileCache(tileSize,
|
||||
getModel().frameBufferModel.getOverdrawFactor(), 1024,
|
||||
new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()));
|
||||
|
||||
// Layers
|
||||
@@ -339,12 +344,15 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
BoundingBox boundingBox = mapDataStore.boundingBox();
|
||||
|
||||
final Model model = getModel();
|
||||
if (model.mapViewPosition.getZoomLevel() == 0 || !boundingBox.contains(model.mapViewPosition.getCenter())) {
|
||||
byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(), boundingBox,
|
||||
model.displayModel.getTileSize());
|
||||
model.mapViewPosition.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
|
||||
if (model.mapViewPosition.getZoomLevel() == 0
|
||||
|| !boundingBox.contains(model.mapViewPosition.getCenter())) {
|
||||
byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(),
|
||||
boundingBox, model.displayModel.getTileSize());
|
||||
model.mapViewPosition
|
||||
.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
|
||||
zoomControls.setZoomLevel(zoomLevel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -366,7 +374,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
PathOverlay overlay = null;
|
||||
if (markers) {
|
||||
Marker origin = createMarker(path.getOrigin().getPoint(), DEFAULT_PATH_COLOR),
|
||||
destination = createMarker(path.getDestination().getPoint(), DEFAULT_PATH_COLOR);
|
||||
destination = createMarker(path.getDestination().getPoint(),
|
||||
DEFAULT_PATH_COLOR);
|
||||
overlay = new MapViewPathOverlay(line, origin, destination);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user