aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java19
-rwxr-xr-xmain/src/cgeo/geocaching/maps/DirectionDrawer.java48
-rwxr-xr-xmain/src/cgeo/geocaching/maps/DirectionOverlay.java83
-rwxr-xr-xmain/src/cgeo/geocaching/maps/DistanceDrawer.java (renamed from main/src/cgeo/geocaching/maps/DistanceOverlay.java)50
-rw-r--r--main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java39
-rwxr-xr-xmain/src/cgeo/geocaching/maps/google/v1/GoogleDirectionOverlay.java53
-rwxr-xr-xmain/src/cgeo/geocaching/maps/google/v1/GoogleDistanceOverlay.java53
-rw-r--r--main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java20
-rw-r--r--main/src/cgeo/geocaching/maps/google/v1/GoogleOverlay.java9
-rw-r--r--main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java8
-rwxr-xr-xmain/src/cgeo/geocaching/maps/mapsforge/MapsforgeDirectionOverlay.java56
-rwxr-xr-xmain/src/cgeo/geocaching/maps/mapsforge/MapsforgeDistanceOverlay.java56
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java20
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java11
-rwxr-xr-xmain/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDirectionOverlay.java57
-rwxr-xr-xmain/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDistanceOverlay.java57
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java20
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java11
18 files changed, 108 insertions, 562 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index afbc1ed..a7983bb 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -140,8 +140,6 @@ public class CGeoMap extends AbstractMap implements ViewFactory {
private MapViewImpl mapView;
private CachesOverlay overlayCaches;
private PositionAndScaleOverlay overlayPositionAndScale;
- private DistanceOverlay overlayDistance;
- private DirectionOverlay overlayDirection;
final private GeoDirHandler geoDirUpdate = new UpdateLoc(this);
private SearchResult searchIntent = null;
@@ -452,18 +450,12 @@ public class CGeoMap extends AbstractMap implements ViewFactory {
overlayCaches = mapView.createAddMapOverlay(mapView.getContext(), getResources().getDrawable(R.drawable.marker));
- if (coordsIntent != null || geocodeIntent != null) {
- overlayDirection = mapView.createAddDirectionOverlay(coordsIntent, geocodeIntent);
- }
- overlayPositionAndScale = mapView.createAddPositionAndScaleOverlay();
+ overlayPositionAndScale = mapView.createAddPositionAndScaleOverlay(coordsIntent, geocodeIntent);
if (trailHistory != null) {
overlayPositionAndScale.setHistory(trailHistory);
}
- if (coordsIntent != null || geocodeIntent != null) {
- overlayDistance = mapView.createAddDistanceOverlay(coordsIntent, geocodeIntent);
- }
mapView.repaintRequired(null);
@@ -1011,19 +1003,10 @@ public class CGeoMap extends AbstractMap implements ViewFactory {
}
if (needsRepaintForDistanceOrAccuracy || needsRepaintForHeading) {
- if (map.overlayDirection != null) {
- map.overlayDirection.setCoordinates(currentLocation);
- map.mapView.repaintRequired(map.overlayDirection);
- }
map.overlayPositionAndScale.setCoordinates(currentLocation);
map.overlayPositionAndScale.setHeading(currentHeading);
map.mapView.repaintRequired(map.overlayPositionAndScale);
-
- if (map.overlayDistance != null) {
- map.overlayDistance.setCoordinates(currentLocation);
- map.mapView.repaintRequired(map.overlayDistance);
- }
}
}
} catch (final RuntimeException e) {
diff --git a/main/src/cgeo/geocaching/maps/DirectionDrawer.java b/main/src/cgeo/geocaching/maps/DirectionDrawer.java
new file mode 100755
index 0000000..ccef59c
--- /dev/null
+++ b/main/src/cgeo/geocaching/maps/DirectionDrawer.java
@@ -0,0 +1,48 @@
+package cgeo.geocaching.maps;
+
+import cgeo.geocaching.location.Geopoint;
+import cgeo.geocaching.maps.interfaces.MapItemFactory;
+import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
+import cgeo.geocaching.settings.Settings;
+
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Point;
+import android.location.Location;
+
+public class DirectionDrawer {
+ private Geopoint currentCoords;
+ private final Geopoint destinationCoords;
+ private final MapItemFactory mapItemFactory;
+
+ private Paint line = null;
+
+ public DirectionDrawer(final Geopoint coords) {
+ this.destinationCoords = coords;
+ this.mapItemFactory = Settings.getMapProvider().getMapItemFactory();
+ }
+
+ public void setCoordinates(final Location coordinatesIn) {
+ currentCoords = new Geopoint(coordinatesIn);
+ }
+
+ void drawDirection(final Canvas canvas, final MapProjectionImpl projection) {
+ if (currentCoords == null) {
+ return;
+ }
+
+ if (line == null) {
+ line = new Paint();
+ line.setAntiAlias(true);
+ line.setStrokeWidth(2f);
+ line.setColor(0xFFEB391E);
+ }
+
+ final Point pos = new Point();
+ final Point dest = new Point();
+ projection.toPixels(mapItemFactory.getGeoPointBase(currentCoords), pos);
+ projection.toPixels(mapItemFactory.getGeoPointBase(destinationCoords), dest);
+
+ canvas.drawLine(pos.x, pos.y, dest.x, dest.y, line);
+ }
+}
diff --git a/main/src/cgeo/geocaching/maps/DirectionOverlay.java b/main/src/cgeo/geocaching/maps/DirectionOverlay.java
deleted file mode 100755
index 0807afa..0000000
--- a/main/src/cgeo/geocaching/maps/DirectionOverlay.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package cgeo.geocaching.maps;
-
-import cgeo.geocaching.DataStore;
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.location.Viewport;
-import cgeo.geocaching.maps.interfaces.GeneralOverlay;
-import cgeo.geocaching.maps.interfaces.MapItemFactory;
-import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
-import cgeo.geocaching.maps.interfaces.MapViewImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl;
-import cgeo.geocaching.settings.Settings;
-
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Point;
-import android.location.Location;
-
-public class DirectionOverlay implements GeneralOverlay {
- private Geopoint currentCoords;
- private final Geopoint destinationCoords;
- private final MapItemFactory mapItemFactory;
-
- private OverlayImpl ovlImpl = null;
-
- private Paint line = null;
-
- public DirectionOverlay(final OverlayImpl ovlImpl, final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- this.ovlImpl = ovlImpl;
-
- if (coords == null) {
- final Viewport bounds = DataStore.getBounds(geocode);
- if (bounds == null) {
- this.destinationCoords = new Geopoint(0, 0);
- } else {
- this.destinationCoords = bounds.center;
- }
- } else {
- this.destinationCoords = coords;
- }
-
- this.mapItemFactory = Settings.getMapProvider().getMapItemFactory();
- }
-
- public void setCoordinates(final Location coordinatesIn) {
- currentCoords = new Geopoint(coordinatesIn);
- }
-
- @Override
- public void draw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) {
- drawInternal(canvas, mapView.getMapProjection());
- }
-
- @Override
- public void drawOverlayBitmap(final Canvas canvas, final Point drawPosition, final MapProjectionImpl projection, final byte drawZoomLevel) {
- drawInternal(canvas, projection);
- }
-
- private void drawInternal(final Canvas canvas, final MapProjectionImpl projection) {
- if (currentCoords == null) {
- return;
- }
-
- if (line == null) {
- line = new Paint();
- line.setAntiAlias(true);
- line.setStrokeWidth(2f);
- line.setColor(0xFFEB391E);
- }
-
- final Point pos = new Point();
- final Point dest = new Point();
- projection.toPixels(mapItemFactory.getGeoPointBase(currentCoords), pos);
- projection.toPixels(mapItemFactory.getGeoPointBase(destinationCoords), dest);
-
- canvas.drawLine(pos.x, pos.y, dest.x, dest.y, line);
- }
-
- @Override
- public OverlayImpl getOverlayImpl() {
- return this.ovlImpl;
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/DistanceOverlay.java b/main/src/cgeo/geocaching/maps/DistanceDrawer.java
index 211db98..6450f70 100755
--- a/main/src/cgeo/geocaching/maps/DistanceOverlay.java
+++ b/main/src/cgeo/geocaching/maps/DistanceDrawer.java
@@ -1,20 +1,14 @@
package cgeo.geocaching.maps;
import cgeo.geocaching.CgeoApplication;
-import cgeo.geocaching.DataStore;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.location.Units;
-import cgeo.geocaching.location.Viewport;
-import cgeo.geocaching.maps.interfaces.GeneralOverlay;
-import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl;
import android.content.Context;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
@@ -22,14 +16,13 @@ import android.location.Location;
import android.util.DisplayMetrics;
import android.view.WindowManager;
-public class DistanceOverlay implements GeneralOverlay {
+public class DistanceDrawer {
private Geopoint currentCoords;
private final Geopoint destinationCoords;
private Paint paintBox = null;
private Paint paintBoxShadow = null;
private Paint paintText = null;
- private Paint paintCompass = null;
private BlurMaskFilter blurBoxShadow = null;
private final boolean needsInvertedColors;
@@ -40,21 +33,8 @@ public class DistanceOverlay implements GeneralOverlay {
private String distanceText = null;
- private OverlayImpl ovlImpl = null;
-
- public DistanceOverlay(final OverlayImpl ovlImpl, final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- this.ovlImpl = ovlImpl;
-
- if (coords == null) {
- final Viewport bounds = DataStore.getBounds(geocode);
- if (bounds == null) {
- this.destinationCoords = new Geopoint(0, 0);
- } else {
- this.destinationCoords = bounds.center;
- }
- } else {
- this.destinationCoords = coords;
- }
+ public DistanceDrawer(final MapViewImpl mapView, final Geopoint destinationCoords) {
+ this.destinationCoords = destinationCoords;
final DisplayMetrics metrics = new DisplayMetrics();
final WindowManager windowManager = (WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE);
@@ -83,17 +63,7 @@ public class DistanceOverlay implements GeneralOverlay {
distanceText = Units.getDistanceFromKilometers(distance);
}
- @Override
- public void draw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) {
- drawInternal(canvas);
- }
-
- @Override
- public void drawOverlayBitmap(final Canvas canvas, final Point drawPosition, final MapProjectionImpl projection, final byte drawZoomLevel) {
- drawInternal(canvas);
- }
-
- private void drawInternal(final Canvas canvas) {
+ void drawDistance(final Canvas canvas) {
if (currentCoords == null) {
return;
}
@@ -120,12 +90,6 @@ public class DistanceOverlay implements GeneralOverlay {
paintText.setTypeface(Typeface.DEFAULT_BOLD);
}
- if (paintCompass == null) {
- paintCompass = new Paint(Paint.ANTI_ALIAS_FLAG);
- paintCompass.setDither(true);
- paintCompass.setFilterBitmap(true);
- }
-
if (needsInvertedColors) {
paintBoxShadow.setColor(0xFF000000);
paintBox.setColor(0xFFFFFFFF);
@@ -169,10 +133,4 @@ public class DistanceOverlay implements GeneralOverlay {
/* Paint distance */
canvas.drawText(distanceText, textX, textY, paintText);
}
-
- @Override
- public OverlayImpl getOverlayImpl() {
- return this.ovlImpl;
- }
-
}
diff --git a/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java b/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
index 63fcd73..51d83aa 100644
--- a/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
@@ -1,5 +1,8 @@
package cgeo.geocaching.maps;
+import cgeo.geocaching.DataStore;
+import cgeo.geocaching.location.Geopoint;
+import cgeo.geocaching.location.Viewport;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
@@ -16,22 +19,40 @@ public class PositionAndScaleOverlay implements GeneralOverlay {
PositionDrawer positionDrawer = null;
ScaleDrawer scaleDrawer = null;
+ DirectionDrawer directionDrawer = null;
+ DistanceDrawer distanceDrawer = null;
- public PositionAndScaleOverlay(OverlayImpl ovlImpl) {
+ public PositionAndScaleOverlay(final OverlayImpl ovlImpl, final MapViewImpl mapView, Geopoint coords, final String geocode) {
this.ovlImpl = ovlImpl;
positionDrawer = new PositionDrawer();
scaleDrawer = new ScaleDrawer();
+
+ if (coords == null && geocode != null) {
+ final Viewport bounds = DataStore.getBounds(geocode);
+ if (bounds != null) {
+ coords = bounds.center;
+ }
+ }
+ if (coords != null) {
+ directionDrawer = new DirectionDrawer(coords);
+ distanceDrawer = new DistanceDrawer(mapView, coords);
+ }
}
- public void setCoordinates(Location coordinatesIn) {
+ public void setCoordinates(final Location coordinatesIn) {
positionDrawer.setCoordinates(coordinatesIn);
+ if (directionDrawer != null) {
+ directionDrawer.setCoordinates(coordinatesIn);
+ distanceDrawer.setCoordinates(coordinatesIn);
+ }
+
}
public Location getCoordinates() {
return positionDrawer.getCoordinates();
}
- public void setHeading(float bearingNow) {
+ public void setHeading(final float bearingNow) {
positionDrawer.setHeading(bearingNow);
}
@@ -40,21 +61,23 @@ public class PositionAndScaleOverlay implements GeneralOverlay {
}
@Override
- public void drawOverlayBitmap(Canvas canvas, Point drawPosition,
- MapProjectionImpl projection, byte drawZoomLevel) {
+ public void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
+ final MapProjectionImpl projection, final byte drawZoomLevel) {
drawInternal(canvas, projection, getOverlayImpl().getMapViewImpl());
}
@Override
- public void draw(Canvas canvas, MapViewImpl mapView, boolean shadow) {
+ public void draw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) {
drawInternal(canvas, mapView.getMapProjection(), mapView);
}
- private void drawInternal(Canvas canvas, MapProjectionImpl projection, MapViewImpl mapView) {
+ private void drawInternal(final Canvas canvas, final MapProjectionImpl projection, final MapViewImpl mapView) {
+ directionDrawer.drawDirection(canvas, projection);
positionDrawer.drawPosition(canvas, projection);
scaleDrawer.drawScale(canvas, mapView);
+ distanceDrawer.drawDistance(canvas);
}
@Override
@@ -66,7 +89,7 @@ public class PositionAndScaleOverlay implements GeneralOverlay {
return positionDrawer.getHistory();
}
- public void setHistory(ArrayList<Location> history) {
+ public void setHistory(final ArrayList<Location> history) {
positionDrawer.setHistory(history);
}
}
diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleDirectionOverlay.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleDirectionOverlay.java
deleted file mode 100755
index cc896c6..0000000
--- a/main/src/cgeo/geocaching/maps/google/v1/GoogleDirectionOverlay.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cgeo.geocaching.maps.google.v1;
-
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.maps.DirectionOverlay;
-import cgeo.geocaching.maps.interfaces.GeneralOverlay;
-import cgeo.geocaching.maps.interfaces.MapViewImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl;
-
-import com.google.android.maps.MapView;
-import com.google.android.maps.Overlay;
-
-import android.graphics.Canvas;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class GoogleDirectionOverlay extends Overlay implements OverlayImpl {
-
- private final DirectionOverlay overlayBase;
- private final Lock lock = new ReentrantLock();
-
- public GoogleDirectionOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- overlayBase = new DirectionOverlay(this, mapView, coords, geocode);
- }
-
- @Override
- public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
- super.draw(canvas, mapView, shadow);
-
- assert mapView instanceof MapViewImpl;
- overlayBase.draw(canvas, (MapViewImpl) mapView, shadow);
- }
-
- public GeneralOverlay getBase() {
- return overlayBase;
- }
-
- @Override
- public void lock() {
- lock.lock();
- }
-
- @Override
- public void unlock() {
- lock.unlock();
- }
-
- @Override
- public MapViewImpl getMapViewImpl() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleDistanceOverlay.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleDistanceOverlay.java
deleted file mode 100755
index 281a6e9..0000000
--- a/main/src/cgeo/geocaching/maps/google/v1/GoogleDistanceOverlay.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cgeo.geocaching.maps.google.v1;
-
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.maps.DistanceOverlay;
-import cgeo.geocaching.maps.interfaces.GeneralOverlay;
-import cgeo.geocaching.maps.interfaces.MapViewImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl;
-
-import com.google.android.maps.MapView;
-import com.google.android.maps.Overlay;
-
-import android.graphics.Canvas;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class GoogleDistanceOverlay extends Overlay implements OverlayImpl {
-
- private final DistanceOverlay overlayBase;
- private final Lock lock = new ReentrantLock();
-
- public GoogleDistanceOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- overlayBase = new DistanceOverlay(this, mapView, coords, geocode);
- }
-
- @Override
- public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
- super.draw(canvas, mapView, shadow);
-
- assert mapView instanceof MapViewImpl;
- overlayBase.draw(canvas, (MapViewImpl) mapView, shadow);
- }
-
- public GeneralOverlay getBase() {
- return overlayBase;
- }
-
- @Override
- public void lock() {
- lock.lock();
- }
-
- @Override
- public void unlock() {
- lock.unlock();
- }
-
- @Override
- public MapViewImpl getMapViewImpl() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java
index 9664c3e..f3b7e9e 100644
--- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java
+++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java
@@ -5,8 +5,6 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.location.Viewport;
import cgeo.geocaching.maps.CachesOverlay;
-import cgeo.geocaching.maps.DirectionOverlay;
-import cgeo.geocaching.maps.DistanceOverlay;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -129,28 +127,14 @@ public class GoogleMapView extends MapView implements MapViewImpl {
}
@Override
- public PositionAndScaleOverlay createAddPositionAndScaleOverlay() {
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay(final Geopoint coords, final String geocode) {
- final GoogleOverlay ovl = new GoogleOverlay();
+ final GoogleOverlay ovl = new GoogleOverlay(this, coords, geocode);
getOverlays().add(ovl);
return (PositionAndScaleOverlay) ovl.getBase();
}
@Override
- public DirectionOverlay createAddDirectionOverlay(final Geopoint coords, final String geocode) {
- final GoogleDirectionOverlay ovl = new GoogleDirectionOverlay(this, coords, geocode);
- getOverlays().add(ovl);
- return (DirectionOverlay) ovl.getBase();
- }
-
- @Override
- public DistanceOverlay createAddDistanceOverlay(final Geopoint coords, final String geocode) {
- final GoogleDistanceOverlay ovl = new GoogleDistanceOverlay(this, coords, geocode);
- getOverlays().add(ovl);
- return (DistanceOverlay) ovl.getBase();
- }
-
- @Override
public int getMapZoomLevel() {
return getZoomLevel();
}
diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleOverlay.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleOverlay.java
index 40a5539..415de1f 100644
--- a/main/src/cgeo/geocaching/maps/google/v1/GoogleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleOverlay.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.google.v1;
+import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
@@ -16,14 +17,14 @@ import java.util.concurrent.locks.ReentrantLock;
public class GoogleOverlay extends Overlay implements OverlayImpl {
private PositionAndScaleOverlay overlayBase = null;
- private Lock lock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- public GoogleOverlay() {
- overlayBase = new PositionAndScaleOverlay(this);
+ public GoogleOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
+ overlayBase = new PositionAndScaleOverlay(this, mapView, coords, geocode);
}
@Override
- public void draw(Canvas canvas, MapView mapView, boolean shadow) {
+ public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
super.draw(canvas, mapView, shadow);
if (overlayBase != null) {
diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java b/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java
index f15f12a..1876dfc 100644
--- a/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java
+++ b/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java
@@ -3,8 +3,6 @@ package cgeo.geocaching.maps.interfaces;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.location.Viewport;
import cgeo.geocaching.maps.CachesOverlay;
-import cgeo.geocaching.maps.DirectionOverlay;
-import cgeo.geocaching.maps.DistanceOverlay;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import org.eclipse.jdt.annotation.NonNull;
@@ -49,11 +47,7 @@ public interface MapViewImpl {
CachesOverlay createAddMapOverlay(Context context, Drawable drawable);
- PositionAndScaleOverlay createAddPositionAndScaleOverlay();
-
- DistanceOverlay createAddDistanceOverlay(Geopoint coords, String geocode);
-
- DirectionOverlay createAddDirectionOverlay(Geopoint coords, String geocode);
+ PositionAndScaleOverlay createAddPositionAndScaleOverlay(final Geopoint coords, final String geocode);
void setMapSource();
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeDirectionOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeDirectionOverlay.java
deleted file mode 100755
index 98c19db..0000000
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeDirectionOverlay.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package cgeo.geocaching.maps.mapsforge;
-
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.maps.DirectionOverlay;
-import cgeo.geocaching.maps.interfaces.GeneralOverlay;
-import cgeo.geocaching.maps.interfaces.MapViewImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl;
-
-import org.mapsforge.android.maps.Projection;
-import org.mapsforge.android.maps.overlay.Overlay;
-
-import android.graphics.Canvas;
-import android.graphics.Point;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class MapsforgeDirectionOverlay extends Overlay implements OverlayImpl {
-
- private DirectionOverlay overlayBase = null;
- private final Lock lock = new ReentrantLock();
-
- public MapsforgeDirectionOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- overlayBase = new DirectionOverlay(this, mapView, coords, geocode);
- }
-
- @Override
- protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
- final Projection projection, final 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;
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeDistanceOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeDistanceOverlay.java
deleted file mode 100755
index ed6b6fb..0000000
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeDistanceOverlay.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package cgeo.geocaching.maps.mapsforge;
-
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.maps.DistanceOverlay;
-import cgeo.geocaching.maps.interfaces.GeneralOverlay;
-import cgeo.geocaching.maps.interfaces.MapViewImpl;
-import cgeo.geocaching.maps.interfaces.OverlayImpl;
-
-import org.mapsforge.android.maps.Projection;
-import org.mapsforge.android.maps.overlay.Overlay;
-
-import android.graphics.Canvas;
-import android.graphics.Point;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class MapsforgeDistanceOverlay extends Overlay implements OverlayImpl {
-
- private DistanceOverlay overlayBase = null;
- private final Lock lock = new ReentrantLock();
-
- public MapsforgeDistanceOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- overlayBase = new DistanceOverlay(this, mapView, coords, geocode);
- }
-
- @Override
- protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
- final Projection projection, final 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;
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java
index a81c108..71bf583 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java
@@ -4,8 +4,6 @@ import cgeo.geocaching.R;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.location.Viewport;
import cgeo.geocaching.maps.CachesOverlay;
-import cgeo.geocaching.maps.DirectionOverlay;
-import cgeo.geocaching.maps.DistanceOverlay;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -114,27 +112,13 @@ public class MapsforgeMapView extends MapView implements MapViewImpl {
}
@Override
- public PositionAndScaleOverlay createAddPositionAndScaleOverlay() {
- final MapsforgeOverlay ovl = new MapsforgeOverlay();
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay(final Geopoint coords, final String geocode) {
+ final MapsforgeOverlay ovl = new MapsforgeOverlay(this, coords, geocode);
getOverlays().add(ovl);
return (PositionAndScaleOverlay) ovl.getBase();
}
@Override
- public DirectionOverlay createAddDirectionOverlay(final Geopoint coords, final String geocode) {
- final MapsforgeDirectionOverlay ovl = new MapsforgeDirectionOverlay(this, coords, geocode);
- getOverlays().add(ovl);
- return (DirectionOverlay) ovl.getBase();
- }
-
- @Override
- public DistanceOverlay createAddDistanceOverlay(final Geopoint coords, final String geocode) {
- final MapsforgeDistanceOverlay ovl = new MapsforgeDistanceOverlay(this, coords, geocode);
- getOverlays().add(ovl);
- return (DistanceOverlay) ovl.getBase();
- }
-
- @Override
public int getLatitudeSpan() {
int span = 0;
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
index 3df4ab0..3926eb6 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.mapsforge;
+import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
@@ -17,15 +18,15 @@ import java.util.concurrent.locks.ReentrantLock;
public class MapsforgeOverlay extends Overlay implements OverlayImpl {
private PositionAndScaleOverlay overlayBase = null;
- private Lock lock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- public MapsforgeOverlay() {
- overlayBase = new PositionAndScaleOverlay(this);
+ public MapsforgeOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
+ overlayBase = new PositionAndScaleOverlay(this, mapView, coords, geocode);
}
@Override
- protected void drawOverlayBitmap(Canvas canvas, Point drawPosition,
- Projection projection, byte drawZoomLevel) {
+ protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
+ final Projection projection, final byte drawZoomLevel) {
if (overlayBase != null) {
overlayBase.drawOverlayBitmap(canvas, drawPosition, new MapsforgeMapProjection(projection), drawZoomLevel);
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDirectionOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDirectionOverlay.java
deleted file mode 100755
index 281b27f..0000000
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDirectionOverlay.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cgeo.geocaching.maps.mapsforge.v024;
-
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.maps.DirectionOverlay;
-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.graphics.Canvas;
-import android.graphics.Point;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class MapsforgeDirectionOverlay extends Overlay implements OverlayImpl {
-
- private DirectionOverlay overlayBase = null;
- private final Lock lock = new ReentrantLock();
-
- public MapsforgeDirectionOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- overlayBase = new DirectionOverlay(this, mapView, coords, geocode);
- }
-
- @Override
- protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
- final Projection projection, final 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;
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDistanceOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDistanceOverlay.java
deleted file mode 100755
index 25b97f0..0000000
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeDistanceOverlay.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cgeo.geocaching.maps.mapsforge.v024;
-
-import cgeo.geocaching.location.Geopoint;
-import cgeo.geocaching.maps.DistanceOverlay;
-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.graphics.Canvas;
-import android.graphics.Point;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class MapsforgeDistanceOverlay extends Overlay implements OverlayImpl {
-
- private DistanceOverlay overlayBase = null;
- private final Lock lock = new ReentrantLock();
-
- public MapsforgeDistanceOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
- overlayBase = new DistanceOverlay(this, mapView, coords, geocode);
- }
-
- @Override
- protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
- final Projection projection, final 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;
- }
-
-}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java
index 937c13b..af9b756 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java
@@ -4,8 +4,6 @@ import cgeo.geocaching.R;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.location.Viewport;
import cgeo.geocaching.maps.CachesOverlay;
-import cgeo.geocaching.maps.DirectionOverlay;
-import cgeo.geocaching.maps.DistanceOverlay;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -105,27 +103,13 @@ public class MapsforgeMapView024 extends MapView implements MapViewImpl {
}
@Override
- public PositionAndScaleOverlay createAddPositionAndScaleOverlay() {
- final MapsforgeOverlay ovl = new MapsforgeOverlay();
+ public PositionAndScaleOverlay createAddPositionAndScaleOverlay(final Geopoint coords, final String geocode) {
+ final MapsforgeOverlay ovl = new MapsforgeOverlay(this, coords, geocode);
getOverlays().add(ovl);
return (PositionAndScaleOverlay) ovl.getBase();
}
@Override
- public DirectionOverlay createAddDirectionOverlay(final Geopoint coords, final String geocode) {
- final MapsforgeDirectionOverlay ovl = new MapsforgeDirectionOverlay(this, coords, geocode);
- getOverlays().add(ovl);
- return (DirectionOverlay) ovl.getBase();
- }
-
- @Override
- public DistanceOverlay createAddDistanceOverlay(final Geopoint coords, final String geocode) {
- final MapsforgeDistanceOverlay ovl = new MapsforgeDistanceOverlay(this, coords, geocode);
- getOverlays().add(ovl);
- return (DistanceOverlay) ovl.getBase();
- }
-
- @Override
public int getLatitudeSpan() {
int span = 0;
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
index bfb3548..fda6dc1 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.mapsforge.v024;
+import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.PositionAndScaleOverlay;
import cgeo.geocaching.maps.interfaces.GeneralOverlay;
import cgeo.geocaching.maps.interfaces.MapViewImpl;
@@ -17,15 +18,15 @@ import java.util.concurrent.locks.ReentrantLock;
public class MapsforgeOverlay extends Overlay implements OverlayImpl {
private PositionAndScaleOverlay overlayBase = null;
- private Lock lock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- public MapsforgeOverlay() {
- overlayBase = new PositionAndScaleOverlay(this);
+ public MapsforgeOverlay(final MapViewImpl mapView, final Geopoint coords, final String geocode) {
+ overlayBase = new PositionAndScaleOverlay(this, mapView, coords, geocode);
}
@Override
- protected void drawOverlayBitmap(Canvas canvas, Point drawPosition,
- Projection projection, byte drawZoomLevel) {
+ protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
+ final Projection projection, final byte drawZoomLevel) {
if (overlayBase != null) {
overlayBase.drawOverlayBitmap(canvas, drawPosition, new MapsforgeMapProjection(projection), drawZoomLevel);