From 68af54e14028fe79c684101ab5afa450bd58b865 Mon Sep 17 00:00:00 2001 From: cepprice Date: Fri, 2 Apr 2021 01:51:28 +0500 Subject: [PATCH] Change user point icons for multi profile mode --- .../measurementtool/MeasurementToolLayer.java | 41 +++++++++---------- .../MultiProfileGeometryWayContext.java | 13 +++--- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index b630233137..90ebcfda36 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -271,10 +271,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL List beforePoints = editingCtx.getBeforePoints(); List afterPoints = editingCtx.getAfterPoints(); if (beforePoints.size() > 0) { - drawPointIcon(canvas, tb, beforePoints.get(beforePoints.size() - 1)); + drawPointIcon(canvas, tb, beforePoints.get(beforePoints.size() - 1), true); } if (afterPoints.size() > 0) { - drawPointIcon(canvas, tb, afterPoints.get(0)); + drawPointIcon(canvas, tb, afterPoints.get(0), true); } if (editingCtx.getSelectedPointPosition() != -1) { @@ -321,25 +321,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL } if (overlapped) { WptPt pt = points.get(0); - if (pt != lastBeforePoint && pt != firstAfterPoint && isInTileBox(tb, pt)) { - float locX = tb.getPixXFromLatLon(pt.lat, pt.lon); - float locY = tb.getPixYFromLatLon(pt.lat, pt.lon); - canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint); - } + drawPointIcon(canvas, tb, pt, false); pt = points.get(points.size() - 1); - if (pt != lastBeforePoint && pt != firstAfterPoint && isInTileBox(tb, pt)) { - float locX = tb.getPixXFromLatLon(pt.lat, pt.lon); - float locY = tb.getPixYFromLatLon(pt.lat, pt.lon); - canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint); - } + drawPointIcon(canvas, tb, pt, false); } else { for (int i = 0; i < points.size(); i++) { WptPt pt = points.get(i); - if (pt != lastBeforePoint && pt != firstAfterPoint && isInTileBox(tb, pt)) { - float locX = tb.getPixXFromLatLon(pt.lat, pt.lon); - float locY = tb.getPixYFromLatLon(pt.lat, pt.lon); - canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint); - } + drawPointIcon(canvas, tb, pt, false); } } @@ -404,14 +392,23 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } - private void drawPointIcon(Canvas canvas, RotatedTileBox tb, WptPt pt) { - canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); + private void drawPointIcon(Canvas canvas, RotatedTileBox tb, WptPt pt, boolean rotate) { + if (rotate) { + canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); + } float locX = tb.getPixXFromLatLon(pt.lat, pt.lon); float locY = tb.getPixYFromLatLon(pt.lat, pt.lon); - if (tb.containsPoint(locX, locY, 0)) { - canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint); + if (editingCtx.isInMultiProfileMode()) { + canvas.drawBitmap(multiProfileGeometryWayContext.getPointIcon(), locX - multiProfileGeometryWayContext.pointIconSize / 2, + locY - multiProfileGeometryWayContext.pointIconSize / 2, bitmapPaint); + } else { + if (tb.containsPoint(locX, locY, 0)) { + canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint); + } + } + if (rotate) { + canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } - canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); } public WptPt addCenterPoint(boolean addPointBefore) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/MultiProfileGeometryWayContext.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/MultiProfileGeometryWayContext.java index 3866611c92..555194ba87 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/MultiProfileGeometryWayContext.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/MultiProfileGeometryWayContext.java @@ -24,6 +24,7 @@ public class MultiProfileGeometryWayContext extends GeometryWayContext { public final float minIconMargin; public final float circleSize; + public final float pointIconSize; private RenderingLineAttributes multiProfileAttrs; @@ -36,6 +37,7 @@ public class MultiProfileGeometryWayContext extends GeometryWayContext { profileIconsBitmapCache = new HashMap<>(); minIconMargin = density * 30; circleSize = density * 70; + pointIconSize = density * 22f; } public void updatePaints(boolean nightMode, @NonNull RenderingLineAttributes multiProfileAttrs) { @@ -46,13 +48,12 @@ public class MultiProfileGeometryWayContext extends GeometryWayContext { @Override protected void recreateBitmaps() { float density = getDensity(); - float size = density * 12.5f; - float outerRadius = density * 6.25f; - float centerRadius = density * 6; - float innerRadius = density * 4; - float centerXY = size / 2; + float outerRadius = density * 11f; + float centerRadius = density * 10.5f; + float innerRadius = density * 6.5f; + float centerXY = pointIconSize / 2; - pointIcon = Bitmap.createBitmap((int) size, (int) size, Bitmap.Config.ARGB_8888); + pointIcon = Bitmap.createBitmap((int) pointIconSize, (int) pointIconSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(pointIcon); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL);