keep a reference to MapView in Overlay
This commit is contained in:
parent
8bd4d8e4d9
commit
2cb8a9d45f
@ -16,7 +16,7 @@ package org.oscim.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@ -201,7 +201,7 @@ public class BoundingBox implements Parcelable {
|
||||
|
||||
/* code below is from osdmroid, @author Nicolas Gramlich */
|
||||
|
||||
public static BoundingBox fromGeoPoints(final ArrayList<? extends GeoPoint> partialPolyLine) {
|
||||
public static BoundingBox fromGeoPoints(final List<? extends GeoPoint> partialPolyLine) {
|
||||
int minLat = Integer.MAX_VALUE;
|
||||
int minLon = Integer.MAX_VALUE;
|
||||
int maxLat = Integer.MIN_VALUE;
|
||||
|
@ -31,20 +31,18 @@ public class BuildingOverlay extends Overlay {
|
||||
final ExtrusionOverlay mExtLayer;
|
||||
|
||||
public BuildingOverlay(MapView mapView) {
|
||||
super();
|
||||
mMapView = mapView;
|
||||
super(mapView);
|
||||
mExtLayer = new ExtrusionOverlay(mapView);
|
||||
mLayer = mExtLayer;
|
||||
}
|
||||
|
||||
private final MapView mMapView;
|
||||
private int multi;
|
||||
|
||||
private float mFadeTime = 300;
|
||||
private final float mFadeTime = 300;
|
||||
private float mAlpha = 1;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e, MapView mapView) {
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
int action = e.getAction() & MotionEvent.ACTION_MASK;
|
||||
if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
multi++;
|
||||
|
@ -25,7 +25,7 @@ public class GenericOverlay extends Overlay {
|
||||
* ...
|
||||
*/
|
||||
public GenericOverlay(MapView mapView, RenderOverlay renderer) {
|
||||
super();
|
||||
super(mapView);
|
||||
mLayer = renderer;
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,7 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSnapToItem(final int pX, final int pY, final Point pSnapPoint,
|
||||
final MapView pMapView) {
|
||||
public boolean onSnapToItem(final int pX, final int pY, final Point pSnapPoint) {
|
||||
// TODO Implement this!
|
||||
return false;
|
||||
}
|
||||
@ -124,17 +123,17 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
|
||||
* ItemGestureListener methods.
|
||||
*/
|
||||
@Override
|
||||
public boolean onSingleTapUp(final MotionEvent event, final MapView mapView) {
|
||||
return (activateSelectedItems(event, mapView, new ActiveItem() {
|
||||
public boolean onSingleTapUp(final MotionEvent event) {
|
||||
return (activateSelectedItems(event, new ActiveItem() {
|
||||
@Override
|
||||
public boolean run(final int index) {
|
||||
final ItemizedIconOverlay<Item> that = ItemizedIconOverlay.this;
|
||||
if (that.mOnItemGestureListener == null) {
|
||||
return false;
|
||||
}
|
||||
return onSingleTapUpHelper(index, that.mItemList.get(index), mapView);
|
||||
return onSingleTapUpHelper(index, that.mItemList.get(index), mMapView);
|
||||
}
|
||||
})) || super.onSingleTapUp(event, mapView);
|
||||
})) || super.onSingleTapUp(event);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,11 +150,11 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongPress(final MotionEvent event, final MapView mapView) {
|
||||
public boolean onLongPress(final MotionEvent event) {
|
||||
|
||||
Log.d(TAG, "onLongPress");
|
||||
|
||||
return (activateSelectedItems(event, mapView, new ActiveItem() {
|
||||
return (activateSelectedItems(event, new ActiveItem() {
|
||||
@Override
|
||||
public boolean run(final int index) {
|
||||
final ItemizedIconOverlay<Item> that = ItemizedIconOverlay.this;
|
||||
@ -164,7 +163,7 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
|
||||
}
|
||||
return onLongPressHelper(index, getItem(index));
|
||||
}
|
||||
})) || super.onLongPress(event, mapView);
|
||||
})) || super.onLongPress(event);
|
||||
}
|
||||
|
||||
protected boolean onLongPressHelper(final int index, final Item item) {
|
||||
@ -178,13 +177,11 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
|
||||
*
|
||||
* @param event
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @param task
|
||||
* ..
|
||||
* @return true if event is handled false otherwise
|
||||
*/
|
||||
private boolean activateSelectedItems(final MotionEvent event, final MapView mapView,
|
||||
private boolean activateSelectedItems(final MotionEvent event,
|
||||
final ActiveItem task) {
|
||||
final int eventX = (int) event.getX();
|
||||
final int eventY = (int) event.getY();
|
||||
|
@ -48,7 +48,6 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
||||
|
||||
protected final Drawable mDefaultMarker;
|
||||
protected boolean mDrawFocusedItem = true;
|
||||
protected MapView mMapView;
|
||||
|
||||
class InternalItem {
|
||||
InternalItem next;
|
||||
@ -237,16 +236,13 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
||||
public abstract int size();
|
||||
|
||||
public ItemizedOverlay(MapView mapView, final Drawable pDefaultMarker) {
|
||||
|
||||
super();
|
||||
super(mapView);
|
||||
|
||||
if (pDefaultMarker == null) {
|
||||
throw new IllegalArgumentException("You must pass a default marker to ItemizedOverlay.");
|
||||
}
|
||||
|
||||
this.mDefaultMarker = pDefaultMarker;
|
||||
|
||||
mMapView = mapView;
|
||||
mLayer = new ItemOverlay(mapView);
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class LabelingOverlay extends Overlay {
|
||||
final TextOverlay mTextLayer;
|
||||
|
||||
public LabelingOverlay(MapView mapView) {
|
||||
super();
|
||||
super(mapView);
|
||||
mTextLayer = new TextOverlay(mapView);
|
||||
mLayer = mTextLayer;
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class LabelingOverlay extends Overlay {
|
||||
private int multi;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e, MapView mapView) {
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
int action = e.getAction() & MotionEvent.ACTION_MASK;
|
||||
if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
multi++;
|
||||
|
@ -60,6 +60,8 @@ public abstract class Overlay {
|
||||
// private static final Rect mRect = new Rect();
|
||||
private boolean mEnabled = true;
|
||||
|
||||
protected final MapView mMapView;
|
||||
|
||||
protected RenderOverlay mLayer;
|
||||
|
||||
public RenderOverlay getLayer() {
|
||||
@ -70,7 +72,8 @@ public abstract class Overlay {
|
||||
// Constructors
|
||||
// ===========================================================
|
||||
|
||||
public Overlay() {
|
||||
public Overlay(MapView mapView) {
|
||||
mMapView = mapView;
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
@ -149,11 +152,8 @@ public abstract class Overlay {
|
||||
/**
|
||||
* Override to perform clean up of resources before shutdown. By default
|
||||
* does nothing.
|
||||
*
|
||||
* @param mapView
|
||||
* ...
|
||||
*/
|
||||
public void onDetach(final MapView mapView) {
|
||||
public void onDetach() {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,11 +166,9 @@ public abstract class Overlay {
|
||||
* ...
|
||||
* @param event
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent event, final MapView mapView) {
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -184,11 +182,9 @@ public abstract class Overlay {
|
||||
* ...
|
||||
* @param event
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onKeyUp(final int keyCode, final KeyEvent event, final MapView mapView) {
|
||||
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -201,11 +197,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onTouchEvent(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onTouchEvent(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -217,11 +211,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onTrackballEvent(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onTrackballEvent(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -235,11 +227,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onDoubleTap(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onDoubleTap(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -251,11 +241,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onDoubleTapEvent(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onDoubleTapEvent(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -267,11 +255,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onSingleTapConfirmed(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onSingleTapConfirmed(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -285,11 +271,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onDown(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onDown(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -307,12 +291,10 @@ public abstract class Overlay {
|
||||
* ...
|
||||
* @param pVelocityY
|
||||
* ...
|
||||
* @param pMapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onFling(final MotionEvent pEvent1, final MotionEvent pEvent2,
|
||||
final float pVelocityX, final float pVelocityY, final MapView pMapView) {
|
||||
final float pVelocityX, final float pVelocityY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -324,11 +306,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onLongPress(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onLongPress(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -346,22 +326,18 @@ public abstract class Overlay {
|
||||
* ...
|
||||
* @param pDistanceY
|
||||
* ...
|
||||
* @param pMapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onScroll(final MotionEvent pEvent1, final MotionEvent pEvent2,
|
||||
final float pDistanceX, final float pDistanceY, final MapView pMapView) {
|
||||
final float pDistanceX, final float pDistanceY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pEvent
|
||||
* ...
|
||||
* @param pMapView
|
||||
* ...
|
||||
*/
|
||||
public void onShowPress(final MotionEvent pEvent, final MapView pMapView) {
|
||||
public void onShowPress(final MotionEvent pEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -373,11 +349,9 @@ public abstract class Overlay {
|
||||
*
|
||||
* @param e
|
||||
* ...
|
||||
* @param mapView
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public boolean onSingleTapUp(final MotionEvent e, final MapView mapView) {
|
||||
public boolean onSingleTapUp(final MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -390,33 +364,6 @@ public abstract class Overlay {
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Convenience method to draw a Drawable at an offset. x and y are pixel
|
||||
// * coordinates. You can find appropriate coordinates from latitude/longitude
|
||||
// * using the MapView.getProjection() method on the MapView passed to you in
|
||||
// * draw(Canvas, MapView, boolean).
|
||||
// *
|
||||
// * @param canvas
|
||||
// * ...
|
||||
// * @param drawable
|
||||
// * ...
|
||||
// * @param x
|
||||
// * ...
|
||||
// * @param y
|
||||
// * ...
|
||||
// * @param shadow
|
||||
// * If true, draw only the drawable's shadow. Otherwise, draw the
|
||||
// * drawable itself.
|
||||
// */
|
||||
// protected synchronized static void drawAt(final android.graphics.Canvas canvas,
|
||||
// final android.graphics.drawable.Drawable drawable, final int x, final int y,
|
||||
// final boolean shadow) {
|
||||
// drawable.copyBounds(mRect);
|
||||
// drawable.setBounds(mRect.left + x, mRect.top + y, mRect.right + x, mRect.bottom + y);
|
||||
// drawable.draw(canvas);
|
||||
// drawable.setBounds(mRect);
|
||||
// }
|
||||
|
||||
// ===========================================================
|
||||
// Inner and Anonymous Classes
|
||||
// ===========================================================
|
||||
@ -440,13 +387,9 @@ public abstract class Overlay {
|
||||
* To be filled with the the interesting point (in screen
|
||||
* coordinates) that is closest to the given x and y. Can be
|
||||
* untouched if not snapping.
|
||||
* @param mapView
|
||||
* The {@link MapView} that is requesting the snap. Use
|
||||
* MapView.getProjection() to convert between on-screen
|
||||
* pixels and latitude/longitude pairs.
|
||||
* @return Whether or not to snap to the interesting point.
|
||||
*/
|
||||
boolean onSnapToItem(int x, int y, Point snapPoint, MapView mapView);
|
||||
boolean onSnapToItem(int x, int y, Point snapPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.overlay.Overlay.Snappable;
|
||||
import org.oscim.renderer.overlays.RenderOverlay;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.view.KeyEvent;
|
||||
@ -67,7 +66,7 @@ public class OverlayManager extends AbstractList<Overlay> {
|
||||
}
|
||||
|
||||
private boolean mDirtyOverlays;
|
||||
private List<RenderOverlay> mDrawLayers = new ArrayList<RenderOverlay>();
|
||||
private final List<RenderOverlay> mDrawLayers = new ArrayList<RenderOverlay>();
|
||||
|
||||
public List<RenderOverlay> getRenderLayers() {
|
||||
if (mDirtyOverlays)
|
||||
@ -76,12 +75,12 @@ public class OverlayManager extends AbstractList<Overlay> {
|
||||
return mDrawLayers;
|
||||
}
|
||||
|
||||
public void onDetach(final MapView pMapView) {
|
||||
public void onDetach() {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
o.onDetach(pMapView);
|
||||
o.onDetach();
|
||||
}
|
||||
|
||||
Overlay[] mOverlays;
|
||||
@ -105,58 +104,57 @@ public class OverlayManager extends AbstractList<Overlay> {
|
||||
mDirtyOverlays = false;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent event, final MapView pMapView) {
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onKeyDown(keyCode, event, pMapView))
|
||||
if (o.onKeyDown(keyCode, event))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyUp(final int keyCode, final KeyEvent event, final MapView pMapView) {
|
||||
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onKeyUp(keyCode, event, pMapView))
|
||||
if (o.onKeyUp(keyCode, event))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event, final MapView pMapView) {
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onTouchEvent(event, pMapView))
|
||||
if (o.onTouchEvent(event))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onTrackballEvent(final MotionEvent event, final MapView pMapView) {
|
||||
public boolean onTrackballEvent(final MotionEvent event) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onTrackballEvent(event, pMapView))
|
||||
if (o.onTrackballEvent(event))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onSnapToItem(final int x, final int y, final Point snapPoint,
|
||||
final MapView pMapView) {
|
||||
public boolean onSnapToItem(final int x, final int y, final Point snapPoint) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o instanceof Snappable)
|
||||
if (((Snappable) o).onSnapToItem(x, y, snapPoint, pMapView))
|
||||
if (((Snappable) o).onSnapToItem(x, y, snapPoint))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -164,34 +162,34 @@ public class OverlayManager extends AbstractList<Overlay> {
|
||||
|
||||
/* GestureDetector.OnDoubleTapListener */
|
||||
|
||||
public boolean onDoubleTap(final MotionEvent e, final MapView pMapView) {
|
||||
public boolean onDoubleTap(final MotionEvent e) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onDoubleTap(e, pMapView))
|
||||
if (o.onDoubleTap(e))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onDoubleTapEvent(final MotionEvent e, final MapView pMapView) {
|
||||
public boolean onDoubleTapEvent(final MotionEvent e) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onDoubleTapEvent(e, pMapView))
|
||||
if (o.onDoubleTapEvent(e))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onSingleTapConfirmed(final MotionEvent e, final MapView pMapView) {
|
||||
public boolean onSingleTapConfirmed(final MotionEvent e) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onSingleTapConfirmed(e, pMapView))
|
||||
if (o.onSingleTapConfirmed(e))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -199,67 +197,67 @@ public class OverlayManager extends AbstractList<Overlay> {
|
||||
|
||||
/* OnGestureListener */
|
||||
|
||||
public boolean onDown(final MotionEvent pEvent, final MapView pMapView) {
|
||||
public boolean onDown(final MotionEvent pEvent) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onDown(pEvent, pMapView))
|
||||
if (o.onDown(pEvent))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onFling(final MotionEvent pEvent1, final MotionEvent pEvent2,
|
||||
final float pVelocityX, final float pVelocityY, final MapView pMapView) {
|
||||
final float pVelocityX, final float pVelocityY) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onFling(pEvent1, pEvent2, pVelocityX, pVelocityY, pMapView))
|
||||
if (o.onFling(pEvent1, pEvent2, pVelocityX, pVelocityY))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onLongPress(final MotionEvent pEvent, final MapView pMapView) {
|
||||
public boolean onLongPress(final MotionEvent pEvent) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onLongPress(pEvent, pMapView))
|
||||
if (o.onLongPress(pEvent))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onScroll(final MotionEvent pEvent1, final MotionEvent pEvent2,
|
||||
final float pDistanceX, final float pDistanceY, final MapView pMapView) {
|
||||
final float pDistanceX, final float pDistanceY) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onScroll(pEvent1, pEvent2, pDistanceX, pDistanceY, pMapView))
|
||||
if (o.onScroll(pEvent1, pEvent2, pDistanceX, pDistanceY))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onShowPress(final MotionEvent pEvent, final MapView pMapView) {
|
||||
public void onShowPress(final MotionEvent pEvent) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
o.onShowPress(pEvent, pMapView);
|
||||
o.onShowPress(pEvent);
|
||||
|
||||
}
|
||||
|
||||
public boolean onSingleTapUp(final MotionEvent pEvent, final MapView pMapView) {
|
||||
public boolean onSingleTapUp(final MotionEvent pEvent) {
|
||||
if (mDirtyOverlays)
|
||||
updateOverlays();
|
||||
|
||||
for (Overlay o : mOverlays)
|
||||
if (o.onSingleTapUp(pEvent, pMapView))
|
||||
if (o.onSingleTapUp(pEvent))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.oscim.overlay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.core.MapPosition;
|
||||
@ -28,7 +29,6 @@ import org.oscim.theme.renderinstruction.Line;
|
||||
import org.oscim.utils.FastMath;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Cap;
|
||||
@ -162,8 +162,8 @@ public class PathOverlay extends Overlay {
|
||||
|
||||
}
|
||||
|
||||
public PathOverlay(MapView mapView, final int color, final Context ctx) {
|
||||
super();
|
||||
public PathOverlay(MapView mapView, final int color) {
|
||||
super(mapView);
|
||||
this.mPaint.setColor(color);
|
||||
this.mPaint.setStrokeWidth(2.0f);
|
||||
this.mPaint.setStyle(Paint.Style.STROKE);
|
||||
@ -262,6 +262,9 @@ public class PathOverlay extends Overlay {
|
||||
}
|
||||
|
||||
public void clearPath() {
|
||||
if (mPoints.isEmpty())
|
||||
return;
|
||||
|
||||
synchronized (mPoints) {
|
||||
mPoints.clear();
|
||||
mUpdatePoints = true;
|
||||
@ -270,7 +273,7 @@ public class PathOverlay extends Overlay {
|
||||
|
||||
public void addPoint(final GeoPoint pt) {
|
||||
synchronized (mPoints) {
|
||||
this.mPoints.add(pt);
|
||||
mPoints.add(pt);
|
||||
mUpdatePoints = true;
|
||||
|
||||
}
|
||||
@ -278,12 +281,12 @@ public class PathOverlay extends Overlay {
|
||||
|
||||
public void addPoint(final int latitudeE6, final int longitudeE6) {
|
||||
synchronized (mPoints) {
|
||||
this.mPoints.add(new GeoPoint(latitudeE6, longitudeE6));
|
||||
mPoints.add(new GeoPoint(latitudeE6, longitudeE6));
|
||||
mUpdatePoints = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfPoints() {
|
||||
return this.mPoints.size();
|
||||
public List<GeoPoint> getPoints() {
|
||||
return mPoints;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
*/
|
||||
public boolean handleMotionEvent(MotionEvent e) {
|
||||
|
||||
if (mOverlayManager.onTouchEvent(e, mMapView))
|
||||
if (mOverlayManager.onTouchEvent(e))
|
||||
return true;
|
||||
|
||||
mGestureDetector.onTouchEvent(e);
|
||||
@ -104,7 +104,7 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
mMulti = 0;
|
||||
mWasMulti = false;
|
||||
if (mOverlayManager.onDown(e, mMapView))
|
||||
if (mOverlayManager.onDown(e))
|
||||
return true;
|
||||
|
||||
return onActionDown(e);
|
||||
@ -346,12 +346,12 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
|
||||
@Override
|
||||
public void onShowPress(MotionEvent e) {
|
||||
mOverlayManager.onShowPress(e, mMapView);
|
||||
mOverlayManager.onShowPress(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return mOverlayManager.onSingleTapUp(e, mMapView);
|
||||
return mOverlayManager.onSingleTapUp(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -391,7 +391,7 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
|
||||
final float distanceY) {
|
||||
|
||||
if (mOverlayManager.onScroll(e1, e2, distanceX, distanceY, mMapView)) {
|
||||
if (mOverlayManager.onScroll(e1, e2, distanceX, distanceY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
if (mLongPress)
|
||||
return;
|
||||
|
||||
if (mOverlayManager.onLongPress(e, mMapView)) {
|
||||
if (mOverlayManager.onLongPress(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -495,12 +495,12 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
/******************* DoubleTapListener ****************/
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||
return mOverlayManager.onSingleTapConfirmed(e, mMapView);
|
||||
return mOverlayManager.onSingleTapConfirmed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
if (mOverlayManager.onDoubleTap(e, mMapView))
|
||||
if (mOverlayManager.onDoubleTap(e))
|
||||
return true;
|
||||
|
||||
mLongPress = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user