Use a new arrow for track direction

This commit is contained in:
Vitaliy 2020-09-24 11:07:28 +03:00
parent 7712d144d9
commit 8a59bfe127
3 changed files with 23 additions and 19 deletions

View file

@ -132,7 +132,7 @@ public class GpxGeometryWay extends GeometryWay<GpxGeometryWayContext, GeometryW
@Override
public double getPointStepPx(double zoomCoef) {
return getPointBitmap().getHeight() * DIRECTION_ARROW_DISTANCE_MULTIPLIER * zoomCoef;
return getPointBitmap().getHeight() + trackWidth * 1.5f;
}
}
}
}

View file

@ -15,6 +15,6 @@ public class GpxGeometryWayContext extends GeometryWayContext {
@Override
protected int getArrowBitmapResId() {
return R.drawable.mm_special_arrow_up;
return R.drawable.ic_action_direction_arrow;
}
}

View file

@ -1,19 +1,16 @@
package net.osmand.plus.views.layers.geometry;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.views.layers.geometry.GeometryWayDrawer.PathPoint;
import net.osmand.plus.views.layers.geometry.GpxGeometryWay.GeometryArrowsStyle;
import java.util.ArrayList;
import java.util.List;
public class GpxGeometryWayDrawer extends GeometryWayDrawer<GpxGeometryWayContext> {
private static final float DIRECTION_ARROW_CIRCLE_MULTIPLIER = 1.5f;
public GpxGeometryWayDrawer(GpxGeometryWayContext context) {
super(context);
}
@ -33,16 +30,23 @@ public class GpxGeometryWayDrawer extends GeometryWayDrawer<GpxGeometryWayContex
void draw(Canvas canvas, GeometryWayContext context) {
if (style instanceof GeometryArrowsStyle) {
GeometryArrowsStyle arrowsWayStyle = (GeometryArrowsStyle) style;
Bitmap bitmap = style.getPointBitmap();
float arrowWidth = style.getPointBitmap().getWidth();
if (arrowWidth > arrowsWayStyle.getTrackWidth()) {
Paint paint = context.getPaintIcon();
paint.setColor(arrowsWayStyle.getTrackColor());
paint.setStrokeWidth(arrowWidth * DIRECTION_ARROW_CIRCLE_MULTIPLIER);
canvas.drawPoint(x, y, paint);
}
float newWidth = arrowsWayStyle.getTrackWidth() / 2f;
float paintH2 = bitmap.getHeight() / 2f;
float paintW2 = newWidth / 2f;
Matrix matrix = getMatrix();
matrix.reset();
matrix.postScale(newWidth / bitmap.getWidth(), 1);
matrix.postRotate((float) angle, paintW2, paintH2);
matrix.postTranslate(x - paintW2, y - paintH2);
Paint paint = context.getPaintIconCustom();
Integer pointColor = style.getPointColor();
paint.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, matrix, paint);
}
super.draw(canvas, context);
}
}
}
}