- Timestamp:
- 2015-07-01T21:11:45+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r8551 r8552 26 26 import java.util.Collections; 27 27 import java.util.Comparator; 28 import java.util.Linked List;28 import java.util.LinkedHashSet; 29 29 import java.util.List; 30 import java.util. ListIterator;30 import java.util.Set; 31 31 import java.util.concurrent.CopyOnWriteArrayList; 32 32 import java.util.concurrent.locks.ReentrantReadWriteLock; … … 35 35 import javax.swing.ActionMap; 36 36 import javax.swing.InputMap; 37 import javax.swing.JComponent; 37 38 import javax.swing.JFrame; 38 39 import javax.swing.JPanel; … … 268 269 public MouseEvent lastMEvent = new MouseEvent(this, 0, 0, 0, 0, 0, 0, false); // In case somebody reads it before first mouse move 269 270 270 private final transient List<MapViewPaintable> temporaryLayers = new LinkedList<>(); 271 /** 272 * Temporary layers (selection rectangle, etc.) that are never cached and 273 * drawn on top of regular layers. 274 * Access must be synchronized. 275 */ 276 private final transient Set<MapViewPaintable> temporaryLayers = new LinkedHashSet<>(); 271 277 272 278 private transient BufferedImage nonChangedLayersBuffer; … … 782 788 } 783 789 784 for (MapViewPaintable mvp : temporaryLayers) { 785 mvp.paint(tempG, this, box); 790 synchronized (temporaryLayers) { 791 for (MapViewPaintable mvp : temporaryLayers) { 792 mvp.paint(tempG, this, box); 793 } 786 794 } 787 795 … … 1063 1071 } 1064 1072 1073 /** 1074 * Adds a new temporary layer. 1075 * <p> 1076 * A temporary layer is a layer that is painted above all normal layers. Layers are painted in the order they are added. 1077 * 1078 * @param mvp The layer to paint. 1079 * @return <code>true</code> if the layer was added. 1080 */ 1065 1081 public boolean addTemporaryLayer(MapViewPaintable mvp) { 1066 if (temporaryLayers.contains(mvp)) return false; 1067 return temporaryLayers.add(mvp); 1068 } 1069 1082 synchronized (temporaryLayers) { 1083 return temporaryLayers.add(mvp); 1084 } 1085 } 1086 1087 /** 1088 * Removes a layer previously added as temporary layer. 1089 * @param mvp The layer to remove. 1090 * @return <code>true</code> if that layer was removed. 1091 */ 1070 1092 public boolean removeTemporaryLayer(MapViewPaintable mvp) { 1071 return temporaryLayers.remove(mvp); 1093 synchronized (temporaryLayers) { 1094 return temporaryLayers.remove(mvp); 1095 } 1096 } 1097 1098 /** 1099 * Gets a list of temporary layers. 1100 * @return The layers in the order they are added. 1101 */ 1102 public List<MapViewPaintable> getTemporaryLayers() { 1103 synchronized (temporaryLayers) { 1104 return Collections.unmodifiableList(new ArrayList<>(temporaryLayers)); 1105 } 1072 1106 } 1073 1107 … … 1140 1174 } 1141 1175 nonChangedLayers.clear(); 1142 temporaryLayers.clear(); 1176 synchronized (temporaryLayers) { 1177 temporaryLayers.clear(); 1178 } 1143 1179 } 1144 1180
Note:
See TracChangeset
for help on using the changeset viewer.