diff --git a/src/org/openstreetmap/josm/data/osm/DataSet.java b/src/org/openstreetmap/josm/data/osm/DataSet.java
index eaad637..991703c 100644
|
a
|
b
|
public final class DataSet implements Data, Cloneable, ProjectionChangeListener
|
| 752 | 752 | return; |
| 753 | 753 | |
| 754 | 754 | highlightedVirtualNodes = waySegments; |
| 755 | | // can't use fireHighlightingChanged because it requires an OsmPrimitive |
| 756 | | highlightUpdateCount++; |
| | 755 | fireHighlightingChanged(); |
| 757 | 756 | } |
| 758 | 757 | |
| 759 | 758 | /** |
| … |
… |
public final class DataSet implements Data, Cloneable, ProjectionChangeListener
|
| 765 | 764 | return; |
| 766 | 765 | |
| 767 | 766 | highlightedWaySegments = waySegments; |
| 768 | | // can't use fireHighlightingChanged because it requires an OsmPrimitive |
| 769 | | highlightUpdateCount++; |
| | 767 | fireHighlightingChanged(); |
| 770 | 768 | } |
| 771 | 769 | |
| 772 | 770 | /** |
diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java
index 63e4bb4..eed786c 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 {
|
| 149 | 150 | */ |
| 150 | 151 | private class LayerInvalidatedListener implements PaintableInvalidationListener { |
| 151 | 152 | private boolean ignoreRepaint; |
| | 153 | |
| | 154 | private final Set<MapViewPaintable> invalidatedLayers = Collections.newSetFromMap(new IdentityHashMap<MapViewPaintable, Boolean>()); |
| | 155 | |
| 152 | 156 | @Override |
| 153 | 157 | public void paintableInvalidated(PaintableInvalidationEvent event) { |
| | 158 | invalidate(event.getLayer()); |
| | 159 | } |
| | 160 | |
| | 161 | public synchronized void invalidate(MapViewPaintable mapViewPaintable) { |
| 154 | 162 | ignoreRepaint = true; |
| | 163 | invalidatedLayers.add(mapViewPaintable); |
| 155 | 164 | repaint(); |
| 156 | 165 | } |
| 157 | 166 | |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 159 | 168 | * Temporary until all {@link MapViewPaintable}s support this. |
| 160 | 169 | * @param p The paintable. |
| 161 | 170 | */ |
| 162 | | public void addTo(MapViewPaintable p) { |
| | 171 | public synchronized void addTo(MapViewPaintable p) { |
| 163 | 172 | if (p instanceof AbstractMapViewPaintable) { |
| 164 | 173 | ((AbstractMapViewPaintable) p).addInvalidationListener(this); |
| 165 | 174 | } |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 169 | 178 | * Temporary until all {@link MapViewPaintable}s support this. |
| 170 | 179 | * @param p The paintable. |
| 171 | 180 | */ |
| 172 | | public void removeFrom(MapViewPaintable p) { |
| | 181 | public synchronized void removeFrom(MapViewPaintable p) { |
| 173 | 182 | if (p instanceof AbstractMapViewPaintable) { |
| 174 | 183 | ((AbstractMapViewPaintable) p).removeInvalidationListener(this); |
| 175 | 184 | } |
| | 185 | invalidatedLayers.remove(p); |
| 176 | 186 | } |
| 177 | 187 | |
| 178 | 188 | /** |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 185 | 195 | } |
| 186 | 196 | ignoreRepaint = false; |
| 187 | 197 | } |
| | 198 | |
| | 199 | /** |
| | 200 | * Retrives a set of all layers that have been marked as invalid since the last call to this method. |
| | 201 | * @return The layers |
| | 202 | */ |
| | 203 | protected synchronized Set<MapViewPaintable> collectInvalidatedLayers() { |
| | 204 | Set<MapViewPaintable> layers = Collections.newSetFromMap(new IdentityHashMap<MapViewPaintable, Boolean>()); |
| | 205 | layers.addAll(invalidatedLayers); |
| | 206 | invalidatedLayers.clear(); |
| | 207 | return layers; |
| | 208 | } |
| 188 | 209 | } |
| 189 | 210 | |
| 190 | 211 | /** |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 505 | 526 | private transient BufferedImage offscreenBuffer; |
| 506 | 527 | // Layers that wasn't changed since last paint |
| 507 | 528 | private final transient List<Layer> nonChangedLayers = new ArrayList<>(); |
| 508 | | private transient Layer changedLayer; |
| 509 | 529 | private int lastViewID; |
| 510 | 530 | private boolean paintPreferencesChanged = true; |
| 511 | 531 | private Rectangle lastClipBounds = new Rectangle(); |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 521 | 541 | */ |
| 522 | 542 | private final HashMap<Layer, LayerPainter> registeredLayers = new HashMap<>(); |
| 523 | 543 | |
| | 544 | |
| | 545 | |
| 524 | 546 | /** |
| 525 | 547 | * Constructs a new {@code MapView}. |
| 526 | 548 | * @param layerManager The layers to display. |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 843 | 865 | List<Layer> visibleLayers = layerManager.getVisibleLayersInZOrder(); |
| 844 | 866 | |
| 845 | 867 | int nonChangedLayersCount = 0; |
| | 868 | Set<MapViewPaintable> invalidated = invalidatedListener.collectInvalidatedLayers(); |
| 846 | 869 | for (Layer l: visibleLayers) { |
| 847 | | if (l.isChanged() || l == changedLayer) { |
| | 870 | if (l.isChanged() || invalidated.contains(l)) { |
| 848 | 871 | break; |
| 849 | 872 | } else { |
| 850 | 873 | nonChangedLayersCount++; |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 901 | 924 | } |
| 902 | 925 | |
| 903 | 926 | nonChangedLayers.clear(); |
| 904 | | changedLayer = null; |
| 905 | 927 | for (int i = 0; i < nonChangedLayersCount; i++) { |
| 906 | 928 | nonChangedLayers.add(visibleLayers.get(i)); |
| 907 | 929 | } |
| … |
… |
LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
|
| 1235 | 1257 | evt.getPropertyName().equals(Layer.FILTER_STATE_PROP)) { |
| 1236 | 1258 | Layer l = (Layer) evt.getSource(); |
| 1237 | 1259 | if (l.isVisible()) { |
| 1238 | | changedLayer = l; |
| 1239 | | repaint(); |
| | 1260 | invalidatedListener.invalidate(l); |
| 1240 | 1261 | } |
| 1241 | 1262 | } |
| 1242 | 1263 | } |
diff --git a/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java b/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
index faf94af..a57bd9a 100644
|
a
|
b
|
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 136 | 136 | * Initial zoom lvl is set to bestZoom |
| 137 | 137 | */ |
| 138 | 138 | public int currentZoomLevel; |
| 139 | | private boolean needRedraw; |
| 140 | 139 | |
| 141 | 140 | private final AttributionSupport attribution = new AttributionSupport(); |
| 142 | 141 | private final TileHolder clickedTileHolder = new TileHolder(); |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 263 | 262 | tile.setImage(null); |
| 264 | 263 | } |
| 265 | 264 | tile.setLoaded(success); |
| 266 | | needRedraw = true; |
| 267 | | if (Main.map != null) { |
| 268 | | Main.map.repaint(100); |
| 269 | | } |
| | 265 | // TODO: Delay 100 ms |
| | 266 | invalidate(); |
| 270 | 267 | if (Main.isDebugEnabled()) { |
| 271 | 268 | Main.debug("tileLoadingFinished() tile: " + tile + " success: " + success); |
| 272 | 269 | } |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 296 | 293 | * @see #invalidate() To trigger a repaint of all places where the layer is displayed. |
| 297 | 294 | */ |
| 298 | 295 | protected void redraw() { |
| 299 | | needRedraw = true; |
| 300 | | if (isVisible()) Main.map.repaint(); |
| 301 | | } |
| 302 | | |
| 303 | | @Override |
| 304 | | public void invalidate() { |
| 305 | | needRedraw = true; |
| 306 | | super.invalidate(); |
| | 296 | invalidate(); |
| 307 | 297 | } |
| 308 | 298 | |
| 309 | 299 | /** |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 1035 | 1025 | @Override |
| 1036 | 1026 | public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { |
| 1037 | 1027 | boolean done = (infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0; |
| 1038 | | needRedraw = true; |
| 1039 | 1028 | if (Main.isDebugEnabled()) { |
| 1040 | 1029 | Main.debug("imageUpdate() done: " + done + " calling repaint"); |
| 1041 | 1030 | } |
| 1042 | | Main.map.repaint(done ? 0 : 100); |
| | 1031 | // TODO: Trigger delayed invalidation if !done. |
| | 1032 | invalidate(); |
| 1043 | 1033 | return !done; |
| 1044 | 1034 | } |
| 1045 | 1035 | |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 1521 | 1511 | public void paint(Graphics2D g, MapView mv, Bounds bounds) { |
| 1522 | 1512 | ProjectionBounds pb = mv.getState().getViewArea().getProjectionBounds(); |
| 1523 | 1513 | |
| 1524 | | needRedraw = false; |
| 1525 | | |
| 1526 | 1514 | int zoom = currentZoomLevel; |
| 1527 | 1515 | if (getDisplaySettings().isAutoZoom()) { |
| 1528 | 1516 | zoom = getBestZoom(); |
| … |
… |
implements ImageObserver, TileLoaderListener, ZoomChangeListener, FilterChangeLi
|
| 1758 | 1746 | |
| 1759 | 1747 | @Override |
| 1760 | 1748 | public boolean isChanged() { |
| 1761 | | return needRedraw; |
| | 1749 | // we use #invalidate() |
| | 1750 | return false; |
| 1762 | 1751 | } |
| 1763 | 1752 | |
| 1764 | 1753 | /** |
diff --git a/src/org/openstreetmap/josm/gui/layer/Layer.java b/src/org/openstreetmap/josm/gui/layer/Layer.java
index 7347110..f70f0d8 100644
|
a
|
b
|
public abstract class Layer extends AbstractMapViewPaintable implements Destroya
|
| 425 | 425 | * Check changed status of layer |
| 426 | 426 | * |
| 427 | 427 | * @return True if layer was changed since last paint |
| | 428 | * @deprecated This is not supported by multiple map views. |
| | 429 | * Fire an {@link #invalidate()} to trigger a repaint. |
| | 430 | * Let this method return false if you only use invalidation events. |
| 428 | 431 | */ |
| | 432 | @Deprecated |
| 429 | 433 | public boolean isChanged() { |
| 430 | 434 | return true; |
| 431 | 435 | } |