Changeset 32211 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java
- Timestamp:
- 2016-06-01T00:55:28+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java
r32060 r32211 14 14 import java.awt.event.KeyEvent; 15 15 import java.awt.event.MouseEvent; 16 import java.awt.event.MouseListener; 17 import java.awt.event.MouseMotionListener; 16 import java.awt.event.WindowAdapter; 18 17 import java.awt.event.WindowEvent; 19 import java.awt.event.WindowListener;20 18 import java.util.ArrayList; 21 19 import java.util.Collection; … … 63 61 import org.openstreetmap.josm.tools.Shortcut; 64 62 65 public class Address extends MapMode implements MouseListener, MouseMotionListener, ActionListener{63 public class Address extends MapMode { 66 64 67 65 // perhaps make all these tags configurable in the future … … 76 74 private String relationMemberHouse = "house"; 77 75 78 private JRadioButton plus _one = new JRadioButton("+1", false);79 private JRadioButton plus _two = new JRadioButton("+2", true); // enable this by default80 private JRadioButton minus _one = new JRadioButton("-1", false);81 private JRadioButton minus _two = new JRadioButton("-2", false);76 private JRadioButton plusOne = new JRadioButton("+1", false); 77 private JRadioButton plusTwo = new JRadioButton("+2", true); // enable this by default 78 private JRadioButton minusOne = new JRadioButton("-1", false); 79 private JRadioButton minusTwo = new JRadioButton("-2", false); 82 80 final JCheckBox tagPolygon = new JCheckBox(tr("on polygon")); 83 81 84 JDialog dialog = null;85 JButton clearButton = null;82 JDialog dialog; 83 JButton clearButton; 86 84 final JTextField inputNumber = new JTextField(); 87 85 final JTextField inputStreet = new JTextField(); 88 86 JLabel link = new JLabel(); 89 private Way selectedWay; 87 private transient Way selectedWay; 90 88 private boolean shift; 91 89 private boolean ctrl; … … 114 112 // dialog.setVisible(false); 115 113 // kill the window completely to fix an issue on some linux distro and full screen mode. 116 if(dialog != null) 117 { 114 if(dialog != null) { 118 115 dialog.dispose(); 119 116 dialog = null; … … 131 128 List<Way> mouseOnExistingWays = new ArrayList<>(); 132 129 List<Way> mouseOnExistingBuildingWays = new ArrayList<>(); 133 mouseOnExistingWays = new ArrayList<>();134 130 Node currentMouseNode = mv.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate); 135 131 if (currentMouseNode != null) { … … 140 136 && currentMouseNode.get(tagHouseStreet) == null 141 137 && findWayInRelationAddr(currentMouseNode) == null 142 && !inputStreet.getText(). equals("")) {138 && !inputStreet.getText().isEmpty()) { 143 139 // house number already present but not linked to a street 144 140 Collection<Command> cmds = new LinkedList<>(); … … 199 195 inputNumber.setText(""); 200 196 setNewSelection(mouseOnExistingWays.get(0)); 201 } else if (mouseOnExistingWays. size() == 0) {197 } else if (mouseOnExistingWays.isEmpty()) { 202 198 // clicked a non highway and not a node => add the new address 203 if (inputStreet.getText(). equals("") || inputNumber.getText().equals("")) {199 if (inputStreet.getText().isEmpty() || inputNumber.getText().isEmpty()) { 204 200 Toolkit.getDefaultToolkit().beep(); 205 201 } else { … … 217 213 } 218 214 } 219 220 215 } 221 216 … … 297 292 } 298 293 299 private Node createNewNode(MouseEvent e, Collection<Command> cmds) { 294 private static Node createNewNode(MouseEvent e, Collection<Command> cmds) { 300 295 // DrawAction.mouseReleased() but without key modifiers 301 296 Node n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY())); … … 398 393 399 394 private static void pruneSuccsAndReverse(List<Integer> is) { 400 //if (is.size() < 2) return;401 402 395 HashSet<Integer> is2 = new HashSet<>(); 403 396 for (int i : is) { … … 415 408 try { 416 409 return ImageProvider.getCursor("crosshair", null); 417 } catch (Exception e) { 410 } catch (RuntimeException e) { 411 Main.warn(e); 418 412 } 419 413 return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); … … 422 416 private void applyInputNumberChange() { 423 417 Integer num = Integer.parseInt(inputNumber.getText()); 424 if (plus _one.isSelected())418 if (plusOne.isSelected()) 425 419 num = num + 1; 426 if (plus _two.isSelected())420 if (plusTwo.isSelected()) 427 421 num = num + 2; 428 if (minus _one.isSelected() && num > 1)422 if (minusOne.isSelected() && num > 1) 429 423 num = num - 1; 430 if (minus _two.isSelected() && num > 2)424 if (minusTwo.isSelected() && num > 2) 431 425 num = num - 2; 432 426 inputNumber.setText(num.toString()); … … 435 429 private void revertInputNumberChange() { 436 430 Integer num = Integer.parseInt(inputNumber.getText()); 437 if (plus _one.isSelected())431 if (plusOne.isSelected()) 438 432 num = num - 1; 439 if (plus _two.isSelected())433 if (plusTwo.isSelected()) 440 434 num = num - 2; 441 if (minus _one.isSelected() && num > 1)435 if (minusOne.isSelected() && num > 1) 442 436 num = num + 1; 443 if (minus _two.isSelected() && num > 2)437 if (minusTwo.isSelected() && num > 2) 444 438 num = num + 2; 445 439 inputNumber.setText(num.toString()); … … 471 465 }); 472 466 ButtonGroup bgIncremental = new ButtonGroup(); 473 bgIncremental.add(plus_one); 474 bgIncremental.add(plus_two); 475 bgIncremental.add(minus_one); 476 bgIncremental.add(minus_two); 477 p.add(minus_one, GBC.std().insets(10, 0, 10, 0)); 478 // p.add(plus_one, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 0, 0, 0)); 479 p.add(plus_one, GBC.std().insets(0, 0, 10, 0)); 467 bgIncremental.add(plusOne); 468 bgIncremental.add(plusTwo); 469 bgIncremental.add(minusOne); 470 bgIncremental.add(minusTwo); 471 p.add(minusOne, GBC.std().insets(10, 0, 10, 0)); 472 p.add(plusOne, GBC.std().insets(0, 0, 10, 0)); 480 473 tagPolygon.setSelected(Main.pref.getBoolean("cadastrewms.addr.onBuilding", false)); 481 474 tagPolygon.addChangeListener(new ChangeListener() { … … 486 479 }); 487 480 p.add(tagPolygon, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 0)); 488 p.add(minus _two, GBC.std().insets(10, 0, 10, 0));489 p.add(plus _two, GBC.std().insets(0, 0, 10, 0));481 p.add(minusTwo, GBC.std().insets(10, 0, 10, 0)); 482 p.add(plusTwo, GBC.std().insets(0, 0, 10, 0)); 490 483 p.add(clearButton, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 0)); 491 484 … … 508 501 } 509 502 }); 510 dialog.addWindowListener(new Window Listener() {503 dialog.addWindowListener(new WindowAdapter() { 511 504 @Override 512 public void windowClosing(WindowEvent arg 0) {505 public void windowClosing(WindowEvent arg) { 513 506 exitMode(); 514 507 Main.map.selectMapMode((MapMode)Main.map.getDefaultButtonAction()); 515 508 } 516 @Override517 public void windowClosed(WindowEvent e) {}518 @Override519 public void windowActivated(WindowEvent arg0) {}520 @Override521 public void windowDeactivated(WindowEvent arg0) {}522 @Override523 public void windowDeiconified(WindowEvent arg0) {}524 @Override525 public void windowIconified(WindowEvent arg0) {}526 @Override527 public void windowOpened(WindowEvent arg0) {}528 509 }); 529 510 String bounds = Main.pref.get("cadastrewms.addr.bounds",null); … … 544 525 } 545 526 546 private void setNewSelection(OsmPrimitive osm) { 527 private static void setNewSelection(OsmPrimitive osm) { 547 528 Collection<OsmPrimitive> newSelection = new LinkedList<>(Main.main.getCurrentDataSet().getSelected()); 548 529 newSelection.clear();
Note:
See TracChangeset
for help on using the changeset viewer.
