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.LatLong;
|
||||||
import org.mapsforge.core.model.MapPosition;
|
import org.mapsforge.core.model.MapPosition;
|
||||||
import org.mapsforge.core.util.LatLongUtils;
|
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.AwtBitmap;
|
||||||
import org.mapsforge.map.awt.graphics.AwtGraphicFactory;
|
import org.mapsforge.map.awt.graphics.AwtGraphicFactory;
|
||||||
import org.mapsforge.map.awt.util.AwtUtil;
|
import org.mapsforge.map.awt.util.AwtUtil;
|
||||||
@ -107,8 +108,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
public void moveTo(Point point) {
|
public void moveTo(Point point) {
|
||||||
Marker marker = (Marker) this.layers[0];
|
Marker marker = (Marker) this.layers[0];
|
||||||
this.delete();
|
this.delete();
|
||||||
marker = new Marker(convertPoint(point), marker.getBitmap(), marker.getHorizontalOffset(),
|
marker = new Marker(convertPoint(point), marker.getBitmap(),
|
||||||
marker.getVerticalOffset());
|
marker.getHorizontalOffset(), marker.getVerticalOffset());
|
||||||
this.layers[0] = marker;
|
this.layers[0] = marker;
|
||||||
MapViewDrawing.this.getLayerManager().getLayers().add(marker);
|
MapViewDrawing.this.getLayerManager().getLayers().add(marker);
|
||||||
}
|
}
|
||||||
@ -188,6 +189,10 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
private int tileSize;
|
private int tileSize;
|
||||||
|
|
||||||
public MapViewDrawing() {
|
public MapViewDrawing() {
|
||||||
|
super();
|
||||||
|
Parameters.NUMBER_OF_THREADS = 2;
|
||||||
|
Parameters.SQUARE_FRAME_BUFFER = false;
|
||||||
|
|
||||||
getMapScaleBar().setVisible(true);
|
getMapScaleBar().setVisible(true);
|
||||||
DisplayModel model = getModel().displayModel;
|
DisplayModel model = getModel().displayModel;
|
||||||
this.tileSize = DEFAULT_TILE_SIZE;
|
this.tileSize = DEFAULT_TILE_SIZE;
|
||||||
@ -198,10 +203,11 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
return new LatLong(point.getLatitude(), point.getLongitude());
|
return new LatLong(point.getLatitude(), point.getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
private TileRendererLayer createTileRendererLayer(TileCache tileCache, MapDataStore mapDataStore,
|
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
|
||||||
MapViewPosition mapViewPosition, HillsRenderConfig hillsRenderConfig) {
|
MapDataStore mapDataStore, MapViewPosition mapViewPosition,
|
||||||
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore, mapViewPosition, false,
|
HillsRenderConfig hillsRenderConfig) {
|
||||||
true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
|
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
|
||||||
|
mapViewPosition, false, true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTap(LatLong tapLatLong, org.mapsforge.core.model.Point layerXY,
|
public boolean onTap(LatLong tapLatLong, org.mapsforge.core.model.Point layerXY,
|
||||||
org.mapsforge.core.model.Point tapXY) {
|
org.mapsforge.core.model.Point tapXY) {
|
||||||
@ -258,7 +264,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
public void drawGraph(File file) {
|
public void drawGraph(File file) {
|
||||||
|
|
||||||
// Tile cache
|
// 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()));
|
new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()));
|
||||||
|
|
||||||
// Layers
|
// Layers
|
||||||
@ -271,10 +278,12 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
BoundingBox boundingBox = mapDataStore.boundingBox();
|
BoundingBox boundingBox = mapDataStore.boundingBox();
|
||||||
|
|
||||||
final Model model = getModel();
|
final Model model = getModel();
|
||||||
if (model.mapViewPosition.getZoomLevel() == 0 || !boundingBox.contains(model.mapViewPosition.getCenter())) {
|
if (model.mapViewPosition.getZoomLevel() == 0
|
||||||
byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(), boundingBox,
|
|| !boundingBox.contains(model.mapViewPosition.getCenter())) {
|
||||||
model.displayModel.getTileSize());
|
byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(),
|
||||||
model.mapViewPosition.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
|
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;
|
PathOverlay overlay = null;
|
||||||
if (markers) {
|
if (markers) {
|
||||||
Marker origin = createMarker(path.getOrigin().getPoint(), DEFAULT_PATH_COLOR),
|
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);
|
overlay = new MapViewPathOverlay(line, origin, destination);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user