diff --git a/vtm/src/org/oscim/map/Map.java b/vtm/src/org/oscim/map/Map.java index a360efe2..e10f5303 100644 --- a/vtm/src/org/oscim/map/Map.java +++ b/vtm/src/org/oscim/map/Map.java @@ -2,6 +2,7 @@ * Copyright 2013 Hannes Janetzek * Copyright 2016 Andrey Novikov * Copyright 2016 Stephan Leuschner + * Copyright 2016 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -25,7 +26,6 @@ import org.oscim.event.Event; import org.oscim.event.EventDispatcher; import org.oscim.event.EventListener; import org.oscim.event.Gesture; -import org.oscim.event.GestureDetector; import org.oscim.event.MotionEvent; import org.oscim.layers.Layer; import org.oscim.layers.MapEventLayer; @@ -106,7 +106,6 @@ public abstract class Map implements TaskQueue { protected final MapPosition mMapPosition; protected final MapEventLayer mEventLayer; - protected GestureDetector mGestureDetector; protected boolean mClearMap = true; @@ -147,7 +146,7 @@ public abstract class Map implements TaskQueue { /** * Create OsmTileLayer with given TileSource and * set as base map (layer 1) - *

+ *

* TODO deprecate */ public VectorTileLayer setBaseMap(TileSource tileSource) { @@ -239,7 +238,7 @@ public abstract class Map implements TaskQueue { public abstract boolean postDelayed(Runnable action, long delay); /** - * Post a task to run on a shared worker-thread. Shoul only use for + * Post a task to run on a shared worker-thread. Should only use for * tasks running less than a second. */ @Override @@ -342,7 +341,7 @@ public abstract class Map implements TaskQueue { /** * This function is run on main-thread before rendering a frame. - *

+ *

* For internal use only. Do not call! */ protected void prepareFrame() { @@ -353,10 +352,11 @@ public abstract class Map implements TaskQueue { mAnimator.updateAnimation(); boolean changed = mViewport.getMapPosition(pos); + boolean sizeChanged = mViewport.sizeChanged(); if (mClearMap) events.fire(CLEAR_EVENT, pos); - else if (changed) + else if (changed || sizeChanged) events.fire(POSITION_EVENT, pos); else events.fire(UPDATE_EVENT, pos); diff --git a/vtm/src/org/oscim/map/ViewController.java b/vtm/src/org/oscim/map/ViewController.java index a9c51be5..47e1973f 100644 --- a/vtm/src/org/oscim/map/ViewController.java +++ b/vtm/src/org/oscim/map/ViewController.java @@ -136,9 +136,6 @@ public class ViewController extends Viewport { * Scale map by scale width center at pivot in pixel relative to * screen center. Map scale is clamp to MIN_SCALE and MAX_SCALE. * - * @param scale - * @param pivotX - * @param pivotY * @return true if scale was changed */ public boolean scaleMap(float scale, float pivotX, float pivotY) { @@ -172,10 +169,6 @@ public class ViewController extends Viewport { /** * Rotate map by radians around pivot. Pivot is in pixel relative * to screen center. - * - * @param radians - * @param pivotX - * @param pivotY */ public void rotateMap(double radians, float pivotX, float pivotY) { ThreadUtils.assertMainThread(); @@ -269,6 +262,12 @@ public class ViewController extends Viewport { return mNextFrame; } + boolean sizeChanged() { + synchronized (mNextFrame) { + return mNextFrame.sizeChanged(this); + } + } + void syncViewport() { synchronized (mNextFrame) { mNextFrame.copy(this); diff --git a/vtm/src/org/oscim/map/Viewport.java b/vtm/src/org/oscim/map/Viewport.java index b42f39a4..062dedf9 100644 --- a/vtm/src/org/oscim/map/Viewport.java +++ b/vtm/src/org/oscim/map/Viewport.java @@ -26,20 +26,16 @@ import org.oscim.core.Point; import org.oscim.core.Tile; import org.oscim.renderer.GLMatrix; import org.oscim.utils.FastMath; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * The Viewport class contains a MapPosition and the projection matrices. * It provides functions to modify the MapPosition and translate between * map and screen coordinates. - *

+ *

* Public methods are thread safe. */ public class Viewport { - static final Logger log = LoggerFactory.getLogger(Viewport.class); - private final static int MAX_ZOOMLEVEL = 20; private final static int MIN_ZOOMLEVEL = 2; private final static float MIN_TILT = 0; @@ -389,8 +385,12 @@ public class Viewport { } } + boolean sizeChanged(Viewport viewport) { + return mHeight != viewport.mHeight || mWidth != viewport.mWidth; + } + protected boolean copy(Viewport viewport) { - boolean sizeChanged = mHeight != viewport.mHeight || mWidth != viewport.mWidth; + boolean sizeChanged = sizeChanged(viewport); mHeight = viewport.mHeight; mWidth = viewport.mWidth;