Ignore:
Timestamp:
2009-08-23T21:23:13+02:00 (16 years ago)
Author:
pieren
Message:

improve georeferencing action cancellation; fixed bug of raster image loaded from cache not working on Java1.6; improve mouse click bounce detection during georeferencing process

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java

    r17181 r17215  
    44
    55import java.awt.GridBagLayout;
    6 import java.awt.Point;
    76import java.awt.event.ActionEvent;
    87import java.awt.event.MouseEvent;
     
    3736    private int cGetLambertCrosspieces = 2;
    3837    private EastNorth ea1;
    39     private Point mousePrevious = new Point();
     38    private long mouseClickedTime = 0;
    4039    private EastNorth georefpoint1;
    4140    private EastNorth georefpoint2;
     41    /**
     42     * The time which needs to pass between two clicks during georeferencing, in milliseconds
     43     */
     44    private int initialClickDelay;
    4245
    4346    public MenuActionGrabPlanImage() {
     
    4851        countMouseClicked = 0;
    4952        mode = 0;
    50         mousePrevious.setLocation(0, 0);
     53        mouseClickedTime = System.currentTimeMillis();
    5154    }
    5255   
     
    7578                downloadWMSPlanImage = new DownloadWMSPlanImage();
    7679                downloadWMSPlanImage.download(wmsLayer);
     80                initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay",200);
    7781                // download sub-images of the cadastre scan and join them into one single
    7882                Main.worker.execute(this);
     
    9094        boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
    9195        if (wmsLayer.images.size() == 1 && !loadedFromCache) {
     96            mouseClickedTime = System.currentTimeMillis();
    9297            Main.map.mapView.addMouseListener(this);
    9398            if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false)
     
    95100            else
    96101                startGeoreferencing();
    97         } else // action cancelled or image loaded from cache (and already georeferenced)
     102        } else // action cancelled or image loaded from cache (and already georeferenced)
    98103            Main.map.repaint();
    99104    }
    100105
    101106    public void mouseClicked(MouseEvent e) {
    102         if (e.getX() == mousePrevious.getX() && e.getY() == mousePrevious.getY())
    103             return; // double click filtered
     107        if (System.currentTimeMillis() - mouseClickedTime < initialClickDelay) {
     108            System.out.println("mouse click bounce detected");
     109            return; // mouse click anti-bounce
     110        }
    104111        else
    105             mousePrevious.setLocation(e.getX(), e.getY());
     112            mouseClickedTime = System.currentTimeMillis();
    106113        countMouseClicked++;
    107114        EastNorth ea = Main.proj.latlon2eastNorth(Main.map.mapView.getLatLon(e.getX(), e.getY()));
    108         System.out.println("clic:"+countMouseClicked+" ,"+ea);
     115        System.out.println("clic:"+countMouseClicked+" ,"+ea+", mode:"+mode);
    109116        // ignore clicks outside the image
    110117        if (ea.east() < wmsLayer.images.get(0).min.east() || ea.east() > wmsLayer.images.get(0).max.east()
     
    153160                        null, options, options[0]);
    154161            if (ret == JOptionPane.OK_OPTION) {
    155                 mousePrevious.setLocation(0, 0);
     162                mouseClickedTime = System.currentTimeMillis();
    156163            } else
    157164                if (canceledOrRestartCurrAction("image cropping"))
     
    192199                        null, options, options[0]);
    193200            if (ret == JOptionPane.OK_OPTION) {
    194                 mousePrevious.setLocation(0, 0);
     201                mouseClickedTime = System.currentTimeMillis();
    195202            } else
    196203                if (canceledOrRestartCurrAction("georeferencing"))
     
    257264        if (countMouseClicked == 1) number = "first";
    258265        else number = "second";
    259         pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinate")).setVisible(true);
     266        pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinates")).setVisible(true);
    260267        if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) {
    261268            if (canceledOrRestartCurrAction("georeferencing"))
Note: See TracChangeset for help on using the changeset viewer.