From a2ac25cddaf3f6353e01d473322aab820b64db0f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 20 Oct 2011 19:15:53 +0200 Subject: [PATCH] Update favorite icon --- OsmAnd/res/values/strings.xml | 1 - .../net/osmand/plus/views/FavoritesLayer.java | 46 ++++++------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 59fa9bfe12..5a60853c39 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -38,7 +38,6 @@ Delete %1$s? Suburb - Suburb Hamlet Village Town diff --git a/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java index d5dee52522..2f7d02d021 100644 --- a/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/FavoritesLayer.java @@ -8,6 +8,8 @@ import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.R; import android.content.Context; import android.content.DialogInterface.OnClickListener; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; @@ -26,13 +28,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I private static final int radius = 15; private OsmandMapTileView view; - private Path path; - private Path pathDst; private Paint paint; - private Matrix matrix; - private Paint paintBlack; private DisplayMetrics dm; private FavouritesDbHelper favorites; + private Bitmap favoriteIcon; public FavoritesLayer(){ @@ -45,33 +44,16 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I dm = new DisplayMetrics(); WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE); wmgr.getDefaultDisplay().getMetrics(dm); - path = new Path(); - pathDst = new Path(); - int coef1 = (int) (radius * dm.density); - int coef2 = (int) (radius * dm.density/2); - float a = (float) (Math.PI/ 5); - path.moveTo(FloatMath.sin(0)*coef1, -FloatMath.cos(0)*coef1); - for (int j = 1; j < 10; j++) { - if (j % 2 == 1) { - path.lineTo(FloatMath.sin(j * a) * coef2, -FloatMath.cos(j * a) * coef2); - } else { - path.lineTo(FloatMath.sin(j * a) * coef1, -FloatMath.cos(j * a) * coef1); - } - } - matrix = new Matrix(); - path.close(); paint = new Paint(); - paint.setStyle(Style.FILL); - paint.setARGB(200, 255, 150, 0); - paintBlack = new Paint(); - paintBlack.setStyle(Style.STROKE); - paintBlack.setARGB(255, 0, 0, 0); - paintBlack.setAntiAlias(true); - paintBlack.setStrokeWidth(2); + paint.setAntiAlias(true); + paint.setFilterBitmap(true); + paint.setDither(true); favorites = view.getApplication().getFavorites(); + favoriteIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.poi_favourite); + } @Override @@ -82,7 +64,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I @Override public boolean drawInScreenPixels() { - return false; + return true; } @@ -93,12 +75,10 @@ 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 = view.getMapXForPoint(o.getLongitude()); - int y = view.getMapYForPoint(o.getLatitude()); - matrix.setTranslate(x, y); - path.transform(matrix, pathDst); - canvas.drawPath(pathDst, paint); - canvas.drawPath(pathDst, paintBlack); + int x = view.getRotatedMapXForPoint(o.getLatitude(), o.getLongitude()); + int y = view.getRotatedMapYForPoint(o.getLatitude(), o.getLongitude()); + canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2, + y - favoriteIcon.getHeight() / 2, paint); } } }