Skip to content

Commit

Permalink
Fix: Color not always initialized in GpxLegendLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
bailuk committed Dec 25, 2018
1 parent d83d312 commit c39a8f9
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,28 +21,36 @@ 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);
walker.walkTrack(getGpxList());
}



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;
Expand Down

0 comments on commit c39a8f9

Please sign in to comment.