Changeset 26644 in osm for applications/editors/josm/plugins/utilsplugin2
- Timestamp:
- 2011-09-12T19:25:00+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2
- Files:
-
- 2 added
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/build.xml
r26639 r26644 30 30 <project name="utilsplugin2" default="dist" basedir="."> 31 31 <!-- enter the SVN commit message --> 32 <property name="commit.message" value="Utilsplugin2: configuring custom URLs"/>32 <property name="commit.message" value="Utilsplugin2: select all inside (testing)"/> 33 33 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 34 34 <property name="plugin.main.version" value="4395"/> -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
r26639 r26644 30 30 JMenuItem intWays; 31 31 JMenuItem intWaysR; 32 JMenuItem allInside; 32 33 JMenuItem undoSelection; 33 34 JMenuItem extractPoint; … … 73 74 intWays = MainMenu.add(selectionMenu, new IntersectedWaysAction()); 74 75 intWaysR = MainMenu.add(selectionMenu, new IntersectedWaysRecursiveAction()); 76 allInside = MainMenu.add(selectionMenu, new SelectAllInsideAction()); 75 77 selModifiedNodes = MainMenu.add(selectionMenu, new SelectModNodesAction()); 76 78 selModifiedWays = MainMenu.add(selectionMenu, new SelectModWaysAction()); … … 110 112 undoSelection.setEnabled(enabled); 111 113 selectURL.setEnabled(enabled); 114 allInside.setEnabled(enabled); 112 115 } 113 116 @Override -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysAction.java
r25876 r26644 30 30 31 31 public void actionPerformed(ActionEvent e) { 32 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();33 Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);34 Set<Way> activeWays = new HashSet<Way>();35 36 32 Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class); 37 33 -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysRecursiveAction.java
r26639 r26644 32 32 public void actionPerformed(ActionEvent e) { 33 33 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 34 Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class); 35 Set<Way> activeWays = new HashSet<Way>(); 36 34 37 35 Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class); 38 36 -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java
r26051 r26644 9 9 import javax.swing.JOptionPane; 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm.BBox; 12 import org.openstreetmap.josm.data.osm.DataSet; 11 13 import org.openstreetmap.josm.data.osm.Node; 12 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 263 265 } 264 266 265 267 268 269 static void addAllInsideWay(DataSet data, Way way, Set<Way> newWays, Set<Node> newNodes) { 270 if (!way.isClosed()) return; 271 BBox box = way.getBBox(); 272 List<Node> polyNodes = way.getNodes(); 273 List<Node> searchNodes = data.searchNodes(box); 274 Set<Node> newestNodes = new HashSet<Node>(); 275 Set<Way> newestWays = new HashSet<Way>(); 276 for (Node n : searchNodes) { 277 if (Geometry.nodeInsidePolygon(n, polyNodes)) { 278 newestNodes.add(n); 279 } 280 } 281 282 List<Way> searchWays = data.searchWays(box); 283 for (Way w : searchWays) { 284 if (newestNodes.containsAll(w.getNodes())) { 285 newestWays.add(w); 286 } 287 } 288 for (Way w : newestWays) { 289 newestNodes.removeAll(w.getNodes()); 290 // do not select nodes of already selected ways 291 } 292 293 newNodes.addAll(newestNodes); 294 newWays.addAll(newestWays); 295 } 266 296 } -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java
r26641 r26644 20 20 * Extends current selection by selecting nodes on all touched ways 21 21 */ 22 public class IntersectedWaysAction extends JosmAction {22 public class SelectAllInsideAction extends JosmAction { 23 23 24 public IntersectedWaysAction() {25 super(tr(" Intersecting ways"), "intway", tr("Select intersecting ways"),26 Shortcut.registerShortcut("tools: intway", tr("Tool: {0}","Intersecting ways"),27 KeyEvent.VK_I, Shortcut.GROUP_EDIT ), true);28 putValue("help", ht("/Action/Select IntersectingWays"));24 public SelectAllInsideAction() { 25 super(tr("All inside [testing]"), "selinside", tr("Select all inside selected polygons"), 26 Shortcut.registerShortcut("tools:selinside", tr("Tool: {0}","All inside"), 27 KeyEvent.VK_I, Shortcut.GROUP_EDIT ,KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK), true); 28 putValue("help", ht("/Action/SelectAllInside")); 29 29 } 30 30 … … 39 39 if (!selectedWays.isEmpty()) { 40 40 Set<Way> newWays = new HashSet<Way>(); 41 NodeWayUtils.addWaysIntersectingWays( 42 getCurrentDataSet().getWays(), 43 selectedWays, newWays); 41 Set<Node> newNodes = new HashSet<Node>(); 42 for (Way w: selectedWays) { 43 NodeWayUtils.addAllInsideWay(getCurrentDataSet(),w,newWays,newNodes); 44 } 44 45 getCurrentDataSet().addSelected(newWays); 46 getCurrentDataSet().addSelected(newNodes); 45 47 return; 46 48 } else {
Note:
See TracChangeset
for help on using the changeset viewer.