Index: applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/LatLng.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/LatLng.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/LatLng.java	(revision 12778)
@@ -3,9 +3,9 @@
 /**
  * Class to represent a latitude/longitude pair.
- * 
+ *
  * (c) 2006 Jonathan Stott
- * 
+ *
  * Created on 11-02-2006
- * 
+ *
  * @author Jonathan Stott
  * @version 1.0
@@ -27,5 +27,5 @@
   /**
    * Create a new LatLng object to represent a latitude/longitude pair.
-   * 
+   *
    * @param lat
    *          the latitude in degrees
@@ -42,5 +42,5 @@
   /**
    * Get a String representation of this LatLng object.
-   * 
+   *
    * @return a String representation of this LatLng object.
    * @since 1.0
@@ -54,5 +54,5 @@
    * Convert this latitude and longitude into an OSGB (Ordnance Survey of Great
    * Britain) grid reference.
-   * 
+   *
    * @return the converted OSGB grid reference
    * @since 1.0
@@ -124,5 +124,5 @@
   /**
    * Convert this latitude and longitude to a UTM reference.
-   * 
+   *
    * @return the converted UTM reference
    * @since 1.0
@@ -212,5 +212,5 @@
    * Convert this LatLng from the OSGB36 datum to the WGS84 datum using an
    * approximate Helmert transformation.
-   * 
+   *
    * @since 1.0
    */
@@ -260,5 +260,5 @@
    * Convert this LatLng from the WGS84 datum to the OSGB36 datum using an
    * approximate Helmert transformation.
-   * 
+   *
    * @since 1.0
    */
@@ -310,5 +310,5 @@
    * Calculate the surface distance in kilometres from the this LatLng to the
    * given LatLng.
-   * 
+   *
    * @param ll
    * @return the surface distance in km
@@ -334,5 +334,5 @@
   /**
    * Return the latitude in degrees.
-   * 
+   *
    * @return the latitude in degrees
    * @since 1.0
@@ -345,5 +345,5 @@
   /**
    * Return the longitude in degrees.
-   * 
+   *
    * @return the longitude in degrees
    * @since 1.0
Index: applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/OSRef.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/OSRef.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/OSRef.java	(revision 12778)
@@ -3,9 +3,9 @@
 /**
  * Class to represent an Ordnance Survey grid reference
- * 
+ *
  * (c) 2006 Jonathan Stott
- * 
+ *
  * Created on 11-02-2006
- * 
+ *
  * @author Jonathan Stott
  * @version 1.0
@@ -27,5 +27,5 @@
   /**
    * Create a new Ordnance Survey grid reference.
-   * 
+   *
    * @param easting
    *          the easting in metres
@@ -45,5 +45,5 @@
    * first character must be H, N, S, O or T. The second character can be any
    * uppercase character from A through Z excluding I.
-   * 
+   *
    * @param ref
    *          a String representing a six-figure Ordnance Survey grid reference
@@ -83,5 +83,5 @@
    * Return a String representation of this OSGB grid reference showing the
    * easting and northing.
-   * 
+   *
    * @return a String represenation of this OSGB grid reference
    * @since 1.0
@@ -95,5 +95,5 @@
    * Return a String representation of this OSGB grid reference using the
    * six-figure notation in the form XY123456
-   * 
+   *
    * @return a String representing this OSGB grid reference in six-figure
    *         notation
@@ -147,5 +147,5 @@
    * OSGB36 datum. Note that, the LatLng object may need to be converted to the
    * WGS84 datum depending on the application.
-   * 
+   *
    * @return a LatLng object representing this OSGB grid reference using the
    *         OSGB36 datum
@@ -225,5 +225,5 @@
   /**
    * Get the easting.
-   * 
+   *
    * @return the easting in metres
    * @since 1.0
@@ -236,5 +236,5 @@
   /**
    * Get the northing.
-   * 
+   *
    * @return the northing in metres
    * @since 1.0
Index: applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/RefEll.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/RefEll.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/RefEll.java	(revision 12778)
@@ -4,9 +4,9 @@
  * Class to represent a reference ellipsoid. Also provides a number of
  * pre-determined reference ellipsoids as constants.
- * 
+ *
  * (c) 2006 Jonathan Stott
- * 
+ *
  * Created on 11-Feb-2006
- * 
+ *
  * @author Jonathan Stott
  * @version 1.0
@@ -43,5 +43,5 @@
   /**
    * Create a new reference ellipsoid
-   * 
+   *
    * @param maj
    *          semi-major axis
@@ -59,5 +59,5 @@
   /**
    * Return the semi-major axis.
-   * 
+   *
    * @return the semi-major axis
    * @since 1.0
@@ -70,5 +70,5 @@
   /**
    * Return the semi-minor axis
-   * 
+   *
    * @return the semi-minor axis
    * @since 1.0
@@ -81,5 +81,5 @@
   /**
    * Return the eccentricity.
-   * 
+   *
    * @return the eccentricity
    * @since 1.0
Index: applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/Test.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/Test.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/Test.java	(revision 12778)
@@ -4,9 +4,9 @@
  * Class to illustrate the use of the various functions of the classes in the
  * Jcoord package.
- * 
+ *
  * (c) 2006 Jonathan Stott
- * 
+ *
  * Created on 11-Feb-2006
- * 
+ *
  * @author Jonathan Stott
  * @version 1.0
@@ -17,5 +17,5 @@
   /**
    * Main method
-   * 
+   *
    * @param args
    *          not used
@@ -26,5 +26,5 @@
     /*
      * Calculate Surface Distance between two Latitudes/Longitudes
-     * 
+     *
      * The distance() function takes a reference to a LatLng object as a
      * parameter and calculates the surface distance between the the given
@@ -45,5 +45,5 @@
     /*
      * Convert OS Grid Reference to Latitude/Longitude
-     * 
+     *
      * Note that the OSGB-Latitude/Longitude conversions use the OSGB36 datum by
      * default. The majority of applications use the WGS84 datum, for which the
@@ -76,5 +76,5 @@
     /*
      * Convert Latitude/Longitude to OS Grid Reference
-     * 
+     *
      * Note that the OSGB-Latitude/Longitude conversions use the OSGB36 datum by
      * default. The majority of applications use the WGS84 datum, for which the
@@ -107,5 +107,5 @@
     /*
      * Convert Six-Figure OS Grid Reference String to an OSRef Object
-     * 
+     *
      * To convert a string representing a six-figure OSGB grid reference:
      */
Index: applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/UTMRef.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/UTMRef.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/UTMRef.java	(revision 12778)
@@ -3,9 +3,9 @@
 /**
  * Class to represent a UTM reference
- * 
+ *
  * (c) 2006 Jonathan Stott
- * 
+ *
  * Created on 11-Feb-2006
- * 
+ *
  * @author Jonathan Stott
  * @version 1.0
@@ -37,5 +37,5 @@
   /**
    * Create a new UTM reference object.
-   * 
+   *
    * @param easting
    *          the easting
@@ -58,5 +58,5 @@
   /**
    * Convert this UTM reference to a latitude and longitude.
-   * 
+   *
    * @return the converted latitude and longitude
    * @since 1.0
@@ -130,5 +130,5 @@
   /**
    * Work out the UTM latitude zone from the latitude.
-   * 
+   *
    * @param latitude
    *          the latitude to find the UTM latitude zone for
@@ -184,5 +184,5 @@
   /**
    * Convert this UTM reference to a String representation for printing out.
-   * 
+   *
    * @return a String representation of this UTM reference
    * @since 1.0
@@ -196,5 +196,5 @@
   /**
    * Get the easting.
-   * 
+   *
    * @return the easting
    * @since 1.0
@@ -207,5 +207,5 @@
   /**
    * Get the northing.
-   * 
+   *
    * @return the northing
    * @since 1.0
@@ -218,5 +218,5 @@
   /**
    * Get the latitude zone character.
-   * 
+   *
    * @return the latitude zone character
    * @since 1.0
@@ -229,5 +229,5 @@
   /**
    * Get the longitude zone number.
-   * 
+   *
    * @return the longitude zone number
    * @since 1.0
Index: applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/Util.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/Util.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/uk/me/jstott/jcoord/Util.java	(revision 12778)
@@ -3,9 +3,9 @@
 /**
  * Some utility functions used by classes in the uk.me.jstott.jcoord package.
- * 
+ *
  * (c) 2006 Jonathan Stott
- * 
+ *
  * Created on 11-Feb-2006
- * 
+ *
  * @author Jonathan Stott
  * @version 1.0
@@ -16,5 +16,5 @@
   /**
    * Calculate sin^2(x).
-   * 
+   *
    * @param x
    *          x
@@ -29,5 +29,5 @@
   /**
    * Calculate cos^2(x).
-   * 
+   *
    * @param x
    *          x
@@ -42,5 +42,5 @@
   /**
    * Calculate tan^2(x).
-   * 
+   *
    * @param x
    *          x
@@ -55,5 +55,5 @@
   /**
    * Calculate sec(x).
-   * 
+   *
    * @param x
    *          x
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java	(revision 12778)
@@ -15,59 +15,59 @@
 
 public class GeorefImage implements Serializable {
-	public BufferedImage image = null;
-	public EastNorth min, max;
-	public boolean downloadingStarted;
+    public BufferedImage image = null;
+    public EastNorth min, max;
+    public boolean downloadingStarted;
 
-	public GeorefImage(boolean downloadingStarted) {
-		this.downloadingStarted = downloadingStarted;
-	}
+    public GeorefImage(boolean downloadingStarted) {
+        this.downloadingStarted = downloadingStarted;
+    }
 
-	public boolean contains(EastNorth en, double dx, double dy) {
-		return min.east()+dx <= en.east() && en.east() <= max.east()+dx
-			&& min.north()+dy <= en.north() && en.north() <= max.north()+dy;
-	}
+    public boolean contains(EastNorth en, double dx, double dy) {
+        return min.east()+dx <= en.east() && en.east() <= max.east()+dx
+            && min.north()+dy <= en.north() && en.north() <= max.north()+dy;
+    }
 
-	/* this does not take dx and dy offset into account! */
-	public boolean isVisible(NavigatableComponent nc) {
-		Point minPt = nc.getPoint(min), maxPt = nc.getPoint(max);
-		Graphics g = nc.getGraphics();
+    /* this does not take dx and dy offset into account! */
+    public boolean isVisible(NavigatableComponent nc) {
+        Point minPt = nc.getPoint(min), maxPt = nc.getPoint(max);
+        Graphics g = nc.getGraphics();
 
-		return (g.hitClip(minPt.x, maxPt.y,
-				maxPt.x - minPt.x, minPt.y - maxPt.y));
-	}
+        return (g.hitClip(minPt.x, maxPt.y,
+                maxPt.x - minPt.x, minPt.y - maxPt.y));
+    }
 
