Changeset 4126 in josm for trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
- Timestamp:
- 2011-06-07T19:05:14+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r4087 r4126 20 20 import java.util.concurrent.locks.ReentrantReadWriteLock; 21 21 22 import org.openstreetmap.josm.Main; 22 23 import org.openstreetmap.josm.data.Bounds; 23 24 import org.openstreetmap.josm.data.SelectionChangedListener; … … 34 35 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 35 36 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 37 import org.openstreetmap.josm.data.projection.Projection; 38 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 36 39 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 37 40 import org.openstreetmap.josm.tools.FilteredCollection; 38 41 import org.openstreetmap.josm.tools.Predicate; 39 42 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 43 import org.openstreetmap.josm.tools.Utils; 40 44 41 45 /** … … 83 87 * @author imi 84 88 */ 85 public class DataSet implements Cloneable {89 public class DataSet implements Cloneable, ProjectionChangeListener { 86 90 87 91 /** … … 120 124 private final ReadWriteLock lock = new ReentrantReadWriteLock(); 121 125 private final Object selectionLock = new Object(); 126 127 public DataSet() { 128 /* 129 * Transparently register as projection change lister. No need to explicitly remove the 130 * the listener, projection change listeners are managed as WeakReferences. 131 */ 132 Main.addProjectionChangeListener(this); 133 } 122 134 123 135 public Lock getReadLock() { … … 975 987 } 976 988 989 /** 990 * Invalidates the internal cache of projected east/north coordinates. 991 * 992 * This method can be invoked after the globally configured projection method 993 * changed. In contrast to {@link DataSet#reproject()} it only invalidates the 994 * cache and doesn't reproject the coordinates. 995 */ 996 public void invalidateEastNorthCache() { 997 if (Main.getProjection() == null) return; // sanity check 998 try { 999 beginUpdate(); 1000 for (Node n: Utils.filteredCollection(allPrimitives, Node.class)) { 1001 n.invalidateEastNorthCache(); 1002 } 1003 } finally { 1004 endUpdate(); 1005 } 1006 } 1007 977 1008 public void cleanupDeletedPrimitives() { 978 1009 beginUpdate(); … … 1064 1095 return ret; 1065 1096 } 1097 1098 /* --------------------------------------------------------------------------------- */ 1099 /* interface ProjectionChangeListner */ 1100 /* --------------------------------------------------------------------------------- */ 1101 @Override 1102 public void projectionChanged(Projection oldValue, Projection newValue) { 1103 invalidateEastNorthCache(); 1104 } 1066 1105 }
Note:
See TracChangeset
for help on using the changeset viewer.