Update some parameters to improve performances of MapViewDrawing.
This commit is contained in:
parent
bd1c393053
commit
d442a7e910
@ -21,6 +21,7 @@ import org.mapsforge.core.model.BoundingBox;
|
||||
import org.mapsforge.core.model.LatLong;
|
||||
import org.mapsforge.core.model.MapPosition;
|
||||
import org.mapsforge.core.util.LatLongUtils;
|
||||
import org.mapsforge.core.util.Parameters;
|
||||
import org.mapsforge.map.awt.graphics.AwtBitmap;
|
||||
import org.mapsforge.map.awt.graphics.AwtGraphicFactory;
|
||||
import org.mapsforge.map.awt.util.AwtUtil;
|
||||
@ -88,7 +89,7 @@ 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;
|
||||
}
|
||||
|
||||
@ -107,8 +108,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
public void moveTo(Point point) {
|
||||
Marker marker = (Marker) this.layers[0];
|
||||
this.delete();
|
||||
marker = new Marker(convertPoint(point), marker.getBitmap(), marker.getHorizontalOffset(),
|
||||
marker.getVerticalOffset());
|
||||
marker = new Marker(convertPoint(point), marker.getBitmap(),
|
||||
marker.getHorizontalOffset(), marker.getVerticalOffset());
|
||||
this.layers[0] = marker;
|
||||
MapViewDrawing.this.getLayerManager().getLayers().add(marker);
|
||||
}
|
||||
@ -118,11 +119,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 });
|
||||
}
|
||||
|
||||
}
|
||||
@ -188,6 +189,10 @@ public class MapViewDrawing extends MapView implements Drawing {
|
||||
private int tileSize;
|
||||
|
||||
public MapViewDrawing() {
|
||||
super();
|
||||
Parameters.NUMBER_OF_THREADS = 2;
|
||||
Parameters.SQUARE_FRAME_BUFFER = false;
|
||||
|
||||
getMapScaleBar().setVisible(true);
|
||||
DisplayModel model = getModel().displayModel;
|
||||
this.tileSize = DEFAULT_TILE_SIZE;
|
||||
@ -198,10 +203,11 @@ 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) {
|
||||
@ -258,7 +264,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
|
||||
@ -271,10 +278,12 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,7 +306,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 {
|
||||
|
Loading…
Reference in New Issue
Block a user