Changeset 1814 in josm for trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
- Timestamp:
- 2009-07-19T19:04:49+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r1640 r1814 38 38 public OrthogonalizeAction() { 39 39 super(tr("Orthogonalize Shape"), 40 "ortho",41 tr("Move nodes so all angles are 90 or 270 degree"),42 Shortcut.registerShortcut("tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")),43 KeyEvent.VK_Q,44 Shortcut.GROUP_EDIT), true);40 "ortho", 41 tr("Move nodes so all angles are 90 or 270 degree"), 42 Shortcut.registerShortcut("tools:orthogonalize", tr("Tool: {0}", tr("Orthogonalize Shape")), 43 KeyEvent.VK_Q, 44 Shortcut.GROUP_EDIT), true); 45 45 } 46 46 47 47 public void actionPerformed(ActionEvent e) { 48 48 49 Collection<OsmPrimitive> sel = Main.ds.getSelected();49 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 50 50 51 51 ArrayList<Node> dirnodes = new ArrayList<Node>(); … … 84 84 double angle2 = Math.abs(way.nodes.get(i2).getEastNorth().heading(way.nodes.get(i3).getEastNorth())); 85 85 double delta = Math.abs(angle2 - angle1); 86 while(delta > Math.PI) delta -= Math.PI; 86 while(delta > Math.PI) { 87 delta -= Math.PI; 88 } 87 89 if(delta < Math.PI/4) { 88 90 JOptionPane.showMessageDialog(Main.parent, tr("Please select ways with almost right angles to orthogonalize.")); … … 96 98 "to undesirable results when doing rectangular alignments.<br>" + 97 99 "Change your projection to get rid of this warning.<br>" + 98 99 100 if (!DontShowAgainInfo.show("align_rectangular_4326", msg, false)) {100 "Do you want to continue?"); 101 102 if (!DontShowAgainInfo.show("align_rectangular_4326", msg, false)) 101 103 return; 102 }103 104 } 104 105 // Check, if selection held neither none nor two nodes … … 122 123 123 124 for (OsmPrimitive osm : sel) { 124 if(!(osm instanceof Way)) 125 if(!(osm instanceof Way)) { 125 126 continue; 127 } 126 128 127 129 Way way = (Way)osm; … … 158 160 diff = heading_diff(headings[i], headings[i - 1]); 159 161 } 160 if (diff > angle_diff_max) angle_diff_max = diff; 162 if (diff > angle_diff_max) { 163 angle_diff_max = diff; 164 } 161 165 } 162 166 … … 164 168 // rearrange headings: everything < 0 gets PI/2-rotated 165 169 for (int i=0; i < sides; i++) { 166 if (headings[i] < 0) 170 if (headings[i] < 0) { 167 171 headings[i] += Math.PI/2; 172 } 168 173 } 169 174 } … … 217 222 // been duplicated 218 223 219 if (u == 0) continue; 224 if (u == 0) { 225 continue; 226 } 220 227 221 228 // q is a number between 0 and 1 … … 257 264 double llimit = -Math.PI/4; 258 265 double ulimit = Math.PI/4; 259 while (h - align_to > ulimit) h -= Math.PI/2; 260 while (h - align_to < llimit) h += Math.PI/2; 266 while (h - align_to > ulimit) { 267 h -= Math.PI/2; 268 } 269 while (h - align_to < llimit) { 270 h += Math.PI/2; 271 } 261 272 262 273 return h;
Note:
See TracChangeset
for help on using the changeset viewer.