Changeset 13141 in josm for trunk/src/org
- Timestamp:
- 2017-11-22T01:09:28+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r12987 r13141 33 33 import java.util.Collection; 34 34 import java.util.ConcurrentModificationException; 35 import java.util.Iterator; 35 36 import java.util.List; 36 37 import java.util.Objects; … … 56 57 57 58 import org.openstreetmap.josm.Main; 58 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; 59 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; 59 import org.openstreetmap.josm.data.SelectionChangedListener; 60 60 import org.openstreetmap.josm.data.SystemOfMeasurement; 61 61 import org.openstreetmap.josm.data.SystemOfMeasurement.SoMChangeListener; … … 67 67 import org.openstreetmap.josm.data.osm.DataSet; 68 68 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 69 import org.openstreetmap.josm.data.osm.Node; 69 70 import org.openstreetmap.josm.data.osm.OsmPrimitive; 70 71 import org.openstreetmap.josm.data.osm.Way; 72 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 73 import org.openstreetmap.josm.data.osm.event.SelectionEventManager; 71 74 import org.openstreetmap.josm.data.preferences.AbstractProperty; 72 75 import org.openstreetmap.josm.data.preferences.BooleanProperty; … … 80 83 import org.openstreetmap.josm.gui.widgets.JosmTextField; 81 84 import org.openstreetmap.josm.spi.preferences.Config; 85 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; 86 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; 82 87 import org.openstreetmap.josm.tools.ColorHelper; 83 88 import org.openstreetmap.josm.tools.Destroyable; … … 85 90 import org.openstreetmap.josm.tools.ImageProvider; 86 91 import org.openstreetmap.josm.tools.Logging; 92 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 87 93 import org.openstreetmap.josm.tools.Utils; 88 94 … … 100 106 * @author imi 101 107 */ 102 public final class MapStatus extends JPanel implements Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener { 108 public final class MapStatus extends JPanel implements 109 Helpful, Destroyable, PreferenceChangedListener, SoMChangeListener, SelectionChangedListener { 103 110 104 111 private final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(Config.getPref().get("statusbar.decimal-format", "0.0")); … … 947 954 948 955 Config.getPref().addPreferenceChangeListener(this); 956 SelectionEventManager.getInstance().addSelectionListener(this, FireMode.IN_EDT_CONSOLIDATED); 949 957 950 958 mvComponentAdapter = new ComponentAdapter() { … … 1108 1116 SystemOfMeasurement.removeSoMChangeListener(this); 1109 1117 Config.getPref().removePreferenceChangeListener(this); 1118 SelectionEventManager.getInstance().removeSelectionListener(this); 1110 1119 mv.removeComponentListener(mvComponentAdapter); 1111 1120 … … 1153 1162 return Math.min(80, 20 + Math.max(0, w-1280) * 60 / (1920-1280)); 1154 1163 } 1164 1165 @Override 1166 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 1167 if (newSelection.size() == 2) { 1168 Iterator<? extends OsmPrimitive> it = newSelection.iterator(); 1169 OsmPrimitive n1 = it.next(); 1170 OsmPrimitive n2 = it.next(); 1171 // show distance between two selected nodes with coordinates 1172 if (n1 instanceof Node && n2 instanceof Node) { 1173 LatLon c1 = ((Node) n1).getCoor(); 1174 LatLon c2 = ((Node) n2).getCoor(); 1175 if (c1 != null && c2 != null) { 1176 setDist(c1.greatCircleDistance(c2)); 1177 return; 1178 } 1179 } 1180 } 1181 setDist(new SubclassFilteredCollection<OsmPrimitive, Way>(newSelection, Way.class::isInstance)); 1182 } 1155 1183 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r12909 r13141 19 19 import java.util.Comparator; 20 20 import java.util.HashSet; 21 import java.util.Iterator;22 21 import java.util.LinkedList; 23 22 import java.util.List; … … 44 43 import org.openstreetmap.josm.actions.relation.SelectInRelationListAction; 45 44 import org.openstreetmap.josm.data.SelectionChangedListener; 46 import org.openstreetmap.josm.data.coor.LatLon;47 45 import org.openstreetmap.josm.data.osm.DataSet; 48 46 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; … … 67 65 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 68 66 import org.openstreetmap.josm.gui.MainApplication; 69 import org.openstreetmap.josm.gui.MapFrame;70 67 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 71 68 import org.openstreetmap.josm.gui.PopupMenuHandler; … … 85 82 import org.openstreetmap.josm.tools.InputMapUtils; 86 83 import org.openstreetmap.josm.tools.Shortcut; 87 import org.openstreetmap.josm.tools.SubclassFilteredCollection;88 84 import org.openstreetmap.josm.tools.Utils; 89 85 import org.openstreetmap.josm.tools.bugreport.BugReport; … … 618 614 if (selection != null) { 619 615 remember(selection); 620 MapFrame map = MainApplication.getMap();621 if (selection.size() == 2) {622 Iterator<? extends OsmPrimitive> it = selection.iterator();623 OsmPrimitive n1 = it.next();624 OsmPrimitive n2 = it.next();625 // show distance between two selected nodes with coordinates626 if (n1 instanceof Node && n2 instanceof Node) {627 LatLon c1 = ((Node) n1).getCoor();628 LatLon c2 = ((Node) n2).getCoor();629 if (c1 != null && c2 != null) {630 map.statusLine.setDist(c1.greatCircleDistance(c2));631 return;632 }633 }634 }635 map.statusLine.setDist(636 new SubclassFilteredCollection<OsmPrimitive, Way>(selection, Way.class::isInstance));637 616 } 638 617 } … … 695 674 696 675 /* ------------------------------------------------------------------------ */ 697 /* interface SelectionChange Listener*/676 /* interface SelectionChangedListener */ 698 677 /* ------------------------------------------------------------------------ */ 699 678 @Override
Note:
See TracChangeset
for help on using the changeset viewer.