Changeset 10809 in josm
- Timestamp:
- 2016-08-15T17:40:22+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r10788 r10809 752 752 753 753 highlightedVirtualNodes = waySegments; 754 // can't use fireHighlightingChanged because it requires an OsmPrimitive 755 highlightUpdateCount++; 754 fireHighlightingChanged(); 756 755 } 757 756 … … 765 764 766 765 highlightedWaySegments = waySegments; 767 // can't use fireHighlightingChanged because it requires an OsmPrimitive 768 highlightUpdateCount++; 766 fireHighlightingChanged(); 769 767 } 770 768 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r10806 r10809 26 26 import java.util.Collections; 27 27 import java.util.HashMap; 28 import java.util.IdentityHashMap; 28 29 import java.util.LinkedHashSet; 29 30 import java.util.List; … … 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 paintableInvalidated(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 } … … 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); … … 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 … … 183 193 } 184 194 ignoreRepaint = false; 195 } 196 197 /** 198 * Retrieves 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; 185 206 } 186 207 } … … 504 525 // Layers that wasn't changed since last paint 505 526 private final transient List<Layer> nonChangedLayers = new ArrayList<>(); 506 private transient Layer changedLayer;507 527 private int lastViewID; 508 528 private boolean paintPreferencesChanged = true; … … 842 862 843 863 int nonChangedLayersCount = 0; 864 Set<MapViewPaintable> invalidated = invalidatedListener.collectInvalidatedLayers(); 844 865 for (Layer l: visibleLayers) { 845 if (l.isChanged() || l == changedLayer) {866 if (l.isChanged() || invalidated.contains(l)) { 846 867 break; 847 868 } else { … … 900 921 901 922 nonChangedLayers.clear(); 902 changedLayer = null;903 923 for (int i = 0; i < nonChangedLayersCount; i++) { 904 924 nonChangedLayers.add(visibleLayers.get(i)); … … 1205 1225 Layer l = (Layer) evt.getSource(); 1206 1226 if (l.isVisible()) { 1207 changedLayer = l; 1208 repaint(); 1227 invalidatedListener.invalidate(l); 1209 1228 } 1210 1229 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r10805 r10809 51 51 import javax.swing.JSeparator; 52 52 import javax.swing.JTextField; 53 import javax.swing.Timer; 53 54 54 55 import org.openstreetmap.gui.jmapviewer.AttributionSupport; … … 137 138 */ 138 139 public int currentZoomLevel; 139 private boolean needRedraw;140 140 141 141 private final AttributionSupport attribution = new AttributionSupport(); … … 158 158 protected T tileSource; 159 159 protected TileLoader tileLoader; 160 161 /** 162 * A timer that is used to delay invalidation events if required. 163 */ 164 private final Timer invalidateLaterTimer = new Timer(100, e -> this.invalidate()); 160 165 161 166 private final MouseAdapter adapter = new MouseAdapter() { … … 264 269 } 265 270 tile.setLoaded(success); 266 needRedraw = true; 267 if (Main.map != null) { 268 Main.map.repaint(100); 269 } 271 invalidateLater(); 270 272 if (Main.isDebugEnabled()) { 271 273 Main.debug("tileLoadingFinished() tile: " + tile + " success: " + success); … … 297 299 */ 298 300 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(); 301 invalidate(); 307 302 } 308 303 … … 1030 1025 public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { 1031 1026 boolean done = (infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0; 1032 needRedraw = true;1033 1027 if (Main.isDebugEnabled()) { 1034 1028 Main.debug("imageUpdate() done: " + done + " calling repaint"); 1035 1029 } 1036 Main.map.repaint(done ? 0 : 100); 1030 1031 if (done) { 1032 invalidate(); 1033 } else { 1034 invalidateLater(); 1035 } 1037 1036 return !done; 1037 } 1038 1039 /** 1040 * Invalidate the layer at a time in the future so taht the user still sees the interface responsive. 1041 */ 1042 private void invalidateLater() { 1043 GuiHelper.runInEDT(() -> { 1044 if (!invalidateLaterTimer.isRunning()) { 1045 invalidateLaterTimer.setRepeats(false); 1046 invalidateLaterTimer.start(); 1047 } 1048 }); 1038 1049 } 1039 1050 … … 1753 1764 @Override 1754 1765 public boolean isChanged() { 1755 return needRedraw; 1766 // we use #invalidate() 1767 return false; 1756 1768 } 1757 1769 … … 1899 1911 ProjectionBounds pb = graphics.getClipBounds().getProjectionBounds(); 1900 1912 1901 needRedraw = false; // TEMPORARY1902 1903 1913 drawInViewArea(graphics.getDefaultGraphics(), graphics.getMapView(), pb); 1904 1914 } -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r10611 r10809 426 426 * 427 427 * @return True if layer was changed since last paint 428 */ 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. 431 */ 432 @Deprecated 429 433 public boolean isChanged() { 430 434 return true;
Note:
See TracChangeset
for help on using the changeset viewer.