Change rendering line attributes
This commit is contained in:
parent
d22c799325
commit
dad003d8d3
2 changed files with 22 additions and 27 deletions
|
@ -69,7 +69,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
private float[] calculations = new float[2];
|
||||
|
||||
private final RenderingLineAttributes lineAttrs = new RenderingLineAttributes("measureDistanceLine");
|
||||
private final RenderingLineAttributes textAttrs = new RenderingLineAttributes("rulerCircle");
|
||||
private final RenderingLineAttributes textAttrs = new RenderingLineAttributes("rulerLineFont");
|
||||
private Paint paint;
|
||||
private Path path;
|
||||
private List<LatLon> route = new ArrayList<>();
|
||||
|
@ -77,7 +77,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
private TIntArrayList tx = new TIntArrayList();
|
||||
private TIntArrayList ty = new TIntArrayList();
|
||||
private Path linePath = new Path();
|
||||
private String distanceText;
|
||||
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
|
||||
|
@ -141,8 +140,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
paint.setAlpha(200);
|
||||
|
||||
float textSize = TEXT_SIZE * map.getResources().getDisplayMetrics().density;
|
||||
textAttrs.paint.setTextSize(textSize);
|
||||
textAttrs.paint2.setTextSize(textSize);
|
||||
textAttrs.paint3.setTextSize(textSize);
|
||||
|
||||
widgetsFactory = new MapMarkersWidgetsFactory(map);
|
||||
|
||||
|
@ -250,7 +249,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) {
|
||||
lineAttrs.updatePaints(view, nightMode, tileBox);
|
||||
textAttrs.updatePaints(view, nightMode, tileBox);
|
||||
textAttrs.paint2.setStyle(Paint.Style.FILL);
|
||||
textAttrs.paint.setStyle(Paint.Style.FILL);
|
||||
|
||||
int locX = (int) tileBox.getPixXFromLatLon(myLoc.getLatitude(), myLoc.getLongitude());
|
||||
int locY = (int) tileBox.getPixYFromLatLon(myLoc.getLatitude(), myLoc.getLongitude());
|
||||
|
@ -277,6 +276,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
float generalDist = (float) MapUtils.getDistance(myLoc.getLatitude(), myLoc.getLongitude(), marker.getLatitude(), marker.getLongitude());
|
||||
String generalDistSt = OsmAndFormatter.getFormattedDistance(generalDist, view.getApplication());
|
||||
boolean locationInvisible = locX < 0 || locX > tileBox.getPixWidth() || locY < 0 || locY > tileBox.getPixHeight();
|
||||
String distanceText;
|
||||
if (locationInvisible) {
|
||||
float centerToMarkerDist = (float) MapUtils.getDistance(tileBox.getLatLonFromPixel(pos[0], pos[1]), marker.getLatitude(), marker.getLongitude());
|
||||
String centerToMarkerDistSt = OsmAndFormatter.getFormattedDistance(centerToMarkerDist, view.getApplication());
|
||||
|
@ -289,7 +289,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
distanceText = generalDistSt;
|
||||
}
|
||||
Rect bounds = new Rect();
|
||||
textAttrs.paint2.getTextBounds(distanceText, 0, distanceText.length(), bounds);
|
||||
textAttrs.paint.getTextBounds(distanceText, 0, distanceText.length(), bounds);
|
||||
float hOffset = pm.getLength() / 2 - bounds.width() / 2;
|
||||
lineAttrs.paint.setColor(colors[marker.colorIndex]);
|
||||
|
||||
|
@ -300,12 +300,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
if (locX >= markerX) {
|
||||
canvas.rotate(180, pos[0], pos[1]);
|
||||
canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint3);
|
||||
canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint2);
|
||||
canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint);
|
||||
canvas.rotate(-180, pos[0], pos[1]);
|
||||
} else {
|
||||
canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint3);
|
||||
canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint2);
|
||||
canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint);
|
||||
}
|
||||
canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
}
|
||||
|
|
|
@ -76,10 +76,9 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
private Bitmap centerIconNight;
|
||||
private Paint bitmapPaint;
|
||||
private RenderingLineAttributes lineAttrs;
|
||||
private RenderingLineAttributes lineFontAttrs;
|
||||
private RenderingLineAttributes circleAttrs;
|
||||
private RenderingLineAttributes circleAttrsAlt;
|
||||
private float circleTextSize;
|
||||
private float lineTextSize;
|
||||
|
||||
private Handler handler;
|
||||
|
||||
|
@ -122,8 +121,12 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
|
||||
lineAttrs = new RenderingLineAttributes("rulerLine");
|
||||
|
||||
circleTextSize = TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
|
||||
lineTextSize = DISTANCE_TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
|
||||
float circleTextSize = TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
|
||||
float lineTextSize = DISTANCE_TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
|
||||
|
||||
lineFontAttrs = new RenderingLineAttributes("rulerLineFont");
|
||||
lineFontAttrs.paint.setTextSize(lineTextSize);
|
||||
lineFontAttrs.paint2.setTextSize(lineTextSize);
|
||||
|
||||
circleAttrs = new RenderingLineAttributes("rulerCircle");
|
||||
circleAttrs.paint2.setTextSize(circleTextSize);
|
||||
|
@ -179,6 +182,8 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
|
||||
if (rulerModeOn()) {
|
||||
lineAttrs.updatePaints(view, settings, tb);
|
||||
lineFontAttrs.updatePaints(view, settings, tb);
|
||||
lineFontAttrs.paint.setStyle(Style.FILL);
|
||||
circleAttrs.updatePaints(view, settings, tb);
|
||||
circleAttrs.paint2.setStyle(Style.FILL);
|
||||
circleAttrsAlt.updatePaints(view, settings, tb);
|
||||
|
@ -221,14 +226,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
}
|
||||
if (mode == RulerMode.FIRST || mode == RulerMode.SECOND) {
|
||||
updateData(tb, center);
|
||||
RenderingLineAttributes attrs;
|
||||
if (mode == RulerMode.FIRST) {
|
||||
circleAttrs.paint2.setTextSize(circleTextSize);
|
||||
circleAttrs.paint3.setTextSize(circleTextSize);
|
||||
attrs = circleAttrs;
|
||||
} else {
|
||||
attrs = circleAttrsAlt;
|
||||
}
|
||||
RenderingLineAttributes attrs = mode == RulerMode.FIRST ? circleAttrs : circleAttrsAlt;
|
||||
for (int i = 1; i <= cacheDistances.size(); i++) {
|
||||
drawCircle(canvas, tb, i, center, attrs);
|
||||
}
|
||||
|
@ -268,22 +266,19 @@ public class RulerControlLayer extends OsmandMapLayer {
|
|||
private void drawTextOnCenterOfPath(Canvas canvas, float x1, float x2, Path path, String text) {
|
||||
PathMeasure pm = new PathMeasure(path, false);
|
||||
Rect bounds = new Rect();
|
||||
circleAttrs.paint2.getTextBounds(text, 0, text.length(), bounds);
|
||||
lineFontAttrs.paint.getTextBounds(text, 0, text.length(), bounds);
|
||||
float hOffset = pm.getLength() / 2 - bounds.width() / 2;
|
||||
|
||||
circleAttrs.paint2.setTextSize(lineTextSize);
|
||||
circleAttrs.paint3.setTextSize(lineTextSize);
|
||||
|
||||
if (x1 >= x2) {
|
||||
float[] pos = new float[2];
|
||||
pm.getPosTan(pm.getLength() / 2, pos, null);
|
||||
canvas.rotate(180, pos[0], pos[1]);
|
||||
canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, circleAttrs.paint3);
|
||||
canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, circleAttrs.paint2);
|
||||
canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, lineFontAttrs.paint2);
|
||||
canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, lineFontAttrs.paint);
|
||||
canvas.rotate(-180, pos[0], pos[1]);
|
||||
} else {
|
||||
canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, circleAttrs.paint3);
|
||||
canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, circleAttrs.paint2);
|
||||
canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, lineFontAttrs.paint2);
|
||||
canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, lineFontAttrs.paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue