Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 17215)
@@ -11,4 +11,6 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.image.BufferedImage;
 import java.io.*;
 import java.util.ArrayList;
@@ -127,4 +129,8 @@
             return false;
         }
+        if (wmsLayer.isRaster()) {
+            // serialized raster bufferedImage hangs-up on Java6. Recreate them here
+            wmsLayer.images.get(0).image = RasterImageModifier.fixRasterImage(wmsLayer.images.get(0).image);
+        }
         return true;
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 17215)
@@ -246,39 +246,41 @@
             rd.close();
             urlConn.disconnect();
-            if (lines.indexOf(cImageFormat) != -1) {
-                int i = lines.indexOf(cImageFormat);
-                int j = lines.indexOf(".", i);
-                wmsLayer.setRaster(lines.substring(i+cImageFormat.length(), j).equals("image"));
-            }
-            if (!wmsLayer.isRaster() && lines.indexOf(cInterfaceVector) != -1) {  // "afficherCarteCommune.do"
-                // shall be something like: interfaceRef = "afficherCarteCommune.do?c=X2269";
-                lines = lines.substring(lines.indexOf(cInterfaceVector),lines.length());
-                lines = lines.substring(0, lines.indexOf("'"));
-                System.out.println("interface ref.:"+lines);
-                return lines;
-            } else if (wmsLayer.isRaster() && lines.indexOf(cInterfaceRasterTA) != -1) { // "afficherCarteTa.do"
-                // list of values parsed in listOfFeuilles (list all non-georeferenced images)
-                lines = getFeuillesList();
-                if (!downloadCancelled) {
-                	parseFeuillesList(lines);
-	                if (listOfFeuilles.size() > 0) {
-	                    int res = selectFeuilleDialog();
-	                    if (res != -1) {
-	                        wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name);
-	                        checkLayerDuplicates(wmsLayer);
-	                        interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune());
-	                        wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).ref);
-	                        lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.elementAt(res).ref);
-	                        System.out.println("interface ref.:"+lines);
-	                        return lines;
-	                    }
-	                }
-                }
-                return null;
-            } else if (lines.indexOf(cCommuneListStart) != -1 && lines.indexOf(cCommuneListEnd) != -1) {
-                // list of values parsed in listOfCommunes
-                int i = lines.indexOf(cCommuneListStart);
-                int j = lines.indexOf(cCommuneListEnd, i);
-                parseCommuneList(lines.substring(i, j));
+            if (lines != null) {
+                if (lines.indexOf(cImageFormat) != -1) {
+                    int i = lines.indexOf(cImageFormat);
+                    int j = lines.indexOf(".", i);
+                    wmsLayer.setRaster(lines.substring(i+cImageFormat.length(), j).equals("image"));
+                }
+                if (!wmsLayer.isRaster() && lines.indexOf(cInterfaceVector) != -1) {  // "afficherCarteCommune.do"
+                    // shall be something like: interfaceRef = "afficherCarteCommune.do?c=X2269";
+                    lines = lines.substring(lines.indexOf(cInterfaceVector),lines.length());
+                    lines = lines.substring(0, lines.indexOf("'"));
+                    System.out.println("interface ref.:"+lines);
+                    return lines;
+                } else if (wmsLayer.isRaster() && lines.indexOf(cInterfaceRasterTA) != -1) { // "afficherCarteTa.do"
+                    // list of values parsed in listOfFeuilles (list all non-georeferenced images)
+                    lines = getFeuillesList();
+                    if (!downloadCancelled) {
+                        parseFeuillesList(lines);
+                        if (listOfFeuilles.size() > 0) {
+                            int res = selectFeuilleDialog();
+                            if (res != -1) {
+                                wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name);
+                                checkLayerDuplicates(wmsLayer);
+                                interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune());
+                                wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).ref);
+                                lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.elementAt(res).ref);
+                                System.out.println("interface ref.:"+lines);
+                                return lines;
+                            }
+                        }
+                    }
+                    return null;
+                } else if (lines.indexOf(cCommuneListStart) != -1 && lines.indexOf(cCommuneListEnd) != -1) {
+                    // list of values parsed in listOfCommunes
+                    int i = lines.indexOf(cCommuneListStart);
+                    int j = lines.indexOf(cCommuneListEnd, i);
+                    parseCommuneList(lines.substring(i, j));
+                }
             }
         } catch (MalformedURLException e) {
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 17215)
@@ -20,5 +20,4 @@
 import org.openstreetmap.josm.actions.UploadAction;
 import org.openstreetmap.josm.actions.UploadAction.UploadHook;
-import org.openstreetmap.josm.gui.IconToggleButton;
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MapFrame;
@@ -73,7 +72,12 @@
  * 1.1 11-Jun-2009 - fixed a null exception error when trying to displace a vectorized layer
  *                 - propose to use shortcut F11 for grabbing
