Changeset 33077 in osm for applications/editors/josm/plugins/terracer/src
- Timestamp:
- 2016-11-20T12:32:08+01:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/terracer/src/terracer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java
r32426 r33077 1 /** 2 * Terracer: A JOSM Plugin for terraced houses. 3 * 4 * Copyright 2009 CloudMade Ltd. 5 * 6 * Released under the GPLv2, see LICENSE file for details. 7 */ 1 // License: GPL. For details, see LICENSE file. 8 2 package terracer; 9 3 … … 45 39 * HouseNumberinputHandler class. 46 40 * 47 * @author casualwalker 41 * @author casualwalker - Copyright 2009 CloudMade Ltd 48 42 */ 49 43 public class HouseNumberInputDialog extends ExtendedDialog { 50 44 /* 51 final staticString MIN_NUMBER = "plugin.terracer.lowest_number";52 final staticString MAX_NUMBER = "plugin.terracer.highest_number";53 final staticString INTERPOLATION = "plugin.terracer.interpolation_mode";45 static final String MIN_NUMBER = "plugin.terracer.lowest_number"; 46 static final String MAX_NUMBER = "plugin.terracer.highest_number"; 47 static final String INTERPOLATION = "plugin.terracer.interpolation_mode"; 54 48 */ 55 final staticString DEFAULT_SEGMENTS = "plugins.terracer.segments";56 final staticString HANDLE_RELATION = "plugins.terracer.handle_relation";57 final staticString KEEP_OUTLINE = "plugins.terracer.keep_outline";58 final staticString INTERPOLATION = "plugins.terracer.interpolation";59 60 // final privateWay street;61 final privateString streetName;62 final privateString buildingType;63 final privateboolean relationExists;49 static final String DEFAULT_SEGMENTS = "plugins.terracer.segments"; 50 static final String HANDLE_RELATION = "plugins.terracer.handle_relation"; 51 static final String KEEP_OUTLINE = "plugins.terracer.keep_outline"; 52 static final String INTERPOLATION = "plugins.terracer.interpolation"; 53 54 //private final Way street; 55 private final String streetName; 56 private final String buildingType; 57 private final boolean relationExists; 64 58 final ArrayList<Node> housenumbers; 65 59 … … 97 91 * @param housenumbers a list of house numbers in this outline (may be empty) 98 92 */ 99 public HouseNumberInputDialog(HouseNumberInputHandler handler, Way street, String streetName, String buildingType, boolean relationExists, ArrayList<Node> housenumbers) { 93 public HouseNumberInputDialog(HouseNumberInputHandler handler, Way street, String streetName, 94 String buildingType, boolean relationExists, ArrayList<Node> housenumbers) { 100 95 super(Main.parent, 101 96 tr("Terrace a house"), 102 new String[] { 97 new String[] {tr("OK"), tr("Cancel")}, 103 98 true 104 99 ); … … 190 185 inputPanel.add(messageLabel, c); 191 186 192 inputPanel.add(loLabel, GBC.std().insets(3, 3,0,0));193 inputPanel.add(getLo(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3,0,0));194 inputPanel.add(hiLabel, GBC.std().insets(3, 3,0,0));195 inputPanel.add(getHi(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3,0,0));196 inputPanel.add(numbersLabel, GBC.std().insets(3, 3,0,0));197 inputPanel.add(getNumbers(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3,0,0));198 inputPanel.add(interpolationLabel, GBC.std().insets(3, 3,0,0));199 inputPanel.add(getInterpolation(), GBC.eol().insets(5, 3,0,0));200 inputPanel.add(segmentsLabel, GBC.std().insets(3, 3,0,0));201 inputPanel.add(getSegments(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3,0,0));187 inputPanel.add(loLabel, GBC.std().insets(3, 3, 0, 0)); 188 inputPanel.add(getLo(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3, 0, 0)); 189 inputPanel.add(hiLabel, GBC.std().insets(3, 3, 0, 0)); 190 inputPanel.add(getHi(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3, 0, 0)); 191 inputPanel.add(numbersLabel, GBC.std().insets(3, 3, 0, 0)); 192 inputPanel.add(getNumbers(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3, 0, 0)); 193 inputPanel.add(interpolationLabel, GBC.std().insets(3, 3, 0, 0)); 194 inputPanel.add(getInterpolation(), GBC.eol().insets(5, 3, 0, 0)); 195 inputPanel.add(segmentsLabel, GBC.std().insets(3, 3, 0, 0)); 196 inputPanel.add(getSegments(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 3, 0, 0)); 202 197 if (streetName == null) { 203 inputPanel.add(streetLabel, GBC.std().insets(3, 3,0,0));204 inputPanel.add(getStreet(), GBC.eol().insets(5, 3,0,0));198 inputPanel.add(streetLabel, GBC.std().insets(3, 3, 0, 0)); 199 inputPanel.add(getStreet(), GBC.eol().insets(5, 3, 0, 0)); 205 200 } else { 206 inputPanel.add(new JLabel(tr("Street name: ")+"\""+streetName+"\""), GBC.eol().insets(3, 3,0,0));207 } 208 inputPanel.add(buildingLabel, GBC.std().insets(3, 3,0,0));209 inputPanel.add(getBuilding(), GBC.eol().insets(5, 3,0,0));210 inputPanel.add(handleRelationCheckBox, GBC.eol().insets(3, 3,0,0));211 inputPanel.add(keepOutlineCheckBox, GBC.eol().insets(3, 3,0,0));201 inputPanel.add(new JLabel(tr("Street name: ")+"\""+streetName+"\""), GBC.eol().insets(3, 3, 0, 0)); 202 } 203 inputPanel.add(buildingLabel, GBC.std().insets(3, 3, 0, 0)); 204 inputPanel.add(getBuilding(), GBC.eol().insets(5, 3, 0, 0)); 205 inputPanel.add(handleRelationCheckBox, GBC.eol().insets(3, 3, 0, 0)); 206 inputPanel.add(keepOutlineCheckBox, GBC.eol().insets(3, 3, 0, 0)); 212 207 213 208 if (numbers.isVisible()) { … … 275 270 if (it.hasNext()) { 276 271 s.append(it.next().get("addr:housenumber")); 277 while (it.hasNext()) 272 while (it.hasNext()) { 278 273 s.append(';').append(it.next().get("addr:housenumber")); 279 }280 else {274 } 275 } else { 281 276 numbersLabel.setVisible(false); 282 277 numbers.setVisible(false); -
applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java
r31655 r33077 1 /** 2 * Terracer: A JOSM Plugin for terraced houses. 3 * 4 * Copyright 2009 CloudMade Ltd. 5 * 6 * Released under the GPLv2, see LICENSE file for details. 7 */ 1 // License: GPL. For details, see LICENSE file. 8 2 package terracer; 9 3 … … 42 36 * is already cluttered with auto-generated layout code. 43 37 * 44 * @author casualwalker 38 * @author casualwalker - Copyright 2009 CloudMade Ltd 45 39 */ 46 40 public class HouseNumberInputHandler extends JosmAction implements ActionListener, FocusListener, ItemListener { … … 95 89 */ 96 90 private static JButton getButton(Container root, String caption) { 97 Component children[]= root.getComponents();91 Component[] children = root.getComponents(); 98 92 for (Component child : children) { 99 93 JButton b; … … 126 120 // Allow non numeric characters for the low number as long as there is 127 121 // no high number of the segmentcount is 1 128 if (dialog.hi.getText().length() > 0 && (segments() != null || segments() < 1)) {122 if (dialog.hi.getText().length() > 0 && (segments() != null || segments() < 1)) { 129 123 isOk = isOk 130 124 && checkNumberStringField(dialog.lo, tr("Lowest number"), … … 306 300 doKeepOutline(), buildingType()); 307 301 } catch (UserCancelException ex) { 308 // Ignore302 Main.trace(ex); 309 303 } 310 304 … … 396 390 } else { 397 391 String name; 398 if (selected instanceof AutoCompletionListItem) 399 { 400 name = ((AutoCompletionListItem)selected).getValue(); 401 } 402 else 403 { 392 if (selected instanceof AutoCompletionListItem) { 393 name = ((AutoCompletionListItem) selected).getValue(); 394 } else { 404 395 name = selected.toString(); 405 396 } -
applications/editors/josm/plugins/terracer/src/terracer/ReverseTerraceAction.java
r32426 r33077 1 // License: GPL. For details, see LICENSE file. 1 2 package terracer; 2 3 … … 100 101 for (OsmPrimitive prim : n.getReferrers()) { 101 102 if (prim.keySet().contains("building") && prim instanceof Way) { 102 front.add((Way) prim);103 front.add((Way) prim); 103 104 } 104 105 } -
applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java
r33031 r33077 1 /** 2 * Terracer: A JOSM Plugin for terraced houses. 3 * 4 * Copyright 2009 CloudMade Ltd. 5 * 6 * Released under the GPLv2, see LICENSE file for details. 7 */ 1 // License: GPL. For details, see LICENSE file. 8 2 package terracer; 9 3 … … 60 54 * algorithm employed is naive, but it works in the simple case. 61 55 * 62 * @author zere 56 * @author zere - Copyright 2009 CloudMade Ltd 63 57 */ 64 58 public final class TerracerAction extends JosmAction { … … 81 75 } 82 76 83 protected static finalSet<Relation> findAssociatedStreets(Collection<OsmPrimitive> objects) {77 protected static Set<Relation> findAssociatedStreets(Collection<OsmPrimitive> objects) { 84 78 Set<Relation> result = new HashSet<>(); 85 79 if (objects != null) { … … 221 215 // Don't open the dialog 222 216 try { 223 terraceBuilding(outline, init, street, associatedStreet, 0, null, null, 0, housenumbers, streetname, associatedStreet != null, false, "yes"); 217 terraceBuilding(outline, init, street, associatedStreet, 0, null, null, 0, 218 housenumbers, streetname, associatedStreet != null, false, "yes"); 224 219 } catch (UserCancelException ex) { 225 // Ignore220 Main.trace(ex); 226 221 } finally { 227 222 this.commands.clear(); … … 270 265 // If the numbers are the same, the rest has to make the decision, 271 266 // e.g. when comparing 23, 23a and 23b. 272 if (node1Int.equals(node2Int)) 273 { 267 if (node1Int.equals(node2Int)) { 274 268 String node2Rest = mat.group(2); 275 269 return node1Rest.compareTo(node2Rest); … … 295 289 * @param init The node that hints at which side to start the numbering 296 290 * @param street The street, the buildings belong to (may be null) 297 * @param associatedStreet 291 * @param associatedStreet associated street relation 298 292 * @param segments The number of segments to generate 299 293 * @param start Starting housenumber … … 308 302 * @param keepOutline If the outline way should be kept 309 303 * @param buildingValue The value for {@code building} key to add 310 * @throws UserCancelException 304 * @throws UserCancelException if user cancels the operation 311 305 */ 312 306 public void terraceBuilding(final Way outline, Node init, Way street, Relation associatedStreet, Integer segments, … … 403 397 List<Node> nodes = outline.getNodes(); 404 398 ArrayList<Node> nodesToDelete = new ArrayList<>(); 405 for (Node n : nodes) 399 for (Node n : nodes) { 406 400 if (!n.hasKeys() && n.getReferrers().size() == 1 && !reusedNodes.contains(n)) 407 401 nodesToDelete.add(n); 402 } 408 403 if (!nodesToDelete.isEmpty()) 409 404 this.commands.add(DeleteCommand.delete(Main.getLayerManager().getEditLayer(), nodesToDelete)); … … 493 488 } 494 489 } catch (UserCancelException e) { 495 // Ignore490 Main.trace(e); 496 491 } 497 492 } … … 510 505 * @param buildingValue The value for {@code building} key to add 511 506 * @return {@code outline} 512 * @throws UserCancelException 507 * @throws UserCancelException if user cancels the operation 513 508 */ 514 509 private void addressBuilding(Way outline, Way street, String streetName, Relation associatedStreet, … … 560 555 */ 561 556 private Node interpolateAlong(Way w, double l) { 562 List<Pair<Node, Node>> pairs = w.getNodePairs(false);557 List<Pair<Node, Node>> pairs = w.getNodePairs(false); 563 558 for (int i = 0; i < pairs.size(); ++i) { 564 Pair<Node, Node> p = pairs.get(i);559 Pair<Node, Node> p = pairs.get(i); 565 560 final double seg_length = p.a.getCoor().greatCircleDistance(p.b.getCoor()); 566 561 if (l <= seg_length || i == pairs.size() - 1) { … … 698 693 public int i; 699 694 700 publicSortWithIndex(double a, int b) {695 SortWithIndex(double a, int b) { 701 696 x = a; 702 697 i = b; -
applications/editors/josm/plugins/terracer/src/terracer/TerracerPlugin.java
r29771 r33077 1 /** 2 * Terracer: A JOSM Plugin for terraced houses. 3 * 4 * Copyright 2009 CloudMade Ltd. 5 * 6 * Released under the GPLv2, see LICENSE file for details. 7 */ 1 // License: GPL. For details, see LICENSE file. 8 2 package terracer; 9 3 … … 16 10 * Plugin interface implementation for Terracer. 17 11 * 18 * @author zere 12 * @author zere - Copyright 2009 CloudMade Ltd 19 13 */ 20 14 public class TerracerPlugin extends Plugin { -
applications/editors/josm/plugins/terracer/src/terracer/TerracerRuntimeException.java
r30612 r33077 1 /** 2 * Terracer: A JOSM Plugin for terraced houses. 3 * 4 * Copyright 2009 CloudMade Ltd. 5 * 6 * Released under the GPLv2, see LICENSE file for details. 7 */ 1 // License: GPL. For details, see LICENSE file. 8 2 package terracer; 9 3 … … 11 5 * The Class TerracerRuntimeException indicates errors from the Terracer Plugin. 12 6 * 13 * @author casualwalker 7 * @author casualwalker - Copyright 2009 CloudMade Ltd 14 8 */ 15 9 public class TerracerRuntimeException extends RuntimeException { … … 22 16 } 23 17 24 /**25 * @param message26 * @param cause27 */28 18 public TerracerRuntimeException(String message, Throwable cause) { 29 19 super(message, cause); 30 20 } 31 21 32 /**33 * @param message34 */35 22 public TerracerRuntimeException(String message) { 36 23 super(message); 37 24 } 38 25 39 /**40 * @param cause41 */42 26 public TerracerRuntimeException(Throwable cause) { 43 27 super(cause);
Note:
See TracChangeset
for help on using the changeset viewer.