From b1630e017f06aa42e3de3ef61dd4a526dd2f0228 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 12 Jun 2017 17:37:55 +0300 Subject: [PATCH] Fix segment color --- .../other/TrackDetailsMenu.java | 18 ++++++++---- .../src/net/osmand/plus/views/GPXLayer.java | 28 ++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index 2bda41dd35..41d9a4ecdd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -290,7 +290,7 @@ public class TrackDetailsMenu { if (wpt != null) { location = new LatLon(wpt.lat, wpt.lon); List> xAxisPoints = getXAxisPoints(chart); - TrackChartPoints trackChartPoints = new TrackChartPoints(xAxisPoints, location, getGpxItem().group.getGpx()); + TrackChartPoints trackChartPoints = new TrackChartPoints(xAxisPoints, location, getTrackSegment(chart), getGpxItem().group.getGpx().path); if (gpxItem.route) { mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints); } else { @@ -579,12 +579,14 @@ public class TrackDetailsMenu { public class TrackChartPoints { private List> xAxisPoints; private LatLon highlightedPoint; - private GPXFile gpx; + private TrkSegment chartSegment; + private String gpxPath; - public TrackChartPoints(List> xAxisPoints, LatLon highlightedPoint, GPXFile gpx) { + public TrackChartPoints(List> xAxisPoints, LatLon highlightedPoint, TrkSegment chartSegment, String gpxPath) { this.xAxisPoints = xAxisPoints; this.highlightedPoint = highlightedPoint; - this.gpx = gpx; + this.chartSegment = chartSegment; + this.gpxPath = gpxPath; } public List> getXAxisPoints() { @@ -595,8 +597,12 @@ public class TrackDetailsMenu { return highlightedPoint; } - public GPXFile getGpx() { - return gpx; + public TrkSegment getChartSegment() { + return chartSegment; + } + + public String getGpxPath() { + return gpxPath; } } } diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index bd6f0de0e5..6e71985779 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -379,8 +379,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex paintIcon.setColorFilter(null); canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon); } - } else if (paintInnerRect.getColor() != 0){ - paintInnerRect.setColor(0); } this.fullObjectsLatLon = fullObjectsLatLon; this.smallObjectsLatLon = smallObjectsLatLon; @@ -388,21 +386,19 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex } private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) { - if (paintInnerRect.getColor() == 0) { - SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath((trackChartPoints.getGpx().path)); - GpxDataItem gpxDataItem = null; - if (!selectedGpxFile.isShowCurrentTrack()) { - gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path)); - } - int color = gpxDataItem != null ? gpxDataItem.getColor() : 0; - if (selectedGpxFile.isShowCurrentTrack()) { - color = currentTrackColor; - } - if (color == 0) { - color = cachedColor; - } - paintInnerRect.setColor(color); + SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath((trackChartPoints.getGpxPath())); + GpxDataItem gpxDataItem = null; + if (!selectedGpxFile.isShowCurrentTrack()) { + gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path)); } + int color = gpxDataItem != null ? gpxDataItem.getColor() : 0; + if (selectedGpxFile.isShowCurrentTrack()) { + color = currentTrackColor; + } + if (color == 0) { + color = trackChartPoints.getChartSegment().getColor(cachedColor); + } + paintInnerRect.setColor(color); QuadRect latLonBounds = tileBox.getLatLonBounds(); List> xAxisPoints = trackChartPoints.getXAxisPoints(); float r = 12 * tileBox.getDensity();