Change rect color
This commit is contained in:
parent
f6408a44ba
commit
10650ed041
3 changed files with 113 additions and 69 deletions
|
@ -347,6 +347,19 @@ 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()) {
|
||||
|
|
|
@ -143,8 +143,7 @@ public class TrackDetailsMenu {
|
|||
mapActivity.hideTopToolbar(toolbarController);
|
||||
}
|
||||
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
|
||||
mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(null);
|
||||
mapActivity.getMapLayers().getGpxLayer().setAxisGridPoints(null);
|
||||
mapActivity.getMapLayers().getGpxLayer().setAxisValueDetails(null);
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setSelectedPointLatLon(null);
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
|
@ -291,40 +290,46 @@ 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());
|
||||
if (gpxItem.route) {
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setSelectedPointLatLon(location);
|
||||
} else {
|
||||
mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(location);
|
||||
mapActivity.getMapLayers().getGpxLayer().setAxisValueDetails(axisValueDetails);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gpxItem.chartHighlightPos = -1;
|
||||
}
|
||||
fitTrackOnMap(chart, location, forceFit);
|
||||
|
||||
if (segment != null) {
|
||||
Map<String, WptPt> axisGridPoints = getAxisGridPoints(chart);
|
||||
mapActivity.getMapLayers().getGpxLayer().setAxisGridPoints(axisGridPoints);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, WptPt> getAxisGridPoints(LineChart chart) {
|
||||
Map<String, WptPt> axisGridPoints = new HashMap<>();
|
||||
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]);
|
||||
if (pointToAdd != null) {
|
||||
if (gpxItem.chartAxisType == GPXDataSetAxisType.DISTANCE) {
|
||||
axisGridPoints.put(String.format("%.1f", entries[i]), pointToAdd);
|
||||
} else if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME) {
|
||||
IAxisValueFormatter formatter = chart.getXAxis().getValueFormatter();
|
||||
axisGridPoints.put(formatter.getFormattedValue(entries[i], chart.getXAxis()), pointToAdd);
|
||||
}
|
||||
}
|
||||
axisGridPoints.add(pointToAdd);
|
||||
}
|
||||
return axisGridPoints;
|
||||
}
|
||||
|
||||
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) {
|
||||
GPXTrackAnalysis analysis = gpxItem.analysis;
|
||||
if (analysis == null || gpxItem.chartTypes == null) {
|
||||
|
@ -586,4 +591,34 @@ public class TrackDetailsMenu {
|
|||
view.getShadowView().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public class AxisValueDetails {
|
||||
private List<WptPt> axisGridPoints;
|
||||
private List<String> formattedAxisGridEntries;
|
||||
private LatLon selectedPointLatLon;
|
||||
private GpxDisplayItem gpxDisplayItem;
|
||||
|
||||
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 List<WptPt> getAxisGridPoints() {
|
||||
return axisGridPoints;
|
||||
}
|
||||
|
||||
public List<String> getFormattedAxisGridEntries() {
|
||||
return formattedAxisGridEntries;
|
||||
}
|
||||
|
||||
public LatLon getSelectedPointLatLon() {
|
||||
return selectedPointLatLon;
|
||||
}
|
||||
|
||||
public GpxDisplayItem getGpxDisplayItem() {
|
||||
return gpxDisplayItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,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.render.OsmandRenderer;
|
||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
|
@ -69,9 +70,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private int currentTrackColor;
|
||||
|
||||
private Bitmap selectedPoint;
|
||||
private LatLon selectedPointLatLon;
|
||||
|
||||
private Map<String, WptPt> axisGridPoints;
|
||||
private AxisValueDetails axisValueDetails;
|
||||
|
||||
private static final int startZoom = 7;
|
||||
|
||||
|
@ -82,7 +81,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
|
||||
private MapTextLayer textLayer;
|
||||
|
||||
|
||||
private Paint paintOuter;
|
||||
|
||||
private Paint paintInnerCircle;
|
||||
|
@ -91,6 +89,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
|
||||
private Paint paintTextIcon;
|
||||
|
||||
private Paint paintGridTextIcon;
|
||||
|
||||
private OsmandRenderer osmandRenderer;
|
||||
|
||||
private List<TrkSegment> points;
|
||||
|
@ -110,6 +110,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
initUI();
|
||||
}
|
||||
|
||||
public void setAxisValueDetails(AxisValueDetails axisValueDetails) {
|
||||
this.axisValueDetails = axisValueDetails;
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
paint = new Paint();
|
||||
paint.setStyle(Style.STROKE);
|
||||
|
@ -136,6 +140,12 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
paintTextIcon.setColor(Color.BLACK);
|
||||
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);
|
||||
|
||||
paintOuter = new Paint();
|
||||
|
@ -148,7 +158,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
paintInnerCircle.setAntiAlias(true);
|
||||
paintInnerRect = new Paint();
|
||||
paintInnerRect.setStyle(Style.FILL_AND_STROKE);
|
||||
paintInnerRect.setColor(0xddFFFFFF);
|
||||
paintInnerRect.setAntiAlias(true);
|
||||
|
||||
paintIcon = new Paint();
|
||||
|
@ -357,18 +366,20 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
drawBigPoint(canvas, o, fileColor, x, y);
|
||||
}
|
||||
}
|
||||
if (axisGridPoints != null) {
|
||||
if (axisValueDetails != null) {
|
||||
drawAxisGridPoints(canvas, tileBox);
|
||||
}
|
||||
if (selectedPointLatLon != null
|
||||
&& 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());
|
||||
paintIcon.setColorFilter(null);
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
|
||||
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());
|
||||
paintIcon.setColorFilter(null);
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
|
||||
}
|
||||
} else if (paintInnerRect.getColor() != 0){
|
||||
paintInnerRect.setColor(0);
|
||||
}
|
||||
this.fullObjectsLatLon = fullObjectsLatLon;
|
||||
this.smallObjectsLatLon = smallObjectsLatLon;
|
||||
|
@ -376,30 +387,27 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
|
||||
private void drawAxisGridPoints(Canvas canvas, RotatedTileBox tileBox) {
|
||||
for (Map.Entry<String, WptPt> axisGridPoint : axisGridPoints.entrySet()) {
|
||||
float r = 12 * tileBox.getDensity();
|
||||
|
||||
String stringToDisplay = axisGridPoint.getKey();
|
||||
|
||||
float textWidth = paintTextIcon.measureText(stringToDisplay);
|
||||
|
||||
float x = tileBox.getPixXFromLatLon(axisGridPoint.getValue().getLatitude(), axisGridPoint.getValue().getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(axisGridPoint.getValue().getLatitude(), axisGridPoint.getValue().getLongitude());
|
||||
|
||||
// canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintOuter);
|
||||
|
||||
// canvas.drawCircle(x, y, r - (float) Math.ceil(tileBox.getDensity()), paintInnerCircle);
|
||||
// paintTextIcon.setTextSize(r);
|
||||
// canvas.drawText(pointOfChart.getKey(), x, y + r / 2, paintTextIcon);
|
||||
|
||||
// paintInnerRect.setColor();
|
||||
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());
|
||||
}
|
||||
List<WptPt> axisGridPoints = axisValueDetails.getAxisGridPoints();
|
||||
List<String> formattedAxisGridEntries = axisValueDetails.getFormattedAxisGridEntries();
|
||||
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 + (float) Math.ceil(tileBox.getDensity()) - textWidth / 2,
|
||||
y + (float) Math.ceil(tileBox.getDensity()) - r /2,
|
||||
x + (float) Math.ceil(tileBox.getDensity()) + textWidth / 2,
|
||||
y + (float) Math.ceil(tileBox.getDensity()) + r / 2, paintInnerRect);
|
||||
paintTextIcon.setTextSize(r);
|
||||
canvas.drawText(axisGridPoint.getKey(), x, y + r / 2, paintTextIcon);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,18 +471,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
return g.getGpxFile().points;
|
||||
}
|
||||
|
||||
public LatLon getSelectedPointLatLon() {
|
||||
return selectedPointLatLon;
|
||||
}
|
||||
|
||||
public void setSelectedPointLatLon(LatLon selectedPointLatLon) {
|
||||
this.selectedPointLatLon = selectedPointLatLon;
|
||||
}
|
||||
|
||||
public void setAxisGridPoints(Map<String, WptPt> axisGridPoints) {
|
||||
this.axisGridPoints = axisGridPoints;
|
||||
}
|
||||
|
||||
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 && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
|
||||
|
|
Loading…
Reference in a new issue