Changeset 21202 in osm for applications/editors/josm/plugins/cadastre-fr/src
- Timestamp:
- 2010-05-09T18:09:25+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
r20214 r21202 45 45 private EastNorth georefpoint2; 46 46 private boolean ignoreMouseClick = false; 47 private boolean clickOnTheMap = false; 47 48 48 49 /** … … 133 134 return; 134 135 if (ignoreMouseClick) return; // In case we are currently just allowing zooming to read lambert coordinates 135 countMouseClicked++;136 136 EastNorth ea = Main.proj.latlon2eastNorth(Main.map.mapView.getLatLon(e.getX(), e.getY())); 137 137 System.out.println("clic:"+countMouseClicked+" ,"+ea+", mode:"+mode); 138 // ignore clicks outside the image 139 if (ea.east() < wmsLayer.images.get(0).min.east() || ea.east() > wmsLayer.images.get(0).max.east() 140 || ea.north() < wmsLayer.images.get(0).min.north() || ea.north() > wmsLayer.images.get(0).max.north()) 141 return; 142 if (mode == cGetCorners) { 143 if (countMouseClicked == 1) { 144 ea1 = ea; 145 continueCropping(); 146 } 147 if (countMouseClicked == 2) { 148 wmsLayer.cropImage(ea1, ea); 149 Main.map.mapView.repaint(); 150 startGeoreferencing(); 151 } 152 } else if (mode == cGetLambertCrosspieces) { 153 if (countMouseClicked == 1) { 154 ea1 = ea; 155 inputLambertPosition(); // This will automatically asks for second point and continue the georeferencing 156 } 157 if (countMouseClicked == 2) { 158 ea2 = ea; 159 inputLambertPosition(); // This will automatically ends the georeferencing 138 if (clickOnTheMap) { 139 clickOnTheMap = false; 140 handleNewCoordinates(ea.east(), ea.north()); 141 } else { 142 countMouseClicked++; 143 // ignore clicks outside the image 144 if (ea.east() < wmsLayer.images.get(0).min.east() || ea.east() > wmsLayer.images.get(0).max.east() 145 || ea.north() < wmsLayer.images.get(0).min.north() || ea.north() > wmsLayer.images.get(0).max.north()) 146 return; 147 if (mode == cGetCorners) { 148 if (countMouseClicked == 1) { 149 ea1 = ea; 150 continueCropping(); 151 } 152 if (countMouseClicked == 2) { 153 wmsLayer.cropImage(ea1, ea); 154 Main.map.mapView.repaint(); 155 startGeoreferencing(); 156 } 157 } else if (mode == cGetLambertCrosspieces) { 158 if (countMouseClicked == 1) { 159 ea1 = ea; 160 inputLambertPosition(); // This will automatically asks for second point and continue the georeferencing 161 } 162 if (countMouseClicked == 2) { 163 ea2 = ea; 164 inputLambertPosition(); // This will automatically ends the georeferencing 165 } 160 166 } 161 167 } … … 249 255 Main.map.mapView.repaint(); 250 256 actionCompleted(); 257 clickOnTheMap = false; 258 ignoreMouseClick = false; 251 259 } 252 260 … … 289 297 p.add(labelNorth, GBC.std().insets(0, 0, 10, 0)); 290 298 p.add(inputNorth, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 5, 0, 5)); 299 final Object[] options = {tr("OK"), 300 tr("Cancel"), 301 tr("I use the mouse")}; 291 302 final JOptionPane pane = new JOptionPane(p, 292 JOptionPane.INFORMATION_MESSAGE, JOptionPane. OK_CANCEL_OPTION,293 null );303 JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, 304 null, options, options[0]); 294 305 String number; 295 306 if (countMouseClicked == 1) … … 308 319 if (JOptionPane.VALUE_PROPERTY.equals(evt.getPropertyName())) { 309 320 ignoreMouseClick = false; 310 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(311 pane.getValue())) {321 // Cancel 322 if (pane.getValue().equals(options[1])) { 312 323 if (canceledOrRestartCurrAction("georeferencing")) 313 324 startGeoreferencing(); 314 325 } 315 if (inputEast.getText().length() != 0 316 && inputNorth.getText().length() != 0) { 317 try { 318 double e = Double.parseDouble(inputEast.getText()); 319 double n = Double.parseDouble(inputNorth.getText()); 320 if (countMouseClicked == 1) { 321 georefpoint1 = new EastNorth(e, n); 322 continueGeoreferencing(); 323 } else { 324 georefpoint2 = new EastNorth(e, n); 325 endGeoreferencing(); 326 // Click on the map 327 if (pane.getValue().equals(options[2])) { 328 clickOnTheMap = true; 329 } else { 330 // OK (coordinates manually entered) 331 clickOnTheMap = false; 332 if (inputEast.getText().length() != 0 333 && inputNorth.getText().length() != 0) { 334 double e, n; 335 try { 336 e = Double.parseDouble(inputEast.getText()); 337 n = Double.parseDouble(inputNorth.getText()); 338 } catch (NumberFormatException ex) { 339 return; 326 340 } 327 } catch (NumberFormatException e) { 328 return; 341 handleNewCoordinates(e, n); 329 342 } 330 343 } … … 332 345 } 333 346 }); 347 } 348 349 private void handleNewCoordinates(double e, double n) { 350 if (countMouseClicked == 1) { 351 georefpoint1 = new EastNorth(e, n); 352 continueGeoreferencing(); 353 } else { 354 georefpoint2 = new EastNorth(e, n); 355 endGeoreferencing(); 356 } 334 357 } 335 358 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r21191 r21202 78 78 } 79 79 inputDepartement.setToolTipText(tr("<html>Departement number (optional)</html>")); 80 80 if (!Main.pref.get("cadastrewms.codeDepartement").equals("")) { 81 for (int i=0; i < departements.length; i=i+2) 82 if (departements[i].equals(Main.pref.get("cadastrewms.codeDepartement"))) 83 inputDepartement.setSelectedIndex(i/2); 84 } 81 85 p.add(labelSectionNewLocation, GBC.eol()); 82 86 p.add(labelLocation, GBC.std().insets(10, 0, 0, 0)); … … 104 108 Main.pref.put("cadastrewms.location", location); 105 109 Main.pref.put("cadastrewms.codeCommune", codeCommune); 110 Main.pref.put("cadastrewms.codeDepartement", codeDepartement); 106 111 if (Main.map != null) { 107 112 for (Layer l : Main.map.mapView.getAllLayers()) {
Note:
See TracChangeset
for help on using the changeset viewer.