Update interface

This commit is contained in:
vshcherb 2013-10-23 23:26:05 +02:00
parent 1a52c0c971
commit 35b7eda9a3
15 changed files with 60 additions and 59 deletions

View file

@ -216,20 +216,20 @@ public class RotatedTileBox {
}
public int getPixXFromLatLon(double latitude, double longitude) {
public float getPixXFromLatLon(double latitude, double longitude) {
float xTile = (float) MapUtils.getTileNumberX(zoom, longitude);
float yTile = (float) MapUtils.getTileNumberY(zoom, latitude);
return getPixXFromTile(xTile, yTile);
}
public int getPixXFromTile(double tileX, double tileY, float zoom) {
public float getPixXFromTile(double tileX, double tileY, float zoom) {
double pw = MapUtils.getPowZoom(zoom - this.zoom);
float xTile = (float) (tileX / pw);
float yTile = (float) (tileY / pw);
return getPixXFromTile(xTile, yTile);
}
protected int getPixXFromTile(double xTile, double yTile) {
protected float getPixXFromTile(double xTile, double yTile) {
double rotX;
final double dTileX = xTile - oxTile;
final double dTileY = yTile - oyTile;
@ -239,24 +239,24 @@ public class RotatedTileBox {
rotX = dTileX;
}
double dx = rotX * zoomFactor;
return (int) (dx + cx);
return (float) (dx + cx);
}
public int getPixYFromLatLon(double latitude, double longitude) {
public float getPixYFromLatLon(double latitude, double longitude) {
float xTile = (float) MapUtils.getTileNumberX(zoom, longitude);
float yTile = (float) MapUtils.getTileNumberY(zoom, latitude);
return getPixYFromTile(xTile, yTile);
}
public int getPixYFromTile(double tileX, double tileY, float zoom) {
public float getPixYFromTile(double tileX, double tileY, float zoom) {
double pw = MapUtils.getPowZoom(zoom - this.zoom);
float xTile = (float) (tileX / pw);
float yTile = (float) (tileY / pw);
return getPixYFromTile(xTile, yTile);
}
protected int getPixYFromTile(float xTile, float yTile) {
protected float getPixYFromTile(float xTile, float yTile) {
final double dTileX = xTile - oxTile;
final double dTileY = yTile - oyTile;
double rotY;
@ -266,7 +266,7 @@ public class RotatedTileBox {
rotY = dTileY;
}
double dy = rotY * zoomFactor;
return (int) (dy + cy);
return (float) (dy + cy);
}
public int getPixXFromLonNoRot(double longitude) {

View file

@ -90,8 +90,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
final QuadRect latlon = tileBox.getLatLonBounds();
List<Recording> objects = recs.getObjects(latlon. top, latlon.left, latlon.bottom, latlon.right);
for (Recording o : objects) {
int x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
int y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
Bitmap b;
if (o.isPhoto()) {
b = photo;
@ -189,8 +189,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
int compare = getRadiusPoi(tileBox);
int radius = compare * 3 / 2;
for (Recording n : plugin.getAllRecordings()) {
int x = tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = tileBox.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
int x = (int) tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
if (calculateBelongs(ex, ey, x, y, compare)) {
compare = radius;
am.add(n);

View file

@ -545,8 +545,8 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
boolean first = true;
while (it.hasNext()) {
WptPt pt = it.next();
int x = tb.getPixXFromLatLon(pt.lat, pt.lon);
int y = tb.getPixYFromLatLon(pt.lat, pt.lon);
int x = (int) tb.getPixXFromLatLon(pt.lat, pt.lon);
int y = (int) tb.getPixYFromLatLon(pt.lat, pt.lon);
if (pt.desc != null || !it.hasNext() || first) {
if (calculateBelongsBig(ex, ey, x, y, r)) {
res.add(pt);

View file

@ -181,8 +181,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
try {
for (int i = 0; i < objects.size(); i++) {
OpenStreetNote n = objects.get(i);
int x = tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
radius = small;
res.add(n);

View file

@ -123,10 +123,10 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
prevlongitude = op.prevlatlon.getLongitude();
}
int locationX = tileBox.getPixXFromLatLon(latitude, longitude);
int locationY = tileBox.getPixYFromLatLon(latitude, longitude);
int prevlocationX = tileBox.getPixXFromLatLon(prevlatitude, prevlongitude);
int prevlocationY = tileBox.getPixYFromLatLon(prevlatitude, prevlongitude);
int locationX = (int) tileBox.getPixXFromLatLon(latitude, longitude);
int locationY = (int) tileBox.getPixYFromLatLon(latitude, longitude);
int prevlocationX = (int) tileBox.getPixXFromLatLon(prevlatitude, prevlongitude);
int prevlocationY = (int) tileBox.getPixYFromLatLon(prevlatitude, prevlongitude);
// int y = opIcon.getHeight()/2;
// int x = opIcon.getWidth()/2;
@ -157,8 +157,8 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
for (int i = 0; i < myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId).size(); i++) {
OsMoDroidPoint n = myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId).get(i);
if (!om.contains(n)) {
int x = tb.getPixXFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
int y = tb.getPixYFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
int x = (int) tb.getPixXFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
if (Math.abs(x - ex) <= opIcon.getWidth() && Math.abs(y - ey) <= opIcon.getHeight()) {
om.add(n);
}

View file

@ -210,8 +210,8 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
int ex = (int) point.x;
int ey = (int) point.y;
LatLon position = plugin.getParkingPosition();
int x = tb.getPixXFromLatLon(position.getLatitude(), position.getLongitude());
int y = tb.getPixYFromLatLon(position.getLatitude(), position.getLongitude());
int x = (int) tb.getPixXFromLatLon(position.getLatitude(), position.getLongitude());
int y = (int) tb.getPixYFromLatLon(position.getLatitude(), position.getLongitude());
// the width of an image is 40 px, the height is 60 px -> radius = 20,
// the position of a parking point relatively to the icon is at the center of the bottom line of the image
if (Math.abs(x - ex) <= radius && ((y - ey) <= radius * 2) && ((y - ey) >= -radius)) {

View file

@ -1,13 +1,16 @@
package net.osmand.plus.render;
import android.graphics.*;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.views.BaseMapLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.RectF;
public class MapVectorLayer extends BaseMapLayer {
@ -110,10 +113,10 @@ public class MapVectorLayer extends BaseMapLayer {
calc.setRotate(bmpLoc.getRotate());
QuadPoint lt = bmpLoc.getLeftTopTile(cz);
QuadPoint rb = bmpLoc.getRightBottomTile(cz);
final int x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
final int x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
final int y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
final int y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
final float x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
final float x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
final float y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
final float y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
destImage.set(x1, y1, x2, y2);
if(!bmp.isRecycled()){
canvas.drawBitmap(bmp, null, destImage, paintImg);

View file

@ -14,7 +14,6 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Canvas;
@ -23,10 +22,8 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
@ -119,8 +116,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
if(latLon != null){
int x = box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int tx = x - boxLeg.getMinimumWidth() / 2;
int ty = y - boxLeg.getMinimumHeight() + SHADOW_OF_LEG;

View file

@ -82,8 +82,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
for (FavouritePoint o : favorites.getFavouritePoints()) {
if (o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
&& o.getLongitude() <= latLonBounds.right ) {
int x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
int y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2,
y - favoriteIcon.getHeight(), paint);
}
@ -102,8 +102,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
int ex = (int) point.x;
int ey = (int) point.y;
for (FavouritePoint n : favorites.getFavouritePoints()) {
int x = tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
if (calculateBelongs(ex, ey, x, y, r)) {
res.add(n);
}

View file

@ -396,10 +396,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
int cz = getZoom();
QuadPoint lt = bufferImgLoc.getLeftTopTile(cz);
QuadPoint rb = bufferImgLoc.getRightBottomTile(cz);
final int x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
final int x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
final int y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
final int y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
final float x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
final float x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
final float y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
final float y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
if(!bufferBitmap.isRecycled()){
canvas.drawBitmap(bufferBitmap, null, new RectF(x1, y1, x2, y2), paintImg);
}
@ -665,7 +665,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
}
public void moveTo(float dx, float dy) {
final RotatedTileBox tb = currentViewport;
final QuadPoint cp = currentViewport.getCenterPixelPoint();
final LatLon latlon = currentViewport.getLatLonFromPixel(cp.x + dx, cp.y + dy);
currentViewport.setLatLonCenter(latlon.getLatitude(), latlon.getLongitude());

View file

@ -75,8 +75,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
try {
for (int i = 0; i < objects.size(); i++) {
Amenity n = objects.get(i);
int x = tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int y = tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int x = (int) tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
if (Math.abs(x - ex) <= compare && Math.abs(y - ey) <= compare) {
compare = radius;
am.add(n);
@ -173,8 +173,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
latLonBounds.right, tileBox.getZoom(), filter, objects);
int r = getRadiusPoi(tileBox);
for (Amenity o : objects) {
int x = tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int y = tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
canvas.drawCircle(x, y, r, pointAltUI);
canvas.drawCircle(x, y, r, point);
String id = null;
@ -197,8 +197,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
if (view.getSettings().SHOW_POI_LABEL.get()) {
TIntHashSet set = new TIntHashSet();
for (Amenity o : objects) {
int x = tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int y = tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int tx = tileBox.getPixXFromLonNoRot(o.getLocation().getLongitude());
int ty = tileBox.getPixYFromLatNoRot(o.getLocation().getLatitude());
String name = o.getName(view.getSettings().USE_ENGLISH_NAMES.get());

View file

@ -164,8 +164,8 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
if (latLon != null) {
int ex = (int) point.x;
int ey = (int) point.y;
int x = tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
if (calculateBelongs(ex, ey, x, y, r)) {
TargetPoint tp = new TargetPoint();
tp.location = latLon;

View file

@ -157,7 +157,9 @@ public class RouteLayer extends OsmandMapLayer {
path.lineTo(x, y);
}
canvas.drawPath(path, paint);
drawArrowsOverPath(canvas, path, coloredArrowUp);
if(tb.getZoomAnimation() == 0) {
drawArrowsOverPath(canvas, path, coloredArrowUp);
}
}
}

View file

@ -87,8 +87,8 @@ public class TransportInfoLayer extends OsmandMapLayer {
if (start) {
LatLon location = st.getLocation();
if (tileBox.containsLatLon(location.getLatitude(), location.getLongitude())) {
int x = tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
canvas.drawRect(x - getRadius(tileBox), y - getRadius(tileBox), x + getRadius(tileBox), y
+ getRadius(tileBox), toShow);
}
@ -136,8 +136,8 @@ public class TransportInfoLayer extends OsmandMapLayer {
}
if (start) {
LatLon location = st.getLocation();
int x = tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
if (Math.abs(x - ex) < getRadius(tileBox) * 3 /2 && Math.abs(y - ey) < getRadius(tileBox) * 3 /2) {
AccessibleToast.makeText(view.getContext(), st.getName(view.getSettings().USE_ENGLISH_NAMES.get()) + " : " + //$NON-NLS-1$
route.getType() + " " + route.getRef() //$NON-NLS-1$

View file

@ -54,8 +54,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
try {
for (int i = 0; i < objects.size(); i++) {
TransportStop n = objects.get(i);
int x = tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int y = tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int x = (int) tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
radius = small;
res.add(n);