From 71e84acc9fcc7078c97bb46a0cb35eda8be67384 Mon Sep 17 00:00:00 2001 From: Andrew Davie Date: Fri, 1 Apr 2016 03:29:05 +1100 Subject: [PATCH] Final pass clean-up on code. It's done. I've been through and cleaned up the code - minor improvements and cleanups. I'm happy with it and will I stop making changes and wait for review. I also now understand how git branches work :) so I will work on my own branch. I hope that this addition makes it into OsmAnd; I'm confident that it is robust and well written. There will probably be a bug or two, but relatively minor I am sure. --- .../src/net/osmand/plus/views/GPXLayer.java | 2 +- .../src/net/osmand/plus/views/Renderable.java | 38 ++----------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index d9e8b2a1a8..58821e4dc0 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -338,7 +338,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex ts.renders.add(new Renderable.Altitude(ts.points, 10)); ts.renders.add(new Renderable.StandardTrack(ts.points, 18)); //ts.renders.add(new Renderable.Conveyor(ts.points, view, 20, 250)); - ts.renders.add(new Renderable.DistanceMarker(ts.points, view, 1000)); + ts.renders.add(new Renderable.DistanceMarker(ts.points, 1000)); //ts.renders.add(new Renderable.Speed(ts.points, 50, 128)); ts.renders.add(new Renderable.Arrows(ts.points, view, 10, 250)); } diff --git a/OsmAnd/src/net/osmand/plus/views/Renderable.java b/OsmAnd/src/net/osmand/plus/views/Renderable.java index 37f17b2c53..aec1930ee1 100644 --- a/OsmAnd/src/net/osmand/plus/views/Renderable.java +++ b/OsmAnd/src/net/osmand/plus/views/Renderable.java @@ -1,26 +1,19 @@ package net.osmand.plus.views; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.Path; import android.graphics.Rect; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.plus.GPXUtilities; -import net.osmand.util.MapAlgorithms; -import net.osmand.util.MapUtils; import java.util.List; import java.util.Timer; import java.util.TimerTask; -import gnu.trove.list.array.TIntArrayList; - - public class Renderable { // This class handles the actual drawing of segment 'layers'. A segment is a piece of track @@ -60,7 +53,6 @@ public class Renderable { Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); double zoom = -1; - boolean shadow = false; // TODO: fixup shadow support AsynchronousResampler culler = null; // The currently active resampler public RenderableSegment(List pt) { @@ -92,15 +84,6 @@ public class Renderable { // view.refreshMap(); // force a redraw //} } - - public List getPoints() { - return points; - } - - protected boolean isIn(float x, float y, float rx, float by) { - return x >= 0f && x <= rx && y >= 0f && y <= by; - } - } //---------------------------------------------------------------------------------------------- @@ -133,8 +116,8 @@ public class Renderable { double cullDistance = Math.pow(2.0, base - zoom); culler = new AsynchronousResampler.RamerDouglasPeucer(this, cullDistance); - if (zoom < newZoom) { // if line would look worse (we're zooming in) then... - culled = null; // use full-resolution until re-cull complete + if (zoom < newZoom) { // if line would look worse (we're zooming in) then... + culled = null; // use full-resolution until re-cull complete } zoom = newZoom; culler.execute(""); @@ -347,16 +330,11 @@ public class Renderable { //---------------------------------------------------------------------------------------------- public static class DistanceMarker extends RenderableSegment { - // EXPERIMENTAL! - private float dotScale; private double segmentSize; - private OsmandMapTileView view; - public DistanceMarker(List pt, OsmandMapTileView view, double segmentSize) { + public DistanceMarker(List pt, double segmentSize) { super(pt); - //this.view = view; - this.dotScale = view.getScaleCoefficient(); this.segmentSize = segmentSize; } @@ -430,7 +408,6 @@ public class Renderable { //---------------------------------------------------------------------------------------------- public static class Arrows extends RenderableSegment { - // EXPERIMENTAL! WORK IN PROGRESS... private double segmentSize; @@ -449,13 +426,6 @@ public class Renderable { } } - public int getComplementaryColor(int colorToInvert) { - float[] hsv = new float[3]; - Color.RGBToHSV(Color.red(colorToInvert), Color.green(colorToInvert), Color.blue(colorToInvert), hsv); - hsv[0] = (hsv[0] + 180) % 360; - return Color.HSVToColor(hsv); - } - @Override public void drawSingleSegment(Paint p, Canvas canvas, RotatedTileBox tileBox) { if (culled != null && !culled.isEmpty() && zoom > 14 @@ -467,7 +437,7 @@ public class Renderable { float arrowSize = (float) Math.pow(2.0,zoom-18) * 128; int pCol = p.getColor(); - p.setColor(Color.RED); //getComplementaryColor(p.getColor())); // and a complementary colour + p.setColor(Color.RED); float lastx = 0; float lasty = 0;