diff --git a/src/org/openstreetmap/josm/data/osm/DataSet.java b/src/org/openstreetmap/josm/data/osm/DataSet.java
index fe3febc..173c0d2 100644
a
|
b
|
public final class DataSet implements Data, Cloneable, ProjectionChangeListener
|
751 | 751 | return; |
752 | 752 | |
753 | 753 | highlightedVirtualNodes = waySegments; |
754 | | // can't use fireHighlightingChanged because it requires an OsmPrimitive |
755 | | highlightUpdateCount++; |
| 754 | fireHighlightingChanged(); |
756 | 755 | } |
757 | 756 | |
758 | 757 | /** |
… |
… |
public final class DataSet implements Data, Cloneable, ProjectionChangeListener
|
764 | 763 | return; |
765 | 764 | |
766 | 765 | highlightedWaySegments = waySegments; |
767 | | // can't use fireHighlightingChanged because it requires an OsmPrimitive |
768 | | highlightUpdateCount++; |
| 766 | fireHighlightingChanged(); |
769 | 767 | } |
770 | 768 | |
771 | 769 | /** |
diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java
index da3079e..a6008b4 100644
a
|
b
|
import java.util.Arrays;
|
26 | 26 | import java.util.Collection; |
27 | 27 | import java.util.Collections; |
28 | 28 | import java.util.HashMap; |
| 29 | import java.util.IdentityHashMap; |
29 | 30 | import java.util.LinkedHashSet; |
30 | 31 | import java.util.List; |
31 | 32 | import java.util.Set; |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
147 | 148 | */ |
148 | 149 | private class LayerInvalidatedListener implements PaintableInvalidationListener { |
149 | 150 | private boolean ignoreRepaint; |
| 151 | |
| 152 | private final Set<MapViewPaintable> invalidatedLayers = Collections.newSetFromMap(new IdentityHashMap<MapViewPaintable, Boolean>()); |
| 153 | |
150 | 154 | @Override |
151 | 155 | public void paintablInvalidated(PaintableInvalidationEvent event) { |
| 156 | invalidate(event.getLayer()); |
| 157 | } |
| 158 | |
| 159 | public synchronized void invalidate(MapViewPaintable mapViewPaintable) { |
152 | 160 | ignoreRepaint = true; |
| 161 | invalidatedLayers.add(mapViewPaintable); |
153 | 162 | repaint(); |
154 | 163 | } |
155 | 164 | |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
157 | 166 | * Temporary until all {@link MapViewPaintable}s support this. |
158 | 167 | * @param p The paintable. |
159 | 168 | */ |
160 | | public void addTo(MapViewPaintable p) { |
| 169 | public synchronized void addTo(MapViewPaintable p) { |
161 | 170 | if (p instanceof AbstractMapViewPaintable) { |
162 | 171 | ((AbstractMapViewPaintable) p).addInvalidationListener(this); |
163 | 172 | } |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
167 | 176 | * Temporary until all {@link MapViewPaintable}s support this. |
168 | 177 | * @param p The paintable. |
169 | 178 | */ |
170 | | public void removeFrom(MapViewPaintable p) { |
| 179 | public synchronized void removeFrom(MapViewPaintable p) { |
171 | 180 | if (p instanceof AbstractMapViewPaintable) { |
172 | 181 | ((AbstractMapViewPaintable) p).removeInvalidationListener(this); |
173 | 182 | } |
| 183 | invalidatedLayers.remove(p); |
174 | 184 | } |
175 | 185 | |
176 | 186 | /** |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
183 | 193 | } |
184 | 194 | ignoreRepaint = false; |
185 | 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Retrives a set of all layers that have been marked as invalid since the last call to this method. |
| 199 | * @return The layers |
| 200 | */ |
| 201 | protected synchronized Set<MapViewPaintable> collectInvalidatedLayers() { |
| 202 | Set<MapViewPaintable> layers = Collections.newSetFromMap(new IdentityHashMap<MapViewPaintable, Boolean>()); |
| 203 | layers.addAll(invalidatedLayers); |
| 204 | invalidatedLayers.clear(); |
| 205 | return layers; |
| 206 | } |
186 | 207 | } |
187 | 208 | |
188 | 209 | /** |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
509 | 530 | private transient BufferedImage offscreenBuffer; |
510 | 531 | // Layers that wasn't changed since last paint |
511 | 532 | private final transient List<Layer> nonChangedLayers = new ArrayList<>(); |
512 | | private transient Layer changedLayer; |
513 | 533 | private int lastViewID; |
514 | 534 | private boolean paintPreferencesChanged = true; |
515 | 535 | private Rectangle lastClipBounds = new Rectangle(); |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
525 | 545 | */ |
526 | 546 | private final HashMap<Layer, LayerPainter> registeredLayers = new HashMap<>(); |
527 | 547 | |
| 548 | |
| 549 | |
528 | 550 | /** |
529 | 551 | * Constructs a new {@code MapView}. |
530 | 552 | * @param layerManager The layers to display. |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
846 | 868 | List<Layer> visibleLayers = layerManager.getVisibleLayersInZOrder(); |
847 | 869 | |
848 | 870 | int nonChangedLayersCount = 0; |
| 871 | Set<MapViewPaintable> invalidated = invalidatedListener.collectInvalidatedLayers(); |
849 | 872 | for (Layer l: visibleLayers) { |
850 | | if (l.isChanged() || l == changedLayer) { |
| 873 | if (l.isChanged() || invalidated.contains(l)) { |
851 | 874 | break; |
852 | 875 | } else { |
853 | 876 | nonChangedLayersCount++; |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
904 | 927 | } |
905 | 928 | |
906 | 929 | nonChangedLayers.clear(); |
907 | | changedLayer = null; |
908 | 930 | for (int i = 0; i < nonChangedLayersCount; i++) { |
909 | 931 | nonChangedLayers.add(visibleLayers.get(i)); |
910 | 932 | } |
… |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
1226 | 1248 | evt.getPropertyName().equals(Layer.FILTER_STATE_PROP)) { |
1227 | 1249 | Layer l = (Layer) evt.getSource(); |
1228 | 1250 | if (l.isVisible()) { |
1229 | | changedLayer = l; |
1230 | | repaint(); |
| 1251 | invalidatedListener.invalidate(l); |
1231 | 1252 | } |
1232 | 1253 | } |
1233 | 1254 | } |
diff --git a/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java b/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
index a3a5a10..de7bb15 100644
a
|
b
|
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
128 | 128 | * Initial zoom lvl is set to bestZoom |
129 | 129 | */ |
130 | 130 | public int currentZoomLevel; |
131 | | private boolean needRedraw; |
132 | 131 | |
133 | 132 | private final AttributionSupport attribution = new AttributionSupport(); |
134 | 133 | private final TileHolder clickedTileHolder = new TileHolder(); |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
252 | 251 | tile.setImage(null); |
253 | 252 | } |
254 | 253 | tile.setLoaded(success); |
255 | | needRedraw = true; |
256 | | if (Main.map != null) { |
257 | | Main.map.repaint(100); |
258 | | } |
| 254 | // TODO: Delay 100 ms |
| 255 | invalidate(); |
259 | 256 | if (Main.isDebugEnabled()) { |
260 | 257 | Main.debug("tileLoadingFinished() tile: " + tile + " success: " + success); |
261 | 258 | } |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
284 | 281 | * @see MapFrame#repaint() |
285 | 282 | */ |
286 | 283 | protected void redraw() { |
287 | | needRedraw = true; |
288 | | if (isVisible()) Main.map.repaint(); |
| 284 | invalidate(); |
289 | 285 | } |
290 | 286 | |
291 | 287 | @Override |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
842 | 838 | if (tileLoader instanceof TMSCachedTileLoader) { |
843 | 839 | ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks(); |
844 | 840 | } |
845 | | needRedraw = true; |
| 841 | invalidate(); |
846 | 842 | } |
847 | 843 | |
848 | 844 | protected int getMaxZoomLvl() { |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
1016 | 1012 | @Override |
1017 | 1013 | public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { |
1018 | 1014 | boolean done = (infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0; |
1019 | | needRedraw = true; |
1020 | 1015 | if (Main.isDebugEnabled()) { |
1021 | 1016 | Main.debug("imageUpdate() done: " + done + " calling repaint"); |
1022 | 1017 | } |
1023 | | Main.map.repaint(done ? 0 : 100); |
| 1018 | // TODO: Trigger delayed invalidation if !done. |
| 1019 | invalidate(); |
1024 | 1020 | return !done; |
1025 | 1021 | } |
1026 | 1022 | |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
1537 | 1533 | return; |
1538 | 1534 | } |
1539 | 1535 | |
1540 | | needRedraw = false; |
1541 | | |
1542 | 1536 | int zoom = currentZoomLevel; |
1543 | 1537 | if (getDisplaySettings().isAutoZoom()) { |
1544 | 1538 | zoom = getBestZoom(); |
… |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
1786 | 1780 | |
1787 | 1781 | @Override |
1788 | 1782 | public boolean isChanged() { |
1789 | | return needRedraw; |
| 1783 | // we use #invalidate() |
| 1784 | return false; |
1790 | 1785 | } |
1791 | 1786 | |
1792 | 1787 | /** |
diff --git a/src/org/openstreetmap/josm/gui/layer/Layer.java b/src/org/openstreetmap/josm/gui/layer/Layer.java
index b4f5797..116c175 100644
a
|
b
|
public abstract class Layer extends AbstractMapViewPaintable implements Destroya
|
447 | 447 | * Check changed status of layer |
448 | 448 | * |
449 | 449 | * @return True if layer was changed since last paint |
| 450 | * @deprecated This is not supported by multiple map views. |
| 451 | * Fire an {@link #invalidate()} to trigger a repaint. |
| 452 | * Let this method return false if you only use invalidation events. |
450 | 453 | */ |
| 454 | @Deprecated |
451 | 455 | public boolean isChanged() { |
452 | 456 | return true; |
453 | 457 | } |