Change continuous rendering settings

This commit is contained in:
Victor Shcherb 2011-10-08 22:08:07 +02:00
parent 4522ff2424
commit 155b4e2166
4 changed files with 51 additions and 31 deletions

View file

@ -524,7 +524,7 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{
private Set<Long> registerStreetInCities(String name, String nameEn, LatLon location, Collection<City> result) throws SQLException {
if (result.isEmpty()) {
return null;
return Collections.emptySet();
}
if (Algoritms.isEmpty(nameEn)) {
nameEn = Junidecode.unidecode(name);

View file

@ -564,11 +564,11 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> USE_STEP_BY_STEP_RENDERING = new BooleanPreference("use_step_by_step_rendering",
false, false);
true, false);
{
USE_STEP_BY_STEP_RENDERING.setModeDefaultValue(ApplicationMode.CAR, false);
USE_STEP_BY_STEP_RENDERING.setModeDefaultValue(ApplicationMode.BICYCLE, false);
USE_STEP_BY_STEP_RENDERING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
USE_STEP_BY_STEP_RENDERING.setModeDefaultValue(ApplicationMode.CAR, true);
USE_STEP_BY_STEP_RENDERING.setModeDefaultValue(ApplicationMode.BICYCLE, true);
USE_STEP_BY_STEP_RENDERING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
}
// this value string is synchronized with settings_pref.xml preference name

View file

@ -67,6 +67,11 @@ public class MapRenderRepositories {
// this box is checked for interrupted process or
private RotatedTileBox requestedBox = null;
// location of rendered bitmap
private RotatedTileBox prevBmpLocation = null;
// already rendered bitmap
private Bitmap prevBmp;
// location of rendered bitmap
private RotatedTileBox bmpLocation = null;
// already rendered bitmap
@ -131,6 +136,10 @@ public class MapRenderRepositories {
return bmpLocation;
}
public RotatedTileBox getPrevBmpLocation() {
return prevBmpLocation;
}
protected void closeConnection(BinaryMapIndexReader c, String file){
files.remove(file);
try {
@ -403,6 +412,8 @@ public class MapRenderRepositories {
boolean stepByStep = prefs.USE_STEP_BY_STEP_RENDERING.get();
// 1. generate image step by step
if (stepByStep) {
this.prevBmp = this.bmp;
this.prevBmpLocation = this.bmpLocation;
this.bmp = bmp;
this.bmpLocation = tileRect;
}
@ -422,6 +433,9 @@ public class MapRenderRepositories {
if (!stepByStep) {
this.bmp = bmp;
this.bmpLocation = tileRect;
} else {
this.prevBmpLocation = null;
this.prevBmp = null;
}
if(prefs.DEBUG_RENDERING_INFO.get()){
String timeInfo = "Search done in "+ searchTime+" ms"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
@ -463,14 +477,16 @@ public class MapRenderRepositories {
return bmp;
}
public Bitmap getPrevBitmap() {
return prevBmp;
}
public synchronized void clearCache() {
cObjects = new ArrayList<BinaryMapDataObject>();
cObjectsBox = new RectF();
if(bmp != null){
bmp = null;
}
requestedBox = bmpLocation = null;
prevBmp = bmp = null;
requestedBox = prevBmpLocation = bmpLocation = null;
}

View file

@ -114,28 +114,32 @@ public class MapVectorLayer extends BaseMapLayer {
}
MapRenderRepositories renderer = resourceManager.getRenderer();
Bitmap bmp = renderer.getBitmap();
RotatedTileBox bmpLoc = renderer.getBitmapLocation();
if (bmp != null && bmpLoc != null) {
float rot = bmpLoc.getRotate();
float mult = (float) MapUtils.getPowZoom(view.getZoom() - bmpLoc.getZoom());
float tx = view.getXTile();
float ty = view.getYTile();
float dleftX1 = (bmpLoc.getLeftTileX() * mult - tx) ;
float dtopY1 = (bmpLoc.getTopTileY() * mult - ty);
float cos = bmpLoc.getRotateCos();
float sin = bmpLoc.getRotateSin();
float x1 = MapUtils.calcDiffPixelX(sin, cos, dleftX1, dtopY1, view.getTileSize()) + view.getCenterPointX();
float y1 = MapUtils.calcDiffPixelY(sin, cos, dleftX1, dtopY1, view.getTileSize()) + view.getCenterPointY();
canvas.rotate(-rot, view.getCenterPointX(), view.getCenterPointY());
destImage.set(x1, y1, x1 + bmpLoc.getTileWidth() * mult * view.getTileSize(), y1 + bmpLoc.getTileHeight() * mult * view.getTileSize());
if(!bmp.isRecycled()){
canvas.drawBitmap(bmp, null, destImage, paintImg);
}
drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation());
drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation());
}
}
private void drawRenderedMap(Canvas canvas, Bitmap bmp, RotatedTileBox bmpLoc) {
if (bmp != null && bmpLoc != null) {
float rot = bmpLoc.getRotate();
float mult = (float) MapUtils.getPowZoom(view.getZoom() - bmpLoc.getZoom());
float tx = view.getXTile();
float ty = view.getYTile();
float dleftX1 = (bmpLoc.getLeftTileX() * mult - tx) ;
float dtopY1 = (bmpLoc.getTopTileY() * mult - ty);
float cos = bmpLoc.getRotateCos();
float sin = bmpLoc.getRotateSin();
float x1 = MapUtils.calcDiffPixelX(sin, cos, dleftX1, dtopY1, view.getTileSize()) + view.getCenterPointX();
float y1 = MapUtils.calcDiffPixelY(sin, cos, dleftX1, dtopY1, view.getTileSize()) + view.getCenterPointY();
canvas.rotate(-rot, view.getCenterPointX(), view.getCenterPointY());
destImage.set(x1, y1, x1 + bmpLoc.getTileWidth() * mult * view.getTileSize(), y1 + bmpLoc.getTileHeight() * mult * view.getTileSize());
if(!bmp.isRecycled()){
canvas.drawBitmap(bmp, null, destImage, paintImg);
}
}
}