move PausableThread to mapgenerator package
- add experimental regionlookup
This commit is contained in:
@@ -30,6 +30,7 @@ import org.oscim.database.MapDatabaseFactory;
|
||||
import org.oscim.database.MapDatabases;
|
||||
import org.oscim.database.MapInfo;
|
||||
import org.oscim.database.OpenResult;
|
||||
import org.oscim.stuff.RegionLookup;
|
||||
import org.oscim.theme.ExternalRenderTheme;
|
||||
import org.oscim.theme.InternalRenderTheme;
|
||||
import org.oscim.theme.RenderTheme;
|
||||
@@ -84,6 +85,7 @@ public class MapView extends GLSurfaceView {
|
||||
private int mNumMapWorkers = 4;
|
||||
private DebugSettings debugSettings;
|
||||
private String mRenderTheme;
|
||||
private Map<String, String> mMapOptions;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
@@ -145,6 +147,7 @@ public class MapView extends GLSurfaceView {
|
||||
mJobQueue = new JobQueue();
|
||||
|
||||
mMapRenderer = MapRendererFactory.createMapRenderer(this, mapGeneratorType);
|
||||
|
||||
mMapWorkers = new MapWorker[mNumMapWorkers];
|
||||
|
||||
for (int i = 0; i < mNumMapWorkers; i++) {
|
||||
@@ -162,7 +165,7 @@ public class MapView extends GLSurfaceView {
|
||||
if (i == 0)
|
||||
mMapDatabase = mapDatabase;
|
||||
|
||||
mMapWorkers[i] = new MapWorker(i, this, mapGenerator, mMapRenderer);
|
||||
mMapWorkers[i] = new MapWorker(i, mJobQueue, mapGenerator, mMapRenderer);
|
||||
mMapWorkers[i].start();
|
||||
}
|
||||
|
||||
@@ -186,21 +189,12 @@ public class MapView extends GLSurfaceView {
|
||||
|
||||
if (!debugFrameTime)
|
||||
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
||||
|
||||
mRegionLookup = new RegionLookup(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the debug settings which are used in this MapView.
|
||||
*/
|
||||
public DebugSettings getDebugSettings() {
|
||||
return debugSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the job queue which is used in this MapView.
|
||||
*/
|
||||
public JobQueue getJobQueue() {
|
||||
return mJobQueue;
|
||||
}
|
||||
RegionLookup mRegionLookup;
|
||||
|
||||
/**
|
||||
* @return the map database which is used for reading map files.
|
||||
@@ -216,13 +210,6 @@ public class MapView extends GLSurfaceView {
|
||||
return mMapViewPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the currently used projection of the map. Do not keep this object for a longer time.
|
||||
*/
|
||||
public Projection getProjection() {
|
||||
return mProjection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
if (this.isClickable())
|
||||
@@ -247,7 +234,12 @@ public class MapView extends GLSurfaceView {
|
||||
mMapRenderer.updateMap(true);
|
||||
}
|
||||
|
||||
private Map<String, String> mMapOptions;
|
||||
/**
|
||||
* @return the debug settings which are used in this MapView.
|
||||
*/
|
||||
public DebugSettings getDebugSettings() {
|
||||
return debugSettings;
|
||||
}
|
||||
|
||||
public Map<String, String> getMapOptions() {
|
||||
return mMapOptions;
|
||||
|
||||
@@ -334,22 +334,24 @@ public class TouchHandler {
|
||||
public void onLongPress(MotionEvent e) {
|
||||
Log.d("mapsforge", "long press");
|
||||
|
||||
mMapView.mRegionLookup.updateRegion();
|
||||
|
||||
// mMapView.zoom((byte) -1);
|
||||
|
||||
mPrevScale = 0;
|
||||
// mPrevScale = 0;
|
||||
|
||||
mTimer = new CountDownTimer((int) mScaleDuration, 30) {
|
||||
@Override
|
||||
public void onTick(long tick) {
|
||||
scale2(tick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
scale2(0);
|
||||
|
||||
}
|
||||
}.start();
|
||||
// mTimer = new CountDownTimer((int) mScaleDuration, 30) {
|
||||
// @Override
|
||||
// public void onTick(long tick) {
|
||||
// scale2(tick);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFinish() {
|
||||
// scale2(0);
|
||||
//
|
||||
// }
|
||||
// }.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
package org.oscim.view.mapgenerator;
|
||||
|
||||
import org.oscim.view.IMapRenderer;
|
||||
import org.oscim.view.MapView;
|
||||
import org.oscim.view.utils.PausableThread;
|
||||
|
||||
/**
|
||||
* A MapWorker uses a {@link IMapGenerator} to generate map tiles. It runs in a separate thread to avoid blocking the UI
|
||||
@@ -33,17 +31,15 @@ public class MapWorker extends PausableThread {
|
||||
/**
|
||||
* @param id
|
||||
* thread id
|
||||
* @param mapView
|
||||
* the MapView for which this MapWorker generates map tiles.
|
||||
* @param mapGenerator
|
||||
* ...
|
||||
* @param mapRenderer
|
||||
* ...
|
||||
*/
|
||||
public MapWorker(int id, MapView mapView, IMapGenerator mapGenerator,
|
||||
public MapWorker(int id, JobQueue jobQueue, IMapGenerator mapGenerator,
|
||||
IMapRenderer mapRenderer) {
|
||||
super();
|
||||
mJobQueue = mapView.getJobQueue();
|
||||
mJobQueue = jobQueue;
|
||||
mMapGenerator = mapGenerator;
|
||||
mMapRenderer = mapRenderer;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.view.utils;
|
||||
package org.oscim.view.mapgenerator;
|
||||
|
||||
/**
|
||||
* An abstract base class for threads which support pausing and resuming.
|
||||
Reference in New Issue
Block a user