-	public boolean paint(Graphics g, NavigatableComponent nc, double dx, double dy) {
-		if (image == null || min == null || max == null) return false;
+    public boolean paint(Graphics g, NavigatableComponent nc, double dx, double dy) {
+        if (image == null || min == null || max == null) return false;
 
-		EastNorth mi = new EastNorth(min.east()+dx, min.north()+dy);
-		EastNorth ma = new EastNorth(max.east()+dx, max.north()+dy);
-		Point minPt = nc.getPoint(mi), maxPt = nc.getPoint(ma);
+        EastNorth mi = new EastNorth(min.east()+dx, min.north()+dy);
+        EastNorth ma = new EastNorth(max.east()+dx, max.north()+dy);
+        Point minPt = nc.getPoint(mi), maxPt = nc.getPoint(ma);
 
-		/* this is isVisible() but taking dx, dy into account */
-		if(!(g.hitClip(minPt.x, maxPt.y,
-				maxPt.x - minPt.x, minPt.y - maxPt.y)))
-			return false;
+        /* this is isVisible() but taking dx, dy into account */
+        if(!(g.hitClip(minPt.x, maxPt.y,
+                maxPt.x - minPt.x, minPt.y - maxPt.y)))
+            return false;
 
-		g.drawImage(image,
-			minPt.x, maxPt.y, maxPt.x, minPt.y, // dest
-			0, 0, image.getWidth(), image.getHeight(), // src
-			null);
+        g.drawImage(image,
+            minPt.x, maxPt.y, maxPt.x, minPt.y, // dest
+            0, 0, image.getWidth(), image.getHeight(), // src
+            null);
 
-		return true;
-	}
+        return true;
+    }
 
