Merge pull request #3918 from osmandapp/gpx_improvements

Gpx improvements
This commit is contained in:
Alexey 2017-06-13 19:20:51 +03:00 committed by GitHub
commit bdd16d2fb9
4 changed files with 205 additions and 48 deletions

View file

@ -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;
@ -25,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;
@ -51,6 +53,7 @@ public class TrackDetailsMenu {
private GpxDisplayItem gpxItem; private GpxDisplayItem gpxItem;
private TrackDetailsBarController toolbarController; private TrackDetailsBarController toolbarController;
private TrkSegment segment; private TrkSegment segment;
private TrackChartPoints trackChartPoints;
private static boolean VISIBLE; private static boolean VISIBLE;
@ -140,11 +143,12 @@ public class TrackDetailsMenu {
mapActivity.hideTopToolbar(toolbarController); mapActivity.hideTopToolbar(toolbarController);
} }
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode(); mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(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;
trackChartPoints = null;
} }
public void updateInfo(final View main) { public void updateInfo(final View main) {
@ -286,11 +290,20 @@ public class TrackDetailsMenu {
gpxItem.chartHighlightPos = highlights[0].getX(); gpxItem.chartHighlightPos = highlights[0].getX();
WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos); WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos);
if (wpt != null) { if (wpt != null) {
if (trackChartPoints == null) {
trackChartPoints = new TrackChartPoints();
int segmentColor = getTrackSegment(chart).getColor(0);
trackChartPoints.setSegmentColor(segmentColor);
trackChartPoints.setGpx(getGpxItem().group.getGpx());
}
location = new LatLon(wpt.lat, wpt.lon); location = new LatLon(wpt.lat, wpt.lon);
List<Pair<String, WptPt>> xAxisPoints = getXAxisPoints(chart);
trackChartPoints.setHighlightedPoint(location);
trackChartPoints.setXAxisPoints(xAxisPoints);
if (gpxItem.route) { if (gpxItem.route) {
mapActivity.getMapLayers().getMapInfoLayer().setSelectedPointLatLon(location); mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
} else { } else {
mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(location); mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints);
} }
} }
} else { } else {
@ -299,6 +312,17 @@ public class TrackDetailsMenu {
fitTrackOnMap(chart, location, forceFit); fitTrackOnMap(chart, location, forceFit);
} }
private List<Pair<String, WptPt>> getXAxisPoints(LineChart chart) {
List<Pair<String, WptPt>> 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));
}
return xAxisPoints;
}
private void updateView(final View parentView) { private void updateView(final View parentView) {
GPXTrackAnalysis analysis = gpxItem.analysis; GPXTrackAnalysis analysis = gpxItem.analysis;
if (analysis == null || gpxItem.chartTypes == null) { if (analysis == null || gpxItem.chartTypes == null) {
@ -560,4 +584,43 @@ public class TrackDetailsMenu {
view.getShadowView().setVisibility(View.GONE); view.getShadowView().setVisibility(View.GONE);
} }
} }
public class TrackChartPoints {
private List<Pair<String, WptPt>> xAxisPoints;
private LatLon highlightedPoint;
private int segmentColor;
private GPXFile gpx;
public List<Pair<String, WptPt>> getXAxisPoints() {
return xAxisPoints;
}
public LatLon getHighlightedPoint() {
return highlightedPoint;
}
public int getSegmentColor() {
return segmentColor;
}
public GPXFile getGpx() {
return gpx;
}
public void setXAxisPoints(List<Pair<String, WptPt>> xAxisPoints) {
this.xAxisPoints = xAxisPoints;
}
public void setHighlightedPoint(LatLon highlightedPoint) {
this.highlightedPoint = highlightedPoint;
}
public void setSegmentColor(int segmentColor) {
this.segmentColor = segmentColor;
}
public void setGpx(GPXFile gpx) {
this.gpx = gpx;
}
}
} }

View file

