package cgeo.geocaching.maps;

import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.interfaces.MapItemFactory;
import cgeo.geocaching.maps.interfaces.MapProjectionImpl;
import cgeo.geocaching.settings.Settings;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.location.Location;

public class DirectionDrawer {
    private Geopoint currentCoords;
    private final Geopoint destinationCoords;
    private final MapItemFactory mapItemFactory;

    private Paint line = null;

    public DirectionDrawer(final Geopoint coords) {
        this.destinationCoords = coords;
        this.mapItemFactory = Settings.getMapProvider().getMapItemFactory();
    }

    public void setCoordinates(final Location coordinatesIn) {
        currentCoords = new Geopoint(coordinatesIn);
    }

    void drawDirection(final Canvas canvas, final MapProjectionImpl projection) {
        if (currentCoords == null) {
            return;
        }

        if (line == null) {
            line = new Paint();
            line.setAntiAlias(true);
            line.setStrokeWidth(4f);
            line.setColor(0x80EB391E);
        }

        final Point pos = new Point();
        final Point dest = new Point();
        projection.toPixels(mapItemFactory.getGeoPointBase(currentCoords), pos);
        projection.toPixels(mapItemFactory.getGeoPointBase(destinationCoords), dest);

        canvas.drawLine(pos.x, pos.y, dest.x, dest.y, line);
    }
}

@@ -20,24 +20,64 @@
 hing.maps;%0A%0A
+import cgeo.geocaching.CgeoApplication;%0A
 import cgeo.
@@ -102,24 +102,24 @@
 n.Geopoint;%0A
-
 import cgeo.
@@ -258,24 +258,56 @@
 .Settings;%0A%0A
+import android.content.Context;%0A
 import andro
@@ -421,16 +421,87 @@
 ocation;
+%0Aimport android.util.DisplayMetrics;%0Aimport android.view.WindowManager;
 %0A%0Apublic
@@ -655,16 +655,47 @@
 Factory;
+%0A    private final float width;
 %0A%0A    pr
@@ -886,24 +886,321 @@
 mFactory();%0A
+%0A        final DisplayMetrics metrics = new DisplayMetrics();%0A        final WindowManager windowManager = (WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE);%0A        windowManager.getDefaultDisplay().getMetrics(metrics);%0A%0A        width = 4f * metrics.density;%0A%0A
     %7D%0A%0A    p
@@ -1596,18 +1596,21 @@
 keWidth(
-4f
+width
 );%0A     

Make direction width depend on pixel density