Browse Source

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

Holt59 3 years ago
parent
commit
8200497675

+ 3
- 1
src/main/org/insa/graphics/drawing/components/MapViewDrawing.java View File

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

+ 6
- 3
src/main/org/insa/graphics/drawing/overlays/PolylineAutoScaling.java View File

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

Loading…
Cancel
Save