Remove border overlapping when zooming gradient track

This commit is contained in:
cepprice 2021-04-04 03:22:09 +05:00
parent 241a2387b1
commit 6cfc02979f

View file

@ -61,6 +61,7 @@ public class Renderable {
public List<WptPt> points = null; // Original list of points public List<WptPt> points = null; // Original list of points
protected List<WptPt> culled = new ArrayList<>(); // Reduced/resampled list of points protected List<WptPt> culled = new ArrayList<>(); // Reduced/resampled list of points
protected List<WptPt> oldCulled = new ArrayList<>();
protected int pointSize; protected int pointSize;
protected double segmentSize; protected double segmentSize;
@ -116,7 +117,7 @@ public class Renderable {
updateLocalPaint(p); updateLocalPaint(p);
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
if (scaleType != null) { if (scaleType != null) {
drawGradient(getPointsForDrawing(), p, canvas, tileBox); drawGradient(getPointsForDrawingWithBorder(), p, canvas, tileBox);
} else { } else {
drawSolid(getPointsForDrawing(), p, canvas, tileBox); drawSolid(getPointsForDrawing(), p, canvas, tileBox);
} }
@ -126,6 +127,9 @@ public class Renderable {
public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) { public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
if (QuadRect.trivialOverlap(tileBox.getLatLonBounds(), trackBounds)) { // is visible? if (QuadRect.trivialOverlap(tileBox.getLatLonBounds(), trackBounds)) { // is visible?
if (tileBox.getZoomAnimation() > 0 && !Algorithms.isEmpty(culled) && scaleType != null) {
oldCulled = new ArrayList<>(culled);
}
startCuller(zoom); startCuller(zoom);
drawSingleSegment(zoom, p, canvas, tileBox); drawSingleSegment(zoom, p, canvas, tileBox);
} }
@ -139,6 +143,16 @@ public class Renderable {
return culled.isEmpty() ? points : culled; return culled.isEmpty() ? points : culled;
} }
public List<WptPt> getPointsForDrawingWithBorder() {
if (!culled.isEmpty()) {
return culled;
} else if (!oldCulled.isEmpty()) {
return oldCulled;
} else {
return points;
}
}
public void drawGeometry(Canvas canvas, RotatedTileBox tileBox, QuadRect quadRect, int arrowColor, int trackColor, float trackWidth) { public void drawGeometry(Canvas canvas, RotatedTileBox tileBox, QuadRect quadRect, int arrowColor, int trackColor, float trackWidth) {
if (geometryWay != null) { if (geometryWay != null) {
List<WptPt> points = getPointsForDrawing(); List<WptPt> points = getPointsForDrawing();
@ -290,7 +304,8 @@ public class Renderable {
super(pt, 0); super(pt, 0);
} }
@Override public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) { @Override
public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
if (points.size() != pointSize) { if (points.size() != pointSize) {
int prevSize = pointSize; int prevSize = pointSize;
pointSize = points.size(); pointSize = points.size();