Add points of chart for route
This commit is contained in:
parent
10650ed041
commit
dbd5da99ab
5 changed files with 142 additions and 121 deletions
|
@ -347,19 +347,6 @@ public class GpxSelectionHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public SelectedGpxFile getSelectedFileFromDisplayItemByName(String name) {
|
||||
SelectedGpxFile selectedGpxFile = null;
|
||||
name = name.replaceAll(" ", "_").concat(".gpx");
|
||||
for (SelectedGpxFile s : selectedGPXFiles) {
|
||||
String nameOfSelectedGpx = s.getGpxFile().path.replaceAll(" ", "_");
|
||||
nameOfSelectedGpx = nameOfSelectedGpx.substring(nameOfSelectedGpx.lastIndexOf("/") + 1, nameOfSelectedGpx.length());
|
||||
if (nameOfSelectedGpx.equals(name)) {
|
||||
selectedGpxFile = s;
|
||||
}
|
||||
}
|
||||
return selectedGpxFile;
|
||||
}
|
||||
|
||||
public SelectedGpxFile getSelectedCurrentRecordingTrack() {
|
||||
for (SelectedGpxFile s : selectedGPXFiles) {
|
||||
if (s.isShowCurrentTrack()) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.other;
|
|||
|
||||
import android.graphics.Matrix;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -12,7 +13,6 @@ import android.widget.TextView;
|
|||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
|
||||
|
@ -26,6 +26,7 @@ import net.osmand.plus.GPXUtilities;
|
|||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -44,9 +45,7 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TrackDetailsMenu {
|
||||
|
||||
|
@ -143,8 +142,8 @@ public class TrackDetailsMenu {
|
|||
mapActivity.hideTopToolbar(toolbarController);
|
||||
}
|
||||
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
|
||||
mapActivity.getMapLayers().getGpxLayer().setAxisValueDetails(null);
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setSelectedPointLatLon(null);
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(null);
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(null);
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
segment = null;
|
||||
|
@ -290,13 +289,12 @@ public class TrackDetailsMenu {
|
|||
WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos);
|
||||
if (wpt != null) {
|
||||
location = new LatLon(wpt.lat, wpt.lon);
|
||||
List<String> formattedAxisEntries = getFormattedAxisEntries(chart);
|
||||
List<WptPt> axisGridPoints = getAxisGridPoints(chart);
|
||||
AxisValueDetails axisValueDetails = new AxisValueDetails(axisGridPoints, formattedAxisEntries, location, getGpxItem());
|
||||
List<Pair<String, WptPt>> xAxisPoints = getXAxisPoints(chart);
|
||||
TrackChartPoints trackChartPoints = new TrackChartPoints(xAxisPoints, location, getGpxItem().group.getGpx());
|
||||
if (gpxItem.route) {
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setSelectedPointLatLon(location);
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
|
||||
} else {
|
||||
mapActivity.getMapLayers().getGpxLayer().setAxisValueDetails(axisValueDetails);
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -305,29 +303,15 @@ public class TrackDetailsMenu {
|
|||
fitTrackOnMap(chart, location, forceFit);
|
||||
}
|
||||
|
||||
private List<WptPt> getAxisGridPoints (LineChart chart) {
|
||||
List<WptPt> axisGridPoints = new ArrayList<>();
|
||||
float[] entries = chart.getXAxis().mEntries;
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
WptPt pointToAdd = getPoint(chart, entries[i]);
|
||||
axisGridPoints.add(pointToAdd);
|
||||
}
|
||||
return axisGridPoints;
|
||||
}
|
||||
|
||||
private List<String> getFormattedAxisEntries (LineChart chart) {
|
||||
private List<Pair<String, WptPt>> getXAxisPoints(LineChart chart) {
|
||||
List<Pair<String, WptPt>> xAxisPoints = new ArrayList<>();
|
||||
float[] entries = chart.getXAxis().mEntries;
|
||||
List<String> formattedAxisEntries = new ArrayList<>();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
String formattedAxisEntry = "";
|
||||
if (gpxItem.chartAxisType == GPXDataSetAxisType.DISTANCE) {
|
||||
formattedAxisEntry = String.format("%.1f", entries[i]);
|
||||
} else if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME) {
|
||||
formattedAxisEntry = chart.getXAxis().getValueFormatter().getFormattedValue(entries[i], chart.getXAxis());
|
||||
}
|
||||
formattedAxisEntries.add(formattedAxisEntry);
|
||||
}
|
||||
return formattedAxisEntries;
|
||||
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));
|
||||
}
|
||||
return xAxisPoints;
|
||||
}
|
||||
|
||||
private void updateView(final View parentView) {
|
||||
|
@ -592,33 +576,27 @@ public class TrackDetailsMenu {
|
|||
}
|
||||
}
|
||||
|
||||
public class AxisValueDetails {
|
||||
private List<WptPt> axisGridPoints;
|
||||
private List<String> formattedAxisGridEntries;
|
||||
private LatLon selectedPointLatLon;
|
||||
private GpxDisplayItem gpxDisplayItem;
|
||||
public class TrackChartPoints {
|
||||
private List<Pair<String, WptPt>> xAxisPoints;
|
||||
private LatLon highlightedPoint;
|
||||
private GPXFile gpx;
|
||||
|
||||
public AxisValueDetails(List<WptPt> axisGridPoints, List<String> formattedAxisGridEntries, LatLon selectedPointLatLon, GpxDisplayItem gpxDisplayItem) {
|
||||
this.axisGridPoints = axisGridPoints;
|
||||
this.formattedAxisGridEntries = formattedAxisGridEntries;
|
||||
this.selectedPointLatLon = selectedPointLatLon;
|
||||
this.gpxDisplayItem = gpxDisplayItem;
|
||||
public TrackChartPoints(List<Pair<String, WptPt>> xAxisPoints, LatLon highlightedPoint, GPXFile gpx) {
|
||||
this.xAxisPoints = xAxisPoints;
|
||||
this.highlightedPoint = highlightedPoint;
|
||||
this.gpx = gpx;
|
||||
}
|
||||
|
||||
public List<WptPt> getAxisGridPoints() {
|
||||
return axisGridPoints;
|
||||
public List<Pair<String, WptPt>> getXAxisPoints() {
|
||||
return xAxisPoints;
|
||||
}
|
||||
|
||||
public List<String> getFormattedAxisGridEntries() {
|
||||
return formattedAxisGridEntries;
|
||||
public LatLon getHighlightedPoint() {
|
||||
return highlightedPoint;
|
||||
}
|
||||
|
||||
public LatLon getSelectedPointLatLon() {
|
||||
return selectedPointLatLon;
|
||||
}
|
||||
|
||||
public GpxDisplayItem getGpxDisplayItem() {
|
||||
return gpxDisplayItem;
|
||||
public GPXFile getGpx() {
|
||||
return gpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.support.annotation.ColorInt;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.util.Pair;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -36,7 +37,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu.AxisValueDetails;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu.TrackChartPoints;
|
||||
import net.osmand.plus.render.OsmandRenderer;
|
||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
|
@ -70,7 +71,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private int currentTrackColor;
|
||||
|
||||
private Bitmap selectedPoint;
|
||||
private AxisValueDetails axisValueDetails;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private static final int startZoom = 7;
|
||||
|
||||
|
@ -110,8 +111,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
initUI();
|
||||
}
|
||||
|
||||
public void setAxisValueDetails(AxisValueDetails axisValueDetails) {
|
||||
this.axisValueDetails = axisValueDetails;
|
||||
public void setTrackChartPoints(TrackChartPoints trackChartPoints) {
|
||||
this.trackChartPoints = trackChartPoints;
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
|
@ -366,15 +367,15 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
drawBigPoint(canvas, o, fileColor, x, y);
|
||||
}
|
||||
}
|
||||
if (axisValueDetails != null) {
|
||||
drawAxisGridPoints(canvas, tileBox);
|
||||
LatLon selectedPointLatLon = axisValueDetails.getSelectedPointLatLon();
|
||||
if (selectedPointLatLon.getLatitude() >= latLonBounds.bottom
|
||||
&& selectedPointLatLon.getLatitude() <= latLonBounds.top
|
||||
&& selectedPointLatLon.getLongitude() >= latLonBounds.left
|
||||
&& selectedPointLatLon.getLongitude() <= latLonBounds.right) {
|
||||
float x = tileBox.getPixXFromLatLon(selectedPointLatLon.getLatitude(), selectedPointLatLon.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(selectedPointLatLon.getLatitude(), selectedPointLatLon.getLongitude());
|
||||
if (trackChartPoints != null) {
|
||||
drawXAxisPoints(canvas, tileBox);
|
||||
LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
|
||||
if (highlightedPoint.getLatitude() >= latLonBounds.bottom
|
||||
&& highlightedPoint.getLatitude() <= latLonBounds.top
|
||||
&& highlightedPoint.getLongitude() >= latLonBounds.left
|
||||
&& highlightedPoint.getLongitude() <= latLonBounds.right) {
|
||||
float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
paintIcon.setColorFilter(null);
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
|
||||
}
|
||||
|
@ -386,28 +387,44 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
}
|
||||
|
||||
private void drawAxisGridPoints(Canvas canvas, RotatedTileBox tileBox) {
|
||||
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
|
||||
if (paintInnerRect.getColor() == 0) {
|
||||
SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileFromDisplayItemByName((axisValueDetails.getGpxDisplayItem().group.getGpxName()));
|
||||
GpxDataItem gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path));
|
||||
paintInnerRect.setColor(gpxDataItem.getColor());
|
||||
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);
|
||||
}
|
||||
List<WptPt> axisGridPoints = axisValueDetails.getAxisGridPoints();
|
||||
List<String> formattedAxisGridEntries = axisValueDetails.getFormattedAxisGridEntries();
|
||||
QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
List<Pair<String, WptPt>> xAxisPoints = trackChartPoints.getXAxisPoints();
|
||||
float r = 12 * tileBox.getDensity();
|
||||
paintGridTextIcon.setTextSize(r);
|
||||
for (int i = 0; i < axisGridPoints.size(); i++) {
|
||||
String textOnPoint = formattedAxisGridEntries.get(i);
|
||||
float textWidth = paintGridTextIcon.measureText(textOnPoint);
|
||||
float x = tileBox.getPixXFromLatLon(axisGridPoints.get(i).getLatitude(), axisGridPoints.get(i).getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(axisGridPoints.get(i).getLatitude(), axisGridPoints.get(i).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);
|
||||
for (int i = 0; i < xAxisPoints.size(); i++) {
|
||||
WptPt axisPoint = xAxisPoints.get(i).second;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ import android.view.View.OnClickListener;
|
|||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu.TrackChartPoints;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
@ -57,7 +57,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
private TopTextView streetNameView;
|
||||
private TopToolbarView topToolbarView;
|
||||
|
||||
private LatLon selectedPointLatLon;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
public MapInfoLayer(MapActivity map, RouteLayer layer){
|
||||
this.map = map;
|
||||
|
@ -219,13 +219,9 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
});
|
||||
}
|
||||
|
||||
public LatLon getSelectedPointLatLon() {
|
||||
return selectedPointLatLon;
|
||||
}
|
||||
|
||||
public void setSelectedPointLatLon(LatLon selectedPointLatLon) {
|
||||
this.selectedPointLatLon = selectedPointLatLon;
|
||||
routeLayer.setSelectedPointLatLon(selectedPointLatLon);
|
||||
public void setTrackChartPoints(TrackChartPoints trackChartPoints) {
|
||||
this.trackChartPoints = trackChartPoints;
|
||||
routeLayer.setTrackChartPoints(trackChartPoints);
|
||||
}
|
||||
|
||||
private static class TextState {
|
||||
|
|
|
@ -13,7 +13,10 @@ import net.osmand.Location;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu.TrackChartPoints;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -29,6 +32,7 @@ import android.graphics.Path;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.support.v4.util.Pair;
|
||||
|
||||
public class RouteLayer extends OsmandMapLayer {
|
||||
|
||||
|
@ -48,10 +52,12 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
|
||||
private Paint paintIcon;
|
||||
private Paint paintIconAction;
|
||||
private Paint paintGridTextIcon;
|
||||
private Paint paintInnerRect;
|
||||
|
||||
private Paint paintIconSelected;
|
||||
private Bitmap selectedPoint;
|
||||
private LatLon selectedPointLatLon;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private RenderingLineAttributes attrs;
|
||||
|
||||
|
@ -60,12 +66,8 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
this.helper = helper;
|
||||
}
|
||||
|
||||
public LatLon getSelectedPointLatLon() {
|
||||
return selectedPointLatLon;
|
||||
}
|
||||
|
||||
public void setSelectedPointLatLon(LatLon selectedPointLatLon) {
|
||||
this.selectedPointLatLon = selectedPointLatLon;
|
||||
public void setTrackChartPoints(TrackDetailsMenu.TrackChartPoints trackChartPoints) {
|
||||
this.trackChartPoints = trackChartPoints;
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
|
@ -77,7 +79,13 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
paintIcon.setAntiAlias(true);
|
||||
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);
|
||||
|
@ -94,6 +102,11 @@ 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,18 +162,48 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
double lon = rightLongitude - leftLongitude + 0.1;
|
||||
drawLocations(tileBox, canvas, topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon);
|
||||
|
||||
if (selectedPointLatLon != null
|
||||
&& selectedPointLatLon.getLatitude() >= latlonRect.bottom
|
||||
&& selectedPointLatLon.getLatitude() <= latlonRect.top
|
||||
&& selectedPointLatLon.getLongitude() >= latlonRect.left
|
||||
&& selectedPointLatLon.getLongitude() <= latlonRect.right) {
|
||||
float x = tileBox.getPixXFromLatLon(selectedPointLatLon.getLatitude(), selectedPointLatLon.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(selectedPointLatLon.getLatitude(), selectedPointLatLon.getLongitude());
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIconSelected);
|
||||
if (trackChartPoints != null) {
|
||||
drawXAxisPoints(canvas, tileBox);
|
||||
LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
|
||||
if (highlightedPoint != null
|
||||
&& highlightedPoint.getLatitude() >= latlonRect.bottom
|
||||
&& highlightedPoint.getLatitude() <= latlonRect.top
|
||||
&& highlightedPoint.getLongitude() >= latlonRect.left
|
||||
&& highlightedPoint.getLongitude() <= latlonRect.right) {
|
||||
float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIconSelected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
|
||||
QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
List<Pair<String, WptPt>> xAxisPoints = trackChartPoints.getXAxisPoints();
|
||||
float r = 12 * tileBox.getDensity();
|
||||
paintGridTextIcon.setTextSize(r);
|
||||
for (int i = 0; i < xAxisPoints.size(); i++) {
|
||||
WptPt axisPoint = xAxisPoints.get(i).second;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {}
|
||||
|
|
Loading…
Reference in a new issue