Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r8957 r9594 213 213 214 214 /** 215 * Replies the current dataset 215 * Replies the current dataset. 216 216 * 217 217 * @return the current dataset. null, if no current dataset exists 218 218 */ 219 p rotectedstatic DataSet getCurrentDataSet() {219 public static DataSet getCurrentDataSet() { 220 220 return Main.main != null ? Main.main.getCurrentDataSet() : null; 221 221 } -
trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java
r9183 r9594 2 2 package org.openstreetmap.josm.actions; 3 3 4 import java.awt.event.ActionEvent;5 4 import java.util.ArrayList; 6 5 import java.util.Collection; … … 24 23 * @since 7144 25 24 */ 26 public class SelectByInternalPointAction extends JosmAction { 25 public final class SelectByInternalPointAction { 26 27 private SelectByInternalPointAction() { 28 // Hide public constructor for utility class 29 } 27 30 28 31 /** … … 35 38 */ 36 39 public static Collection<OsmPrimitive> getSurroundingObjects(EastNorth internalPoint) { 37 final DataSet ds = getCurrentDataSet();40 final DataSet ds = JosmAction.getCurrentDataSet(); 38 41 if (ds == null) { 39 42 return Collections.emptySet(); … … 42 45 final Map<Double, OsmPrimitive> found = new TreeMap<>(); 43 46 for (Way w : ds.getWays()) { 44 if (w.isUsable() && w.isClosed() && w.isSelectable()) { 45 if (Geometry.nodeInsidePolygon(n, w.getNodes())) { 46 found.put(Geometry.closedWayArea(w), w); 47 } 47 if (w.isUsable() && w.isClosed() && w.isSelectable() && Geometry.nodeInsidePolygon(n, w.getNodes())) { 48 found.put(Geometry.closedWayArea(w), w); 48 49 } 49 50 } 50 51 for (Relation r : ds.getRelations()) { 51 if (r.isUsable() && r.isMultipolygon() && r.isSelectable()) { 52 if (Geometry.isNodeInsideMultiPolygon(n, r, null)) { 53 for (RelationMember m : r.getMembers()) { 54 if (m.isWay() && m.getWay().isClosed()) { 55 found.values().remove(m.getWay()); 56 } 52 if (r.isUsable() && r.isMultipolygon() && r.isSelectable() && Geometry.isNodeInsideMultiPolygon(n, r, null)) { 53 for (RelationMember m : r.getMembers()) { 54 if (m.isWay() && m.getWay().isClosed()) { 55 found.values().remove(m.getWay()); 57 56 } 58 // estimate multipolygon size by its bounding box area59 BBox bBox = r.getBBox();60 EastNorth en1 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getTopLeft());61 EastNorth en2 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getBottomRight());62 double s = Math.abs((en1.east() - en2.east()) * (en1.north() - en2.north()));63 if (s == 0) s = 1e8;64 found.put(s, r);65 57 } 58 // estimate multipolygon size by its bounding box area 59 BBox bBox = r.getBBox(); 60 EastNorth en1 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getTopLeft()); 61 EastNorth en2 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getBottomRight()); 62 double s = Math.abs((en1.east() - en2.east()) * (en1.north() - en2.north())); 63 found.put(s <= 0 ? 1e8 : s, r); 66 64 } 67 65 } … … 89 87 public static void performSelection(EastNorth internalPoint, boolean doAdd, boolean doRemove) { 90 88 final Collection<OsmPrimitive> surroundingObjects = getSurroundingObjects(internalPoint); 89 final DataSet ds = JosmAction.getCurrentDataSet(); 91 90 if (surroundingObjects.isEmpty()) { 92 91 return; 93 92 } else if (doRemove) { 94 final Collection<OsmPrimitive> newSelection = new ArrayList<>( getCurrentDataSet().getSelected());93 final Collection<OsmPrimitive> newSelection = new ArrayList<>(ds.getSelected()); 95 94 newSelection.removeAll(surroundingObjects); 96 getCurrentDataSet().setSelected(newSelection);95 ds.setSelected(newSelection); 97 96 } else if (doAdd) { 98 final Collection<OsmPrimitive> newSelection = new ArrayList<>( getCurrentDataSet().getSelected());97 final Collection<OsmPrimitive> newSelection = new ArrayList<>(ds.getSelected()); 99 98 newSelection.add(surroundingObjects.iterator().next()); 100 getCurrentDataSet().setSelected(newSelection);99 ds.setSelected(newSelection); 101 100 } else { 102 getCurrentDataSet().setSelected(surroundingObjects.iterator().next());101 ds.setSelected(surroundingObjects.iterator().next()); 103 102 } 104 103 } 105 106 @Override107 public void actionPerformed(ActionEvent e) {108 throw new UnsupportedOperationException();109 }110 104 }
Note:
See TracChangeset
for help on using the changeset viewer.