Merge pull request #9031 from osmandapp/Text_scale_map_icon37
Scale map icons with text scale
This commit is contained in:
commit
490059b627
7 changed files with 73 additions and 49 deletions
|
@ -7,6 +7,7 @@ import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -89,14 +90,16 @@ public class AudioNotesLayer extends OsmandMapLayer implements
|
||||||
if (contextMenuLayer.getMoveableObject() instanceof Recording) {
|
if (contextMenuLayer.getMoveableObject() instanceof Recording) {
|
||||||
Recording objectInMotion = (Recording) contextMenuLayer.getMoveableObject();
|
Recording objectInMotion = (Recording) contextMenuLayer.getMoveableObject();
|
||||||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||||
drawRecording(canvas, objectInMotion, pf.x, pf.y);
|
float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
|
||||||
|
drawRecording(canvas, objectInMotion, pf.x, pf.y, textScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
float iconSize = audio.getWidth() * 3 / 2.5f;
|
float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
|
||||||
|
float iconSize = audio.getWidth() * 3 / 2.5f * textScale;
|
||||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||||
|
|
||||||
DataTileManager<Recording> recs = plugin.getRecordings();
|
DataTileManager<Recording> recs = plugin.getRecordings();
|
||||||
|
@ -111,7 +114,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements
|
||||||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
|
|
||||||
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
||||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
Rect destRect = getIconDestinationRect(x, y, pointSmall.getWidth(), pointSmall.getHeight(), textScale);
|
||||||
|
canvas.drawBitmap(pointSmall, null, destRect, paintIcon);
|
||||||
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
|
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
|
||||||
} else {
|
} else {
|
||||||
fullObjects.add(o);
|
fullObjects.add(o);
|
||||||
|
@ -122,14 +126,14 @@ public class AudioNotesLayer extends OsmandMapLayer implements
|
||||||
for (Recording o : fullObjects) {
|
for (Recording o : fullObjects) {
|
||||||
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
drawRecording(canvas, o, x, y);
|
drawRecording(canvas, o, x, y, textScale);
|
||||||
}
|
}
|
||||||
this.fullObjectsLatLon = fullObjectsLatLon;
|
this.fullObjectsLatLon = fullObjectsLatLon;
|
||||||
this.smallObjectsLatLon = smallObjectsLatLon;
|
this.smallObjectsLatLon = smallObjectsLatLon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawRecording(Canvas canvas, Recording o, float x, float y) {
|
private void drawRecording(Canvas canvas, Recording o, float x, float y, float textScale) {
|
||||||
Bitmap b;
|
Bitmap b;
|
||||||
if (o.isPhoto()) {
|
if (o.isPhoto()) {
|
||||||
b = photo;
|
b = photo;
|
||||||
|
@ -138,7 +142,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements
|
||||||
} else {
|
} else {
|
||||||
b = video;
|
b = video;
|
||||||
}
|
}
|
||||||
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
|
Rect destRect = getIconDestinationRect(x, y, b.getWidth(), b.getHeight(), textScale);
|
||||||
|
canvas.drawBitmap(b, null, destRect, paintIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -104,9 +104,6 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
int offsetY = bounds.centerY() - uiListIcon.getIntrinsicHeight() / 2;
|
int offsetY = bounds.centerY() - uiListIcon.getIntrinsicHeight() / 2;
|
||||||
uiListIcon.setBounds(offsetX, offsetY, uiListIcon.getIntrinsicWidth() + offsetX,
|
uiListIcon.setBounds(offsetX, offsetY, uiListIcon.getIntrinsicWidth() + offsetX,
|
||||||
uiListIcon.getIntrinsicHeight() + offsetY);
|
uiListIcon.getIntrinsicHeight() + offsetY);
|
||||||
} else if (withShadow) {
|
|
||||||
bs.inset(bs.width() / 3, bs.height() / 3);
|
|
||||||
favIcon.setBounds(bs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,17 +148,16 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawBitmap(@NonNull Canvas canvas, Rect bs, Bitmap bitmap, Paint paintBackground) {
|
public void drawBitmap(@NonNull Canvas canvas, Rect bs, Bitmap bitmap, Paint paintBackground) {
|
||||||
canvas.drawBitmap(bitmap, bs.exactCenterX() - bitmap.getWidth() / 2f,
|
canvas.drawBitmap(bitmap, null, bs, paintBackground);
|
||||||
bs.exactCenterY() - bitmap.getHeight() / 2f, paintBackground);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawBitmapInCenter(Canvas canvas, float x, float y, boolean history) {
|
public void drawBitmapInCenter(Canvas canvas, Rect destRect, boolean history) {
|
||||||
this.history = history;
|
this.history = history;
|
||||||
float dx = x - getIntrinsicWidth() / 2f;
|
setBounds(destRect);
|
||||||
float dy = y - getIntrinsicHeight() / 2f;
|
Rect bounds = new Rect(destRect);
|
||||||
canvas.translate(dx, dy);
|
bounds.inset(bounds.width() / 3, bounds.height() / 3);
|
||||||
|
favIcon.setBounds(bounds);
|
||||||
draw(canvas);
|
draw(canvas);
|
||||||
canvas.translate(-dx, -dy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
@ -104,7 +105,8 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
FavouritePoint objectInMotion = (FavouritePoint) contextMenuLayer.getMoveableObject();
|
FavouritePoint objectInMotion = (FavouritePoint) contextMenuLayer.getMoveableObject();
|
||||||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||||
MapMarker mapMarker = mapMarkersHelper.getMapMarker(objectInMotion);
|
MapMarker mapMarker = mapMarkersHelper.getMapMarker(objectInMotion);
|
||||||
drawBigPoint(canvas, objectInMotion, pf.x, pf.y, mapMarker);
|
float textScale = this.settings.TEXT_SCALE.get();
|
||||||
|
drawBigPoint(canvas, objectInMotion, pf.x, pf.y, mapMarker, textScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +115,9 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
cache.clear();
|
cache.clear();
|
||||||
if (this.settings.SHOW_FAVORITES.get() && favorites.isFavoritesLoaded()) {
|
if (this.settings.SHOW_FAVORITES.get() && favorites.isFavoritesLoaded()) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
|
float textScale = this.settings.TEXT_SCALE.get();
|
||||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||||
true, (FavouritePoint) null).getIntrinsicWidth() * 3 / 2.5f;
|
true, (FavouritePoint) null).getIntrinsicWidth() * 3 / 2.5f * textScale;
|
||||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||||
|
|
||||||
// request to load
|
// request to load
|
||||||
|
@ -147,17 +150,15 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
color = grayColor;
|
color = grayColor;
|
||||||
} else {
|
} else {
|
||||||
color = favorites.getColorWithCategory(o,defaultColor);
|
color = favorites.getColorWithCategory(o,defaultColor);
|
||||||
// color = o.getColor() == 0 ? defaultColor : o.getColor();
|
|
||||||
}
|
}
|
||||||
paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||||
Bitmap pointSmallTop = getBitmap(o, "top");
|
Bitmap pointSmallTop = getBitmap(o, "top");
|
||||||
Bitmap pointSmallCenter = getBitmap(o, "center");
|
Bitmap pointSmallCenter = getBitmap(o, "center");
|
||||||
Bitmap pointSmallBottom = getBitmap(o, "bottom");
|
Bitmap pointSmallBottom = getBitmap(o, "bottom");
|
||||||
float left = x - pointSmallTop.getWidth() / 2f;
|
Rect destRect = getIconDestinationRect(x, y, pointSmallTop.getWidth(), pointSmallTop.getHeight(), textScale);
|
||||||
float top = y - pointSmallTop.getHeight() / 2f;
|
canvas.drawBitmap(pointSmallBottom, null, destRect, null);
|
||||||
canvas.drawBitmap(pointSmallBottom, left, top, null);
|
canvas.drawBitmap(pointSmallCenter, null, destRect, paintIcon);
|
||||||
canvas.drawBitmap(pointSmallCenter, left, top, paintIcon);
|
canvas.drawBitmap(pointSmallTop, null, destRect, null);
|
||||||
canvas.drawBitmap(pointSmallTop, left, top, null);
|
|
||||||
smallObjectsLatLon.add(new LatLon(lat, lon));
|
smallObjectsLatLon.add(new LatLon(lat, lon));
|
||||||
} else {
|
} else {
|
||||||
fullObjects.add(new Pair<>(o, marker));
|
fullObjects.add(new Pair<>(o, marker));
|
||||||
|
@ -169,7 +170,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
FavouritePoint o = pair.first;
|
FavouritePoint o = pair.first;
|
||||||
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||||
drawBigPoint(canvas, o, x, y, pair.second);
|
drawBigPoint(canvas, o, x, y, pair.second, textScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.fullObjectsLatLon = fullObjectsLatLon;
|
this.fullObjectsLatLon = fullObjectsLatLon;
|
||||||
|
@ -190,7 +191,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
return pointSmall;
|
return pointSmall;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBigPoint(Canvas canvas, FavouritePoint o, float x, float y, @Nullable MapMarker marker) {
|
private void drawBigPoint(Canvas canvas, FavouritePoint o, float x, float y, @Nullable MapMarker marker, float textScale) {
|
||||||
FavoriteImageDrawable fid;
|
FavoriteImageDrawable fid;
|
||||||
boolean history = false;
|
boolean history = false;
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
|
@ -199,7 +200,8 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
} else {
|
} else {
|
||||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), favorites.getColorWithCategory(o,defaultColor), true, o);
|
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), favorites.getColorWithCategory(o,defaultColor), true, o);
|
||||||
}
|
}
|
||||||
fid.drawBitmapInCenter(canvas, x, y, history);
|
Rect destRest = getIconDestinationRect(x, y, fid.getIntrinsicWidth(), fid.getIntrinsicHeight(), textScale);
|
||||||
|
fid.drawBitmapInCenter(canvas, destRest, history);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getSmallIconId(String layer, int iconId) {
|
private int getSmallIconId(String layer, int iconId) {
|
||||||
|
|
|
@ -196,7 +196,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
if (gpxFile != null) {
|
if (gpxFile != null) {
|
||||||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||||
MapMarker mapMarker = mapMarkersHelper.getMapMarker(objectInMotion);
|
MapMarker mapMarker = mapMarkersHelper.getMapMarker(objectInMotion);
|
||||||
drawBigPoint(canvas, objectInMotion, getFileColor(gpxFile), pf.x, pf.y, mapMarker);
|
float textScale = view.getSettings().TEXT_SCALE.get();
|
||||||
|
drawBigPoint(canvas, objectInMotion, getFileColor(gpxFile), pf.x, pf.y, mapMarker, textScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,8 +372,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
|
|
||||||
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
|
float textScale = view.getSettings().TEXT_SCALE.get();
|
||||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||||
true, (WptPt) null).getIntrinsicWidth() * 3 / 2.5f;
|
true, (WptPt) null).getIntrinsicWidth() * 3 / 2.5f * textScale;
|
||||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||||
|
|
||||||
List<LatLon> fullObjectsLatLon = new ArrayList<>();
|
List<LatLon> fullObjectsLatLon = new ArrayList<>();
|
||||||
|
@ -408,7 +410,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
color = getPointColor(o, fileColor);
|
color = getPointColor(o, fileColor);
|
||||||
}
|
}
|
||||||
paintIcon.setColorFilter(new PorterDuffColorFilter(color | 0xff000000, PorterDuff.Mode.MULTIPLY));
|
paintIcon.setColorFilter(new PorterDuffColorFilter(color | 0xff000000, PorterDuff.Mode.MULTIPLY));
|
||||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
Rect destRect = getIconDestinationRect(x, y, pointSmall.getWidth(), pointSmall.getHeight(), textScale);
|
||||||
|
canvas.drawBitmap(pointSmall, null, destRect, paintIcon);
|
||||||
smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
|
smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
|
||||||
} else {
|
} else {
|
||||||
fullObjects.add(new Pair<>(o, marker));
|
fullObjects.add(new Pair<>(o, marker));
|
||||||
|
@ -423,7 +426,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
WptPt o = pair.first;
|
WptPt o = pair.first;
|
||||||
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
|
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
|
||||||
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||||
drawBigPoint(canvas, o, fileColor, x, y, pair.second);
|
drawBigPoint(canvas, o, fileColor, x, y, pair.second, textScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (trackChartPoints != null) {
|
if (trackChartPoints != null) {
|
||||||
|
@ -497,7 +500,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
return g.getColor() == 0 ? defPointColor : g.getColor();
|
return g.getColor() == 0 ? defPointColor : g.getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBigPoint(Canvas canvas, WptPt o, int fileColor, float x, float y, @Nullable MapMarker marker) {
|
private void drawBigPoint(Canvas canvas, WptPt o, int fileColor, float x, float y, @Nullable MapMarker marker, float textScale) {
|
||||||
int pointColor = getPointColor(o, fileColor);
|
int pointColor = getPointColor(o, fileColor);
|
||||||
FavoriteImageDrawable fid;
|
FavoriteImageDrawable fid;
|
||||||
boolean history = false;
|
boolean history = false;
|
||||||
|
@ -507,7 +510,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
} else {
|
} else {
|
||||||
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true, o);
|
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true, o);
|
||||||
}
|
}
|
||||||
fid.drawBitmapInCenter(canvas, x, y, history);
|
Rect destRest = getIconDestinationRect(x, y, fid.getIntrinsicWidth(), fid.getIntrinsicHeight(), textScale);
|
||||||
|
fid.drawBitmapInCenter(canvas, destRest, history);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.graphics.Path;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.PorterDuff.Mode;
|
import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -624,6 +625,18 @@ public abstract class OsmandMapLayer {
|
||||||
return (int) (r * tb.getDensity());
|
return (int) (r * tb.getDensity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rect getIconDestinationRect(float x, float y, int width, int height, float scale) {
|
||||||
|
int scaledWidth = width;
|
||||||
|
int scaledHeight = height;
|
||||||
|
if (scale != 1.0f) {
|
||||||
|
scaledWidth = (int) (width * scale);
|
||||||
|
scaledHeight = (int) (height * scale);
|
||||||
|
}
|
||||||
|
Rect rect = new Rect(0, 0, scaledWidth, scaledHeight);
|
||||||
|
rect.offset((int) x - scaledWidth / 2, (int) y - scaledHeight / 2);
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class MapLayerData<T> {
|
public abstract class MapLayerData<T> {
|
||||||
public int ZOOM_THRESHOLD = 1;
|
public int ZOOM_THRESHOLD = 1;
|
||||||
public RotatedTileBox queriedBox;
|
public RotatedTileBox queriedBox;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
@ -220,7 +221,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
data.queryNewData(tileBox);
|
data.queryNewData(tileBox);
|
||||||
objects = data.getResults();
|
objects = data.getResults();
|
||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
float iconSize = poiBackground.getWidth() * 3 / 2;
|
float textScale = app.getSettings().TEXT_SCALE.get();
|
||||||
|
float iconSize = poiBackground.getWidth() * 3 / 2 * textScale;
|
||||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||||
WaypointHelper wph = app.getWaypointHelper();
|
WaypointHelper wph = app.getWaypointHelper();
|
||||||
|
|
||||||
|
@ -233,7 +235,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
if (tileBox.containsPoint(x, y, iconSize)) {
|
if (tileBox.containsPoint(x, y, iconSize)) {
|
||||||
if (intersects(boundIntersections, x, y, iconSize, iconSize) ||
|
if (intersects(boundIntersections, x, y, iconSize, iconSize) ||
|
||||||
(app.getSettings().SHOW_NEARBY_POI.get() && wph.isRouteCalculated() && !wph.isAmenityNoPassed(o))) {
|
(app.getSettings().SHOW_NEARBY_POI.get() && wph.isRouteCalculated() && !wph.isAmenityNoPassed(o))) {
|
||||||
canvas.drawBitmap(poiBackgroundSmall, x - poiBackgroundSmall.getWidth() / 2, y - poiBackgroundSmall.getHeight() / 2, paintIconBackground);
|
Rect destRect = getIconDestinationRect(x, y, poiBackgroundSmall.getWidth(), poiBackgroundSmall.getHeight(), textScale);
|
||||||
|
canvas.drawBitmap(poiBackgroundSmall, null, destRect, paintIconBackground);
|
||||||
smallObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(),
|
smallObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(),
|
||||||
o.getLocation().getLongitude()));
|
o.getLocation().getLongitude()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -249,7 +252,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation()
|
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation()
|
||||||
.getLongitude());
|
.getLongitude());
|
||||||
if (tileBox.containsPoint(x, y, iconSize)) {
|
if (tileBox.containsPoint(x, y, iconSize)) {
|
||||||
canvas.drawBitmap(poiBackground, x - poiBackground.getWidth() / 2, y - poiBackground.getHeight() / 2, paintIconBackground);
|
Rect destRect = getIconDestinationRect(x, y, poiBackground.getWidth(), poiBackground.getHeight(), textScale);
|
||||||
|
canvas.drawBitmap(poiBackground, null, destRect, paintIconBackground);
|
||||||
String id = null;
|
String id = null;
|
||||||
PoiType st = o.getType().getPoiTypeByKeyName(o.getSubType());
|
PoiType st = o.getType().getPoiTypeByKeyName(o.getSubType());
|
||||||
if (st != null) {
|
if (st != null) {
|
||||||
|
@ -262,12 +266,10 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
Drawable img = RenderingIcons.getDrawableIcon(view.getContext(), id, false);
|
Drawable img = RenderingIcons.getDrawableIcon(view.getContext(), id, false);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
canvas.save();
|
destRect = getIconDestinationRect(x, y, poiSize, poiSize, textScale);
|
||||||
canvas.translate(x - poiSize / 2f, y - poiSize / 2f);
|
img.setBounds(destRect);
|
||||||
img.setBounds(0, 0, poiSize, poiSize);
|
|
||||||
img.setColorFilter(poiColorFilter);
|
img.setColorFilter(poiColorFilter);
|
||||||
img.draw(canvas);
|
img.draw(canvas);
|
||||||
canvas.restore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.Path;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
@ -233,7 +234,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
float iconSize = stopBus.getWidth() * 3 / 2.5f;
|
float textScale = mapActivity.getMyApplication().getSettings().TEXT_SCALE.get();
|
||||||
|
float iconSize = stopBus.getWidth() * 3 / 2.5f * textScale;
|
||||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tb);
|
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tb);
|
||||||
List<TransportStop> fullObjects = new ArrayList<>();
|
List<TransportStop> fullObjects = new ArrayList<>();
|
||||||
for (TransportStop o : objects) {
|
for (TransportStop o : objects) {
|
||||||
|
@ -241,7 +243,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
|
float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
|
||||||
|
|
||||||
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
||||||
canvas.drawBitmap(stopSmall, x - stopSmall.getWidth() / 2f, y - stopSmall.getHeight() / 2f, paintIcon);
|
Rect destRect = getIconDestinationRect(x, y, stopSmall.getWidth(), stopSmall.getHeight(), textScale);
|
||||||
|
canvas.drawBitmap(stopSmall, null, destRect, paintIcon);
|
||||||
} else {
|
} else {
|
||||||
fullObjects.add(o);
|
fullObjects.add(o);
|
||||||
}
|
}
|
||||||
|
@ -254,17 +257,16 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
TransportStopType type = TransportStopType.findType(stopRoute.route.getType());
|
TransportStopType type = TransportStopType.findType(stopRoute.route.getType());
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
Drawable foregroundIcon = RenderingIcons.getDrawableIcon(mapActivity, type.getResName(), false);
|
Drawable foregroundIcon = RenderingIcons.getDrawableIcon(mapActivity, type.getResName(), false);
|
||||||
canvas.drawBitmap(backgroundIcon, x - backgroundIconHalfWidth, y - backgroundIconHalfHeight, paintIcon);
|
Rect destRect = getIconDestinationRect(x, y, backgroundIcon.getWidth(), backgroundIcon.getHeight(), textScale);
|
||||||
canvas.save();
|
canvas.drawBitmap(backgroundIcon, null, destRect, paintIcon);
|
||||||
canvas.translate(x - foregroundIcon.getIntrinsicWidth() / 2f, y - foregroundIcon.getIntrinsicHeight() / 2f);
|
destRect = getIconDestinationRect(x, y, foregroundIcon.getIntrinsicWidth(), foregroundIcon.getIntrinsicHeight(), textScale);
|
||||||
foregroundIcon.setBounds(0, 0, foregroundIcon.getIntrinsicWidth(), foregroundIcon.getIntrinsicHeight());
|
foregroundIcon.setBounds(destRect);
|
||||||
foregroundIcon.setColorFilter(nightMode ? paintDarkIconFilter : paintLightIconFilter);
|
foregroundIcon.setColorFilter(nightMode ? paintDarkIconFilter : paintLightIconFilter);
|
||||||
foregroundIcon.draw(canvas);
|
foregroundIcon.draw(canvas);
|
||||||
canvas.restore();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Bitmap b = stopBus;
|
Rect destRect = getIconDestinationRect(x, y, stopBus.getWidth(), stopBus.getHeight(), textScale);
|
||||||
canvas.drawBitmap(b, x - b.getWidth() / 2f, y - b.getHeight() / 2f, paintIcon);
|
canvas.drawBitmap(stopBus, null, destRect, paintIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue