- Timestamp:
- 2017-04-28T14:36:21+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r11712 r12014 50 50 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 51 51 import org.openstreetmap.josm.tools.JosmRuntimeException; 52 import org.openstreetmap.josm.tools.ListenerList; 52 53 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 53 54 import org.openstreetmap.josm.tools.Utils; … … 156 157 private Collection<WaySegment> highlightedVirtualNodes = new LinkedList<>(); 157 158 private Collection<WaySegment> highlightedWaySegments = new LinkedList<>(); 159 private final ListenerList<HighlightUpdateListener> highlightUpdateListeners = ListenerList.create(); 158 160 159 161 // Number of open calls to beginUpdate … … 161 163 // Events that occurred while dataset was locked but should be fired after write lock is released 162 164 private final List<AbstractDatasetChangedEvent> cachedEvents = new ArrayList<>(); 163 164 private int highlightUpdateCount;165 165 166 166 private UploadPolicy uploadPolicy; … … 267 267 public Lock getReadLock() { 268 268 return lock.readLock(); 269 }270 271 /**272 * This method can be used to detect changes in highlight state of primitives. If highlighting was changed273 * then the method will return different number.274 * @return the current highlight counter275 */276 public int getHighlightUpdateCount() {277 return highlightUpdateCount;278 269 } 279 270 … … 726 717 public Collection<WaySegment> getHighlightedWaySegments() { 727 718 return Collections.unmodifiableCollection(highlightedWaySegments); 719 } 720 721 /** 722 * Adds a listener that gets notified whenever way segment / virtual nodes highlights change. 723 * @param listener The Listener 724 * @since 12014 725 */ 726 public void addHighlightUpdateListener(HighlightUpdateListener listener) { 727 highlightUpdateListeners.addListener(listener); 728 } 729 730 /** 731 * Removes a listener that was added with {@link #addHighlightUpdateListener(HighlightUpdateListener)} 732 * @param listener The Listener 733 * @since 12014 734 */ 735 public void removeHighlightUpdateListener(HighlightUpdateListener listener) { 736 highlightUpdateListeners.removeListener(listener); 728 737 } 729 738 … … 1335 1344 1336 1345 void fireHighlightingChanged() { 1337 highlightUpdateCount++; 1346 HighlightUpdateListener.HighlightUpdateEvent e = new HighlightUpdateListener.HighlightUpdateEvent(this); 1347 highlightUpdateListeners.fireEvent(l -> l.highlightUpdated(e)); 1338 1348 } 1339 1349 -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintable.java
r10600 r12014 88 88 /** 89 89 * This needs to be called whenever the content of this view was invalidated. 90 * It triggers a repaint of the components that display this layer. 90 91 */ 91 92 public void invalidate() { -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r11893 r12014 66 66 import org.openstreetmap.josm.data.osm.DataSetMerger; 67 67 import org.openstreetmap.josm.data.osm.DatasetConsistencyTest; 68 import org.openstreetmap.josm.data.osm.HighlightUpdateListener; 68 69 import org.openstreetmap.josm.data.osm.IPrimitive; 69 70 import org.openstreetmap.josm.data.osm.Node; … … 117 118 * @since 17 118 119 */ 119 public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener {120 public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener, HighlightUpdateListener { 120 121 private static final int HATCHED_SIZE = 15; 121 122 /** Property used to know if this layer has to be saved on disk */ … … 126 127 private boolean requiresSaveToFile; 127 128 private boolean requiresUploadToServer; 128 private int highlightUpdateCount;129 129 130 130 /** … … 364 364 data.addDataSetListener(new DataSetListenerAdapter(this)); 365 365 data.addDataSetListener(MultipolygonCache.getInstance()); 366 data.addHighlightUpdateListener(this); 366 367 DataSet.addSelectionListener(this); 367 368 if (name != null && name.startsWith(createLayerName("")) && Character.isDigit( … … 400 401 */ 401 402 @Override public void paint(final Graphics2D g, final MapView mv, Bounds box) { 402 highlightUpdateCount = data.getHighlightUpdateCount();403 404 403 boolean active = mv.getLayerManager().getActiveLayer() == this; 405 404 boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true); … … 908 907 909 908 @Override 910 public boolean isChanged() {911 return highlightUpdateCount != data.getHighlightUpdateCount();912 }913 914 @Override915 909 public void onPostSaveToFile() { 916 910 setRequiresSaveToFile(false); … … 952 946 super.destroy(); 953 947 DataSet.removeSelectionListener(this); 948 data.removeHighlightUpdateListener(this); 954 949 } 955 950 … … 1102 1097 return v.getBounds(); 1103 1098 } 1099 1100 @Override 1101 public void highlightUpdated(HighlightUpdateEvent e) { 1102 invalidate(); 1103 } 1104 1104 }
Note:
See TracChangeset
for help on using the changeset viewer.