Changeset 34968 in osm for applications/editors/josm/plugins
- Timestamp:
- 2019-04-07T09:48:42+02:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/buildings_tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/buildings_tools/build.xml
r34572 r34968 4 4 <property name="commit.message" value="BuildingTools: Alt key to disable tags"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="14 153"/>6 <property name="plugin.main.version" value="14960"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/Building.java
r34850 r34968 3 3 4 4 import static org.openstreetmap.josm.plugins.buildings_tools.BuildingsToolsPlugin.eastNorth2latlon; 5 import static org.openstreetmap.josm.plugins.buildings_tools.BuildingsToolsPlugin.latlon2eastNorth;6 5 import static org.openstreetmap.josm.tools.I18n.tr; 7 6 8 7 import java.awt.Graphics2D; 9 8 import java.awt.Point; 9 import java.awt.geom.Area; 10 10 import java.awt.geom.GeneralPath; 11 11 import java.util.ArrayList; … … 79 79 public boolean isRectDrawing() { 80 80 return drawingAngle != null && ToolSettings.getWidth() == 0 && ToolSettings.getLenStep() == 0 81 && ToolSettings.Shape.RECTANGLE .equals(ToolSettings.getShape());81 && ToolSettings.Shape.RECTANGLE == ToolSettings.getShape(); 82 82 } 83 83 … … 134 134 final EastNorth p1 = en[0]; 135 135 en[1] = new EastNorth(p1.east() + Math.sin(heading) * len * meter, p1.north() + Math.cos(heading) * len * meter); 136 if (ToolSettings.Shape.RECTANGLE .equals(ToolSettings.getShape())) {136 if (ToolSettings.Shape.RECTANGLE == ToolSettings.getShape()) { 137 137 en[2] = new EastNorth(p1.east() + Math.sin(heading) * len * meter + Math.cos(heading) * width * meter, 138 138 p1.north() + Math.cos(heading) * len * meter - Math.sin(heading) * width * meter); … … 217 217 b.moveTo(pp1.x, pp1.y); 218 218 b.lineTo(pp2.x, pp2.y); 219 if (ToolSettings.Shape.RECTANGLE .equals(ToolSettings.getShape())) {219 if (ToolSettings.Shape.RECTANGLE == ToolSettings.getShape()) { 220 220 Point pp3 = mv.getPoint(eastNorth2latlon(en[2])); 221 221 Point pp4 = mv.getPoint(eastNorth2latlon(en[3])); … … 238 238 * Returns a node with address tags under the building. 239 239 * 240 * @param w 241 * the building way 240 242 * @return A node with address tags under the building. 241 243 */ 242 private Node getAddressNode() { 243 BBox bbox = new BBox(eastNorth2latlon(en[0]), eastNorth2latlon(en[1])); 244 if (ToolSettings.Shape.RECTANGLE.equals(ToolSettings.getShape())) { 245 bbox.add(eastNorth2latlon(en[2])); 246 bbox.add(eastNorth2latlon(en[3])); 247 } 244 private static Node getAddressNode(Way w) { 245 BBox bbox = w.getBBox(); 248 246 List<Node> nodes = new LinkedList<>(); 249 nodesloop:247 Area area = Geometry.getArea(w.getNodes()); 250 248 for (Node n : MainApplication.getLayerManager().getEditDataSet().searchNodes(bbox)) { 251 249 if (n.isUsable() && findUsableTag(n)) { 252 double x = projection1(latlon2eastNorth(n.getCoor())); 253 double y = projection2(latlon2eastNorth(n.getCoor())); 254 if (Math.signum(x) != Math.signum(len) || Math.signum(y) != Math.signum(width)) 255 continue; 256 if (Math.abs(x) > Math.abs(len) || Math.abs(y) > Math.abs(width)) 257 continue; 258 for (OsmPrimitive p : n.getReferrers()) { 259 // Don't use nodes if they're referenced by ways 260 if (p.getType() == OsmPrimitiveType.WAY) 261 continue nodesloop; 250 EastNorth enTest = n.getEastNorth(); 251 if (area.contains(enTest.getX(), enTest.getY())) { 252 boolean useNode = true; 253 for (OsmPrimitive p : n.getReferrers()) { 254 // Don't use nodes if they're referenced by ways 255 if (p.getType() == OsmPrimitiveType.WAY) { 256 useNode = false; 257 break; 258 } 259 } 260 if (useNode) { 261 nodes.add(n); 262 } 262 263 } 263 nodes.add(n);264 264 } 265 265 } … … 297 297 created[i] = false; 298 298 } 299 if (nodes[i]. getCoor().isOutSideWorld()) {299 if (nodes[i].isOutSideWorld()) { 300 300 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 301 301 tr("Cannot place building outside of the world.")); … … 325 325 ds.addSelected(w.getNodes()); 326 326 327 int oldNumWays = ds.getWays().size(); 327 328 CreateCircleAction action = new CreateCircleAction(); 328 329 action.setEnabled(true); … … 332 333 ds.clearSelection(); 333 334 ds.addSelected(selectedPrimitives); 334 335 // get the way with the smallest id with the assumption that it is 336 // newest way created by CreateCirclAction 337 List<Way> ways = new ArrayList<>(ds.getWays()); 338 Collections.sort(ways); 339 w = ways.get(0); 340 341 addAddress(w, null); 342 343 return w; 335 if (oldNumWays < ds.getWays().size()) { 336 // get the way with the smallest id with the assumption that it is 337 // newest way created by CreateCirclAction 338 List<Way> ways = new ArrayList<>(ds.getWays()); 339 Collections.sort(ways); 340 w = ways.get(0); 341 342 addAddress(w, null); 343 344 return w; 345 } else { 346 // CreateCircleAction failed 347 if (!addNodesCmd.isEmpty()) { 348 UndoRedoHandler.getInstance().undo(1); 349 } 350 return null; 351 } 344 352 } 345 353 … … 362 370 created[i] = false; 363 371 } 364 if (nodes[i]. getCoor().isOutSideWorld()) {372 if (nodes[i].isOutSideWorld()) { 365 373 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 366 374 tr("Cannot place building outside of the world.")); … … 458 466 } 459 467 460 private void addAddress(Way w, Collection<Command> cmdList) {468 private static void addAddress(Way w, Collection<Command> cmdList) { 461 469 if (ToolSettings.PROP_USE_ADDR_NODE.get()) { 462 Node addrNode = getAddressNode( );470 Node addrNode = getAddressNode(w); 463 471 if (addrNode != null) { 464 472 Collection<Command> addressCmds = cmdList != null ? cmdList : new LinkedList<>(); -
applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/BuildingSizeDialog.java
r34572 r34968 32 32 shapeGroup.add(circleRadio); 33 33 shapeGroup.add(rectangleRadio); 34 circleRadio.setSelected(ToolSettings.Shape.CIRCLE .equals(ToolSettings.getShape()));35 rectangleRadio.setSelected(ToolSettings.Shape.RECTANGLE .equals(ToolSettings.getShape()));34 circleRadio.setSelected(ToolSettings.Shape.CIRCLE == ToolSettings.getShape()); 35 rectangleRadio.setSelected(ToolSettings.Shape.RECTANGLE == ToolSettings.getShape()); 36 36 37 37 panel.add(rectangleRadio, GBC.eol().fill(GBC.HORIZONTAL)); -
applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java
r34904 r34968 81 81 private static Cursor getCursor() { 82 82 try { 83 if (ToolSettings.Shape.CIRCLE .equals(ToolSettings.getShape())) {83 if (ToolSettings.Shape.CIRCLE == ToolSettings.getShape()) { 84 84 return ImageProvider.getCursor("crosshair", "silo"); 85 85 } else { … … 226 226 private boolean isRectDrawing() { 227 227 return building.isRectDrawing() && (!shift || ToolSettings.isBBMode()) 228 && ToolSettings.Shape.RECTANGLE .equals(ToolSettings.getShape());228 && ToolSettings.Shape.RECTANGLE == ToolSettings.getShape(); 229 229 } 230 230 … … 234 234 building.setPlaceRect(p); 235 235 return shift ? Mode.DrawingAngFix : Mode.None; 236 } else if (ToolSettings.Shape.CIRCLE .equals(ToolSettings.getShape())) {236 } else if (ToolSettings.Shape.CIRCLE == ToolSettings.getShape()) { 237 237 if (ToolSettings.getWidth() != 0) { 238 238 building.setPlaceCircle(p, ToolSettings.getWidth(), shift); … … 320 320 if (building.getLength() != 0) { 321 321 Way w; 322 if (ToolSettings.Shape.CIRCLE .equals(ToolSettings.getShape())) {322 if (ToolSettings.Shape.CIRCLE == ToolSettings.getShape()) { 323 323 w = building.createCircle(); 324 324 } else {
Note:
See TracChangeset
for help on using the changeset viewer.