diff --git a/vtm/src/org/oscim/core/BoundingBox.java b/vtm/src/org/oscim/core/BoundingBox.java index 1347f0c5..084a07f5 100644 --- a/vtm/src/org/oscim/core/BoundingBox.java +++ b/vtm/src/org/oscim/core/BoundingBox.java @@ -161,29 +161,29 @@ public class BoundingBox { @Override public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("BoundingBox [minLat="); - stringBuilder.append(minLatitudeE6); - stringBuilder.append(", minLon="); - stringBuilder.append(minLongitudeE6); - stringBuilder.append(", maxLat="); - stringBuilder.append(maxLatitudeE6); - stringBuilder.append(", maxLon="); - stringBuilder.append(maxLongitudeE6); - stringBuilder.append("]"); - return stringBuilder.toString(); + StringBuilder sb = new StringBuilder(); + sb.append("BoundingBox [minLat="); + sb.append(minLatitudeE6); + sb.append(", minLon="); + sb.append(minLongitudeE6); + sb.append(", maxLat="); + sb.append(maxLatitudeE6); + sb.append(", maxLon="); + sb.append(maxLongitudeE6); + sb.append("]"); + return sb.toString(); } public String format() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(minLatitudeE6 / CONVERSION_FACTOR); - stringBuilder.append(','); - stringBuilder.append(minLongitudeE6 / CONVERSION_FACTOR); - stringBuilder.append(','); - stringBuilder.append(maxLatitudeE6 / CONVERSION_FACTOR); - stringBuilder.append(','); - stringBuilder.append(maxLongitudeE6 / CONVERSION_FACTOR); - return stringBuilder.toString(); + StringBuilder sb = new StringBuilder(); + sb.append(minLatitudeE6 / CONVERSION_FACTOR); + sb.append(','); + sb.append(minLongitudeE6 / CONVERSION_FACTOR); + sb.append(','); + sb.append(maxLatitudeE6 / CONVERSION_FACTOR); + sb.append(','); + sb.append(maxLongitudeE6 / CONVERSION_FACTOR); + return sb.toString(); } /** diff --git a/vtm/src/org/oscim/core/GeoPoint.java b/vtm/src/org/oscim/core/GeoPoint.java index b3792cad..b5898e2d 100644 --- a/vtm/src/org/oscim/core/GeoPoint.java +++ b/vtm/src/org/oscim/core/GeoPoint.java @@ -127,13 +127,13 @@ public class GeoPoint implements Comparable { @Override public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("GeoPoint [lat="); - stringBuilder.append(this.getLatitude()); - stringBuilder.append(", lon="); - stringBuilder.append(this.getLongitude()); - stringBuilder.append("]"); - return stringBuilder.toString(); + StringBuilder sb = new StringBuilder(); + sb.append("GeoPoint [lat="); + sb.append(this.getLatitude()); + sb.append(", lon="); + sb.append(this.getLongitude()); + sb.append("]"); + return sb.toString(); } /** @@ -182,31 +182,4 @@ public class GeoPoint implements Comparable { return (int) (RADIUS_EARTH_METERS * tt); } - - // =========================================================== - // Parcelable - // =========================================================== - - // @Override - // public int describeContents() { - // return 0; - // } - // - // @Override - // public void writeToParcel(final Parcel out, final int flags) { - // out.writeInt(latitudeE6); - // out.writeInt(longitudeE6); - // } - // - // public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - // @Override - // public GeoPoint createFromParcel(final Parcel in) { - // return new GeoPoint(in.readInt(), in.readInt()); - // } - // - // @Override - // public GeoPoint[] newArray(final int size) { - // return new GeoPoint[size]; - // } - // }; } diff --git a/vtm/src/org/oscim/core/GeometryBuffer.java b/vtm/src/org/oscim/core/GeometryBuffer.java index 87700586..267e5a0f 100644 --- a/vtm/src/org/oscim/core/GeometryBuffer.java +++ b/vtm/src/org/oscim/core/GeometryBuffer.java @@ -1,9 +1,23 @@ package org.oscim.core; +// TODO +// - getter methods! +// - check indexPos < Short.Max +// - should make internals private, maybe +/** + * Class to hold temporary geometry data for processing. Only One + * geometry type can be set at a time. Use 'clear()' to reset the + * internal state. + * - 'points[]' holds the coordinates + * - 'index[]' is used to encode multi-linestrings and (multi-)polygons. + */ public class GeometryBuffer { - public enum GeometryType { + private final static int GROW_INDICES = 64; + private final static int GROW_POINTS = 512; + + public enum GeometryType { NONE(0), POINT(1), LINE(2), @@ -15,15 +29,8 @@ public class GeometryBuffer { } public final int nativeInt; - } - // TODO - // - check indexPos < Short.Max - // - make internals private - - final static boolean CHECK_STATE = true; - public float[] points; public short[] index; public int indexPos; @@ -33,9 +40,9 @@ public class GeometryBuffer { public GeometryBuffer(float[] points, short[] index) { if (points == null) - throw new IllegalArgumentException("GeometryBuffer points is null"); + points = new float[GROW_POINTS]; if (index == null) - throw new IllegalArgumentException("GeometryBuffer index is null"); + index = new short[GROW_INDICES]; this.points = points; this.index = index; @@ -45,11 +52,7 @@ public class GeometryBuffer { } public GeometryBuffer(int numPoints, int numIndices) { - this.points = new float[numPoints * 2]; - this.index = new short[numIndices]; - this.type = GeometryType.NONE; - this.indexPos = 0; - this.pointPos = 0; + this(new float[numPoints * 2], new short[numIndices]); } // ---- API ---- @@ -69,13 +72,16 @@ public class GeometryBuffer { index[indexPos] += 2; } - public boolean isPoly(){ + + public boolean isPoly() { return type == GeometryType.POLY; } - public boolean isLine(){ + + public boolean isLine() { return type == GeometryType.LINE; } - public boolean isPoint(){ + + public boolean isPoint() { return type == GeometryType.POINT; } @@ -85,13 +91,11 @@ public class GeometryBuffer { } public void startPoints() { - if (CHECK_STATE) - setOrCheckMode(GeometryType.POINT); + setOrCheckMode(GeometryType.POINT); } public void startLine() { - if (CHECK_STATE) - setOrCheckMode(GeometryType.LINE); + setOrCheckMode(GeometryType.LINE); // start next if ((index[0] >= 0) && (++indexPos >= index.length)) @@ -107,8 +111,7 @@ public class GeometryBuffer { public void startPolygon() { boolean start = (type == GeometryType.NONE); - if (CHECK_STATE) - setOrCheckMode(GeometryType.POLY); + setOrCheckMode(GeometryType.POLY); if ((indexPos + 3) > index.length) ensureIndexSize(indexPos + 2, true); @@ -130,8 +133,7 @@ public class GeometryBuffer { } public void startHole() { - if (CHECK_STATE) - checkMode(GeometryType.POLY); + checkMode(GeometryType.POLY); if ((indexPos + 2) > index.length) ensureIndexSize(indexPos + 1, true); @@ -149,7 +151,7 @@ public class GeometryBuffer { if (size * 2 < points.length) return points; - float[] tmp = new float[size * 2 + 512]; + float[] tmp = new float[size * 2 + GROW_POINTS]; if (copy) System.arraycopy(points, 0, tmp, 0, points.length); @@ -161,7 +163,7 @@ public class GeometryBuffer { if (size < index.length) return index; - short[] tmp = new short[size + 64]; + short[] tmp = new short[size + GROW_INDICES]; if (copy) System.arraycopy(index, 0, tmp, 0, index.length); @@ -175,14 +177,14 @@ public class GeometryBuffer { return; if (type != GeometryType.NONE) - throw new IllegalArgumentException("GeometryBuffer not cleared " + m + "<>" + type); + throw new IllegalArgumentException("not cleared " + m + "<>" + type); type = m; } private void checkMode(GeometryType m) { if (type != m) - throw new IllegalArgumentException("GeometryBuffer not cleared " + m + "<>" + type); + throw new IllegalArgumentException("not cleared " + m + "<>" + type); } } diff --git a/vtm/src/org/oscim/core/MapElement.java b/vtm/src/org/oscim/core/MapElement.java index a287fe83..bc3b735c 100644 --- a/vtm/src/org/oscim/core/MapElement.java +++ b/vtm/src/org/oscim/core/MapElement.java @@ -14,20 +14,21 @@ */ package org.oscim.core; +// TODO +// - make this class (and description) more generic or +// move it to tilesource package + /** - * MapElement is created by TileDataSource(s) and passed to MapTileLoader - * via ITileDataSink.process() MapTileLoader processes the - * data into MapTile.layers. - * ----- - * This is really just a buffer object that belongs to TileDataSource, so - * dont keep a reference to it when passed as parameter. + * Reusable containter for geometry with tags. + * MapElement is created by TileDataSource(s) and passed to + * MapTileLoader via ITileDataSink.process(). + * This is just a buffer that belongs to TileDataSource, + * so dont keep a reference to it when passed as parameter. */ public class MapElement extends GeometryBuffer { - // osm layer of the way. + // OSM layer of the way. public int layer; - // osm tags of the way. - //public Tag[] tags; public final TagSet tags = new TagSet(); @@ -41,13 +42,13 @@ public class MapElement extends GeometryBuffer { public void setLayer(int layer) { this.layer = layer; - //this.tags = tags; } @Override public void clear() { super.clear(); } + // ---- random stuff, to be removed ---- // building tags public int height; diff --git a/vtm/src/org/oscim/layers/Layer.java b/vtm/src/org/oscim/layers/Layer.java index f0f76379..3f1ce43d 100644 --- a/vtm/src/org/oscim/layers/Layer.java +++ b/vtm/src/org/oscim/layers/Layer.java @@ -35,8 +35,8 @@ public abstract class Layer { /** */ - public void setEnabled(boolean pEnabled) { - mEnabled = pEnabled; + public void setEnabled(boolean enabled) { + mEnabled = enabled; } /** diff --git a/vtm/src/org/oscim/layers/MapEventLayer.java b/vtm/src/org/oscim/layers/MapEventLayer.java index 5606fd12..0bab7754 100644 --- a/vtm/src/org/oscim/layers/MapEventLayer.java +++ b/vtm/src/org/oscim/layers/MapEventLayer.java @@ -14,7 +14,6 @@ */ package org.oscim.layers; -import org.oscim.backend.CanvasAdapter; import org.oscim.backend.Log; import org.oscim.backend.input.MotionEvent; import org.oscim.core.Tile; @@ -69,7 +68,8 @@ public class MapEventLayer extends InputLayer { mMapPosition = map.getViewport(); mTracker = new VelocityTracker(); } - private long mPrevTime; + + //private long mPrevTime; private boolean mEnableRotation = true; private boolean mEnableTilt = true; @@ -99,7 +99,7 @@ public class MapEventLayer extends InputLayer { @Override public boolean onTouchEvent(MotionEvent e) { - mPrevTime = e.getTime(); + //mPrevTime = e.getTime(); int action = getAction(e); @@ -168,6 +168,8 @@ public class MapEventLayer extends InputLayer { } if (e.getPointerCount() < 2) { + if (!mEnableMove) + return true; if (mx > 1 || mx < -1 || my > 1 || my < -1) { mMapPosition.moveMap(mx, my); @@ -200,7 +202,7 @@ public class MapEventLayer extends InputLayer { boolean changed = false; - if (!mBeginTilt && (mBeginScale || startScale)) { + if (mEnableZoom && !mBeginTilt && (mBeginScale || startScale)) { mBeginScale = true; float scale = (float) (pinchWidth / mPrevPinchWidth); @@ -222,7 +224,7 @@ public class MapEventLayer extends InputLayer { changed = mMapPosition.scaleMap(scale, fx, fy); } - if (!mBeginRotate && Math.abs(slope) < 1) { + if (mEnableTilt && !mBeginRotate && Math.abs(slope) < 1) { float my2 = y2 - mPrevY2; float threshold = PINCH_TILT_THRESHOLD; //Log.d(TAG, r + " " + slope + " m1:" + my + " m2:" + my2); @@ -233,7 +235,8 @@ public class MapEventLayer extends InputLayer { mBeginTilt = true; changed = mMapPosition.tiltMap(my / 5); } - } else if (!mBeginTilt && (mBeginRotate || Math.abs(r) > PINCH_ROTATE_THRESHOLD)) { + } else if (mEnableRotation && !mBeginTilt && + (mBeginRotate || Math.abs(r) > PINCH_ROTATE_THRESHOLD)) { //Log.d(TAG, "rotate: " + mBeginRotate + " " + Math.toDegrees(rad)); if (!mBeginRotate) { mAngle = rad; @@ -289,80 +292,64 @@ public class MapEventLayer extends InputLayer { } } - @Override - public boolean onDoubleTap(MotionEvent e) { - - mDoubleTap = true; - //mMapPosition.animateZoom(2); - - if (debug) - printState("onDoubleTap"); - - // avoid onLongPress - mMap.getLayers().cancelGesture(); - - return true; - } - - @Override - public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX, - final float distanceY) { - - if (e2.getPointerCount() == 1) { - mMapPosition.moveMap(-distanceX, -distanceY); - mMap.updateMap(true); - return true; - } - - return false; - } - private boolean onFling(float velocityX, float velocityY) { - if (mWasMulti) return true; int w = Tile.SIZE * 3; int h = Tile.SIZE * 3; - //if (mMap.enablePagedFling) { - // double a = Math.sqrt(velocityX * velocityX + velocityY * velocityY); - // - // float vx = (float) (velocityX / a); - // float vy = (float) (velocityY / a); - // - // if (a < 400) - // return true; - // - // float move = Math.min(mMap.getWidth(), mMap.getHeight()) * 2 / 3; - // mMapPosition.animateTo(vx * move, vy * move, 250); - //} else { - float s = 1; //(200 / CanvasAdapter.dpi); - mMapPosition.animateFling( - Math.round(velocityX * s), - Math.round(velocityY * s), + Math.round(velocityX), + Math.round(velocityY), -w, w, -h, h); return true; } - private void printState(String action) { - Log.d(TAG, action - + " " + mDoubleTap - + " " + mBeginScale - + " " + mBeginRotate - + " " + mBeginTilt); - } + //@Override + //public boolean onDoubleTap(MotionEvent e) { + // + // mDoubleTap = true; + // //mMapPosition.animateZoom(2); + // + // if (debug) + // printState("onDoubleTap"); + // + // // avoid onLongPress + // mMap.getLayers().cancelGesture(); + // + // return true; + //} + // + //@Override + //public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX, + // final float distanceY) { + // + // if (e2.getPointerCount() == 1) { + // mMapPosition.moveMap(-distanceX, -distanceY); + // mMap.updateMap(true); + // return true; + // } + // + // return false; + //} + // + + // + //private void printState(String action) { + // Log.d(TAG, action + // + " " + mDoubleTap + // + " " + mBeginScale + // + " " + mBeginRotate + // + " " + mBeginTilt); + //} /******************************************************************************* * Copyright 2011 See libgdx AUTHORS file. - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -379,7 +366,7 @@ public class MapEventLayer extends InputLayer { float[] meanY = new float[sampleSize]; long[] meanTime = new long[sampleSize]; - public void start (float x, float y, long timeStamp) { + public void start(float x, float y, long timeStamp) { lastX = x; lastY = y; deltaX = 0; @@ -393,7 +380,7 @@ public class MapEventLayer extends InputLayer { lastTime = timeStamp; } - public void update (float x, float y, long timeStamp) { + public void update(float x, float y, long timeStamp) { long currTime = timeStamp; deltaX = x - lastX; deltaY = y - lastY; @@ -408,21 +395,23 @@ public class MapEventLayer extends InputLayer { numSamples++; } - public float getVelocityX () { + public float getVelocityX() { float meanX = getAverage(this.meanX, numSamples); float meanTime = getAverage(this.meanTime, numSamples) / 1000.0f; - if (meanTime == 0) return 0; + if (meanTime == 0) + return 0; return meanX / meanTime; } - public float getVelocityY () { + public float getVelocityY() { float meanY = getAverage(this.meanY, numSamples); float meanTime = getAverage(this.meanTime, numSamples) / 1000.0f; - if (meanTime == 0) return 0; + if (meanTime == 0) + return 0; return meanY / meanTime; } - private float getAverage (float[] values, int numSamples) { + private float getAverage(float[] values, int numSamples) { numSamples = Math.min(sampleSize, numSamples); float sum = 0; for (int i = 0; i < numSamples; i++) { @@ -431,25 +420,26 @@ public class MapEventLayer extends InputLayer { return sum / numSamples; } - private long getAverage (long[] values, int numSamples) { + private long getAverage(long[] values, int numSamples) { numSamples = Math.min(sampleSize, numSamples); long sum = 0; for (int i = 0; i < numSamples; i++) { sum += values[i]; } - if (numSamples == 0) return 0; + if (numSamples == 0) + return 0; return sum / numSamples; } - private float getSum (float[] values, int numSamples) { - numSamples = Math.min(sampleSize, numSamples); - float sum = 0; - for (int i = 0; i < numSamples; i++) { - sum += values[i]; - } - if (numSamples == 0) return 0; - return sum; - } + //private float getSum (float[] values, int numSamples) { + // numSamples = Math.min(sampleSize, numSamples); + // float sum = 0; + // for (int i = 0; i < numSamples; i++) { + // sum += values[i]; + // } + // if (numSamples == 0) return 0; + // return sum; + //} } } diff --git a/vtm/src/org/oscim/layers/labeling/TextRenderLayer.java b/vtm/src/org/oscim/layers/labeling/TextRenderLayer.java index 941869a5..8f2baf6a 100644 --- a/vtm/src/org/oscim/layers/labeling/TextRenderLayer.java +++ b/vtm/src/org/oscim/layers/labeling/TextRenderLayer.java @@ -54,7 +54,7 @@ import org.oscim.view.Map; import org.oscim.view.Viewport; class TextRenderLayer extends BasicRenderLayer { - private final static String TAG = TextRenderLayer.class.getName(); + //private final static String TAG = TextRenderLayer.class.getName(); private final static float MIN_CAPTION_DIST = 5; private final static float MIN_WAY_DIST = 3; diff --git a/vtm/src/org/oscim/layers/tile/vector/MapTileLoader.java b/vtm/src/org/oscim/layers/tile/vector/MapTileLoader.java index 44de7310..1d52d2cc 100644 --- a/vtm/src/org/oscim/layers/tile/vector/MapTileLoader.java +++ b/vtm/src/org/oscim/layers/tile/vector/MapTileLoader.java @@ -117,28 +117,10 @@ public class MapTileLoader extends TileLoader implements IRenderCallback, ITileD debug = debugSettings; } - /** - */ public MapTileLoader(TileManager tileManager) { super(tileManager); mClipper = new LineClipper(0, 0, Tile.SIZE, Tile.SIZE, true); - - // MapElement m = mDebugWay = new MapElement(); - // m.startLine(); - // int s = Tile.SIZE; - // m.addPoint(0, 0); - // m.addPoint(0, s); - // m.addPoint(s, s); - // m.addPoint(s, 0); - // m.addPoint(0, 0); - // m.tags = new Tag[] { new Tag("debug", "box") }; - // m.type = GeometryType.LINE; - // - // m = mDebugPoint = new MapElement(); - // m.startPoints(); - // m.addPoint(s >> 1, 10); - // m.type = GeometryType.POINT; } @Override diff --git a/vtm/src/org/oscim/tilesource/test/TestTileSource.java b/vtm/src/org/oscim/tilesource/test/TestTileSource.java index 82c79a20..11c79e01 100644 --- a/vtm/src/org/oscim/tilesource/test/TestTileSource.java +++ b/vtm/src/org/oscim/tilesource/test/TestTileSource.java @@ -79,9 +79,9 @@ public class TestTileSource extends TileSource { mElem = new MapElement(); } - private final boolean renderWays = true; - private final boolean renderBoundary = false; - private final boolean renderPlace = false; + private boolean renderWays = true; + private boolean renderBoundary = true; + private boolean renderPlace = false; @Override public QueryResult executeQuery(MapTile tile, @@ -171,7 +171,7 @@ public class TestTileSource extends TileSource { } e.setLayer(1); - e.tags.set(mTagsWay); + e.tags.set(mTagsBoundary); mapDataSink.process(e); } diff --git a/vtm/src/org/oscim/view/Layers.java b/vtm/src/org/oscim/view/Layers.java index b542190e..c29dfaa1 100644 --- a/vtm/src/org/oscim/view/Layers.java +++ b/vtm/src/org/oscim/view/Layers.java @@ -40,8 +40,8 @@ public class Layers extends AbstractList { } @Override - public synchronized Layer get(final int pIndex) { - return mLayerList.get(pIndex); + public synchronized Layer get(int index) { + return mLayerList.get(index); } @Override @@ -50,21 +50,21 @@ public class Layers extends AbstractList { } @Override - public synchronized void add(final int pIndex, final Layer pElement) { - mLayerList.add(pIndex, pElement); + public synchronized void add(int index, Layer element) { + mLayerList.add(index, element); mDirtyLayers = true; } @Override - public synchronized Layer remove(final int pIndex) { + public synchronized Layer remove(int index) { mDirtyLayers = true; - return mLayerList.remove(pIndex); + return mLayerList.remove(index); } @Override - public synchronized Layer set(final int pIndex, final Layer pElement) { + public synchronized Layer set(int index, Layer element) { mDirtyLayers = true; - return mLayerList.set(pIndex, pElement); + return mLayerList.set(index, element); } private boolean mDirtyLayers; @@ -114,13 +114,9 @@ public class Layers extends AbstractList { int numRenderLayers = 0; int numInputLayers = 0; - //Log.d(TAG, "update layers:"); - for (int i = 0, n = mLayerList.size(); i < n; i++) { Layer o = mLayerList.get(i); - //Log.d(TAG, "\t" + o.getClass().getName()); - if (o.getLayer() != null) numRenderLayers++; @@ -150,23 +146,23 @@ public class Layers extends AbstractList { mDirtyLayers = false; } - private boolean mCancelGesture; + //private boolean mCancelGesture; public boolean handleMotionEvent(MotionEvent e) { - boolean handleGesture = true; + //boolean handleGesture = true; - if (mCancelGesture) { - int action = e.getAction(); - handleGesture = (action == MotionEvent.ACTION_CANCEL || - action == MotionEvent.ACTION_UP); - } + //if (mCancelGesture) { + // int action = e.getAction(); + // handleGesture = (action == MotionEvent.ACTION_CANCEL || + // action == MotionEvent.ACTION_UP); + //} - // if (handleGesture) { - // if (mGestureDetector.onTouchEvent(e)) - // return true; + //if (handleGesture) { + // if (mGestureDetector.onTouchEvent(e)) + // return true; // - // mCancelGesture = false; - // } + // mCancelGesture = false; + //} if (onTouchEvent(e)) return true; @@ -174,17 +170,17 @@ public class Layers extends AbstractList { return false; } - /** - * Call this to not foward events to generic GestureDetector until - * next ACTION_UP or ACTION_CANCEL event. - Use with care for the - * case that an InputLayer recognized the start of its gesture and - * does further processing in only onTouch callback. - */ - public void cancelGesture() { - mCancelGesture = true; - } + ///** + // * Call this to not foward events to generic GestureDetector until + // * next ACTION_UP or ACTION_CANCEL event. - Use with care for the + // * case that an InputLayer recognized the start of its gesture and + // * does further processing in only onTouch callback. + // */ + //public void cancelGesture() { + // mCancelGesture = true; + //} - public boolean onTouchEvent(final MotionEvent event) { + public boolean onTouchEvent(MotionEvent event) { if (mDirtyLayers) updateLayers(); @@ -198,7 +194,7 @@ public class Layers extends AbstractList { return false; } - public boolean onKeyDown(final int keyCode, final KeyEvent event) { + public boolean onKeyDown(int keyCode, KeyEvent event) { if (mDirtyLayers) updateLayers(); @@ -209,7 +205,7 @@ public class Layers extends AbstractList { return false; } - public boolean onKeyUp(final int keyCode, final KeyEvent event) { + public boolean onKeyUp(int keyCode, KeyEvent event) { if (mDirtyLayers) updateLayers(); @@ -220,7 +216,7 @@ public class Layers extends AbstractList { return false; } - public boolean onTrackballEvent(final MotionEvent event) { + public boolean onTrackballEvent(MotionEvent event) { if (mDirtyLayers) updateLayers(); @@ -243,254 +239,113 @@ public class Layers extends AbstractList { return false; } - /* GestureDetector.OnDoubleTapListener */ - - public boolean onDoubleTap(final MotionEvent e) { - - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) { - if (o.onDoubleTap(e)) { - if (debugInput) - Log.d(TAG, "onDoubleTap\t" + o.getClass()); - return true; - } - } - return false; - } - - public boolean onDoubleTapEvent(final MotionEvent e) { - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) { - if (o.onDoubleTapEvent(e)) { - if (debugInput) - Log.d(TAG, "onDoubleTapEvent\t" + o.getClass()); - return true; - } - } - return false; - } - - public boolean onSingleTapConfirmed(final MotionEvent e) { - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) { - if (o.onSingleTapConfirmed(e)) { - if (debugInput) - Log.d(TAG, "onSingleTapConfirmed\tt" + o.getClass()); - return true; - } - } - return false; - } - - /* OnGestureListener */ - public boolean onDown(final MotionEvent pEvent) { - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) { - if (o.onDown(pEvent)) { - if (debugInput) - Log.d(TAG, "onDown\t" + o.getClass()); - return true; - } - } - return false; - } - - ////@Override - //public boolean onFling(final MotionEvent pEvent1, final MotionEvent pEvent2, - // final float pVelocityX, final float pVelocityY) { - // if (mDirtyLayers) - // updateLayers(); + // /* GestureDetector.OnDoubleTapListener */ // - // for (InputLayer o : mInputLayer) { - // if (o.onFling(pEvent1, pEvent2, pVelocityX, pVelocityY)) { - // if (debugInput) - // Log.d(TAG, "onFling\t" + o.getClass()); - // return true; - // } - // } - // return false; - //} - - public void onLongPress(final MotionEvent pEvent) { - if (mCancelGesture) - return; - - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) - if (o.onLongPress(pEvent)) - return; - } - - public boolean onScroll(final MotionEvent pEvent1, final MotionEvent pEvent2, - final float pDistanceX, final float pDistanceY) { - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) { - if (o.onScroll(pEvent1, pEvent2, pDistanceX, pDistanceY)) { - if (debugInput) - Log.d(TAG, "onScroll\t" + o.getClass()); - return true; - } - } - return false; - } - - public void onShowPress(final MotionEvent pEvent) { - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) - o.onShowPress(pEvent); - - } - - public boolean onSingleTapUp(final MotionEvent pEvent) { - if (mDirtyLayers) - updateLayers(); - - for (InputLayer o : mInputLayer) { - if (o.onSingleTapUp(pEvent)) { - if (debugInput) - Log.d(TAG, "onSingleTapUp\t" + o.getClass()); - return true; - } - } - return false; - } - - // /** - // * Gets the optional TilesLayer class. - // * - // * @return the tilesLayer - // */ - // public TilesLayer getTilesLayer() { - // return mTilesLayer; - // } + // public boolean onDoubleTap(MotionEvent e) { // - // /** - // * Sets the optional TilesLayer class. If set, this overlay will be - // drawn before all other - // * overlays and will not be included in the editable list of overlays and - // can't be cleared - // * except by a subsequent call to setTilesLayer(). - // * - // * @param tilesLayer - // * the tilesLayer to set - // */ - // public void setTilesLayer(final TilesLayer tilesLayer) { - // mTilesLayer = tilesLayer; - // } - - // public void onDraw(final Canvas c, final MapView pMapView) { - // // if ((mTilesLayer != null) && mTilesLayer.isEnabled()) { - // // mTilesLayer.draw(c, pMapView, true); - // // } - // // - // // if ((mTilesLayer != null) && mTilesLayer.isEnabled()) { - // // mTilesLayer.draw(c, pMapView, false); - // // } + // if (mDirtyLayers) + // updateLayers(); // - // for (final Layer overlay : mLayerList) { - // if (overlay.isEnabled()) { - // overlay.draw(c, pMapView, true); + // for (InputLayer o : mInputLayer) { + // if (o.onDoubleTap(e)) { + // if (debugInput) + // Log.d(TAG, "onDoubleTap\t" + o.getClass()); + // return true; // } // } + // return false; + // } // - // for (final Layer overlay : mLayerList) { - // if (overlay.isEnabled()) { - // overlay.draw(c, pMapView, false); + // public boolean onDoubleTapEvent(MotionEvent e) { + // if (mDirtyLayers) + // updateLayers(); + // + // for (InputLayer o : mInputLayer) { + // if (o.onDoubleTapEvent(e)) { + // if (debugInput) + // Log.d(TAG, "onDoubleTapEvent\t" + o.getClass()); + // return true; // } // } + // return false; + // } + // + // public boolean onSingleTapConfirmed(MotionEvent e) { + // if (mDirtyLayers) + // updateLayers(); + // + // for (InputLayer o : mInputLayer) { + // if (o.onSingleTapConfirmed(e)) { + // if (debugInput) + // Log.d(TAG, "onSingleTapConfirmed\tt" + o.getClass()); + // return true; + // } + // } + // return false; + // } + // + // /* OnGestureListener */ + // public boolean onDown(MotionEvent e) { + // if (mDirtyLayers) + // updateLayers(); + // + // for (InputLayer o : mInputLayer) { + // if (o.onDown(e)) { + // if (debugInput) + // Log.d(TAG, "onDown\t" + o.getClass()); + // return true; + // } + // } + // return false; + // } + // + // public void onLongPress(MotionEvent e) { + // if (mCancelGesture) + // return; + // + // if (mDirtyLayers) + // updateLayers(); + // + // for (InputLayer o : mInputLayer) + // if (o.onLongPress(e)) + // return; + // } + // + // public boolean onScroll(MotionEvent e1, MotionEvent e2, + // float dx, float dy) { + // if (mDirtyLayers) + // updateLayers(); + // + // for (InputLayer o : mInputLayer) { + // if (o.onScroll(e1, e2, dx, dy)) { + // if (debugInput) + // Log.d(TAG, "onScroll\t" + o.getClass()); + // return true; + // } + // } + // return false; + // } + // + // public void onShowPress(MotionEvent e) { + // if (mDirtyLayers) + // updateLayers(); + // + // for (InputLayer o : mInputLayer) + // o.onShowPress(e); // // } - - // ** Options Menu **// - - // public void setOptionsMenusEnabled(final boolean pEnabled) { - // for (final Layer overlay : mLayerList) { - // if ((overlay instanceof ILayerMenuProvider) - // && ((ILayerMenuProvider) overlay).isOptionsMenuEnabled()) { - // ((ILayerMenuProvider) overlay).setOptionsMenuEnabled(pEnabled); - // } - // } - // } // - // public boolean onCreateOptionsMenu(final Menu pMenu, final int - // menuIdOffset, - // final MapView map) { - // boolean result = true; - // for (final Layer overlay : this.overlaysReversed()) { - // if ((overlay instanceof ILayerMenuProvider) - // && ((ILayerMenuProvider) overlay).isOptionsMenuEnabled()) { - // result &= ((ILayerMenuProvider) overlay).onCreateOptionsMenu(pMenu, - // menuIdOffset, - // map); - // } - // } + // public boolean onSingleTapUp(MotionEvent e) { + // if (mDirtyLayers) + // updateLayers(); // - // if ((mTilesLayer != null) && (mTilesLayer instanceof - // ILayerMenuProvider) - // && ((ILayerMenuProvider) mTilesLayer).isOptionsMenuEnabled()) { - // result &= mTilesLayer.onCreateOptionsMenu(pMenu, menuIdOffset, - // map); - // } - // - // return result; - // } - // - // public boolean onPrepareOptionsMenu(final Menu pMenu, final int - // menuIdOffset, - // final MapView map) { - // for (final Layer overlay : this.overlaysReversed()) { - // if ((overlay instanceof ILayerMenuProvider) - // && ((ILayerMenuProvider) overlay).isOptionsMenuEnabled()) { - // ((ILayerMenuProvider) overlay).onPrepareOptionsMenu(pMenu, - // menuIdOffset, map); - // } - // } - // - // if ((mTilesLayer != null) && (mTilesLayer instanceof - // ILayerMenuProvider) - // && ((ILayerMenuProvider) mTilesLayer).isOptionsMenuEnabled()) { - // mTilesLayer.onPrepareOptionsMenu(pMenu, menuIdOffset, map); - // } - // - // return true; - // } - // - // public boolean onOptionsItemSelected(final MenuItem item, final int - // menuIdOffset, - // final MapView map) { - // for (final Layer overlay : this.overlaysReversed()) { - // if ((overlay instanceof ILayerMenuProvider) - // && ((ILayerMenuProvider) overlay).isOptionsMenuEnabled() - // && ((ILayerMenuProvider) overlay).onOptionsItemSelected(item, - // menuIdOffset, - // map)) { - // return true; - // } - // } - // - // if ((mTilesLayer != null) - // && (mTilesLayer instanceof ILayerMenuProvider) - // && ((ILayerMenuProvider) mTilesLayer).isOptionsMenuEnabled() - // && ((ILayerMenuProvider) mTilesLayer).onOptionsItemSelected(item, - // menuIdOffset, - // map)) { - // return true; - // } - // - // return false; - // } + // for (InputLayer o : mInputLayer) { + // if (o.onSingleTapUp(e)) { + // if (debugInput) + // Log.d(TAG, "onSingleTapUp\t" + o.getClass()); + // return true; + // } + // } + // return false; + // } }