Fix issue with path taking too long to be drawn due to useless syncrhonization.

This commit is contained in:
Holt59 2018-03-11 22:51:34 +01:00
parent 4af68f9f93
commit 8200497675
2 changed files with 9 additions and 4 deletions

View File

@ -414,9 +414,11 @@ public class MapViewDrawing extends MapView implements Drawing {
@Override @Override
public PathOverlay drawPath(Path path, Color color, boolean markers) { public PathOverlay drawPath(Path path, Color color, boolean markers) {
PolylineAutoScaling line = new PolylineAutoScaling(1, DEFAULT_PATH_COLOR); PolylineAutoScaling line = new PolylineAutoScaling(1, DEFAULT_PATH_COLOR);
ArrayList<Point> points = new ArrayList<>(path.getArcs().size() * 4);
for (Arc arc: path.getArcs()) { for (Arc arc: path.getArcs()) {
line.add(arc.getPoints()); points.addAll(arc.getPoints());
} }
line.addAll(points);
PathOverlay overlay = null; PathOverlay overlay = null;
if (markers) { if (markers) {
MarkerAutoScaling origin = createMarker(path.getOrigin().getPoint(), MarkerAutoScaling origin = createMarker(path.getOrigin().getPoint(),

View File

@ -1,7 +1,8 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphics.drawing.overlays;
import java.awt.Color; import java.awt.Color;
import java.util.List; import java.util.ArrayList;
import java.util.Collection;
import org.insa.graph.Point; import org.insa.graph.Point;
import org.mapsforge.core.graphics.Canvas; import org.mapsforge.core.graphics.Canvas;
@ -70,10 +71,12 @@ public class PolylineAutoScaling extends Polyline {
/** /**
* @param points Points to add to this line. * @param points Points to add to this line.
*/ */
public void add(List<Point> points) { public void addAll(Collection<? extends Point> points) {
ArrayList<LatLong> latlongs = new ArrayList<>(points.size());
for (Point point: points) { for (Point point: points) {
add(point); latlongs.add(new LatLong(point.getLatitude(), point.getLongitude()));
} }
getLatLongs().addAll(latlongs);
} }
@Override @Override