Merge pull request #3946 from osmandapp/gpx_improvements
Gpx improvements
This commit is contained in:
commit
11c35cf0e2
3 changed files with 49 additions and 19 deletions
|
@ -10,7 +10,6 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
|
@ -18,7 +17,6 @@ import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
|||
import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
|
||||
import com.github.mikephil.charting.listener.OnChartGestureListener;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ViewPortHandler;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
|
@ -288,11 +286,11 @@ public class TrackDetailsMenu {
|
|||
Highlight[] highlights = chart.getHighlighted();
|
||||
LatLon location = null;
|
||||
|
||||
ViewPortHandler handler = chart.getViewPortHandler();
|
||||
float minimumVisibleXValue = (float) chart.getValuesByTouchPoint(handler.contentLeft(), handler.contentBottom(), YAxis.AxisDependency.LEFT).x;
|
||||
float maximumVisibleXValue = (float) chart.getValuesByTouchPoint(handler.contentRight(), handler.contentBottom(), YAxis.AxisDependency.LEFT).x;
|
||||
float minimumVisibleXValue = chart.getLowestVisibleX();
|
||||
float maximumVisibleXValue = chart.getHighestVisibleX();
|
||||
|
||||
if (highlights != null && highlights.length > 0) {
|
||||
if (minimumVisibleXValue != 0 && maximumVisibleXValue != 0) {
|
||||
if (highlights[0].getX() < minimumVisibleXValue) {
|
||||
gpxItem.chartHighlightPos = minimumVisibleXValue;
|
||||
} else if (highlights[0].getX() > maximumVisibleXValue) {
|
||||
|
@ -300,6 +298,9 @@ public class TrackDetailsMenu {
|
|||
} else {
|
||||
gpxItem.chartHighlightPos = highlights[0].getX();
|
||||
}
|
||||
} else {
|
||||
gpxItem.chartHighlightPos = highlights[0].getX();
|
||||
}
|
||||
WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos);
|
||||
if (wpt != null) {
|
||||
if (trackChartPoints == null) {
|
||||
|
@ -572,7 +573,8 @@ public class TrackDetailsMenu {
|
|||
if (gpxItem.chartHighlightPos != -1) {
|
||||
chart.highlightValue(gpxItem.chartHighlightPos, 0);
|
||||
} else {
|
||||
chart.highlightValue(null);
|
||||
gpxItem.chartHighlightPos = chart.getLowestVisibleX();
|
||||
chart.highlightValue(chart.getLowestVisibleX(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import android.graphics.PointF;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -81,8 +83,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
|
||||
private MapTextLayer textLayer;
|
||||
|
||||
private Paint paintOuterRect;
|
||||
private Paint paintInnerRect;
|
||||
|
||||
private Paint paintGridOuterCircle;
|
||||
private Paint paintGridCircle;
|
||||
|
||||
private Paint paintTextIcon;
|
||||
|
@ -139,11 +143,22 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||
|
||||
paintInnerRect = new Paint();
|
||||
paintInnerRect.setStyle(Style.FILL_AND_STROKE);
|
||||
paintInnerRect.setStyle(Style.FILL);
|
||||
paintInnerRect.setAntiAlias(true);
|
||||
paintOuterRect = new Paint();
|
||||
paintOuterRect.setStyle(Style.STROKE);
|
||||
paintOuterRect.setAntiAlias(true);
|
||||
paintOuterRect.setColor(Color.WHITE);
|
||||
paintOuterRect.setStrokeWidth(3);
|
||||
paintOuterRect.setAlpha(255);
|
||||
paintGridCircle = new Paint();
|
||||
paintGridCircle.setStyle(Style.FILL_AND_STROKE);
|
||||
paintGridCircle.setAntiAlias(true);
|
||||
paintGridOuterCircle = new Paint();
|
||||
paintGridOuterCircle.setStyle(Style.FILL_AND_STROKE);
|
||||
paintGridOuterCircle.setAntiAlias(true);
|
||||
paintGridOuterCircle.setColor(Color.WHITE);
|
||||
paintGridOuterCircle.setAlpha(204);
|
||||
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
|
@ -307,14 +322,17 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
if (ind > 0) {
|
||||
nm = nm.substring(0, ind);
|
||||
}
|
||||
float nmWidth = paintTextIcon.measureText(nm);
|
||||
canvas.drawRect(
|
||||
x - nmWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()),
|
||||
y - r / 2 - 2 * (float) Math.ceil(tileBox.getDensity()),
|
||||
x + nmWidth / 2 + 2 * (float) Math.ceil(tileBox.getDensity()),
|
||||
y + r / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
|
||||
paintInnerRect);
|
||||
canvas.drawText(nm, x, y + r / 2, paintTextIcon);
|
||||
Rect bounds = new Rect();
|
||||
paintTextIcon.getTextBounds(nm, 0, nm.length(), bounds);
|
||||
int nmWidth = bounds.width();
|
||||
int nmHeight = bounds.height();
|
||||
RectF rect = new RectF(x - nmWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()),
|
||||
y + nmHeight / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
|
||||
x + nmWidth / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
|
||||
y - nmHeight / 2 - 2 * (float) Math.ceil(tileBox.getDensity()));
|
||||
canvas.drawRoundRect(rect, 5, 5, paintInnerRect);
|
||||
canvas.drawRoundRect(rect, 5, 5, paintOuterRect);
|
||||
canvas.drawText(nm, x, y + nmHeight / 2, paintTextIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,6 +414,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
trackChartPoints.setSegmentColor(color);
|
||||
}
|
||||
paintGridCircle.setColor(color);
|
||||
paintGridCircle.setAlpha(255);
|
||||
QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
List<WptPt> xAxisPoints = trackChartPoints.getXAxisPoints();
|
||||
float r = 3 * tileBox.getDensity();
|
||||
|
@ -407,6 +426,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
&& axisPoint.getLongitude() <= latLonBounds.right) {
|
||||
float x = tileBox.getPixXFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
|
||||
canvas.drawCircle(x, y, r + 2 * (float) Math.ceil(tileBox.getDensity()), paintGridOuterCircle);
|
||||
canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintGridCircle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
|
||||
private Paint paintIcon;
|
||||
private Paint paintIconAction;
|
||||
private Paint paintGridOuterCircle;
|
||||
private Paint paintGridCircle;
|
||||
|
||||
private Paint paintIconSelected;
|
||||
|
@ -99,6 +100,12 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
paintGridCircle.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
paintGridCircle.setAntiAlias(true);
|
||||
paintGridCircle.setColor(attrs.defaultColor);
|
||||
paintGridCircle.setAlpha(255);
|
||||
paintGridOuterCircle = new Paint();
|
||||
paintGridOuterCircle.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
paintGridOuterCircle.setAntiAlias(true);
|
||||
paintGridOuterCircle.setColor(Color.WHITE);
|
||||
paintGridOuterCircle.setAlpha(204);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,6 +186,7 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
&& axisPoint.getLongitude() <= latLonBounds.right) {
|
||||
float x = tileBox.getPixXFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
|
||||
canvas.drawCircle(x, y, r + 2 * (float) Math.ceil(tileBox.getDensity()), paintGridOuterCircle);
|
||||
canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintGridCircle);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue