Index: plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureActionAbstract.java
===================================================================
--- plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureActionAbstract.java	(revision 24177)
+++ plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureActionAbstract.java	(working copy)
@@ -84,7 +84,14 @@
     public void mouseDragged(MouseEvent e) {
         // Scale the picture
         if(mb_dragging) {
-            doTheScale( ( e.getY() - m_prevY ) / 500.0 );
+            double factor;
+            if ( ( e.getModifiersEx() & e.SHIFT_DOWN_MASK ) != 0 ) {
+                factor = Main.pref.getDouble("piclayer.scalefactors.high_precision", 4000);
+            }
+            else {
+                factor = Main.pref.getDouble("piclayer.scalefactors.low_precision", 400);
+            }            
+            doTheScale( ( e.getY() - m_prevY ) / factor );
             m_prevY = e.getY();
             Main.map.mapView.repaint();
         }
Index: plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java
===================================================================
--- plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java	(revision 24177)
+++ plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java	(working copy)
@@ -32,13 +32,16 @@
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.gui.layer.Layer;
 
 /**
- * Action responsible for creation of a new layer based on
- * an image file.
+ * Action responsible for creation of new layers based on image files.
  */
 public class NewLayerFromFileAction extends JosmAction {
 
+    String m_lastdirprefname = "piclayer.lastdir";
+
     /**
      * Provides filtering of only image files.
      */
@@ -79,28 +82,51 @@
     public void actionPerformed(ActionEvent arg0) {
 
         // Choose a file
-        JFileChooser fc = new JFileChooser();
+        JFileChooser fc = new JFileChooser(Main.pref.get(m_lastdirprefname));
         fc.setAcceptAllFileFilterUsed( false );
         fc.setFileFilter( new ImageFileFilter() );
+        fc.setMultiSelectionEnabled(true); 
         int result = fc.showOpenDialog( Main.parent );
 
         // Create a layer?
         if ( result == JFileChooser.APPROVE_OPTION ) {
-            // Create layer from file
-            PicLayerFromFile layer = new PicLayerFromFile( fc.getSelectedFile() );
-            // Add layer only if successfully initialized
-            try {
-                layer.initialize();
+            // The first loaded layer will be placed at the top of any other layer of the same class,
+            // or at the bottom of the stack if there is no such layer yet
+            // The next layers we load will be placed one after the other after this first layer
+            int newLayerPos = Main.map.mapView.getAllLayers().size();
+            for(Layer l : Main.map.mapView.getLayersOfType(PicLayerFromFile.class)) {
+                int pos = Main.map.mapView.getLayerPos(l);
+                if (pos < newLayerPos) newLayerPos = pos;
             }
-            catch (IOException e) {
-                // Failed
-                System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
-                JOptionPane.showMessageDialog(null, e.getMessage() );
-                return;
+
+            for(File file : fc.getSelectedFiles() ) {
+                // TODO: we need a progress bar here, it can take quite some time
+                
+                // Create layer from file
+                PicLayerFromFile layer = new PicLayerFromFile( file );
+                // Add layer only if successfully initialized
+                try {
+                    layer.initialize();
+                }
+                catch (IOException e) {
+                    // Failed
+                    System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
+                    JOptionPane.showMessageDialog(null, e.getMessage() );
+                    return;
+                }
+                Main.pref.put(m_lastdirprefname, file.getParent());
+        
+                Main.main.addLayer( layer );
+                Main.map.mapView.moveLayer(layer, newLayerPos++);
+                
+                if ( fc.getSelectedFiles().length == 1 && Main.pref.getInteger("piclayer.zoom-on-load", 1) != 0 ) {
+                    // if we are loading a single picture file, zoom on it, so that the user can see something
+                    BoundingXYVisitor v = new BoundingXYVisitor();
+                    layer.visitBoundingBox(v);
+                    Main.map.mapView.recalculateCenterScale(v);
+                }
+
             }
-            // Add layer
-            Main.main.addLayer( layer );
         }
-
     }
 }
Index: plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/LoadPictureCalibrationAction.java
===================================================================
--- plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/LoadPictureCalibrationAction.java	(revision 24177)
+++ plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/LoadPictureCalibrationAction.java	(working copy)
@@ -37,30 +37,32 @@
 import org.openstreetmap.josm.actions.JosmAction;
 
 /**
- * Action for resetting properties of an image.
+ * Action to load the calibration file.
  * 
- * TODO Four almost identical classes. Refactoring needed.
  */
 public class LoadPictureCalibrationAction extends JosmAction {
 
     // Owner layer of the action
-    PicLayerAbstract m_owner = null;
-    
+    PicLayerAbstract m_owner = null;
+    
+    // Persistent FileChooser instance to remember last directory
+    JFileChooser m_filechooser = null;
+
     /**
      * Constructor
      */
     public LoadPictureCalibrationAction( PicLayerAbstract owner ) {
-        super(tr("Load Picture Calibration..."), null, tr("Loads calibration data to a file"), null, false);
+        super(tr("Load Picture Calibration..."), null, tr("Loads calibration data from a file"), null, false);
         // Remember the owner...
         m_owner = owner;
     }
-    
+
     /**
      * Action handler
      */
-    public void actionPerformed(ActionEvent arg0) {
+    public void actionPerformed(ActionEvent arg0) {
         // Save dialog
-        final JFileChooser fc = new JFileChooser();
+        JFileChooser fc = new JFileChooser();
         fc.setAcceptAllFileFilterUsed( false );
         fc.setFileFilter( new CalibrationFileFilter() );
         fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
@@ -69,15 +71,14 @@
         if ( result == JFileChooser.APPROVE_OPTION ) {
                     
             // Load 
-            try {
-                Properties props = new Properties();
-                props.load(new FileInputStream(fc.getSelectedFile()));
-                m_owner.loadCalibration(props);
+            try {
+                m_owner.loadCalibration(fc.getSelectedFile());
             } catch (Exception e) {
                 // Error
                 e.printStackTrace();
                 JOptionPane.showMessageDialog(Main.parent , tr("Loading file failed: {0}", e.getMessage()));
             }
         }
-    }
+    }
+    
 }
Index: plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java
===================================================================
--- plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java	(revision 24177)
+++ plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java	(working copy)
@@ -86,8 +86,14 @@
     public void mouseDragged(MouseEvent e) {
         // Rotate the picture
         if(mb_dragging) {
-            // TODO: Magic number
-            m_currentLayer.rotatePictureBy( ( e.getY() - m_prevY ) / 10.0 );
+            double factor;
+            if ( ( e.getModifiersEx() & e.SHIFT_DOWN_MASK ) != 0 ) {
+                factor = Main.pref.getDouble("piclayer.rotatefactors.high_precision", 100.0);
+            }
+            else {
+                factor = Main.pref.getDouble("piclayer.rotatefactors.low_precision", 10.0 );
+            }            
+            m_currentLayer.rotatePictureBy( ( e.getY() - m_prevY ) / factor );
             m_prevY = e.getY();
             Main.map.mapView.repaint();
         }
Index: plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java
===================================================================
--- plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java	(revision 24177)
+++ plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java	(working copy)
@@ -20,11 +20,16 @@
 
 package org.openstreetmap.josm.plugins.piclayer;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import org.openstreetmap.josm.Main;
+
 import java.awt.Image;
 import java.io.File;
 import java.io.IOException;
 import javax.imageio.ImageIO;
-
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
 /**
  * Layer displaying a picture loaded from a file.
  */
@@ -38,15 +43,68 @@
     public PicLayerFromFile( File file ) {
         // Remember the file
         m_file = file;
+
         // Generate tooltip text
         m_tooltiptext = m_file.getAbsolutePath();
+        
+        // Set the name of the layer as the base name of the file
+        setName(m_file.getName());
     }
 
+    protected String getFilePath() {
+        return m_file.getAbsolutePath();
+    }
+
+    public File getDefaultCalPath() {
+        File calFile = new File(m_file + CalibrationFileFilter.EXTENSION);
+        return calFile;
+    }
+    
     @Override
     protected Image createImage() throws IOException {
         // Try to load file
         Image image = null;
         image = ImageIO.read( m_file );
+        
+        // Manage a potential existing calibration file
+        File calFile = getDefaultCalPath();
+        if ( calFile.exists() ) {
+            String prefkey = "piclayer.autoloadcal";
+            String policy = Main.pref.get(prefkey, "");
+            policy = policy.trim().toLowerCase();
+            boolean loadcal = false;
+
+            String msg = tr("A calibration file associated to the picture file was found:")+"\n"+calFile.getName();
+            if ( policy.equals("yes") ) {
+                loadcal = true;
+            }
+            else if ( policy.equals("no") ) {
+                loadcal = false;
+            }
+            else if ( policy.equals("ask") ) {
+                msg += "\n" + tr("(set  \"{0}\"  to yes/no/ask in the preferences\n"+
+                                "to control the autoloading of calibration files)", prefkey);
+                msg += "\n" + tr("Do you want to apply it ?");
+                int answer = JOptionPane.showConfirmDialog(Main.parent, msg, tr("Load calibration file ?"), JOptionPane.YES_NO_OPTION);
+                if (answer == JOptionPane.YES_OPTION) {
+                    loadcal = true;
+                }
+            }
+            else {
+                msg += "\n" + tr("It will be applied automatically.");
+                msg += "\n" + tr("Also, frow now on, cal files will always be loaded automatically.");
+                msg += "\n" + tr("Set  \"{0}\"  to yes/no/ask in the preferences\n"+
+                                "to control the autoloading of calibration files.", prefkey);
+                // TODO: there should be here a yes/no dialog with a checkbox "do not ask again"
+                JOptionPane.showMessageDialog(Main.parent, msg,
+                    "Automatic loading of the calibration", JOptionPane.INFORMATION_MESSAGE);
+                Main.pref.put(prefkey, "yes");
+                loadcal = true;
+            }
+            if ( loadcal )
+                loadCalibration(calFile);
+        }
+                
         return image;
     }
 
Index: plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java
===================================================================
--- plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java	(revision 24177)
+++ plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java	(working copy)
@@ -30,6 +30,10 @@
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.List;
 import java.util.Properties;
@@ -41,6 +45,7 @@
 import javax.swing.JMenu;
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.RenameLayerAction;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
@@ -101,6 +106,24 @@
      * initial parameters. Throws exception if something fails.
      */
     public void initialize() throws IOException {
+        // First, we initialize the calibration, so that createImage() can rely on it
+        
+        // If the map does not exist - we're screwed. We should not get into this situation in the first place!
+        if ( Main.map != null && Main.map.mapView != null ) {
+            // Geographical position of the image
+            // getCenter() documentation claims it returns a clone, but this is not inline with the code,
+            // which actually returns the same object upon subsequent calls. This messes things up
+            // when we loading several pictures and associated cal's in one go.
+            // So as a workaround, copy the object manually :
+            // TODO: not sure about this code below, probably there is a better way to clone the objects
+            EastNorth center = Main.map.mapView.getCenter();
+            m_initial_position = new EastNorth(center.east(), center.north());
+            m_position = new EastNorth(center.east(), center.north());
+            // Initial scale at which the image was loaded
+            m_initial_scale = Main.map.mapView.getDist100Pixel();
+        } else {
+            throw new IOException(tr("Could not find the map object."));
+        }
 
         // Create image
         Image image = createImage();
@@ -111,16 +134,6 @@
         m_image = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB );
         Graphics g = m_image.getGraphics();
         g.drawImage( image, 0, 0, null );
-
-        // If the map does not exist - we're screwed. We should not get into this situation in the first place!
-        if ( Main.map != null && Main.map.mapView != null ) {
-            // Geographical position of the image
-            m_initial_position = m_position = Main.map.mapView.getCenter();
-            // Initial scale at which the image was loaded
-            m_initial_scale = Main.map.mapView.getDist100Pixel();
-        } else {
-            throw new IOException(tr("Could not find the map object."));
-        }
     }
 
     /**
@@ -155,6 +168,8 @@
                 SeparatorLayerAction.INSTANCE,
                 new SavePictureCalibrationAction(this),
                 new LoadPictureCalibrationAction(this),
+                SeparatorLayerAction.INSTANCE,
+                new RenameLayerAction(null,this)
         };
     }
 
@@ -264,9 +279,25 @@
     }
 
     @Override
+    /**
+     * Computes the (rough) bounding box
+     */
     public void visitBoundingBox(BoundingXYVisitor arg0) {
-        // TODO Auto-generated method stub
+        if ( m_image == null )
+            return;
 
+        EastNorth center = m_position;
+        double w = m_image.getWidth(null);
+        double h = m_image.getHeight(null);
+        double diag_pix = Math.sqrt(w*w+h*h);
+        // TODO: Current formula found with a "pragmatic approach", to define more exactly
+        double factor = 0.01 * Math.max(m_scalex, m_scaley) * m_initial_scale;
+        double offset = factor*diag_pix/2;
+
+        EastNorth topleft = center.add(-offset, -offset);
+        EastNorth bottomright = center.add(offset, offset);
+        arg0.visit(topleft);
+        arg0.visit(bottomright);
     }
 
     /**
@@ -286,6 +317,17 @@
     }
 
     /**
+     * Loads calibration data from file
+     * @param file The file to read from
+     * @return
+     */
+    public void loadCalibration(File file) throws IOException {
+        Properties props = new Properties();
+        props.load(new FileInputStream(file));
+        loadCalibration(props);
+    }
+
+    /**
      * Loads calibration data from properties structure
      * @param props Properties to load from
      * @return
Index: dist/PicLayer.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