+ * 1.2 16-Aug-2009 - implementation of raster image grabbing, cropping and georeferencing (not the
+ *                   overview rasters (Tableau d'assemblage) but directly small units (Feuille)
+ * 1.3 23-Aug-2009 - 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 
  */
 public class CadastrePlugin extends Plugin {
-    static String VERSION = "1.0";
+    static String VERSION = "1.3";
 
     static JMenu cadastreJMenu;
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java	(revision 17215)
@@ -81,5 +81,4 @@
         reversGrey.setSelected(Main.pref.getBoolean("cadastrewms.invertGrey", false));
         reversGrey.setToolTipText(tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds."));
-        reversGrey.setEnabled(alterColors.isSelected());
         cadastrewms.add(reversGrey, GBC.eop().insets(00, 0, 0, 0));
 
@@ -102,4 +101,5 @@
         sliderTrans.setPaintTicks(true);
         sliderTrans.setPaintLabels(false);
+        sliderTrans.setEnabled(transparency.isSelected());
         cadastrewms.add(sliderTrans, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 250, 0));
 
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java	(revision 17215)
@@ -133,6 +133,6 @@
      */
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
-        max = (EastNorth) in.readObject();
-        min = (EastNorth) in.readObject();
+        max = new EastNorth((Double)in.readObject(), (Double)in.readObject());
+        min = new EastNorth((Double)in.readObject(), (Double)in.readObject());
         image = (BufferedImage) ImageIO.read(ImageIO.createImageInputStream(in));
         updatePixelPer();
@@ -143,6 +143,8 @@
      */
     private void writeObject(ObjectOutputStream out) throws IOException {
-        out.writeObject(max);
-        out.writeObject(min);
+        out.writeObject(max.getX());
+        out.writeObject(max.getY());
+        out.writeObject(min.getX());
+        out.writeObject(min.getY());
         ImageIO.write(image, "png", ImageIO.createImageOutputStream(out));
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java	(revision 17215)
@@ -4,5 +4,4 @@
 
 import java.awt.GridBagLayout;
-import java.awt.Point;
 import java.awt.event.ActionEvent;
 import java.awt.event.MouseEvent;
@@ -37,7 +36,11 @@
     private int cGetLambertCrosspieces = 2;
     private EastNorth ea1;
-    private Point mousePrevious = new Point();
+    private long mouseClickedTime = 0;
     private EastNorth georefpoint1;
     private EastNorth georefpoint2;
+    /**
+     * The time which needs to pass between two clicks during georeferencing, in milliseconds
+     */
+    private int initialClickDelay;
 
     public MenuActionGrabPlanImage() {
@@ -48,5 +51,5 @@
         countMouseClicked = 0;
         mode = 0;
-        mousePrevious.setLocation(0, 0);
+        mouseClickedTime = System.currentTimeMillis();
     }
     
@@ -75,4 +78,5 @@
                 downloadWMSPlanImage = new DownloadWMSPlanImage();
                 downloadWMSPlanImage.download(wmsLayer);
+                initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay",200);
                 // download sub-images of the cadastre scan and join them into one single
                 Main.worker.execute(this);
@@ -90,4 +94,5 @@
         boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
         if (wmsLayer.images.size() == 1 && !loadedFromCache) {
+            mouseClickedTime = System.currentTimeMillis();
             Main.map.mapView.addMouseListener(this);
             if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false)
@@ -95,16 +100,18 @@
             else
                 startGeoreferencing();
-    	} else // action cancelled or image loaded from cache (and already georeferenced)
+        } else // action cancelled or image loaded from cache (and already georeferenced)
             Main.map.repaint();
     }
 
     public void mouseClicked(MouseEvent e) {
-        if (e.getX() == mousePrevious.getX() && e.getY() == mousePrevious.getY())
-            return; // double click filtered
+        if (System.currentTimeMillis() - mouseClickedTime < initialClickDelay) {
+            System.out.println("mouse click bounce detected");
+            return; // mouse click anti-bounce
+        }
         else
-            mousePrevious.setLocation(e.getX(), e.getY());
+            mouseClickedTime = System.currentTimeMillis();
         countMouseClicked++;
         EastNorth ea = Main.proj.latlon2eastNorth(Main.map.mapView.getLatLon(e.getX(), e.getY()));
-        System.out.println("clic:"+countMouseClicked+" ,"+ea);
+        System.out.println("clic:"+countMouseClicked+" ,"+ea+", mode:"+mode);
         // ignore clicks outside the image
         if (ea.east() < wmsLayer.images.get(0).min.east() || ea.east() > wmsLayer.images.get(0).max.east()
@@ -153,5 +160,5 @@
 	    		null, options, options[0]);
 	    if (ret == JOptionPane.OK_OPTION) {
-	        mousePrevious.setLocation(0, 0);
+	        mouseClickedTime = System.currentTimeMillis();
 	    } else
 	    	if (canceledOrRestartCurrAction("image cropping"))
@@ -192,5 +199,5 @@
 	    		null, options, options[0]);
 	    if (ret == JOptionPane.OK_OPTION) {
-	        mousePrevious.setLocation(0, 0);
+	        mouseClickedTime = System.currentTimeMillis();
 	    } else
 	    	if (canceledOrRestartCurrAction("georeferencing"))
@@ -257,5 +264,5 @@
         if (countMouseClicked == 1) number = "first";
         else number = "second";
-        pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinate")).setVisible(true);
+        pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinates")).setVisible(true);
         if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) {
             if (canceledOrRestartCurrAction("georeferencing"))
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageModifier.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageModifier.java	(revision 17214)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageModifier.java	(revision 17215)
@@ -60,5 +60,4 @@
     private void makeTransparent() {
         if (bufferedImage.getColorModel() instanceof ComponentColorModel) {
-            // raster image (ComponentColorModel)
             int width = bufferedImage.getWidth();
             int height = bufferedImage.getHeight();
@@ -85,4 +84,20 @@
         return;
     }
+    
+    /**
+     * Temporary fix for Java6 which doesn't de-serialize correctly cached image on disk. 
+     * Recreate a new raster image based on what is loaded/serialized from disk cache. 
+     * @param img
+     * @return new image
+     */
+    public static BufferedImage fixRasterImage(BufferedImage img) {
+        int width = img.getWidth();
+        int height = img.getHeight();
+        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+        int rgbArray[] = new int[width * height];
+        img.getRGB(0, 0, width, height, rgbArray, 0, width);
+        bi.setRGB(0, 0, width, height, rgbArray, 0, width);
+        return bi;
+    }
 
 }
