From 94f76451b1da70e6721f4b5dc1ff282fccaba0dc Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 16 Jun 2017 11:32:49 +0300 Subject: [PATCH] Change rect to circle --- .../other/TrackDetailsMenu.java | 15 ++++---- .../src/net/osmand/plus/views/GPXLayer.java | 35 +++++------------- .../src/net/osmand/plus/views/RouteLayer.java | 36 ++++++------------- 3 files changed, 26 insertions(+), 60 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index 3ba8430163..593408d0e4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -297,7 +297,7 @@ public class TrackDetailsMenu { trackChartPoints.setGpx(getGpxItem().group.getGpx()); } location = new LatLon(wpt.lat, wpt.lon); - List> xAxisPoints = getXAxisPoints(chart); + List xAxisPoints = getXAxisPoints(chart); trackChartPoints.setHighlightedPoint(location); trackChartPoints.setXAxisPoints(xAxisPoints); if (gpxItem.route) { @@ -312,13 +312,12 @@ public class TrackDetailsMenu { fitTrackOnMap(chart, location, forceFit); } - private List> getXAxisPoints(LineChart chart) { - List> xAxisPoints = new ArrayList<>(); + private List getXAxisPoints(LineChart chart) { + List xAxisPoints = new ArrayList<>(); float[] entries = chart.getXAxis().mEntries; for (int i = 0; i < entries.length; i++) { - String formattedEntry = chart.getXAxis().getValueFormatter().getFormattedValue(entries[i], chart.getXAxis()); WptPt pointToAdd = getPoint(chart, entries[i]); - xAxisPoints.add(new Pair<>(formattedEntry, pointToAdd)); + xAxisPoints.add(pointToAdd); } return xAxisPoints; } @@ -586,12 +585,12 @@ public class TrackDetailsMenu { } public class TrackChartPoints { - private List> xAxisPoints; + private List xAxisPoints; private LatLon highlightedPoint; private int segmentColor; private GPXFile gpx; - public List> getXAxisPoints() { + public List getXAxisPoints() { return xAxisPoints; } @@ -607,7 +606,7 @@ public class TrackDetailsMenu { return gpx; } - public void setXAxisPoints(List> xAxisPoints) { + public void setXAxisPoints(List xAxisPoints) { this.xAxisPoints = xAxisPoints; } diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index ab48dd0336..fbc1d463a8 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -86,12 +86,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex private Paint paintInnerCircle; - private Paint paintInnerRect; + private Paint paintGridCircle; private Paint paintTextIcon; - private Paint paintGridTextIcon; - private OsmandRenderer osmandRenderer; private List points; @@ -141,12 +139,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex paintTextIcon.setColor(Color.BLACK); paintTextIcon.setAntiAlias(true); - paintGridTextIcon = new Paint(); - paintGridTextIcon.setTextAlign(Align.CENTER); - paintGridTextIcon.setFakeBoldText(true); - paintGridTextIcon.setColor(Color.WHITE); - paintGridTextIcon.setAntiAlias(true); - textLayer = view.getLayerByClass(MapTextLayer.class); paintOuter = new Paint(); @@ -157,9 +149,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex paintInnerCircle.setStyle(Style.FILL_AND_STROKE); paintInnerCircle.setColor(0xddFFFFFF); paintInnerCircle.setAntiAlias(true); - paintInnerRect = new Paint(); - paintInnerRect.setStyle(Style.FILL_AND_STROKE); - paintInnerRect.setAntiAlias(true); + paintGridCircle = new Paint(); + paintGridCircle.setStyle(Style.FILL_AND_STROKE); + paintGridCircle.setAntiAlias(true); paintIcon = new Paint(); pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small); @@ -397,28 +389,19 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex } trackChartPoints.setSegmentColor(color); } - paintInnerRect.setColor(color); + paintGridCircle.setColor(color); QuadRect latLonBounds = tileBox.getLatLonBounds(); - List> xAxisPoints = trackChartPoints.getXAxisPoints(); - float r = 12 * tileBox.getDensity(); - paintGridTextIcon.setTextSize(r); + List xAxisPoints = trackChartPoints.getXAxisPoints(); + float r = 3 * tileBox.getDensity(); for (int i = 0; i < xAxisPoints.size(); i++) { - WptPt axisPoint = xAxisPoints.get(i).second; + WptPt axisPoint = xAxisPoints.get(i); if (axisPoint.getLatitude() >= latLonBounds.bottom && axisPoint.getLatitude() <= latLonBounds.top && axisPoint.getLongitude() >= latLonBounds.left && axisPoint.getLongitude() <= latLonBounds.right) { - String textOnPoint = xAxisPoints.get(i).first; - float textWidth = paintGridTextIcon.measureText(textOnPoint); float x = tileBox.getPixXFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude()); float y = tileBox.getPixYFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude()); - canvas.drawRect( - x - textWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()), - y - r / 2 - 2 * (float) Math.ceil(tileBox.getDensity()), - x + textWidth / 2 + 2 * (float) Math.ceil(tileBox.getDensity()), - y + r / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), - paintInnerRect); - canvas.drawText(textOnPoint, x, y + r / 2, paintGridTextIcon); + canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintGridCircle); } } } diff --git a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java index 2942cdb124..e1ccc79ad8 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java @@ -52,8 +52,7 @@ public class RouteLayer extends OsmandMapLayer { private Paint paintIcon; private Paint paintIconAction; - private Paint paintGridTextIcon; - private Paint paintInnerRect; + private Paint paintGridCircle; private Paint paintIconSelected; private Bitmap selectedPoint; @@ -80,16 +79,10 @@ public class RouteLayer extends OsmandMapLayer { paintIcon.setColor(Color.BLACK); paintIcon.setStrokeWidth(3); - paintGridTextIcon = new Paint(); - paintGridTextIcon.setTextAlign(Paint.Align.CENTER); - paintGridTextIcon.setFakeBoldText(true); - paintGridTextIcon.setColor(Color.WHITE); - paintGridTextIcon.setAntiAlias(true); - paintIconAction = new Paint(); paintIconAction.setFilterBitmap(true); paintIconAction.setAntiAlias(true); - + attrs = new RenderingLineAttributes("route"); attrs.defaultWidth = (int) (12 * view.getDensity()); attrs.defaultWidth3 = (int) (7 * view.getDensity()); @@ -103,10 +96,10 @@ public class RouteLayer extends OsmandMapLayer { paintIconSelected = new Paint(); selectedPoint = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_default_location); - paintInnerRect = new Paint(); - paintInnerRect.setStyle(Paint.Style.FILL_AND_STROKE); - paintInnerRect.setAntiAlias(true); - paintInnerRect.setColor(attrs.defaultColor); + paintGridCircle = new Paint(); + paintGridCircle.setStyle(Paint.Style.FILL_AND_STROKE); + paintGridCircle.setAntiAlias(true); + paintGridCircle.setColor(attrs.defaultColor); } @Override @@ -177,26 +170,17 @@ public class RouteLayer extends OsmandMapLayer { private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) { QuadRect latLonBounds = tileBox.getLatLonBounds(); - List> xAxisPoints = trackChartPoints.getXAxisPoints(); - float r = 12 * tileBox.getDensity(); - paintGridTextIcon.setTextSize(r); + List xAxisPoints = trackChartPoints.getXAxisPoints(); + float r = 3 * tileBox.getDensity(); for (int i = 0; i < xAxisPoints.size(); i++) { - WptPt axisPoint = xAxisPoints.get(i).second; + WptPt axisPoint = xAxisPoints.get(i); if (axisPoint.getLatitude() >= latLonBounds.bottom && axisPoint.getLatitude() <= latLonBounds.top && axisPoint.getLongitude() >= latLonBounds.left && axisPoint.getLongitude() <= latLonBounds.right) { - String textOnPoint = xAxisPoints.get(i).first; - float textWidth = paintGridTextIcon.measureText(textOnPoint); float x = tileBox.getPixXFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude()); float y = tileBox.getPixYFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude()); - canvas.drawRect( - x - textWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()), - y - r / 2 - 2 * (float) Math.ceil(tileBox.getDensity()), - x + textWidth / 2 + 2 * (float) Math.ceil(tileBox.getDensity()), - y + r / 2 + 3 * (float) Math.ceil(tileBox.getDensity()), - paintInnerRect); - canvas.drawText(textOnPoint, x, y + r / 2, paintGridTextIcon); + canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintGridCircle); } } }