Changeset 21202 in osm for applications/editors


Ignore:
Timestamp:
2010-05-09T18:09:25+02:00 (14 years ago)
Author:
pieren
Message:

Added last departement saved in preference file; now possibility to enter coordinates by mouse click during georeferencing

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  
    4545    private EastNorth georefpoint2;
    4646    private boolean ignoreMouseClick = false;
     47    private boolean clickOnTheMap = false;
    4748   
    4849    /**
     
    133134            return;
    134135        if (ignoreMouseClick) return; // In case we are currently just allowing zooming to read lambert coordinates
    135         countMouseClicked++;
    136136        EastNorth ea = Main.proj.latlon2eastNorth(Main.map.mapView.getLatLon(e.getX(), e.getY()));
    137137        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                }
    160166            }
    161167        }
     
    249255        Main.map.mapView.repaint();
    250256        actionCompleted();
     257        clickOnTheMap = false;
     258        ignoreMouseClick = false;
    251259    }
    252260
     
    289297        p.add(labelNorth, GBC.std().insets(0, 0, 10, 0));
    290298        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")};
    291302        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]);
    294305        String number;
    295306        if (countMouseClicked == 1)
     
    308319                if (JOptionPane.VALUE_PROPERTY.equals(evt.getPropertyName())) {
    309320                    ignoreMouseClick = false;
    310                     if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(
    311                             pane.getValue())) {
     321                    // Cancel
     322                    if (pane.getValue().equals(options[1])) {
    312323                        if (canceledOrRestartCurrAction("georeferencing"))
    313324                            startGeoreferencing();
    314325                    }
    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;
    326340                            }
    327                         } catch (NumberFormatException e) {
    328                             return;
     341                            handleNewCoordinates(e, n);
    329342                        }
    330343                    }
     
    332345            }
    333346        });
     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        }
    334357    }
    335358
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    r21191 r21202  
    7878        }
    7979        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        }
    8185        p.add(labelSectionNewLocation, GBC.eol());
    8286        p.add(labelLocation, GBC.std().insets(10, 0, 0, 0));
     
    104108            Main.pref.put("cadastrewms.location", location);
    105109            Main.pref.put("cadastrewms.codeCommune", codeCommune);
     110            Main.pref.put("cadastrewms.codeDepartement", codeDepartement);
    106111            if (Main.map != null) {
    107112                for (Layer l : Main.map.mapView.getAllLayers()) {
Note: See TracChangeset for help on using the changeset viewer.