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.
This commit is contained in:
parent
112ffdd69a
commit
71e84acc9f
2 changed files with 5 additions and 35 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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<GPXUtilities.WptPt> pt) {
|
||||
|
@ -92,15 +84,6 @@ public class Renderable {
|
|||
// view.refreshMap(); // force a redraw
|
||||
//}
|
||||
}
|
||||
|
||||
public List<GPXUtilities.WptPt> 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<GPXUtilities.WptPt> pt, OsmandMapTileView view, double segmentSize) {
|
||||
public DistanceMarker(List<GPXUtilities.WptPt> 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;
|
||||
|
|
Loading…
Reference in a new issue