Change rect color in split

This commit is contained in:
PavelRatushny 2017-06-16 18:55:06 +03:00
parent 7675977a48
commit 666061081a

View file

@ -81,9 +81,7 @@ 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 paintInnerRect;
private Paint paintInnerCircle;
private Paint paintGridCircle; private Paint paintGridCircle;
@ -135,19 +133,14 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
paintTextIcon.setTextSize(10 * view.getDensity()); paintTextIcon.setTextSize(10 * view.getDensity());
paintTextIcon.setTextAlign(Align.CENTER); paintTextIcon.setTextAlign(Align.CENTER);
paintTextIcon.setFakeBoldText(true); paintTextIcon.setFakeBoldText(true);
paintTextIcon.setColor(Color.BLACK); paintTextIcon.setColor(Color.WHITE);
paintTextIcon.setAntiAlias(true); paintTextIcon.setAntiAlias(true);
textLayer = view.getLayerByClass(MapTextLayer.class); textLayer = view.getLayerByClass(MapTextLayer.class);
paintOuter = new Paint(); paintInnerRect = new Paint();
paintOuter.setColor(0x88555555); paintInnerRect.setStyle(Style.FILL_AND_STROKE);
paintOuter.setAntiAlias(true); paintInnerRect.setAntiAlias(true);
paintOuter.setStyle(Style.FILL_AND_STROKE);
paintInnerCircle = new Paint();
paintInnerCircle.setStyle(Style.FILL_AND_STROKE);
paintInnerCircle.setColor(0xddFFFFFF);
paintInnerCircle.setAntiAlias(true);
paintGridCircle = new Paint(); paintGridCircle = new Paint();
paintGridCircle.setStyle(Style.FILL_AND_STROKE); paintGridCircle.setStyle(Style.FILL_AND_STROKE);
paintGridCircle.setAntiAlias(true); paintGridCircle.setAntiAlias(true);
@ -187,6 +180,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
if (!selectedGPXFiles.isEmpty()) { if (!selectedGPXFiles.isEmpty()) {
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings); drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
if (trackChartPoints != null) {
drawXAxisPoints(canvas, tileBox);
}
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings); drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles); drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
} }
@ -269,6 +265,13 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
List<GpxDisplayGroup> groups = g.getDisplayGroups(); List<GpxDisplayGroup> groups = g.getDisplayGroups();
if (groups != null) { if (groups != null) {
for (GpxDisplayGroup group : groups) { for (GpxDisplayGroup group : groups) {
int color = g.getModifiableGpxFile().getColor(0);
if (color == 0 || color == Color.RED) {
GpxDataItem gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(g.getGpxFile().path));
color = gpxDataItem.getColor();
}
paintInnerRect.setColor(color);
paintInnerRect.setAlpha(179);
List<GpxDisplayItem> items = group.getModifiableList(); List<GpxDisplayItem> items = group.getModifiableList();
drawSplitItems(canvas, tileBox, items, settings); drawSplitItems(canvas, tileBox, items, settings);
} }
@ -280,6 +283,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) { private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
final QuadRect latLonBounds = tileBox.getLatLonBounds(); final QuadRect latLonBounds = tileBox.getLatLonBounds();
int r = (int) (12 * tileBox.getDensity()); int r = (int) (12 * tileBox.getDensity());
paintTextIcon.setTextSize(r);
int dr = r * 3 / 2; int dr = r * 3 / 2;
int px = -1; int px = -1;
int py = -1; int py = -1;
@ -303,9 +307,13 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
if (ind > 0) { if (ind > 0) {
nm = nm.substring(0, ind); nm = nm.substring(0, ind);
} }
canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintOuter); float nmWidth = paintTextIcon.measureText(nm);
canvas.drawCircle(x, y, r - (float) Math.ceil(tileBox.getDensity()), paintInnerCircle); canvas.drawRect(
paintTextIcon.setTextSize(r); 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); canvas.drawText(nm, x, y + r / 2, paintTextIcon);
} }
} }
@ -355,7 +363,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
} }
if (trackChartPoints != null) { if (trackChartPoints != null) {
drawXAxisPoints(canvas, tileBox);
LatLon highlightedPoint = trackChartPoints.getHighlightedPoint(); LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
if (highlightedPoint.getLatitude() >= latLonBounds.bottom if (highlightedPoint.getLatitude() >= latLonBounds.bottom
&& highlightedPoint.getLatitude() <= latLonBounds.top && highlightedPoint.getLatitude() <= latLonBounds.top