Changeset 26049 in osm for applications/editors
- Timestamp:
- 2011-05-24T14:21:13+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
r25913 r26049 22 22 JMenuItem adjNodes; 23 23 JMenuItem unsNodes; 24 JMenuItem midNodes; 24 25 JMenuItem adjWays; 25 26 JMenuItem adjWaysAll; … … 55 56 adjNodes = MainMenu.add(selectionMenu, new AdjacentNodesAction()); 56 57 unsNodes = MainMenu.add(selectionMenu, new UnselectNodesAction()); 58 midNodes = MainMenu.add(selectionMenu, new MiddleNodesAction()); 57 59 adjWays = MainMenu.add(selectionMenu, new AdjacentWaysAction()); 58 60 adjWaysAll = MainMenu.add(selectionMenu, new ConnectedWaysAction()); … … 81 83 adjNodes.setEnabled(enabled); 82 84 unsNodes.setEnabled(enabled); 85 midNodes.setEnabled(enabled); 83 86 adjWays.setEnabled(enabled); 84 87 adjWaysAll.setEnabled(enabled); -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java
r25876 r26049 2 2 package utilsplugin2.selection; 3 3 4 import java.util.Iterator; 4 5 import java.util.Collection; 5 6 import java.util.HashSet; … … 222 223 } 223 224 225 static void addMiddle(Set<Node> selectedNodes, Set<Node> newNodes) { 226 Iterator<Node> it=selectedNodes.iterator(); 227 Node n1 = it.next(); 228 Node n2 = it.next(); 229 Set<Way> ways=new HashSet<Way>(); 230 ways.addAll(OsmPrimitive.getFilteredList(n1.getReferrers(), Way.class)); 231 for (Way w: ways) { 232 System.out.println(w); 233 System.out.println("Node1"+n1); 234 System.out.println("Node2"+n2); 235 236 if (w.isUsable() && w.containsNode(n2) && w.containsNode(n1)) { 237 // Way w goes from n1 to n2 238 List <Node> nodes= w.getNodes(); 239 int i1 = nodes.indexOf(n1); 240 int i2 = nodes.indexOf(n2); 241 int n = nodes.size(); 242 if (i1>i2) { int p=i2; i2=i1; i1=p; } // now i1<i2 243 if (w.isClosed()) { 244 if ((i2-i1)*2 <= n ) { // i1 ... i2 245 for (int i=i1+1;i!=i2; i++) { 246 newNodes.add(nodes.get(i)); 247 } 248 } else { // i2 ... n-1 0 1 ... i1 249 for (int i=i2+1;i!=i1; i=(i+1)%n) { 250 newNodes.add(nodes.get(i)); 251 } 252 } 253 } else { 254 for (int i=i1+1;i<i2;i++) { 255 newNodes.add(nodes.get(i)); 256 } 257 } 258 } 259 if (newNodes.size()==0) { 260 JOptionPane.showMessageDialog(Main.parent, 261 tr("Please select two nodes connected by way!"), 262 tr("Warning"), 263 JOptionPane.WARNING_MESSAGE); 264 } 265 } 266 } 224 267 225 268
Note:
See TracChangeset
for help on using the changeset viewer.