blob: 8c9e0c3804868da6e4a746baf27f66cc9085e5da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
package cgeo.geocaching.maps.mapsforge.v024;
import cgeo.geocaching.maps.PositionOverlay;
import cgeo.geocaching.maps.ScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
import cgeo.geocaching.maps.interfaces.OverlayImpl;
import org.mapsforge.android.mapsold.Overlay;
import org.mapsforge.android.mapsold.Projection;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Point;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class MapsforgeOverlay extends Overlay implements OverlayImpl {
private GeneralOverlay overlayBase = null;
private Lock lock = new ReentrantLock();
public MapsforgeOverlay(Activity activityIn, OverlayImpl.OverlayType ovlType) {
switch (ovlType) {
case PositionOverlay:
overlayBase = new PositionOverlay(activityIn, this);
break;
case ScaleOverlay:
overlayBase = new ScaleOverlay(activityIn, this);
break;
default:
throw new IllegalStateException();
}
}
@Override
protected void drawOverlayBitmap(Canvas canvas, Point drawPosition,
Projection projection, byte drawZoomLevel) {
if (overlayBase != null) {
overlayBase.drawOverlayBitmap(canvas, drawPosition, new MapsforgeMapProjection(projection), drawZoomLevel);
}
}
public GeneralOverlay getBase() {
return overlayBase;
}
@Override
public void lock() {
lock.lock();
}
@Override
public void unlock() {
lock.unlock();
}
@Override
public MapViewImpl getMapViewImpl() {
return (MapViewImpl) internalMapView;
}
}
|