diff --git a/app/src/main/java/ch/bailu/aat/map/layer/gpx/legend/GpxLegendLayer.java b/app/src/main/java/ch/bailu/aat/map/layer/gpx/legend/GpxLegendLayer.java index 80a1582a7..2c182ab42 100644 --- a/app/src/main/java/ch/bailu/aat/map/layer/gpx/legend/GpxLegendLayer.java +++ b/app/src/main/java/ch/bailu/aat/map/layer/gpx/legend/GpxLegendLayer.java @@ -7,6 +7,7 @@ import org.mapsforge.core.model.Point; import ch.bailu.aat.map.MapContext; +import ch.bailu.aat.map.MapMetrics; import ch.bailu.aat.map.MapPaint; import ch.bailu.aat.map.layer.gpx.GpxLayer; @@ -20,21 +21,15 @@ public class GpxLegendLayer extends GpxLayer { public GpxLegendLayer(LegendWalker w) { walker=w; - - backgroundPaint = - MapPaint.createBackgroundPaint(getColor()); - framePaint = MapPaint.createBackgroundPaint(getColor()); - framePaint.setColor(getColor()); + initPaint(); } @Override public void drawInside(MapContext mcontext) { if (color != getColor()) { - backgroundPaint = MapPaint.createBackgroundPaint(getColor()); - framePaint = MapPaint.createEdgePaintLine(mcontext.getMetrics().getDensity()); - framePaint.setColor(getColor()); color = getColor(); + initPaint(mcontext.getMetrics()); } walker.init(mcontext, backgroundPaint, framePaint); @@ -42,6 +37,20 @@ public void drawInside(MapContext mcontext) { } + + private void initPaint(MapMetrics metrics) { + backgroundPaint = MapPaint.createBackgroundPaint(color); + framePaint = MapPaint.createEdgePaintLine(metrics.getDensity()); + framePaint.setColor(color); + } + + + private void initPaint() { + backgroundPaint = MapPaint.createBackgroundPaint(color); + framePaint = MapPaint.createBackgroundPaint(color); + } + + @Override public boolean onTap(Point tapXY) { return false;