Add color to track chart points

This commit is contained in:
PavelRatushny 2017-06-12 18:59:20 +03:00
parent b1630e017f
commit 774fcd0c8f
2 changed files with 26 additions and 20 deletions

View file

@ -53,6 +53,7 @@ public class TrackDetailsMenu {
private GpxDisplayItem gpxItem;
private TrackDetailsBarController toolbarController;
private TrkSegment segment;
private int segmentColor;
private static boolean VISIBLE;
@ -290,7 +291,10 @@ public class TrackDetailsMenu {
if (wpt != null) {
location = new LatLon(wpt.lat, wpt.lon);
List<Pair<String, WptPt>> xAxisPoints = getXAxisPoints(chart);
TrackChartPoints trackChartPoints = new TrackChartPoints(xAxisPoints, location, getTrackSegment(chart), getGpxItem().group.getGpx().path);
if (segmentColor == 0) {
segmentColor = getTrackSegment(chart).getColor(0);
}
TrackChartPoints trackChartPoints = new TrackChartPoints(xAxisPoints, location, segmentColor, getGpxItem().group.getGpx());
if (gpxItem.route) {
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
} else {
@ -579,14 +583,14 @@ public class TrackDetailsMenu {
public class TrackChartPoints {
private List<Pair<String, WptPt>> xAxisPoints;
private LatLon highlightedPoint;
private TrkSegment chartSegment;
private String gpxPath;
private int segmentColor;
private GPXFile gpx;
public TrackChartPoints(List<Pair<String, WptPt>> xAxisPoints, LatLon highlightedPoint, TrkSegment chartSegment, String gpxPath) {
public TrackChartPoints(List<Pair<String, WptPt>> xAxisPoints, LatLon highlightedPoint, int segmentColor, GPXFile gpx) {
this.xAxisPoints = xAxisPoints;
this.highlightedPoint = highlightedPoint;
this.chartSegment = chartSegment;
this.gpxPath = gpxPath;
this.segmentColor = segmentColor;
this.gpx = gpx;
}
public List<Pair<String, WptPt>> getXAxisPoints() {
@ -597,12 +601,12 @@ public class TrackDetailsMenu {
return highlightedPoint;
}
public TrkSegment getChartSegment() {
return chartSegment;
public int getSegmentColor() {
return segmentColor;
}
public String getGpxPath() {
return gpxPath;
public GPXFile getGpx() {
return gpx;
}
}
}

View file

@ -386,17 +386,19 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
}
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
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;
}
int color = trackChartPoints.getSegmentColor();
if (color == 0) {
color = trackChartPoints.getChartSegment().getColor(cachedColor);
GpxDataItem gpxDataItem = null;
if (!trackChartPoints.getGpx().showCurrentTrack) {
gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(trackChartPoints.getGpx().path));
}
color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
if (trackChartPoints.getGpx().showCurrentTrack) {
color = currentTrackColor;
}
if (color == 0) {
color = cachedColor;
}
}
paintInnerRect.setColor(color);
QuadRect latLonBounds = tileBox.getLatLonBounds();