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