@ -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,6 +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.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;
@ -69,7 +71,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private int currentTrackColor; private int currentTrackColor;
private Bitmap selectedPoint; private Bitmap selectedPoint;
private LatLon selectedPointLatLon; private TrackChartPoints trackChartPoints;
private static final int startZoom = 7; private static final int startZoom = 7;
@ -80,13 +82,16 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>(); private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
private MapTextLayer textLayer; private MapTextLayer textLayer;
private Paint paintOuter; private Paint paintOuter;
private Paint paintInnerCircle; private Paint paintInnerCircle;
private Paint paintInnerRect;
private Paint paintTextIcon; private Paint paintTextIcon;
private Paint paintGridTextIcon;
private OsmandRenderer osmandRenderer; private OsmandRenderer osmandRenderer;
private List<TrkSegment> points; private List<TrkSegment> points;
@ -106,6 +111,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
initUI(); initUI();
} }
public void setTrackChartPoints(TrackChartPoints trackChartPoints) {
this.trackChartPoints = trackChartPoints;
}
private void initUI() { private void initUI() {
paint = new Paint(); paint = new Paint();
paint.setStyle(Style.STROKE); paint.setStyle(Style.STROKE);
@ -132,6 +141,12 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
paintTextIcon.setColor(Color.BLACK); paintTextIcon.setColor(Color.BLACK);
paintTextIcon.setAntiAlias(true); 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); textLayer = view.getLayerByClass(MapTextLayer.class);
paintOuter = new Paint(); paintOuter = new Paint();
@ -142,6 +157,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
paintInnerCircle.setStyle(Style.FILL_AND_STROKE); paintInnerCircle.setStyle(Style.FILL_AND_STROKE);
paintInnerCircle.setColor(0xddFFFFFF); paintInnerCircle.setColor(0xddFFFFFF);
paintInnerCircle.setAntiAlias(true); paintInnerCircle.setAntiAlias(true);
paintInnerRect = new Paint();
paintInnerRect.setStyle(Style.FILL_AND_STROKE);
paintInnerRect.setAntiAlias(true);
paintIcon = new Paint(); paintIcon = new Paint();
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small); pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
@ -345,21 +363,66 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
drawBigPoint(canvas, o, fileColor, x, y); drawBigPoint(canvas, o, fileColor, x, y);
} }
} }
if (selectedPointLatLon != null if (trackChartPoints != null) {
&& selectedPointLatLon.getLatitude() >= latLonBounds.bottom drawXAxisPoints(canvas, tileBox);
&& selectedPointLatLon.getLatitude() <= latLonBounds.top LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
&& selectedPointLatLon.getLongitude() >= latLonBounds.left if (highlightedPoint.getLatitude() >= latLonBounds.bottom
&& selectedPointLatLon.getLongitude() <= latLonBounds.right) { && highlightedPoint.getLatitude() <= latLonBounds.top
float x = tileBox.getPixXFromLatLon(selectedPointLatLon.getLatitude(), selectedPointLatLon.getLongitude()); && highlightedPoint.getLongitude() >= latLonBounds.left
float y = tileBox.getPixYFromLatLon(selectedPointLatLon.getLatitude(), selectedPointLatLon.getLongitude()); && highlightedPoint.getLongitude() <= latLonBounds.right) {
float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.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);
} }
}
this.fullObjectsLatLon = fullObjectsLatLon; this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon; this.smallObjectsLatLon = smallObjectsLatLon;
} }
} }
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
int color = trackChartPoints.getSegmentColor();
if (color == 0) {
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;
}
trackChartPoints.setSegmentColor(color);
}
paintInnerRect.setColor(color);
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);
}
}
}
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();
} }
@ -420,14 +483,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
return g.getGpxFile().points; return g.getGpxFile().points;
} }
public LatLon getSelectedPointLatLon() {
return selectedPointLatLon;
}
public void setSelectedPointLatLon(LatLon selectedPointLatLon) {
this.selectedPointLatLon = selectedPointLatLon;
}
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) { private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
return (Math.abs(objx - ex) <= radius * 2 && Math.abs(objy - ey) <= radius * 2); return (Math.abs(objx - ex) <= radius * 2 && Math.abs(objy - ey) <= radius * 2);
// return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ; // return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;

View file

@ -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;
@ -221,13 +221,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 {

View file

@ -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
@ -145,19 +158,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) {}