-	private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
-		max = (EastNorth) in.readObject();
-		min = (EastNorth) in.readObject();
-		image = (BufferedImage) ImageIO.read(ImageIO.createImageInputStream(in));
-	}
-	
-	private void writeObject(ObjectOutputStream out) throws IOException {
-		out.writeObject(max);
-		out.writeObject(min);
-		if(image == null)
-			out.writeObject(null);
-		else
-			ImageIO.write(image, "png", ImageIO.createImageOutputStream(out));
-	}
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+        max = (EastNorth) in.readObject();
+        min = (EastNorth) in.readObject();
+        image = (BufferedImage) ImageIO.read(ImageIO.createImageInputStream(in));
+    }
+
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        out.writeObject(max);
+        out.writeObject(min);
+        if(image == null)
+            out.writeObject(null);
+        else
+            ImageIO.write(image, "png", ImageIO.createImageOutputStream(out));
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java	(revision 12778)
@@ -14,64 +14,64 @@
 
 abstract public class Grabber implements Runnable {
-	protected Bounds b;
-	protected Projection proj;
-	protected double pixelPerDegree;
-	protected MapView mv;
-	protected WMSLayer layer;
-	protected GeorefImage image;
+    protected Bounds b;
+    protected Projection proj;
+    protected double pixelPerDegree;
+    protected MapView mv;
+    protected WMSLayer layer;
+    protected GeorefImage image;
 
-	Grabber(Bounds b, Projection proj,
-			double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
-		this.b = b;
-		this.proj = proj;
-		this.pixelPerDegree = pixelPerDegree;
-		this.image = image;
-		this.mv = mv;
-		this.layer = layer;
-	}
+    Grabber(Bounds b, Projection proj,
+            double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
+        this.b = b;
+        this.proj = proj;
+        this.pixelPerDegree = pixelPerDegree;
+        this.image = image;
+        this.mv = mv;
+        this.layer = layer;
+    }
 
-	abstract void fetch() throws Exception; // the image fetch code
+    abstract void fetch() throws Exception; // the image fetch code
 
-	int width(){
-		return (int) ((b.max.lon() - b.min.lon()) * pixelPerDegree);
-	}
-	int height(){
-		return (int) ((b.max.lat() - b.min.lat()) * pixelPerDegree);
-	}
+    int width(){
+        return (int) ((b.max.lon() - b.min.lon()) * pixelPerDegree);
+    }
+    int height(){
+        return (int) ((b.max.lat() - b.min.lat()) * pixelPerDegree);
+    }
 
-	protected void grabError(Exception e){ // report error when grabing image
-		e.printStackTrace();
-		
-		BufferedImage img = new BufferedImage(width(), height(), BufferedImage.TYPE_INT_ARGB);
-		Graphics g = img.getGraphics();
-		g.setColor(Color.RED);
-		g.fillRect(0, 0, width(), height());
-		Font font = g.getFont();
-		Font tempFont = font.deriveFont(Font.PLAIN).deriveFont(36.0f);
-		g.setFont(tempFont);
-		g.setColor(Color.BLACK);
-		g.drawString(tr("Exception occurred"), 10, height()/2);
-		image.image = img;
-		g.setFont(font);
-	}
+    protected void grabError(Exception e){ // report error when grabing image
+        e.printStackTrace();
 
-	protected void attempt(){ // try to fetch the image
-		int maxTries = 5; // n tries for every image
-		for (int i = 1; i <= maxTries; i++) {
-			try {
-				fetch();
-				break; // break out of the retry loop
-			} catch (Exception e) {
-				try { // sleep some time and then ask the server again
-					Thread.sleep(random(1000, 2000));
-				} catch (InterruptedException e1) {}
+        BufferedImage img = new BufferedImage(width(), height(), BufferedImage.TYPE_INT_ARGB);
+        Graphics g = img.getGraphics();
+        g.setColor(Color.RED);
+        g.fillRect(0, 0, width(), height());
+        Font font = g.getFont();
+        Font tempFont = font.deriveFont(Font.PLAIN).deriveFont(36.0f);
+        g.setFont(tempFont);
+        g.setColor(Color.BLACK);
+        g.drawString(tr("Exception occurred"), 10, height()/2);
+        image.image = img;
+        g.setFont(font);
+    }
 
-				if(i == maxTries) grabError(e);
-			}
-		}
-	}
+    protected void attempt(){ // try to fetch the image
+        int maxTries = 5; // n tries for every image
+        for (int i = 1; i <= maxTries; i++) {
+            try {
+                fetch();
+                break; // break out of the retry loop
+            } catch (Exception e) {
+                try { // sleep some time and then ask the server again
+                    Thread.sleep(random(1000, 2000));
+                } catch (InterruptedException e1) {}
 
-	public static int random(int min, int max) {
-	    return (int)(Math.random() * ((max+1)-min) ) + min;
-	}
+                if(i == maxTries) grabError(e);
+            }
+        }
+    }
+
+    public static int random(int min, int max) {
+        return (int)(Math.random() * ((max+1)-min) ) + min;
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Help_WMSmenuAction.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Help_WMSmenuAction.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Help_WMSmenuAction.java	(revision 12778)
@@ -11,51 +11,51 @@
 public class Help_WMSmenuAction extends JosmAction {
 
-	/**
-	 * 
-	 */
-	
+    /**
+     * 
+     */
+    
 
-	public Help_WMSmenuAction() {
-		//super("Help / About");
-		super(tr("help"), "help", tr("Help / About"), null, false);
-		
-	}
-	
-	public void actionPerformed(ActionEvent e) {
-		//todo - put this into a txt file? 
-		  String helptext = 
-			tr("You can add, edit and delete WMS entries in the WMSplugin Preference Tab - "  +
-			"these will then show up in the WMS menu.\n\n"+
-			
-			"You can also do this manually in the Advanced Preferences, using the following schema:\n"+
-			"wmsplugin.url.1.name=Landsat\n"+
-			"wmsplugin.url.1.url=http://onearth.jpl.nasa.gov....\n"+
-			"wmsplugin.url.2.name=NPE Maps... etc\n\n"+
-					
-			"Full WMS URL input format example (landsat)\n"+
-			"http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&\n"+
-			"layers=global_mosaic&styles=&srs=EPSG:4326&\n"+
-			"format=image/jpeg \n\n"+
-			
-			"For Metacarta's Map Rectifier http://labs.metacarta.com/rectifier/ , you only need to input the relevant 'id'.\n" +
-			"To add a Metacarta Map Rectifier menu item, manually create the URL like in this example," +
-			"replacing 73 with your image id: \n" +
-			"http://labs.metacarta.com/rectifier/wms.cgi?id=73\n" +
-			"&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png\n" +
-			" \n" +
-			"Note: Make sure the image is suitable, copyright-wise, if in doubt, don't use.");
-		
-		JTextPane tp = new JTextPane();
-		  JScrollPane js = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
-				  JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
-		 
-		  
-		  js.getViewport().add(tp);
-		  JFrame jf = new JFrame(tr("WMS Plugin Help"));
-		  jf.getContentPane().add(js);
-		  jf.pack();
-		  jf.setSize(400,500);
-		  jf.setVisible(true); 
-		  tp.setText(helptext);
-	}
+    public Help_WMSmenuAction() {
+        //super("Help / About");
+        super(tr("help"), "help", tr("Help / About"), null, false);
+        
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        //todo - put this into a txt file? 
+          String helptext = 
+            tr("You can add, edit and delete WMS entries in the WMSplugin Preference Tab - "  +
+            "these will then show up in the WMS menu.\n\n"+
+            
+            "You can also do this manually in the Advanced Preferences, using the following schema:\n"+
+            "wmsplugin.url.1.name=Landsat\n"+
+            "wmsplugin.url.1.url=http://onearth.jpl.nasa.gov....\n"+
+            "wmsplugin.url.2.name=NPE Maps... etc\n\n"+
+                    
+            "Full WMS URL input format example (landsat)\n"+
+            "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&\n"+
+            "layers=global_mosaic&styles=&srs=EPSG:4326&\n"+
+            "format=image/jpeg \n\n"+
+            
+            "For Metacarta's Map Rectifier http://labs.metacarta.com/rectifier/ , you only need to input the relevant 'id'.\n" +
+            "To add a Metacarta Map Rectifier menu item, manually create the URL like in this example," +
+            "replacing 73 with your image id: \n" +
+            "http://labs.metacarta.com/rectifier/wms.cgi?id=73\n" +
+            "&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png\n" +
+            " \n" +
+            "Note: Make sure the image is suitable, copyright-wise, if in doubt, don't use.");
+        
+        JTextPane tp = new JTextPane();
+          JScrollPane js = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                  JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+         
+          
+          js.getViewport().add(tp);
+          JFrame jf = new JFrame(tr("WMS Plugin Help"));
+          jf.getContentPane().add(js);
+          jf.pack();
+          jf.setSize(400,500);
+          jf.setVisible(true); 
+          tp.setText(helptext);
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Map_Rectifier_WMSmenuAction.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Map_Rectifier_WMSmenuAction.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Map_Rectifier_WMSmenuAction.java	(revision 12778)
@@ -12,25 +12,25 @@
 public class Map_Rectifier_WMSmenuAction extends JosmAction {
 
-	/**
-	 * tim waters "chippy"
-	 */
-	private static final long serialVersionUID = 1L;
+    /**
+     * tim waters "chippy"
+     */
+    private static final long serialVersionUID = 1L;
 
-	public Map_Rectifier_WMSmenuAction() {
-		super(tr("Rectified Image ..."), "OLmarker", tr("Download Rectified Image from Metacarta's Map Rectifier WMS"), null, false);
-	}
+    public Map_Rectifier_WMSmenuAction() {
+        super(tr("Rectified Image ..."), "OLmarker", tr("Download Rectified Image from Metacarta's Map Rectifier WMS"), null, false);
+    }
 
-	public void actionPerformed(ActionEvent e) {
-		String newid = JOptionPane.showInputDialog(Main.parent, tr("Metacarta Map Rectifier image id"),
-		Main.pref.get("wmsplugin.rectifier_id"));
+    public void actionPerformed(ActionEvent e) {
+        String newid = JOptionPane.showInputDialog(Main.parent, tr("Metacarta Map Rectifier image id"),
+        Main.pref.get("wmsplugin.rectifier_id"));
 
-		if (newid != null && !newid.equals("")) {
-			String newURL = "http://labs.metacarta.com/rectifier/wms.cgi?id="+newid+
-			"&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png";
+        if (newid != null && !newid.equals("")) {
+            String newURL = "http://labs.metacarta.com/rectifier/wms.cgi?id="+newid+
+            "&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png";
 
-			Main.pref.put("wmsplugin.rectifier_id", newid);
-			WMSLayer wmsLayer = new WMSLayer(tr("rectifier id={0}",newid), newURL);
-			Main.main.addLayer(wmsLayer);
-		}
-	}
+            Main.pref.put("wmsplugin.rectifier_id", newid);
+            WMSLayer wmsLayer = new WMSLayer(tr("rectifier id={0}",newid), newURL);
+            Main.main.addLayer(wmsLayer);
+        }
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/OSGBGrabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/OSGBGrabber.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/OSGBGrabber.java	(revision 12778)
@@ -15,50 +15,50 @@
 // FIXME: Remove this hack when we have proper projection support.
 public class OSGBGrabber extends WMSGrabber {
-	public OSGBGrabber(String baseURL) {
-		super(baseURL);
-	}
+    public OSGBGrabber(String baseURL) {
+        super(baseURL);
+    }
 
-	private Epsg4326 latlonProj = new Epsg4326();
+    private Epsg4326 latlonProj = new Epsg4326();
 
-	@Override public GeorefImage grab(Bounds b, Projection proj,
-			double pixelPerDegree) throws IOException {
-		Bounds bnew = toOSGB(b);
-		double pixelPerDegreeNew =
-			pixelPerDegree / (bnew.max.lon() - bnew.min.lon())
-				* (b.max.lon() - b.min.lon());
+    @Override public GeorefImage grab(Bounds b, Projection proj,
+            double pixelPerDegree) throws IOException {
+        Bounds bnew = toOSGB(b);
+        double pixelPerDegreeNew =
+            pixelPerDegree / (bnew.max.lon() - bnew.min.lon())
+                * (b.max.lon() - b.min.lon());
 
-		GeorefImage img = super.grab(bnew, latlonProj, pixelPerDegreeNew);
+        GeorefImage img = super.grab(bnew, latlonProj, pixelPerDegreeNew);
 
-		img.min = proj.latlon2eastNorth(fromOSGB(img.min));
-		img.max = proj.latlon2eastNorth(fromOSGB(img.max));
+        img.min = proj.latlon2eastNorth(fromOSGB(img.min));
+        img.max = proj.latlon2eastNorth(fromOSGB(img.max));
 
-		return img;
-	}
+        return img;
+    }
 
-	protected static Bounds toOSGB(Bounds b) {
-		LatLng[] lls = new LatLng[] {
-			new LatLng(b.min.lat(), b.min.lon()),
-			new LatLng(b.min.lat(), b.max.lon()),
-			new LatLng(b.max.lat(), b.min.lon()),
-			new LatLng(b.max.lat(), b.max.lon()) };
+    protected static Bounds toOSGB(Bounds b) {
+        LatLng[] lls = new LatLng[] {
+            new LatLng(b.min.lat(), b.min.lon()),
+            new LatLng(b.min.lat(), b.max.lon()),
+            new LatLng(b.max.lat(), b.min.lon()),
+            new LatLng(b.max.lat(), b.max.lon()) };
 
-		for (LatLng ll : lls) ll.toOSGB36();
+        for (LatLng ll : lls) ll.toOSGB36();
 
-		OSRef[] grs = new OSRef[lls.length];
-		for (int i = 0; i < lls.length; i++) grs[i] = lls[i].toOSRef();
+        OSRef[] grs = new OSRef[lls.length];
+        for (int i = 0; i < lls.length; i++) grs[i] = lls[i].toOSRef();
 
-		LatLon latlon = new LatLon(grs[0].getNorthing(), grs[0].getEasting());
-		Bounds bnew = new Bounds(latlon, latlon);
-		for (int i = 1; i < grs.length; i++)
-			bnew.extend(new LatLon(grs[i].getNorthing(), grs[i].getEasting()));
+        LatLon latlon = new LatLon(grs[0].getNorthing(), grs[0].getEasting());
+        Bounds bnew = new Bounds(latlon, latlon);
+        for (int i = 1; i < grs.length; i++)
+            bnew.extend(new LatLon(grs[i].getNorthing(), grs[i].getEasting()));
 
-		return bnew;
-	}
+        return bnew;
+    }
 
-	protected static LatLon fromOSGB(EastNorth en) {
-		LatLng ll = new OSRef(en.east(), en.north()).toLatLng();
-		ll.toWGS84();
-		return new LatLon(ll.getLat(), ll.getLng());
-	}
+    protected static LatLon fromOSGB(EastNorth en) {
+        LatLng ll = new OSRef(en.east(), en.north()).toLatLng();
+        ll.toWGS84();
+        return new LatLon(ll.getLat(), ll.getLng());
+    }
 }
 */
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java	(revision 12778)
@@ -17,78 +17,78 @@
 
 public class WMSAdjustAction extends MapMode implements
-		MouseListener, MouseMotionListener{
+        MouseListener, MouseMotionListener{
 
-	GeorefImage selectedImage;
-	WMSLayer selectedLayer;
-	boolean mouseDown;
-	EastNorth prevEastNorth;
+    GeorefImage selectedImage;
+    WMSLayer selectedLayer;
+    boolean mouseDown;
+    EastNorth prevEastNorth;
 
-	public WMSAdjustAction(MapFrame mapFrame) {
-		super(tr("Adjust WMS"), "adjustwms", 
-						tr("Adjust the position of the WMS layer"), mapFrame, 
-						ImageProvider.getCursor("normal", "move"));
-	}
+    public WMSAdjustAction(MapFrame mapFrame) {
+        super(tr("Adjust WMS"), "adjustwms", 
+                        tr("Adjust the position of the WMS layer"), mapFrame, 
+                        ImageProvider.getCursor("normal", "move"));
+    }
 
-	@Override public void enterMode() {
-		super.enterMode();
-		Main.map.mapView.addMouseListener(this);
-		Main.map.mapView.addMouseMotionListener(this);
-	}
+    @Override public void enterMode() {
+        super.enterMode();
+        Main.map.mapView.addMouseListener(this);
+        Main.map.mapView.addMouseMotionListener(this);
+    }
 
-	@Override public void exitMode() {
-		super.exitMode();
-		Main.map.mapView.removeMouseListener(this);
-		Main.map.mapView.removeMouseMotionListener(this);
-	}
+    @Override public void exitMode() {
+        super.exitMode();
+        Main.map.mapView.removeMouseListener(this);
+        Main.map.mapView.removeMouseMotionListener(this);
+    }
 
-	@Override public void mousePressed(MouseEvent e) {
-		if (e.getButton() != MouseEvent.BUTTON1)
-			return;
+    @Override public void mousePressed(MouseEvent e) {
+        if (e.getButton() != MouseEvent.BUTTON1)
+            return;
 
-		 for(Layer layer:Main.map.mapView.getAllLayers()) {
-			if (layer.visible && layer instanceof WMSLayer) {
-				prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
-				selectedLayer = ((WMSLayer)layer);
-				selectedImage = selectedLayer.findImage(prevEastNorth);
-				if(selectedImage!=null){
-					Main.map.mapView.setCursor
-						(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
-				}
-			}
-		}
-	}
+         for(Layer layer:Main.map.mapView.getAllLayers()) {
+            if (layer.visible && layer instanceof WMSLayer) {
+                prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
+                selectedLayer = ((WMSLayer)layer);
+                selectedImage = selectedLayer.findImage(prevEastNorth);
+                if(selectedImage!=null){
+                    Main.map.mapView.setCursor
+                        (Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
+                }
+            }
+        }
+    }
 
-	@Override public void mouseDragged(MouseEvent e) {
-			/*
-		if (e.getButton() != MouseEvent.BUTTON1)
-			return;
-			*/
+    @Override public void mouseDragged(MouseEvent e) {
+            /*
+        if (e.getButton() != MouseEvent.BUTTON1)
+            return;
+            */
 
-		if(selectedImage!=null) {
-			EastNorth eastNorth=
-					Main.map.mapView.getEastNorth(e.getX(),e.getY());
-		        selectedLayer.displace(eastNorth.east()-prevEastNorth.east(), 
-				eastNorth.north()-prevEastNorth.north());
-			prevEastNorth = eastNorth;
-			Main.map.mapView.repaint();
-		}
-	}
+        if(selectedImage!=null) {
+            EastNorth eastNorth=
+                    Main.map.mapView.getEastNorth(e.getX(),e.getY());
+                selectedLayer.displace(eastNorth.east()-prevEastNorth.east(), 
+                eastNorth.north()-prevEastNorth.north());
+            prevEastNorth = eastNorth;
+            Main.map.mapView.repaint();
+        }
+    }
 
-	@Override public void mouseReleased(MouseEvent e) {
-		Main.map.mapView.repaint();
-		Main.map.mapView.setCursor(Cursor.getDefaultCursor());
-		selectedImage = null;	
-		prevEastNorth = null;
-		selectedLayer = null;
-	}
+    @Override public void mouseReleased(MouseEvent e) {
+        Main.map.mapView.repaint();
+        Main.map.mapView.setCursor(Cursor.getDefaultCursor());
+        selectedImage = null;   
+        prevEastNorth = null;
+        selectedLayer = null;
+    }
 
-	public void mouseEntered(MouseEvent e) {
-	}
-	public void mouseExited(MouseEvent e) {
-	}
-	public void mouseMoved(MouseEvent e) {
-	}
+    public void mouseEntered(MouseEvent e) {
+    }
+    public void mouseExited(MouseEvent e) {
+    }
+    public void mouseMoved(MouseEvent e) {
+    }
 
-	@Override public void mouseClicked(MouseEvent e) {
-	}
+    @Override public void mouseClicked(MouseEvent e) {
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java	(revision 12778)
@@ -13,23 +13,23 @@
 public class WMSDownloadAction extends JosmAction {
 
-	private WMSInfo info;
-	
-	public WMSDownloadAction(WMSInfo info) {
-		super(info.name, "wmsmenu", tr("Download WMS tile from {0}",info.name), null, false);
-		this.info = info;
-	}
-	
-	public void actionPerformed(ActionEvent e) {
-		System.out.println(info.url);
-		
-		WMSLayer wmsLayer = new WMSLayer(info.name, info.url);
-		Main.main.addLayer(wmsLayer);
-	}
+    private WMSInfo info;
 
-	public static WMSLayer getLayer(WMSInfo info) {
-		// FIXME: move this to WMSPlugin/WMSInfo/preferences.
-		WMSLayer wmsLayer = new WMSLayer(info.name, info.url);
-		Main.main.addLayer(wmsLayer);
-		return wmsLayer;
-	}
+    public WMSDownloadAction(WMSInfo info) {
+        super(info.name, "wmsmenu", tr("Download WMS tile from {0}",info.name), null, false);
+        this.info = info;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        System.out.println(info.url);
+
+        WMSLayer wmsLayer = new WMSLayer(info.name, info.url);
+        Main.main.addLayer(wmsLayer);
+    }
+
+    public static WMSLayer getLayer(WMSInfo info) {
+        // FIXME: move this to WMSPlugin/WMSInfo/preferences.
+        WMSLayer wmsLayer = new WMSLayer(info.name, info.url);
+        Main.main.addLayer(wmsLayer);
+        return wmsLayer;
+    }
 };
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 12778)
@@ -25,80 +25,80 @@
 
 public class WMSGrabber extends Grabber {
-	protected String baseURL;
+    protected String baseURL;
 
-	WMSGrabber(String baseURL, Bounds b, Projection proj,
-			double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
-		super(b, proj, pixelPerDegree, image, mv, layer);
-		this.baseURL = baseURL;
-	}
+    WMSGrabber(String baseURL, Bounds b, Projection proj,
+            double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
+        super(b, proj, pixelPerDegree, image, mv, layer);
+        this.baseURL = baseURL;
+    }
 
-	public void run() {
-		attempt();
-		mv.repaint();
-	}
+    public void run() {
+        attempt();
+        mv.repaint();
+    }
 
-	void fetch() throws Exception{
-		URL url = null;
-		try {
-			url = getURL(
-				b.min.lon(), b.min.lat(),
-				b.max.lon(), b.max.lat(),
-				width(), height());
-			
-			image.min = proj.latlon2eastNorth(b.min);
-			image.max = proj.latlon2eastNorth(b.max);
+    void fetch() throws Exception{
+        URL url = null;
+        try {
+            url = getURL(
+                b.min.lon(), b.min.lat(),
+                b.max.lon(), b.max.lat(),
+                width(), height());
 
-			if(image.isVisible(mv)) //don't download, if the image isn't visible already
-				image.image = grab(url);
-			image.downloadingStarted = false;
-		} catch(Exception e) {
-			throw new Exception(e.getMessage() + "\nImage couldn't be fetched: " + (url != null ? url.toString() : ""));
-		}
-	}
+            image.min = proj.latlon2eastNorth(b.min);
+            image.max = proj.latlon2eastNorth(b.max);
 
-	public static final NumberFormat
-		latLonFormat = new DecimalFormat("###0.0000000",
-			new DecimalFormatSymbols(Locale.US));
+            if(image.isVisible(mv)) //don't download, if the image isn't visible already
+                image.image = grab(url);
+            image.downloadingStarted = false;
+        } catch(Exception e) {
+            throw new Exception(e.getMessage() + "\nImage couldn't be fetched: " + (url != null ? url.toString() : ""));
+        }
+    }
 
-	protected URL getURL(double w, double s,double e,double n,
-			int wi, int ht) throws MalformedURLException {
-		String str = baseURL;
-		if(!str.endsWith("?"))
-			str += "&";
-		str += "bbox="
-			+ latLonFormat.format(w) + ","
-			+ latLonFormat.format(s) + ","
-			+ latLonFormat.format(e) + ","
-			+ latLonFormat.format(n)
-			+ "&width=" + wi + "&height=" + ht;
-		return new URL(str.replace(" ", "%20"));
-	}
+    public static final NumberFormat
+        latLonFormat = new DecimalFormat("###0.0000000",
+            new DecimalFormatSymbols(Locale.US));
 
-	protected BufferedImage grab(URL url) throws IOException {
-		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-		
-		String contentType = conn.getHeaderField("Content-Type");
-		if( conn.getResponseCode() != 200 
-				|| contentType != null && !contentType.startsWith("image") ) {
-			throw new IOException(readException(conn));
-		}
-		
-		InputStream is = new ProgressInputStream(conn, null);
-		BufferedImage img = ImageIO.read(is);
-		is.close();
-		return img;
-	}
+    protected URL getURL(double w, double s,double e,double n,
+            int wi, int ht) throws MalformedURLException {
+        String str = baseURL;
+        if(!str.endsWith("?"))
+            str += "&";
+        str += "bbox="
+            + latLonFormat.format(w) + ","
+            + latLonFormat.format(s) + ","
+            + latLonFormat.format(e) + ","
+            + latLonFormat.format(n)
+            + "&width=" + wi + "&height=" + ht;
+        return new URL(str.replace(" ", "%20"));
+    }
 
-	protected String readException(URLConnection conn) throws IOException {
-		StringBuilder exception = new StringBuilder();
-		InputStream in = conn.getInputStream();
-		BufferedReader br = new BufferedReader(new InputStreamReader(in));
-		
-		String line = null;
-		while( (line = br.readLine()) != null) {
-			exception.append(line);
-			exception.append('\n');
-		}
-		return exception.toString();
-	}
+    protected BufferedImage grab(URL url) throws IOException {
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+
+        String contentType = conn.getHeaderField("Content-Type");
+        if( conn.getResponseCode() != 200
+                || contentType != null && !contentType.startsWith("image") ) {
+            throw new IOException(readException(conn));
+        }
+
+        InputStream is = new ProgressInputStream(conn, null);
+        BufferedImage img = ImageIO.read(is);
+        is.close();
+        return img;
+    }
+
+    protected String readException(URLConnection conn) throws IOException {
+        StringBuilder exception = new StringBuilder();
+        InputStream in = conn.getInputStream();
+        BufferedReader br = new BufferedReader(new InputStreamReader(in));
+
+        String line = null;
+        while( (line = br.readLine()) != null) {
+            exception.append(line);
+            exception.append('\n');
+        }
+        return exception.toString();
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java	(revision 12778)
@@ -5,35 +5,35 @@
 /**
  * Class that stores info about a WMS server.
- * 
+ *
  * @author Frederik Ramm <frederik@remote.org>
  */
 public class WMSInfo implements Comparable {
-	
-	String name;
-	String url;
-	int prefid;
-	
-	public WMSInfo(String name, String url, int prefid) {
-		this.name=name; this.url=url; this.prefid=prefid;
-	}
 
-	
-	public void save() {
-		Main.pref.put("wmsplugin.url." + prefid + ".name", name);
-		Main.pref.put("wmsplugin.url." + prefid + ".url", url);
-	}
-	public int compareTo(Object c)
-	{
-		Integer i = 0;
-		if(c instanceof WMSInfo)
-		{
-			WMSInfo in = (WMSInfo)c;
-			i = name.compareTo(in.name);
-			if(i == 0)
-				i = url.compareTo(in.url);
-			if(i == 0)
-				i = prefid-in.prefid;
-		}
-		return i;
-	}
+    String name;
+    String url;
+    int prefid;
+
+    public WMSInfo(String name, String url, int prefid) {
+        this.name=name; this.url=url; this.prefid=prefid;
+    }
+
+
+    public void save() {
+        Main.pref.put("wmsplugin.url." + prefid + ".name", name);
+        Main.pref.put("wmsplugin.url." + prefid + ".url", url);
+    }
+    public int compareTo(Object c)
+    {
+        Integer i = 0;
+        if(c instanceof WMSInfo)
+        {
+            WMSInfo in = (WMSInfo)c;
+            i = name.compareTo(in.name);
+            if(i == 0)
+                i = url.compareTo(in.url);
+            if(i == 0)
+                i = prefid-in.prefid;
+        }
+        return i;
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java	(revision 12778)
@@ -45,310 +45,310 @@
 public class WMSLayer extends Layer {
 
-	protected static final Icon icon =
-		new ImageIcon(Toolkit.getDefaultToolkit().createImage(WMSPlugin.class.getResource("/images/wms_small.png")));
-
-	public int messageNum = 5; //limit for messages per layer
-	protected MapView mv;
-	protected String resolution;
-	protected boolean stopAfterPaint = false;
-	protected int ImageSize = 500;
-	protected int dax = 10;
-	protected int day = 10;
-	protected int minZoom = 3;
-	protected double dx = 0.0;
-	protected double dy = 0.0;
-	protected double pixelPerDegree;
-	protected GeorefImage[][] images = new GeorefImage[dax][day];
-	JCheckBoxMenuItem startstop = new JCheckBoxMenuItem(tr("Automatic downloading"), true);
-
-	protected String baseURL;
-	protected final int serializeFormatVersion = 4;
-	
-	private ExecutorService executor;
-
-	public WMSLayer() {
-		this(tr("Blank Layer"), null);
-		initializeImages();
-		mv = Main.map.mapView;
-	}
-
-	public WMSLayer(String name, String baseURL) {
-		super(name);
-		background = true; /* set global background variable */
-		initializeImages();
-		this.baseURL = baseURL;
-		mv = Main.map.mapView;
-		getPPD();
-		
-		executor = Executors.newFixedThreadPool(3);
-	}
-
-	public void getPPD(){
-		pixelPerDegree = mv.getWidth() / (bounds().max.lon() - bounds().min.lon());
-	}
-
-	public void initializeImages() {
-		images = new GeorefImage[dax][day];
-		for(int x = 0; x<dax; ++x)
-			for(int y = 0; y<day; ++y)
-				images[x][y]= new GeorefImage(false);
-	}
-
-	@Override public Icon getIcon() {
-		return icon;
-	}
-
-	public String scale(){
-		LatLon ll1 = mv.getLatLon(0,0);
-		LatLon ll2 = mv.getLatLon(100,0);
-		double dist = ll1.greatCircleDistance(ll2);
-		return dist > 1000 ? (Math.round(dist/100)/10.0)+" km" : Math.round(dist*10)/10+" m";
-	}
-
-	@Override public String getToolTipText() {
-		if(startstop.isSelected())
-			return tr("WMS layer ({0}), automatically downloading in zoom {1}", name, resolution);
-		else
-			return tr("WMS layer ({0}), downloading in zoom {1}", name, resolution);
-	}
-
-	@Override public boolean isMergable(Layer other) {
-		return false;
-	}
-
-	@Override public void mergeFrom(Layer from) {
-	}
-
-	private Bounds XYtoBounds (int x, int y) {
-		return new Bounds( 
-			new LatLon( x * ImageSize / pixelPerDegree,
-				         y * ImageSize / pixelPerDegree),
-			new LatLon((x + 1) *  ImageSize / pixelPerDegree,
-			           (y + 1) * ImageSize / pixelPerDegree));
-	}
-
-	private int modulo (int a, int b) {
-	  if(a%b>=0)return a%b;
-	  else return a%b+b;
-	}	  
-
-	protected Bounds bounds(){
-		return new Bounds(
-			mv.getLatLon(0, mv.getHeight()),
-			mv.getLatLon(mv.getWidth(), 0));
-	}
-
-	@Override public void paint(Graphics g, final MapView mv) {
-		if(baseURL == null) return;
-
-		if( !startstop.isSelected() || (pixelPerDegree / (mv.getWidth() / (bounds().max.lon() - bounds().min.lon())) > minZoom) ){ //don't download when it's too outzoomed
-			for(int x = 0; x<dax; ++x)
-				for(int y = 0; y<day; ++y)
-					images[modulo(x,dax)][modulo(y,day)].paint(g, mv, dx, dy);
-		} else
-			downloadAndPaintVisible(g, mv);
-	}
-
-	public void displace(double dx, double dy) {
-		this.dx += dx;
-		this.dy += dy;
-	}
-
-	protected void downloadAndPaintVisible(Graphics g, final MapView mv){
-		int bminx= (int)Math.floor ((bounds().min.lat() * pixelPerDegree ) / ImageSize );
-		int bminy= (int)Math.floor ((bounds().min.lon() * pixelPerDegree ) / ImageSize );
-		int bmaxx= (int)Math.ceil  ((bounds().max.lat() * pixelPerDegree ) / ImageSize );
-		int bmaxy= (int)Math.ceil  ((bounds().max.lon() * pixelPerDegree ) / ImageSize );
-
-		if((bmaxx - bminx > dax) || (bmaxy - bminy > day)){
-			JOptionPane.showMessageDialog(Main.parent, tr("The requested area is too big. Please zoom in a little, or change resolution"));
-			return;
-		}
-
-		for(int x = bminx; x<bmaxx; ++x)
-			for(int y = bminy; y<bmaxy; ++y){
-				GeorefImage img = images[modulo(x,dax)][modulo(y,day)];
-				if(!img.paint(g, mv, dx, dy) && !img.downloadingStarted){
-					img.downloadingStarted = true;
-					img.image = null;
-					Grabber gr = WMSPlugin.getGrabber(baseURL, XYtoBounds(x,y), Main.main.proj, pixelPerDegree, img, mv, this);
-					executor.submit(gr);
-			}
-		}
-	}
-
-	@Override public void visitBoundingBox(BoundingXYVisitor v) {
-		for(int x = 0; x<dax; ++x)
-			for(int y = 0; y<day; ++y)
-				if(images[x][y].image!=null){
-					v.visit(images[x][y].min);
-					v.visit(images[x][y].max);
-				}
-	}
-
-	@Override public Object getInfoComponent() {
-		return getToolTipText();
-	}
-
-	@Override public Component[] getMenuEntries() {
-		return new Component[]{
-				new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
-				new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),				
-				new JSeparator(),
-				new JMenuItem(new LoadWmsAction()),
-				new JMenuItem(new SaveWmsAction()),
-				new JSeparator(),
-				startstop,
-				new JMenuItem(new changeResolutionAction()),
-				new JMenuItem(new downloadAction()),
-				new JSeparator(),
-				new JMenuItem(new LayerListPopup.InfoAction(this))
-		};
-	}
-
-	public GeorefImage findImage(EastNorth eastNorth) {
-		for(int x = 0; x<dax; ++x)
-			for(int y = 0; y<day; ++y)
-					if(images[x][y].image!=null && images[x][y].min!=null && images[x][y].max!=null)
-						if(images[x][y].contains(eastNorth, dx, dy))
-							return images[x][y];
-		return null;
-	}
-
-	public class downloadAction extends AbstractAction {
-		public downloadAction() {
-			super(tr("Download visible tiles"));
-		}
-		public void actionPerformed(ActionEvent ev) {
-			downloadAndPaintVisible(mv.getGraphics(), mv);
-		}
-	}
-
-	public class changeResolutionAction extends AbstractAction {
-		public changeResolutionAction() {
-			super(tr("Change resolution"));
-		}
-		public void actionPerformed(ActionEvent ev) {
-			initializeImages();
-			resolution = scale();
-			getPPD();
-			mv.repaint();
-		}
-	}
-
-	public class SaveWmsAction extends AbstractAction {
-		public SaveWmsAction() {
-			super(tr("Save WMS layer to file"), ImageProvider.get("save"));
-		}
-		public void actionPerformed(ActionEvent ev) {
-			File f = openFileDialog(false);
-			try
-			{
-				FileOutputStream fos = new FileOutputStream(f);
-				ObjectOutputStream oos = new ObjectOutputStream(fos);
-				oos.writeInt(serializeFormatVersion);
-				oos.writeInt(dax);
-				oos.writeInt(day);
-				oos.writeInt(ImageSize);
-				oos.writeDouble(pixelPerDegree);
-				oos.writeObject(name);
-				oos.writeObject(baseURL);
-				oos.writeObject(images);
-				oos.close();
-				fos.close();
-			}
-			catch (Exception ex) {
-				ex.printStackTrace(System.out);
-			}
-		}
-	}
-
-	public class LoadWmsAction extends AbstractAction {
-		public LoadWmsAction() {
-			super(tr("Load WMS layer from file"), ImageProvider.get("load"));
-		}
-		public void actionPerformed(ActionEvent ev) {
-			File f = openFileDialog(true);
-			if (f == null) return;
-			try
-			{
-				FileInputStream fis = new FileInputStream(f);
-				ObjectInputStream ois = new ObjectInputStream(fis);
-				int sfv = ois.readInt();
-				if (sfv != serializeFormatVersion) {
-					JOptionPane.showMessageDialog(Main.parent,
-						tr("Unsupported WMS file version; found {0}, expected {1}", sfv, serializeFormatVersion),
-						tr("File Format Error"),
-						JOptionPane.ERROR_MESSAGE);
-					return;
-				}
-				startstop.setSelected(false);
-				dax = ois.readInt();
-				day = ois.readInt();
-				ImageSize = ois.readInt();
-				pixelPerDegree = ois.readDouble();
-				name = (String) ois.readObject();
-				baseURL = (String) ois.readObject();
-				images = (GeorefImage[][])ois.readObject();
-				ois.close();
-				fis.close();
-				mv.repaint();
-			}
-			catch (Exception ex) {
-				// FIXME be more specific
-				ex.printStackTrace(System.out);
-				JOptionPane.showMessageDialog(Main.parent,
-					tr("Error loading file"),
-					tr("Error"),
-					JOptionPane.ERROR_MESSAGE);
-				return;
-			}
-		}
-	}
-
-	protected static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple) {
-		String curDir = Main.pref.get("lastDirectory");
-		if (curDir.equals(""))
-			curDir = ".";
-		JFileChooser fc = new JFileChooser(new File(curDir));
-		fc.setMultiSelectionEnabled(multiple);
-		for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
-			fc.addChoosableFileFilter(ExtensionFileFilter.filters[i]);
-		fc.setAcceptAllFileFilterUsed(true);
-
-		int answer = open ? fc.showOpenDialog(Main.parent) : fc.showSaveDialog(Main.parent);
-		if (answer != JFileChooser.APPROVE_OPTION)
-			return null;
-
-		if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
-			Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
-
-		if (!open) {
-			File file = fc.getSelectedFile();
-			if (file == null || (file.exists() && JOptionPane.YES_OPTION !=
-				JOptionPane.showConfirmDialog(Main.parent, tr("File exists. Overwrite?"), tr("Overwrite"), JOptionPane.YES_NO_OPTION)))
-				return null;
-		}
-
-		return fc;
-	}
-
-	public static File openFileDialog(boolean open) {
-		JFileChooser fc = createAndOpenFileChooser(open, false);
-		if (fc == null)
-			return null;
-
-		File file = fc.getSelectedFile();
-
-		String fn = file.getPath();
-		if (fn.indexOf('.') == -1) {
-			FileFilter ff = fc.getFileFilter();
-			if (ff instanceof ExtensionFileFilter)
-				fn = "." + ((ExtensionFileFilter)ff).defaultExtension;
-			else
-				fn += ".osm";
-			file = new File(fn);
-		}
-		return file;
-	}
+    protected static final Icon icon =
+        new ImageIcon(Toolkit.getDefaultToolkit().createImage(WMSPlugin.class.getResource("/images/wms_small.png")));
+
+    public int messageNum = 5; //limit for messages per layer
+    protected MapView mv;
+    protected String resolution;
+    protected boolean stopAfterPaint = false;
+    protected int ImageSize = 500;
+    protected int dax = 10;
+    protected int day = 10;
+    protected int minZoom = 3;
+    protected double dx = 0.0;
+    protected double dy = 0.0;
+    protected double pixelPerDegree;
+    protected GeorefImage[][] images = new GeorefImage[dax][day];
+    JCheckBoxMenuItem startstop = new JCheckBoxMenuItem(tr("Automatic downloading"), true);
+
+    protected String baseURL;
+    protected final int serializeFormatVersion = 4;
+
+    private ExecutorService executor;
+
+    public WMSLayer() {
+        this(tr("Blank Layer"), null);
+        initializeImages();
+        mv = Main.map.mapView;
+    }
+
+    public WMSLayer(String name, String baseURL) {
+        super(name);
+        background = true; /* set global background variable */
+        initializeImages();
+        this.baseURL = baseURL;
+        mv = Main.map.mapView;
+        getPPD();
+
+        executor = Executors.newFixedThreadPool(3);
+    }
+
+    public void getPPD(){
+        pixelPerDegree = mv.getWidth() / (bounds().max.lon() - bounds().min.lon());
+    }
+
+    public void initializeImages() {
+        images = new GeorefImage[dax][day];
+        for(int x = 0; x<dax; ++x)
+            for(int y = 0; y<day; ++y)
+                images[x][y]= new GeorefImage(false);
+    }
+
+    @Override public Icon getIcon() {
+        return icon;
+    }
+
+    public String scale(){
+        LatLon ll1 = mv.getLatLon(0,0);
+        LatLon ll2 = mv.getLatLon(100,0);
+        double dist = ll1.greatCircleDistance(ll2);
+        return dist > 1000 ? (Math.round(dist/100)/10.0)+" km" : Math.round(dist*10)/10+" m";
+    }
+
+    @Override public String getToolTipText() {
+        if(startstop.isSelected())
+            return tr("WMS layer ({0}), automatically downloading in zoom {1}", name, resolution);
+        else
+            return tr("WMS layer ({0}), downloading in zoom {1}", name, resolution);
+    }
+
+    @Override public boolean isMergable(Layer other) {
+        return false;
+    }
+
+    @Override public void mergeFrom(Layer from) {
+    }
+
+    private Bounds XYtoBounds (int x, int y) {
+        return new Bounds(
+            new LatLon( x * ImageSize / pixelPerDegree,
+                         y * ImageSize / pixelPerDegree),
+            new LatLon((x + 1) *  ImageSize / pixelPerDegree,
+                       (y + 1) * ImageSize / pixelPerDegree));
+    }
+
+    private int modulo (int a, int b) {
+      if(a%b>=0)return a%b;
+      else return a%b+b;
+    }
+
+    protected Bounds bounds(){
+        return new Bounds(
+            mv.getLatLon(0, mv.getHeight()),
+            mv.getLatLon(mv.getWidth(), 0));
+    }
+
+    @Override public void paint(Graphics g, final MapView mv) {
+        if(baseURL == null) return;
+
+        if( !startstop.isSelected() || (pixelPerDegree / (mv.getWidth() / (bounds().max.lon() - bounds().min.lon())) > minZoom) ){ //don't download when it's too outzoomed
+            for(int x = 0; x<dax; ++x)
+                for(int y = 0; y<day; ++y)
+                    images[modulo(x,dax)][modulo(y,day)].paint(g, mv, dx, dy);
+        } else
+            downloadAndPaintVisible(g, mv);
+    }
+
+    public void displace(double dx, double dy) {
+        this.dx += dx;
+        this.dy += dy;
+    }
+
+    protected void downloadAndPaintVisible(Graphics g, final MapView mv){
+        int bminx= (int)Math.floor ((bounds().min.lat() * pixelPerDegree ) / ImageSize );
+        int bminy= (int)Math.floor ((bounds().min.lon() * pixelPerDegree ) / ImageSize );
+        int bmaxx= (int)Math.ceil  ((bounds().max.lat() * pixelPerDegree ) / ImageSize );
+        int bmaxy= (int)Math.ceil  ((bounds().max.lon() * pixelPerDegree ) / ImageSize );
+
+        if((bmaxx - bminx > dax) || (bmaxy - bminy > day)){
+            JOptionPane.showMessageDialog(Main.parent, tr("The requested area is too big. Please zoom in a little, or change resolution"));
+            return;
+        }
+
+        for(int x = bminx; x<bmaxx; ++x)
+            for(int y = bminy; y<bmaxy; ++y){
+                GeorefImage img = images[modulo(x,dax)][modulo(y,day)];
+                if(!img.paint(g, mv, dx, dy) && !img.downloadingStarted){
+                    img.downloadingStarted = true;
+                    img.image = null;
+                    Grabber gr = WMSPlugin.getGrabber(baseURL, XYtoBounds(x,y), Main.main.proj, pixelPerDegree, img, mv, this);
+                    executor.submit(gr);
+            }
+        }
+    }
+
+    @Override public void visitBoundingBox(BoundingXYVisitor v) {
+        for(int x = 0; x<dax; ++x)
+            for(int y = 0; y<day; ++y)
+                if(images[x][y].image!=null){
+                    v.visit(images[x][y].min);
+                    v.visit(images[x][y].max);
+                }
+    }
+
+    @Override public Object getInfoComponent() {
+        return getToolTipText();
+    }
+
+    @Override public Component[] getMenuEntries() {
+        return new Component[]{
+                new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
+                new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),
+                new JSeparator(),
+                new JMenuItem(new LoadWmsAction()),
+                new JMenuItem(new SaveWmsAction()),
+                new JSeparator(),
+                startstop,
+                new JMenuItem(new changeResolutionAction()),
+                new JMenuItem(new downloadAction()),
+                new JSeparator(),
+                new JMenuItem(new LayerListPopup.InfoAction(this))
+        };
+    }
+
+    public GeorefImage findImage(EastNorth eastNorth) {
+        for(int x = 0; x<dax; ++x)
+            for(int y = 0; y<day; ++y)
+                    if(images[x][y].image!=null && images[x][y].min!=null && images[x][y].max!=null)
+                        if(images[x][y].contains(eastNorth, dx, dy))
+                            return images[x][y];
+        return null;
+    }
+
+    public class downloadAction extends AbstractAction {
+        public downloadAction() {
+            super(tr("Download visible tiles"));
+        }
+        public void actionPerformed(ActionEvent ev) {
+            downloadAndPaintVisible(mv.getGraphics(), mv);
+        }
+    }
+
+    public class changeResolutionAction extends AbstractAction {
+        public changeResolutionAction() {
+            super(tr("Change resolution"));
+        }
+        public void actionPerformed(ActionEvent ev) {
+            initializeImages();
+            resolution = scale();
+            getPPD();
+            mv.repaint();
+        }
+    }
+
+    public class SaveWmsAction extends AbstractAction {
+        public SaveWmsAction() {
+            super(tr("Save WMS layer to file"), ImageProvider.get("save"));
+        }
+        public void actionPerformed(ActionEvent ev) {
+            File f = openFileDialog(false);
+            try
+            {
+                FileOutputStream fos = new FileOutputStream(f);
+                ObjectOutputStream oos = new ObjectOutputStream(fos);
+                oos.writeInt(serializeFormatVersion);
+                oos.writeInt(dax);
+                oos.writeInt(day);
+                oos.writeInt(ImageSize);
+                oos.writeDouble(pixelPerDegree);
+                oos.writeObject(name);
+                oos.writeObject(baseURL);
+                oos.writeObject(images);
+                oos.close();
+                fos.close();
+            }
+            catch (Exception ex) {
+                ex.printStackTrace(System.out);
+            }
+        }
+    }
+
+    public class LoadWmsAction extends AbstractAction {
+        public LoadWmsAction() {
+            super(tr("Load WMS layer from file"), ImageProvider.get("load"));
+        }
+        public void actionPerformed(ActionEvent ev) {
+            File f = openFileDialog(true);
+            if (f == null) return;
+            try
+            {
+                FileInputStream fis = new FileInputStream(f);
+                ObjectInputStream ois = new ObjectInputStream(fis);
+                int sfv = ois.readInt();
+                if (sfv != serializeFormatVersion) {
+                    JOptionPane.showMessageDialog(Main.parent,
+                        tr("Unsupported WMS file version; found {0}, expected {1}", sfv, serializeFormatVersion),
+                        tr("File Format Error"),
+                        JOptionPane.ERROR_MESSAGE);
+                    return;
+                }
+                startstop.setSelected(false);
+                dax = ois.readInt();
+                day = ois.readInt();
+                ImageSize = ois.readInt();
+                pixelPerDegree = ois.readDouble();
+                name = (String) ois.readObject();
+                baseURL = (String) ois.readObject();
+                images = (GeorefImage[][])ois.readObject();
+                ois.close();
+                fis.close();
+                mv.repaint();
+            }
+            catch (Exception ex) {
+                // FIXME be more specific
+                ex.printStackTrace(System.out);
+                JOptionPane.showMessageDialog(Main.parent,
+                    tr("Error loading file"),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+        }
+    }
+
+    protected static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple) {
+        String curDir = Main.pref.get("lastDirectory");
+        if (curDir.equals(""))
+            curDir = ".";
+        JFileChooser fc = new JFileChooser(new File(curDir));
+        fc.setMultiSelectionEnabled(multiple);
+        for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
+            fc.addChoosableFileFilter(ExtensionFileFilter.filters[i]);
+        fc.setAcceptAllFileFilterUsed(true);
+
+        int answer = open ? fc.showOpenDialog(Main.parent) : fc.showSaveDialog(Main.parent);
+        if (answer != JFileChooser.APPROVE_OPTION)
+            return null;
+
+        if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
+            Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
+
+        if (!open) {
+            File file = fc.getSelectedFile();
+            if (file == null || (file.exists() && JOptionPane.YES_OPTION !=
+                JOptionPane.showConfirmDialog(Main.parent, tr("File exists. Overwrite?"), tr("Overwrite"), JOptionPane.YES_NO_OPTION)))
+                return null;
+        }
+
+        return fc;
+    }
+
+    public static File openFileDialog(boolean open) {
+        JFileChooser fc = createAndOpenFileChooser(open, false);
+        if (fc == null)
+            return null;
+
+        File file = fc.getSelectedFile();
+
+        String fn = file.getPath();
+        if (fn.indexOf('.') == -1) {
+            FileFilter ff = fc.getFileFilter();
+            if (ff instanceof ExtensionFileFilter)
+                fn = "." + ((ExtensionFileFilter)ff).defaultExtension;
+            else
+                fn += ".osm";
+            file = new File(fn);
+        }
+        return file;
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java	(revision 12778)
@@ -39,186 +39,186 @@
 public class WMSPlugin extends Plugin {
 
-	WMSLayer wmsLayer;
-	static JMenu wmsJMenu;
-
-	static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
-	static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>();
-
-	// remember state of menu item to restore on changed preferences
-	static private boolean menuEnabled = false;
-	
-	public WMSPlugin() {
-		try
-		{
-			copy("/resources/ymap.html", "ymap.html");
-		}
-		catch(IOException e) {
-			e.printStackTrace();
-		}
-		refreshMenu();
-	}
-
-	// this parses the preferences settings. preferences for the wms plugin have to
-	// look like this:
-	// wmsplugin.1.name=Landsat
-	// wmsplugin.1.url=http://and.so.on/
-	
-	public void copy(String from, String to) throws FileNotFoundException, IOException
-	{
-		File pluginDir = new File(Main.pref.getPreferencesDir() + "plugins/wmsplugin/");
-		if (!pluginDir.exists())
-			pluginDir.mkdirs();
-		FileOutputStream out = new FileOutputStream(Main.pref.getPreferencesDir() + "plugins/wmsplugin/" + to);
-		InputStream in = WMSPlugin.class.getResourceAsStream(from);
-		byte[] buffer = new byte[8192];
-		for(int len = in.read(buffer); len > 0; len = in.read(buffer))
-			out.write(buffer, 0, len);
-		in.close();
-		out.close();
-	}
-
-	
-	public static void refreshMenu() {
-		wmsList.clear();
-		Map<String,String> prefs = Main.pref.getAllPrefix("wmsplugin.url.");
-		
-		TreeSet<String> keys = new TreeSet<String>(prefs.keySet());
-		int prefid = 0;
-		String name = null;
-		String url = null;
-		int lastid = -1;
-		for (String key : keys) {
-			String[] elements = key.split("\\.");
-			if (elements.length != 4) continue;
-			try {
-				prefid = Integer.parseInt(elements[2]);
-			} catch(NumberFormatException e) {
-				continue;
-			}
-			if (prefid != lastid) {
-				name = url = null; lastid = prefid;
-			}
-			if (elements[3].equals("name"))
-				name = prefs.get(key);
-			else if (elements[3].equals("url"))
-				url = prefs.get(key);
-			if (name != null && url != null)
-				wmsList.add(new WMSInfo(name, url, prefid));
-		}
-		String source = "http://svn.openstreetmap.org/applications/editors/josm/plugins/wmsplugin/sources.cfg";
-		try
-		{
-			MirroredInputStream s = new MirroredInputStream(source,
-			Main.pref.getPreferencesDir() + "plugins/wmsplugin/", -1);
-			InputStreamReader r;
-			try
-			{
-				r = new InputStreamReader(s, "UTF-8");
-			}
-			catch (UnsupportedEncodingException e)
-			{
-				r = new InputStreamReader(s);
-			}
-			BufferedReader reader = new BufferedReader(r);
-			String line;
-			while((line = reader.readLine()) != null)
-			{
-				String val[] = line.split(";");
-				if(!line.startsWith("#") && val.length == 3)
-					setDefault("true".equals(val[0]), tr(val[1]), val[2]);
-			}
-		}
-		catch (IOException e)
-		{
-		}
-
-		Collections.sort(wmsList);
-		MainMenu menu = Main.main.menu;
-
-		if (wmsJMenu == null) {
-			wmsJMenu = new JMenu(tr("WMS"));
-			menu.add(wmsJMenu, KeyEvent.VK_W, "wms");
-			menu.add(wmsJMenu, 5);
-		} else {
-			wmsJMenu.removeAll();
-		}
-		
-		// for each configured WMSInfo, add a menu entry.
-		for (final WMSInfo u : wmsList) {
-			wmsJMenu.add(new JMenuItem(new WMSDownloadAction(u)));
-		}
-		wmsJMenu.addSeparator();
-		wmsJMenu.add(new JMenuItem(new Map_Rectifier_WMSmenuAction()));
-		
-		wmsJMenu.addSeparator();
-		wmsJMenu.add(new JMenuItem(new 
-				JosmAction(tr("Blank Layer"), "blankmenu", tr("Open a blank WMS layer to load data from a file"), null, false) {
-			public void actionPerformed(ActionEvent ev) {
-				Main.main.addLayer(new WMSLayer());
-			}
-		}));
-		wmsJMenu.addSeparator();
-		wmsJMenu.add(new JMenuItem(new Help_WMSmenuAction()));
-		setEnabledAll(menuEnabled);
-	}
-
-	/* add a default entry in case the URL does not yet exist */
-	private static void setDefault(Boolean force, String name, String url)
-	{
-		String testurl = url.replaceAll("=", "_");
-		wmsListDefault.put(name, url);
-
-		if(force && !Main.pref.getBoolean("wmsplugin.default."+testurl))
-		{
-			Main.pref.put("wmsplugin.default."+testurl, true);
-			int id = -1;
-			for(WMSInfo i : wmsList)
-			{
-				if(url.equals(i.url))
-					return;
-				if(i.prefid > id)
-					id = i.prefid;
-			}
-			WMSInfo newinfo = new WMSInfo(name, url, id+1);
-			newinfo.save();
-			wmsList.add(newinfo);
-		}
-	}
-
-	public static Grabber getGrabber(String _baseURL, Bounds _b, Projection _proj,
-			         double _pixelPerDegree, GeorefImage _image, MapView _mv, WMSLayer _layer){
-		if(_baseURL.startsWith("yahoo://"))
-			return new YAHOOGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer);
-		else 
-			return new WMSGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer);
-		// OSBGrabber should be rewrite for thread support first
-		//if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){
-		//	return new OSGBGrabber(_b, _proj, _pixelPerDegree,  _images, _mv, _layer);
-		//} else {
-		//	return new WMSGrabber(_b, _proj, _pixelPerDegree,  _images, _mv, _layer);
-		//}
-	}
-	
-	private static void setEnabledAll(boolean isEnabled) {
-		for(int i=0; i < wmsJMenu.getItemCount(); i++) {
-			JMenuItem item = wmsJMenu.getItem(i);
-			
-			if(item != null) item.setEnabled(isEnabled);
-		}
+    WMSLayer wmsLayer;
+    static JMenu wmsJMenu;
+
+    static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
+    static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>();
+
+    // remember state of menu item to restore on changed preferences
+    static private boolean menuEnabled = false;
+
+    public WMSPlugin() {
+        try
+        {
+            copy("/resources/ymap.html", "ymap.html");
+        }
+        catch(IOException e) {
+            e.printStackTrace();
+        }
+        refreshMenu();
+    }
+
+    // this parses the preferences settings. preferences for the wms plugin have to
+    // look like this:
+    // wmsplugin.1.name=Landsat
+    // wmsplugin.1.url=http://and.so.on/
+
+    public void copy(String from, String to) throws FileNotFoundException, IOException
+    {
+        File pluginDir = new File(Main.pref.getPreferencesDir() + "plugins/wmsplugin/");
+        if (!pluginDir.exists())
+            pluginDir.mkdirs();
+        FileOutputStream out = new FileOutputStream(Main.pref.getPreferencesDir() + "plugins/wmsplugin/" + to);
+        InputStream in = WMSPlugin.class.getResourceAsStream(from);
+        byte[] buffer = new byte[8192];
+        for(int len = in.read(buffer); len > 0; len = in.read(buffer))
+            out.write(buffer, 0, len);
+        in.close();
+        out.close();
+    }
+
+
+    public static void refreshMenu() {
+        wmsList.clear();
+        Map<String,String> prefs = Main.pref.getAllPrefix("wmsplugin.url.");
+
+        TreeSet<String> keys = new TreeSet<String>(prefs.keySet());
+        int prefid = 0;
+        String name = null;
+        String url = null;
+        int lastid = -1;
+        for (String key : keys) {
+            String[] elements = key.split("\\.");
+            if (elements.length != 4) continue;
+            try {
+                prefid = Integer.parseInt(elements[2]);
+            } catch(NumberFormatException e) {
+                continue;
+            }
+            if (prefid != lastid) {
+                name = url = null; lastid = prefid;
+            }
+            if (elements[3].equals("name"))
+                name = prefs.get(key);
+            else if (elements[3].equals("url"))
+                url = prefs.get(key);
+            if (name != null && url != null)
+                wmsList.add(new WMSInfo(name, url, prefid));
+        }
+        String source = "http://svn.openstreetmap.org/applications/editors/josm/plugins/wmsplugin/sources.cfg";
+        try
+        {
+            MirroredInputStream s = new MirroredInputStream(source,
+            Main.pref.getPreferencesDir() + "plugins/wmsplugin/", -1);
+            InputStreamReader r;
+            try
+            {
+                r = new InputStreamReader(s, "UTF-8");
+            }
+            catch (UnsupportedEncodingException e)
+            {
+                r = new InputStreamReader(s);
+            }
+            BufferedReader reader = new BufferedReader(r);
+            String line;
+            while((line = reader.readLine()) != null)
+            {
+                String val[] = line.split(";");
+                if(!line.startsWith("#") && val.length == 3)
+                    setDefault("true".equals(val[0]), tr(val[1]), val[2]);
+            }
+        }
+        catch (IOException e)
+        {
+        }
+
+        Collections.sort(wmsList);
+        MainMenu menu = Main.main.menu;
+
+        if (wmsJMenu == null) {
+            wmsJMenu = new JMenu(tr("WMS"));
+            menu.add(wmsJMenu, KeyEvent.VK_W, "wms");
+            menu.add(wmsJMenu, 5);
+        } else {
+            wmsJMenu.removeAll();
+        }
+
+        // for each configured WMSInfo, add a menu entry.
+        for (final WMSInfo u : wmsList) {
+            wmsJMenu.add(new JMenuItem(new WMSDownloadAction(u)));
+        }
+        wmsJMenu.addSeparator();
+        wmsJMenu.add(new JMenuItem(new Map_Rectifier_WMSmenuAction()));
+
+        wmsJMenu.addSeparator();
+        wmsJMenu.add(new JMenuItem(new
+                JosmAction(tr("Blank Layer"), "blankmenu", tr("Open a blank WMS layer to load data from a file"), null, false) {
+            public void actionPerformed(ActionEvent ev) {
+                Main.main.addLayer(new WMSLayer());
+            }
+        }));
+        wmsJMenu.addSeparator();
+        wmsJMenu.add(new JMenuItem(new Help_WMSmenuAction()));
+        setEnabledAll(menuEnabled);
+    }
+
+    /* add a default entry in case the URL does not yet exist */
+    private static void setDefault(Boolean force, String name, String url)
+    {
+        String testurl = url.replaceAll("=", "_");
+        wmsListDefault.put(name, url);
+
+        if(force && !Main.pref.getBoolean("wmsplugin.default."+testurl))
+        {
+            Main.pref.put("wmsplugin.default."+testurl, true);
+            int id = -1;
+            for(WMSInfo i : wmsList)
+            {
+                if(url.equals(i.url))
+                    return;
+                if(i.prefid > id)
+                    id = i.prefid;
+            }
+            WMSInfo newinfo = new WMSInfo(name, url, id+1);
+            newinfo.save();
+            wmsList.add(newinfo);
+        }
+    }
+
+    public static Grabber getGrabber(String _baseURL, Bounds _b, Projection _proj,
+                     double _pixelPerDegree, GeorefImage _image, MapView _mv, WMSLayer _layer){
+        if(_baseURL.startsWith("yahoo://"))
+            return new YAHOOGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer);
+        else
+            return new WMSGrabber(_baseURL, _b, _proj, _pixelPerDegree, _image, _mv, _layer);
+        // OSBGrabber should be rewrite for thread support first
+        //if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") ){
+        //  return new OSGBGrabber(_b, _proj, _pixelPerDegree,  _images, _mv, _layer);
+        //} else {
+        //  return new WMSGrabber(_b, _proj, _pixelPerDegree,  _images, _mv, _layer);
+        //}
+    }
+
+    private static void setEnabledAll(boolean isEnabled) {
+        for(int i=0; i < wmsJMenu.getItemCount(); i++) {
+            JMenuItem item = wmsJMenu.getItem(i);
+
+            if(item != null) item.setEnabled(isEnabled);
+        }
                menuEnabled = isEnabled;
-	}
-	
-	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-		if (oldFrame==null && newFrame!=null) { 
-			setEnabledAll(true);
-			Main.map.addMapMode(new IconToggleButton
-						(new WMSAdjustAction(Main.map)));
-		} else if (oldFrame!=null && newFrame==null ) {
-			setEnabledAll(false);
-		}
-	}
-	
-	public PreferenceSetting getPreferenceSetting() {
-		return new WMSPreferenceEditor();
-	}
+    }
+
+    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+        if (oldFrame==null && newFrame!=null) {
+            setEnabledAll(true);
+            Main.map.addMapMode(new IconToggleButton
+                        (new WMSAdjustAction(Main.map)));
+        } else if (oldFrame!=null && newFrame==null ) {
+            setEnabledAll(false);
+        }
+    }
+
+    public PreferenceSetting getPreferenceSetting() {
+        return new WMSPreferenceEditor();
+    }
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java	(revision 12778)
@@ -27,128 +27,128 @@
 
 public class WMSPreferenceEditor implements PreferenceSetting {
-	
-	private Map<String,String> orig;
-	private DefaultTableModel model;
-	private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
 
-	public void addGui(final PreferenceDialog gui) {
-		JPanel p = gui.createPreferenceTab("wms", tr("WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS plugin menu"));
-		
-		model = new DefaultTableModel(new String[]{tr("Menu Name"), tr("WMS URL")}, 0);
-		final JTable list = new JTable(model);
-		JScrollPane scroll = new JScrollPane(list);
-		p.add(scroll, GBC.eol().fill(GBC.BOTH));
-		scroll.setPreferredSize(new Dimension(200,200));
-		
-		for (WMSInfo i : WMSPlugin.wmsList) {
-			oldValues.put(i.prefid, i);
-			model.addRow(new String[]{i.name, i.url});
-		}
+    private Map<String,String> orig;
+    private DefaultTableModel model;
+    private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
 
-		final DefaultTableModel modeldef = new DefaultTableModel(
-		new String[]{tr("Menu Name (Default)"), tr("WMS URL (Default)")}, 0);
-		final JTable listdef = new JTable(modeldef){
-			public boolean isCellEditable(int row,int column){return false;}
-		};;
-		JScrollPane scrolldef = new JScrollPane(listdef);
-		p.add(scrolldef, GBC.eol().insets(0,5,0,0).fill(GBC.BOTH));
-		scrolldef.setPreferredSize(new Dimension(200,200));
+    public void addGui(final PreferenceDialog gui) {
+        JPanel p = gui.createPreferenceTab("wms", tr("WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS plugin menu"));
 
-		for (Map.Entry<String,String> i : WMSPlugin.wmsListDefault.entrySet()) {
-			modeldef.addRow(new String[]{i.getKey(), i.getValue()});
-		}
+        model = new DefaultTableModel(new String[]{tr("Menu Name"), tr("WMS URL")}, 0);
+        final JTable list = new JTable(model);
+        JScrollPane scroll = new JScrollPane(list);
+        p.add(scroll, GBC.eol().fill(GBC.BOTH));
+        scroll.setPreferredSize(new Dimension(200,200));
 
-		JButton add = new JButton(tr("Add"));
-		p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
-		p.add(add, GBC.std().insets(0,5,0,0));
-		add.addActionListener(new ActionListener(){
-			public void actionPerformed(ActionEvent e) {
-				JPanel p = new JPanel(new GridBagLayout());
-				p.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
-				JTextField key = new JTextField(10);
-				JTextField value = new JTextField(10);
-				p.add(key, GBC.eop().insets(5,0,0,0).fill(GBC.HORIZONTAL));
-				p.add(new JLabel(tr("WMS URL")), GBC.std().insets(0,0,5,0));
-				p.add(value, GBC.eol().insets(5,0,0,0).fill(GBC.HORIZONTAL));
-				int answer = JOptionPane.showConfirmDialog(gui, p, tr("Enter a menu name and WMS URL"), JOptionPane.OK_CANCEL_OPTION);
-				if (answer == JOptionPane.OK_OPTION) {
-					model.addRow(new String[]{key.getText(), value.getText()});
-				}
-			}
-		});
+        for (WMSInfo i : WMSPlugin.wmsList) {
+            oldValues.put(i.prefid, i);
+            model.addRow(new String[]{i.name, i.url});
+        }
 
-		JButton delete = new JButton(tr("Delete"));
-		p.add(delete, GBC.std().insets(0,5,0,0));
-		delete.addActionListener(new ActionListener(){
-			public void actionPerformed(ActionEvent e) {
-				if (list.getSelectedRow() == -1)
-					JOptionPane.showMessageDialog(gui, tr("Please select the row to delete."));
-				else
-				{
-					Integer i;
-					while ((i = list.getSelectedRow()) != -1)
-						model.removeRow(i);
-				}
-			}
-		});
-		
-		JButton copy = new JButton(tr("Copy Default"));
-		p.add(copy, GBC.std().insets(0,5,0,0));
-		copy.addActionListener(new ActionListener(){
-			public void actionPerformed(ActionEvent e) {
-				Integer line = listdef.getSelectedRow();
-				if (line == -1)
-					JOptionPane.showMessageDialog(gui, tr("Please select the row to copy."));
-				else
-				{
-					model.addRow(new String[]{modeldef.getValueAt(line, 0).toString(),
-					modeldef.getValueAt(line, 1).toString()});
-				}
-			}
-		});
-	}
-	
-	public boolean ok() {
-		boolean change = false;
-		for (int i = 0; i < model.getRowCount(); ++i) {
-			String name = model.getValueAt(i,0).toString();
-			String url = model.getValueAt(i,1).toString();
+        final DefaultTableModel modeldef = new DefaultTableModel(
+        new String[]{tr("Menu Name (Default)"), tr("WMS URL (Default)")}, 0);
+        final JTable listdef = new JTable(modeldef){
+            public boolean isCellEditable(int row,int column){return false;}
+        };;
+        JScrollPane scrolldef = new JScrollPane(listdef);
+        p.add(scrolldef, GBC.eol().insets(0,5,0,0).fill(GBC.BOTH));
+        scrolldef.setPreferredSize(new Dimension(200,200));
 
-			WMSInfo origValue = oldValues.get(i);
-			if (origValue == null)
-			{
-				new WMSInfo(name, url, i).save();
-				change = true;
-			}
-			else
-			{
-				if (!origValue.name.equals(name) || !origValue.url.equals(url))
-				{
-					origValue.name = name; 
-					origValue.url = url;
-					origValue.save();
-					change = true;
-				}
-				oldValues.remove(i);
-			}
-		}
-		
-		// using null values instead of empty string really deletes
-		// the preferences entry
-		for (WMSInfo i : oldValues.values())
-		{
-			i.url = null;
-			i.name = null;
-			i.save();
-			change = true;
-		}
+        for (Map.Entry<String,String> i : WMSPlugin.wmsListDefault.entrySet()) {
+            modeldef.addRow(new String[]{i.getKey(), i.getValue()});
+        }
 
-		if (change) WMSPlugin.refreshMenu();
-		return false;
-	}
-	
+        JButton add = new JButton(tr("Add"));
+        p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
+        p.add(add, GBC.std().insets(0,5,0,0));
+        add.addActionListener(new ActionListener(){
+            public void actionPerformed(ActionEvent e) {
+                JPanel p = new JPanel(new GridBagLayout());
+                p.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
+                JTextField key = new JTextField(10);
+                JTextField value = new JTextField(10);
+                p.add(key, GBC.eop().insets(5,0,0,0).fill(GBC.HORIZONTAL));
+                p.add(new JLabel(tr("WMS URL")), GBC.std().insets(0,0,5,0));
+                p.add(value, GBC.eol().insets(5,0,0,0).fill(GBC.HORIZONTAL));
+                int answer = JOptionPane.showConfirmDialog(gui, p, tr("Enter a menu name and WMS URL"), JOptionPane.OK_CANCEL_OPTION);
+                if (answer == JOptionPane.OK_OPTION) {
+                    model.addRow(new String[]{key.getText(), value.getText()});
+                }
+            }
+        });
+
+        JButton delete = new JButton(tr("Delete"));
+        p.add(delete, GBC.std().insets(0,5,0,0));
+        delete.addActionListener(new ActionListener(){
+            public void actionPerformed(ActionEvent e) {
+                if (list.getSelectedRow() == -1)
+                    JOptionPane.showMessageDialog(gui, tr("Please select the row to delete."));
+                else
+                {
+                    Integer i;
+                    while ((i = list.getSelectedRow()) != -1)
+                        model.removeRow(i);
+                }
+            }
+        });
+
+        JButton copy = new JButton(tr("Copy Default"));
+        p.add(copy, GBC.std().insets(0,5,0,0));
+        copy.addActionListener(new ActionListener(){
+            public void actionPerformed(ActionEvent e) {
+                Integer line = listdef.getSelectedRow();
+                if (line == -1)
+                    JOptionPane.showMessageDialog(gui, tr("Please select the row to copy."));
+                else
+                {
+                    model.addRow(new String[]{modeldef.getValueAt(line, 0).toString(),
+                    modeldef.getValueAt(line, 1).toString()});
+                }
+            }
+        });
+    }
+
+    public boolean ok() {
+        boolean change = false;
+        for (int i = 0; i < model.getRowCount(); ++i) {
+            String name = model.getValueAt(i,0).toString();
+            String url = model.getValueAt(i,1).toString();
+
+            WMSInfo origValue = oldValues.get(i);
+            if (origValue == null)
+            {
+                new WMSInfo(name, url, i).save();
+                change = true;
+            }
+            else
+            {
+                if (!origValue.name.equals(name) || !origValue.url.equals(url))
+                {
+                    origValue.name = name;
+                    origValue.url = url;
+                    origValue.save();
+                    change = true;
+                }
+                oldValues.remove(i);
+            }
+        }
+
+        // using null values instead of empty string really deletes
+        // the preferences entry
+        for (WMSInfo i : oldValues.values())
+        {
+            i.url = null;
+            i.name = null;
+            i.save();
+            change = true;
+        }
+
+        if (change) WMSPlugin.refreshMenu();
+        return false;
+    }
+
     /**
      * Updates a server URL in the preferences dialog. Used by other plugins.
-     * 
+     *
      * @param server The server name
      * @param url The server URL
@@ -156,5 +156,5 @@
     public void setServerUrl(String server, String url)
     {
-        for (int i = 0; i < model.getRowCount(); i++) 
+        for (int i = 0; i < model.getRowCount(); i++)
         {
             if( server.equals(model.getValueAt(i,0).toString()) )
@@ -175,5 +175,5 @@
     public String getServerUrl(String server)
     {
-        for (int i = 0; i < model.getRowCount(); i++) 
+        for (int i = 0; i < model.getRowCount(); i++)
         {
             if( server.equals(model.getValueAt(i,0).toString()) )
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java	(revision 12707)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java	(revision 12778)
@@ -20,35 +20,35 @@
 
 public class YAHOOGrabber extends WMSGrabber{
-	protected String browserCmd;
+    protected String browserCmd;
 
-	YAHOOGrabber(String baseURL, Bounds b, Projection proj,
-			double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
-		super("file:///" + Main.pref.getPreferencesDir() + "plugins/wmsplugin/ymap.html?"
+    YAHOOGrabber(String baseURL, Bounds b, Projection proj,
+            double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
+        super("file:///" + Main.pref.getPreferencesDir() + "plugins/wmsplugin/ymap.html?"
 //                + "request=getmap&format=image/jpeg"
-		, b, proj, pixelPerDegree, image, mv, layer);
-		this.browserCmd = baseURL.replaceFirst("yahoo://", "");
-	}
+        , b, proj, pixelPerDegree, image, mv, layer);
+        this.browserCmd = baseURL.replaceFirst("yahoo://", "");
+    }
 
-	protected BufferedImage grab(URL url) throws IOException {
-		ArrayList<String> cmdParams = new ArrayList<String>();
-		String urlstring = url.toExternalForm();
-		// work around a problem in URL removing 2 slashes
-		if(!urlstring.startsWith("file:///"))
-			urlstring = urlstring.replaceFirst("file:", "file://");
-		StringTokenizer st = new StringTokenizer(MessageFormat.format(browserCmd, urlstring));
-		while( st.hasMoreTokens() )
-			cmdParams.add(st.nextToken());
+    protected BufferedImage grab(URL url) throws IOException {
+        ArrayList<String> cmdParams = new ArrayList<String>();
+        String urlstring = url.toExternalForm();
+        // work around a problem in URL removing 2 slashes
+        if(!urlstring.startsWith("file:///"))
+            urlstring = urlstring.replaceFirst("file:", "file://");
+        StringTokenizer st = new StringTokenizer(MessageFormat.format(browserCmd, urlstring));
+        while( st.hasMoreTokens() )
+            cmdParams.add(st.nextToken());
 
-		System.out.println("WMS::Browsing YAHOO: " + cmdParams);
-		ProcessBuilder builder = new ProcessBuilder( cmdParams);
+        System.out.println("WMS::Browsing YAHOO: " + cmdParams);
+        ProcessBuilder builder = new ProcessBuilder( cmdParams);
 
-		Process browser;
-		try {
-			browser = builder.start();
-		} catch(IOException ioe) {
-			throw new IOException( "Could not start browser. Please check that the executable path is correct.\n" + ioe.getMessage() );
-		}
+        Process browser;
+        try {
+            browser = builder.start();
+        } catch(IOException ioe) {
+            throw new IOException( "Could not start browser. Please check that the executable path is correct.\n" + ioe.getMessage() );
+        }
 
-		return ImageIO.read(browser.getInputStream());
-	}
+        return ImageIO.read(browser.getInputStream());
+    }
 }
