Changeset 29625 in osm for applications/editors
- Timestamp:
- 2013-06-06T02:15:21+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r29579 r29625 15 15 import javax.swing.JPanel; 16 16 17 import org.openstreetmap.josm.Main; 17 18 import org.openstreetmap.josm.data.SelectionChangedListener; 18 19 import org.openstreetmap.josm.data.osm.DataSet; … … 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 22 import org.openstreetmap.josm.data.osm.Way; 23 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 24 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 25 import org.openstreetmap.josm.data.osm.event.DataSetListener; 26 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent; 27 import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent; 28 import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent; 29 import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent; 30 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 31 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 22 32 import org.openstreetmap.josm.gui.NavigatableComponent; 23 33 import org.openstreetmap.josm.gui.SideButton; … … 34 44 * @author ramack 35 45 */ 36 public class MeasurementDialog extends ToggleDialog implements SelectionChangedListener {46 public class MeasurementDialog extends ToggleDialog implements SelectionChangedListener, DataSetListener { 37 47 private static final long serialVersionUID = 4708541586297950021L; 38 48 … … 61 71 */ 62 72 protected JLabel segAngleLabel; 73 74 private DataSet ds; 75 76 private Collection<Way> ways; 77 private Collection<Node> nodes; 63 78 64 79 /** … … 119 134 120 135 /** 121 * Cleans the active Mea usurement Layer136 * Cleans the active Measurement Layer 122 137 */ 123 138 public void resetValues(){ … … 132 147 Node lastNode = null; 133 148 // Don't mix up way and nodes computation (fix #6872). Priority given to ways 134 SubclassFilteredCollection<OsmPrimitive, Way>ways = new SubclassFilteredCollection<OsmPrimitive, Way>(newSelection, OsmPrimitive.wayPredicate);149 ways = new SubclassFilteredCollection<OsmPrimitive, Way>(newSelection, OsmPrimitive.wayPredicate); 135 150 if (ways.isEmpty()) { 136 for (Node n : new SubclassFilteredCollection<OsmPrimitive, Node>(newSelection, OsmPrimitive.nodePredicate)) { 151 nodes = new SubclassFilteredCollection<OsmPrimitive, Node>(newSelection, OsmPrimitive.nodePredicate); 152 for (Node n : nodes) { 137 153 if (n.getCoor() != null) { 138 154 if (lastNode == null) { … … 146 162 } 147 163 } else { 164 nodes = null; 148 165 for (Way w : ways) { 149 166 Node lastN = null; … … 179 196 } 180 197 }); 198 199 DataSet currentDs = Main.main.getCurrentDataSet(); 200 201 if (ds != currentDs) { 202 if (ds != null) { 203 ds.removeDataSetListener(this); 204 } 205 if (currentDs != null) { 206 currentDs.addDataSetListener(this); 207 } 208 ds = currentDs; 209 } 181 210 } 182 211 … … 188 217 super.destroy(); 189 218 DataSet.removeSelectionListener(this); 219 if (ds != null) { 220 ds.removeDataSetListener(this); 221 ds = null; 222 } 190 223 } 224 225 private boolean waysContain(Node n) { 226 if (ways != null) { 227 for (Way w : ways) { 228 if (w.containsNode(n)) { 229 return true; 230 } 231 } 232 } 233 return false; 234 } 235 236 @Override public void nodeMoved(NodeMovedEvent event) { 237 Node n = event.getNode(); 238 // Refresh selection if a node belonging to a selected member has moved (example: scale action) 239 if ((nodes != null && nodes.contains(n)) || waysContain(n)) { 240 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 241 } 242 } 243 244 @Override public void primitivesAdded(PrimitivesAddedEvent event) {} 245 @Override public void primitivesRemoved(PrimitivesRemovedEvent event) {} 246 @Override public void tagsChanged(TagsChangedEvent event) {} 247 @Override public void wayNodesChanged(WayNodesChangedEvent event) { } 248 @Override public void relationMembersChanged(RelationMembersChangedEvent event) {} 249 @Override public void otherDatasetChange(AbstractDatasetChangedEvent event) {} 250 @Override public void dataChanged(DataChangedEvent event) {} 191 251 }
Note:
See TracChangeset
for help on using the changeset viewer.