Index: /applications/editors/josm/plugins/build.xml
===================================================================
--- /applications/editors/josm/plugins/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/build.xml	(revision 15707)
@@ -37,4 +37,5 @@
         <ant antfile="build.xml" target="dist" dir="utilsplugin"/>
         <ant antfile="build.xml" target="dist" dir="validator"/>
+        <ant antfile="build.xml" target="dist" dir="waydownloader"/>
         <ant antfile="build.xml" target="dist" dir="wmsplugin"/>
     </target>
@@ -76,4 +77,5 @@
         <ant antfile="build.xml" target="clean" dir="utilsplugin"/>
         <ant antfile="build.xml" target="clean" dir="validator"/>
+        <ant antfile="build.xml" target="clean" dir="waydownloader"/>
         <ant antfile="build.xml" target="clean" dir="wmsplugin"/>
     </target>
Index: /applications/editors/josm/plugins/cadastre-fr/build.xml
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/cadastre-fr/build.xml	(revision 15707)
@@ -26,5 +26,5 @@
                 <attribute name="Plugin-Description" value="A special handler for the french land registry WMS server."/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/Cadastre"/>
-                <attribute name="Plugin-Mainversion" value="1498"/>
+                <attribute name="Plugin-Mainversion" value="1646"/>
                 <attribute name="Plugin-Stage" value="60"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 15706)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 15707)
@@ -25,8 +25,7 @@
 import javax.swing.JOptionPane;
 import javax.swing.JSeparator;
-import javax.swing.filechooser.FileFilter;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.ExtensionFileFilter;
+import org.openstreetmap.josm.actions.DiskAccessAction;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.data.projection.Lambert;
@@ -46,5 +45,5 @@
 public class WMSLayer extends Layer {
 
-    Component[] component = null;  
+    Component[] component = null;
 
     public int lambertZone = -1;
@@ -54,23 +53,23 @@
 
     protected ArrayList<GeorefImage> images = new ArrayList<GeorefImage>();
-    
+
     protected final int serializeFormatVersion = 2;
-    
+
     private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>();
-    
+
     private CacheControl cacheControl = null;
-    
+
     private String location = "";
 
     private String codeCommune = "";
-    
+
     private EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0));
-    
+
     private boolean isRaster = false;
-    
+
     private EastNorth rasterMin;
-    
+
     private EastNorth rasterCenter;
-    
+
     private double rasterRatio;
 
@@ -81,5 +80,5 @@
         this(tr("Blank Layer"), "", -1);
     }
-    
+
     public WMSLayer(String location, String codeCommune, int lambertZone) {
         super(buildName(location, codeCommune));
@@ -90,5 +89,5 @@
         CadastrePlugin.pluginUsed = true;
     }
-    
+
     private static String buildName(String location, String codeCommune) {
         String ret = new String(location.toUpperCase());
@@ -138,5 +137,5 @@
 
     /**
-     * 
+     *
      * @param b      the original bbox, usually the current bbox on screen
      * @param factor 1 = source bbox 1:1
@@ -202,5 +201,5 @@
     public void paint(Graphics g, final MapView mv) {
         for (GeorefImage img : images)
-            img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent, 
+            img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent,
                     CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
     }
@@ -244,7 +243,7 @@
         return null;
     }
-    
+
     public boolean isOverlapping(Bounds bounds) {
-        GeorefImage georefImage = 
+        GeorefImage georefImage =
             new GeorefImage(new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB ), // not really important
             Main.proj.latlon2eastNorth(bounds.min),
@@ -262,5 +261,5 @@
         }
     }
-    
+
     public void saveNewCache() {
         if (CacheControl.cacheEnabled) {
@@ -270,5 +269,5 @@
         }
     }
-    
+
     public CacheControl getCacheControl() {
         if (cacheControl == null)
@@ -276,5 +275,5 @@
         return cacheControl;
     }
-    
+
     public class SaveWmsAction extends AbstractAction {
         private static final long serialVersionUID = 1L;
@@ -285,5 +284,6 @@
 
         public void actionPerformed(ActionEvent ev) {
-            File f = openFileDialog(false);
+            File f = DiskAccessAction.createAndOpenSaveFileChooser(
+            tr("Save WMS layer"), ".wms");
             try {
                 FileOutputStream fos = new FileOutputStream(f);
@@ -311,7 +311,9 @@
 
         public void actionPerformed(ActionEvent ev) {
-            File f = openFileDialog(true);
-            if (f == null)
-                return;
+            JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true,
+            false, tr("Load WMS layer"));
+            if(fc == null) return;
+            File f = fc.getSelectedFile();
+            if (f == null) return;
             try {
                 FileInputStream fis = new FileInputStream(f);
@@ -342,51 +344,4 @@
     }
 
-    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;
-    }
-
     /**
      * Convert the eastNorth input coordinates to raster coordinates.
@@ -434,5 +389,5 @@
     /**
      * Set the eastNorth position in rasterMin which is the 0,0 coordinate (bottom left corner).
-     * The bounds width is the raster width and height is calculate on a fixed image ratio. 
+     * The bounds width is the raster width and height is calculate on a fixed image ratio.
      * @param bounds
      */
@@ -470,5 +425,5 @@
             img.resize(rasterCenter, proportion);
     }
-    
+
     public void rotate(double angle) {
         this.rasterMin = rasterMin.rotate(rasterCenter, angle);
@@ -476,5 +431,5 @@
             img.rotate(rasterCenter, angle);
     }
-    
+
     /**
      * Repaint the LayerList dialog.
@@ -491,5 +446,5 @@
         }
     }
-    
+
     /**
      * Called by CacheControl when a new cache file is created on disk
@@ -503,5 +458,5 @@
         oos.writeInt(this.lambertZone);
         oos.writeBoolean(this.isRaster);
-        if (this.isRaster) { 
+        if (this.isRaster) {
             oos.writeObject(this.rasterMin);
             oos.writeObject(this.rasterCenter);
@@ -514,5 +469,5 @@
         }
     }
-    
+
     /**
      * Called by CacheControl when a cache file is read from disk
@@ -532,5 +487,5 @@
         this.lambertZone = ois.readInt();
         this.isRaster = ois.readBoolean();
-        if (this.isRaster) { 
+        if (this.isRaster) {
             this.rasterMin = (EastNorth) ois.readObject();
             this.rasterCenter = (EastNorth) ois.readObject();
Index: /applications/editors/josm/plugins/czechaddress/build.xml
===================================================================
--- /applications/editors/josm/plugins/czechaddress/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/czechaddress/build.xml	(revision 15707)
@@ -1,102 +1,56 @@
 <project name="czechaddress" default="dist" basedir=".">
-    <property name="josm.base"              value="../../core"/>
-    <property name="josm.jar"               value="${josm.base}/dist/josm-custom.jar"/>
-    <property name="josm.doc.dir"           value="${josm.base}/doc"/>
+    <property name="josm"                   location="../../core/dist/josm-custom.jar"/>
     <property name="plugin.dist.dir"        value="../../dist"/>
     <property name="plugin.build.dir"       value="build"/>
-    <property name="plugin.javadoc.dir"     value="doc"/>
-    <property name="plugin.basepackage"     value="org.openstreetmap.josm.plugins.czechaddress"/>
-    <property name="plugin.basepackage.dir" value="org/openstreetmap/josm/plugins/czechaddress"/>
     <property name="plugin.jar"             value="${plugin.dist.dir}/${ant.project.name}.jar"/>
     <property name="ant.build.javac.target" value="1.5"/>
-
-    <target name="clean">
-        <delete dir="${plugin.build.dir}"/> 
-        <delete dir="${plugin.jar}"/> 
-    </target>
     <target name="init">
         <mkdir dir="${plugin.build.dir}"/>
-        <mkdir dir="${plugin.build.dir}"/>
     </target>
-
-    <target name="compile"
-            depends="init"
-            description="Compile the plugin">
-                
-        <!-- compile the plugin -->
-        <javac srcdir="src"
-               classpath="${josm.jar}"
-               destdir="${plugin.build.dir}"
-               debug="true"/>
-
-        <!-- create the manifest -->
-        <manifest file="${plugin.build.dir}/${plugin.basepackage.dir}/MANIFEST.MF">
-            <attribute name="Author" value="Radomír Černoch"/>
-            <attribute name="Plugin-Description" value="Creating and handling address nodes and buildings within Czech Republic."/>
-            <attribute name="Plugin-Mainversion" value="1607"/>
-            <attribute name="Plugin-Version" value="0.2.0"/>
-            <attribute name="Plugin-Class" value="${plugin.basepackage}.CzechAddressPlugin"/>
-        </manifest>
-
-        <!-- include the images -->
+    <target name="compile" depends="init">
+        <echo message="creating ${plugin.jar}"/>
+        <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
+            <compilerarg value="-Xlint:deprecation"/>
+            <compilerarg value="-Xlint:unchecked"/>
+        </javac>
+    </target>
+    <target name="dist" depends="compile,revision">
         <copy todir="${plugin.build.dir}/images">
             <fileset dir="images"/>
         </copy>
+        <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
+          <manifest>
+                <attribute name="Author" value="Radomír Černoch"/>
+                <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.czechaddress.CzechAddressPlugin"/>
+                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
+                <attribute name="Plugin-Description" value="Creating and handling address nodes and buildings within Czech Republic."/>
+                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/SlippyMap"/>
+                <attribute name="Plugin-Mainversion" value="1607"/>
+                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
+            </manifest>
+        </jar>
     </target>
-
-    <target name="dist"
-            depends="compile"
-            description="Create the .jar file for distribution">
-        <mkdir dir="${plugin.dist.dir}"/>
-        <jar destfile="${plugin.jar}"
-             basedir="${plugin.build.dir}"
-             manifest="${plugin.build.dir}/${plugin.basepackage.dir}/MANIFEST.MF"/>
+    <target name="revision">
+        <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
+            <env key="LANG" value="C"/>
+            <arg value="info"/>
+            <arg value="--xml"/>
+            <arg value="."/>
+        </exec>
+        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
+        <delete file="REVISION"/>
     </target>
-
-    <target name="doc" description="Create Javadoc API documentation">
-        <!--<ant antfile="build.xml" target="doc" dir="${josm.base}"/>-->
-        <mkdir dir="${plugin.javadoc.dir}"/>
-        <javadoc sourcepath="src"
-                 packagenames="*"
-                 destdir="${plugin.javadoc.dir}"
-                 use="true"
-                 charset="UTF-8">
-            <doctitle><![CDATA[Czech Address JOSM plugin]]></doctitle>
-            <bottom><![CDATA[<i>Licenced under GPLv3. Bugreports should be sent to
-                    <a href='mailto:radomir.cernoch@gmail.com'>Radomír Černoch</a></i>]]>
-            </bottom>
-            <!--<tag name="todo" scope="all" description="To do:"/>-->
-            <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
-            <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
-            <!--<link href="file://${user.home}/devel/core/doc"/>-->
-        </javadoc>
+    <target name="clean">
+        <delete dir="${plugin.build.dir}"/>
+        <delete file="${plugin.jar}"/>
     </target>
-
     <target name="install" depends="dist">
         <property environment="env"/>
-        <condition property="josm.plugins.dir"
-                   value="${env.APPDATA}/JOSM/plugins"
-                   else="${user.home}/.josm/plugins">
-            <and><os family="windows"/></and>
+        <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
+            <and>
+                <os family="windows"/>
+            </and>
         </condition>
         <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
     </target>
-
-    <!-- Before running "run" target, please "ant dist" the JOSM. -->
-    <target name="run" depends="compile">
-        <java classname="JOSM" fork="true">
-            <jvmarg value="-Xmx1024m"/>
-            <jvmarg value="-Xdebug"/>
-            <jvmarg value="-ea"/>
-            <classpath>
-                <pathelement location="${plugin.build.dir}"/>
-                <pathelement path="${java.class.path}"/>
-            </classpath>
-            <classpath>
-                <pathelement location="${josm.jar}"/>
-                <pathelement path="${java.class.path}"/>
-            </classpath>
-        </java>
-    </target>
-
 </project>
Index: /applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java
===================================================================
--- /applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java	(revision 15706)
+++ /applications/editors/josm/plugins/openlayers/src/org/openstreetmap/josm/plugins/openLayers/OpenLayersLayer.java	(revision 15707)
@@ -80,5 +80,5 @@
             new JSeparator(),
             // color,
-            new JMenuItem(new RenameLayerAction(associatedFile, this)),
+            new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
             new JSeparator(),
             new JMenuItem(new LayerListPopup.InfoAction(this)) };
Index: /applications/editors/josm/plugins/openvisible/build.xml
===================================================================
--- /applications/editors/josm/plugins/openvisible/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/openvisible/build.xml	(revision 15707)
@@ -26,5 +26,5 @@
                 <attribute name="Plugin-Dependencies" value="jgrapht-jdk1.5"/>
                 <attribute name="Plugin-Description" value="Allows opening gpx/osm files that intersect the currently visible screen area"/>
-                <attribute name="Plugin-Mainversion" value="1465"/>
+                <attribute name="Plugin-Mainversion" value="1646"/>
                 <attribute name="Plugin-Stage" value="50"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
Index: /applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible/OpenVisibleAction.java
===================================================================
--- /applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible/OpenVisibleAction.java	(revision 15706)
+++ /applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible/OpenVisibleAction.java	(revision 15707)
@@ -29,5 +29,7 @@
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
+import org.openstreetmap.josm.io.GpxImporter;
 import org.openstreetmap.josm.io.GpxReader;
+import org.openstreetmap.josm.io.OsmImporter;
 import org.openstreetmap.josm.io.OsmReader;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -100,16 +102,16 @@
     private void openAsData(File file) throws SAXException, IOException, FileNotFoundException {
         String fn = file.getName();
-        if (ExtensionFileFilter.filters[ExtensionFileFilter.OSM].acceptName(fn)) {
+        if (new OsmImporter().acceptFile(file)) {
             DataSet dataSet = OsmReader.parseDataSet(new FileInputStream(file), null, Main.pleaseWaitDlg);
-            OsmDataLayer layer = new OsmDataLayer(dataSet, file.getName(), file);
+            OsmDataLayer layer = new OsmDataLayer(dataSet, fn, file);
             Main.main.addLayer(layer);
         }
         else
-            JOptionPane.showMessageDialog(Main.parent, fn+": "+tr("Unknown file extension: {0}", fn.substring(file.getName().lastIndexOf('.')+1)));
+            JOptionPane.showMessageDialog(Main.parent, fn+": "+tr("Unknown file extension: {0}", fn.substring(fn.lastIndexOf('.')+1)));
     }
 
     private void openFileAsGpx(File file) throws SAXException, IOException, FileNotFoundException {
         String fn = file.getName();
-        if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(fn)) {
+        if (new GpxImporter().acceptFile(file)) {
             GpxReader r = null;
             if (file.getName().endsWith(".gpx.gz")) {
Index: /applications/editors/josm/plugins/routing/build.xml
===================================================================
--- /applications/editors/josm/plugins/routing/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/routing/build.xml	(revision 15707)
@@ -44,5 +44,5 @@
                 <attribute name="Plugin-Description" value="Provides routing capabilities."/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/Routing"/>
-                <attribute name="Plugin-Mainversion" value="1510"/>
+                <attribute name="Plugin-Mainversion" value="1646"/>
                 <attribute name="Plugin-Stage" value="50"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/EdgeIterator.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/EdgeIterator.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/EdgeIterator.java	(revision 15707)
@@ -3,7 +3,7 @@
 public interface EdgeIterator {
 
-	public boolean hasNext();
-	
-	public RoutingEdge next();
+    public boolean hasNext();
+    
+    public RoutingEdge next();
 
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/PreferencesKeys.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/PreferencesKeys.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/PreferencesKeys.java	(revision 15707)
@@ -28,14 +28,14 @@
 
 public enum PreferencesKeys {
-	KEY_ACTIVE_ROUTE_COLOR ("routing.active.route.color"),
-	KEY_INACTIVE_ROUTE_COLOR ("routing.inactive.route.color"),
-	KEY_ROUTE_WIDTH ("routing.route.width"),
-	KEY_ROUTE_SELECT ("routing.route.select");
+    KEY_ACTIVE_ROUTE_COLOR ("routing.active.route.color"),
+    KEY_INACTIVE_ROUTE_COLOR ("routing.inactive.route.color"),
+    KEY_ROUTE_WIDTH ("routing.route.width"),
+    KEY_ROUTE_SELECT ("routing.route.select");
 
-	public final String key;
-	PreferencesKeys (String key) {
-		this.key=key;
-	}
+    public final String key;
+    PreferencesKeys (String key) {
+        this.key=key;
+    }
 
-	public String getKey() {return key;};
+    public String getKey() {return key;};
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingEdge.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingEdge.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingEdge.java	(revision 15707)
@@ -5,23 +5,23 @@
 public interface RoutingEdge {
 
-	  public LatLon fromLatLon();
+      public LatLon fromLatLon();
 
-	  public LatLon toLatLon();
-	  
-	  public Object fromV();
+      public LatLon toLatLon();
+      
+      public Object fromV();
 
-	  public Object toV();
+      public Object toV();
 
-	  public double getLength();
-	  
-	  public void setLength(double length);
-	  
-	  public double getSpeed();
+      public double getLength();
+      
+      public void setLength(double length);
+      
+      public double getSpeed();
 
-	  public void setSpeed(double speed);
-	  
-	  public boolean isOneway();
-	  
-	  public void setOneway(boolean isOneway);
+      public void setSpeed(double speed);
+      
+      public boolean isOneway();
+      
+      public void setOneway(boolean isOneway);
 
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java	(revision 15707)
@@ -52,327 +52,327 @@
 public class RoutingGraph {
 
-	/**
+    /**
      * Routing Profile
      */
     private RoutingProfile routingProfile;
 
-	/**
-	 * Diferent algorithms to apply to the graph.
-	 */
-	public enum Algorithm {
-		ROUTING_ALG_DIJKSTRA, ROUTING_ALG_BELLMANFORD
-	};
-
-	/**
-	 * Search criteria for the route.
-	 */
-	public enum RouteType {FASTEST,SHORTEST};
-
-	/**
-	 *
-	 */
-	private RouteType routeType;
+    /**
+     * Diferent algorithms to apply to the graph.
+     */
+    public enum Algorithm {
+        ROUTING_ALG_DIJKSTRA, ROUTING_ALG_BELLMANFORD
+    };
+
+    /**
+     * Search criteria for the route.
+     */
+    public enum RouteType {FASTEST,SHORTEST};
+
+    /**
+     *
+     */
+    private RouteType routeType;
 
     /**
      * Associated Osm DataSet
      */
-	private DataSet data;
-
-	/**
-	 * Logger.
-	 */
-	static Logger logger = Logger.getLogger(RoutingGraph.class);
-
-	/**
-	 * Graph state
-	 * <code>true</code> Graph in memory.
-	 * <code>false</code> Graph not created.
-	 */
-//	public boolean graphState;
-
-	/**
-	 * OSM Graph.
-	 */
-//	private DirectedWeightedMultigraph<Node, OsmEdge> graph;
-//	private WeightedMultigraph<Node, OsmEdge> graph;
-	private Graph<Node, OsmEdge> graph;
-	private RoutingGraphDelegator rgDelegator=null;
-
-	/**
-	 * Speeds
-	 */
-	private Map<String,Double> waySpeeds;
-
-	/**
-	 * Default Constructor.
-	 */
-	public RoutingGraph(DataSet data) {
-//		this.graphState = false;
-		this.graph = null;
-//		this.data = data;
-		routeType=RouteType.SHORTEST;
-		routingProfile=new RoutingProfile("default");
-		routingProfile.setOnewayUse(true); // Don't ignore oneways by default
-		this.setWaySpeeds(routingProfile.getWaySpeeds());
-		logger.debug("Created RoutingGraph");
-	}
-
-	/**
-	 * Create OSM graph for routing
-	 *
-	 * @return
-	 */
-	public void createGraph() {
-
-		logger.debug("Creating Graph...");
-		graph = new DirectedWeightedMultigraph<Node, OsmEdge>(OsmEdge.class);
-		rgDelegator=new RoutingGraphDelegator(graph);
-		rgDelegator.setRouteType(this.routeType);
-		// iterate all ways and segments for all nodes:
-		for (Way way : data.ways) {
-			if (way != null && !way.deleted && this.isvalidWay(way)) {
-				Node from = null;
-				for (Node to : way.nodes) {
-					// Ignore the node if deleted
-					if (!to.deleted) {
-						graph.addVertex(to);
-						if (from != null) {
-							addEdge(way, from, to);
-							if (!isOneWay(way)){
-								addEdge(way, to, from);}
-						}
-						from = to;
-					}
-				}
-			}
-		}
-//		graph.vertexSet().size();
-		logger.debug("End Create Graph");
-		logger.debug("Vertex: "+graph.vertexSet().size());
-		logger.debug("Edges: "+graph.edgeSet().size());
-	}
-
-	/**
-	 * Compute weight and add edge to the graph
-	 * @param way
-	 * @param from
-	 * @param to
-	 */
-	private void addEdge(Way way,Node from, Node to) {
-		double length = from.coor.greatCircleDistance(to.coor);
-		
-		OsmEdge edge = new OsmEdge(way, from, to);
-		edge.setSpeed(12.1);
-		graph.addEdge(from, to, edge);
-		// weight = getWeight(way);
-		double weight = getWeight(way, length);
-		setWeight(edge, length);
-		logger.debug("edge for way " + way.id
-				     + "(from node " + from.id + " to node "
-				     + to.id + ") has weight: " + weight);
-		//((GraphDelegator<Node,OsmEdge>) graph).setEdgeWeight(edge, weight);
-		((DirectedWeightedMultigraph<Node,OsmEdge>)graph).setEdgeWeight(edge, weight);
-	}
-
-	/**
-	 * Set the weight for the given segment depending on the highway type
-	 * and the length of the segment. The higher the value, the less it is used
-	 * in routing.
-	 *
-	 * @param way
-	 *            the way.
-	 * @return
-	 */
-	private void setWeight(OsmEdge osmedge, double length) {
-		
-		osmedge.setLength(length);
-		if (this.waySpeeds.containsKey(osmedge.getWay().get("highway")))
-			osmedge.setSpeed(this.waySpeeds.get(osmedge.getWay().get("highway")));
-					
-	}
-
-	/**
-	 * Returns the weight for the given segment depending on the highway type
-	 * and the length of the segment. The higher the value, the less it is used
-	 * in routing.
-	 *
-	 * @param way
-	 *            the way.
-	 * @return
-	 */
-	private double getWeight(Way way, double length) {
-		// Default speed if no setting is found
-		double speed = 1;
-
-		switch (routeType) {
-		case SHORTEST:
-			// Same speed for all types of ways
-			if (this.waySpeeds.containsKey("residential"))
-				speed=this.waySpeeds.get("residential");
-			break;
-		case FASTEST:
-			// Each type of way may have a different speed
-			if (this.waySpeeds.containsKey(way.get("highway")))
-				speed=this.waySpeeds.get(way.get("highway"));
-			logger.debug("Speed="+speed);
-			break;
-		default:
-			break;
-		}
-		// Return the time spent to traverse the way
-		return length / speed;
-	}
-	
-	/**
-	 * Check is One Way.
-	 *
-	 * @param way
-	 *            the way.
-	 * @return <code>true</code> is a one way. <code>false</code> is not a one
-	 *         way.
-	 */
-	private boolean isOneWay(Way way) {
-		// FIXME: oneway=-1 is ignored for the moment!
-		return way.get("oneway") != null
-				|| "motorway".equals(way.get("highway"));
-	}
-
-	/**
-	 * Check if a Way is correct.
-	 *
-	 * @param way
-	 *            The way.
-	 * @return <code>true</code> is valid. <code>false</code> is not valid.
-	 */
-	public boolean isvalidWay(Way way) {
-		if (!way.isTagged())
-			return false;
-
-		return way.get("highway") != null || way.get("junction") != null
-				|| way.get("service") != null;
-
-	}
-
-	public boolean isvalidNode(Node node) {
-		return true;
-	}
-
-	/**
-	 * Apply selected routing algorithm to the graph.
-	 *
-	 * @param nodes
-	 *            Nodes used to calculate path.
-	 * @param algorithm
-	 *            Algorithm used to compute the path,
-	 *            RoutingGraph.Algorithm.ROUTING_ALG_DIJKSTRA or
-	 *            RoutingGraph.Algorithm.ROUTING_ALG_BELLMANFORD
-	 * @return new path.
-	 */
-	public List<OsmEdge> applyAlgorithm(List<Node> nodes, Algorithm algorithm) {
-		List<OsmEdge> path = new ArrayList<OsmEdge>();
-		Graph<Node,OsmEdge> g;
-		double totalWeight = 0;
-
-		if (graph == null)
-			this.createGraph();
-		logger.debug("apply algorithm between nodes ");
-
-		for (Node node : nodes) {
-			logger.debug(node.id);
-		}
-		logger.debug("-----------------------------------");
-
-		// Assign the graph or an undirected view of the graph to g,
-		// depending on whether oneway tags are used or not
-		if (routingProfile.isOnewayUsed())
-			g = graph;
-		else
-			g = new AsUndirectedGraph<Node, OsmEdge>((DirectedWeightedMultigraph<Node,OsmEdge>)graph);
-		//TODO: Problemas no tiene encuenta el tema de oneway.
-		switch (algorithm) {
-		case ROUTING_ALG_DIJKSTRA:
-			logger.debug("Using Dijkstra algorithm");
-			DijkstraShortestPath<Node, OsmEdge> routingk = null;
-			for (int index = 1; index < nodes.size(); ++index) {
-				routingk = new DijkstraShortestPath<Node, OsmEdge>(rgDelegator, nodes
-						.get(index - 1), nodes.get(index));
-				if (routingk.getPathEdgeList() == null) {
-					logger.debug("no path found!");
-					break;
-				}
-				path.addAll(routingk.getPathEdgeList());
-				totalWeight += routingk.getPathLength();
-			}
-			break;
-		case ROUTING_ALG_BELLMANFORD:
-			logger.debug("Using Bellman Ford algorithm");
-			for (int index = 1; index < nodes.size(); ++index) {
-				path = BellmanFordShortestPath.findPathBetween(rgDelegator, nodes
-						.get(index - 1), nodes.get(index));
-				if (path == null) {
-					logger.debug("no path found!");
-					return null;
-				}
-			}
-			break;
-		default:
-			logger.debug("Wrong algorithm");
-			break;
-		}
-
-		logger.debug("shortest path found: " + path + "\nweight: "
-						+ totalWeight);
-		return path;
-	}
-
-	/**
-	 * Return the number of vertices.
-	 * @return the number of vertices.
-	 */
-	public int getVertexCount(){
-		int value=0;
-		if (graph!=null) value=graph.vertexSet().size();
-		return value;
-	}
-
-	/**
-	 * Return the number of edges.
-	 * @return the number of edges.
-	 */
-	public int getEdgeCount(){
-		int value=0;
-		if (graph!=null) value=graph.edgeSet().size();
-		return value;
-	}
-
-	/**
-	 * @param routeType the routeType to set
-	 */
-	public void setTypeRoute(RouteType routetype) {
-		this.routeType = routetype;
-		this.rgDelegator.setRouteType(routetype);
-	}
-
-	/**
-	 * @return the routeType
-	 */
-	public RouteType getTypeRoute() {
-		return routeType;
-	}
-
-	public Map<String, Double> getWaySpeeds() {
-		return waySpeeds;
-	}
-
-	public void setWaySpeeds(Map<String, Double> waySpeeds) {
-		this.waySpeeds = waySpeeds;
-	}
-
-	public void resetGraph() {
-		graph=null;
-	}
-
-	public RoutingProfile getRoutingProfile() {
-		return routingProfile;
-	}
+    private DataSet data;
+
+    /**
+     * Logger.
+     */
+    static Logger logger = Logger.getLogger(RoutingGraph.class);
+
+    /**
+     * Graph state
+     * <code>true</code> Graph in memory.
+     * <code>false</code> Graph not created.
+     */
+//  public boolean graphState;
+
+    /**
+     * OSM Graph.
+     */
+//  private DirectedWeightedMultigraph<Node, OsmEdge> graph;
+//  private WeightedMultigraph<Node, OsmEdge> graph;
+    private Graph<Node, OsmEdge> graph;
+    private RoutingGraphDelegator rgDelegator=null;
+
+    /**
+     * Speeds
+     */
+    private Map<String,Double> waySpeeds;
+
+    /**
+     * Default Constructor.
+     */
+    public RoutingGraph(DataSet data) {
+//      this.graphState = false;
+        this.graph = null;
+        this.data = data;
+        routeType=RouteType.SHORTEST;
+        routingProfile=new RoutingProfile("default");
+        routingProfile.setOnewayUse(true); // Don't ignore oneways by default
+        this.setWaySpeeds(routingProfile.getWaySpeeds());
+        logger.debug("Created RoutingGraph");
+    }
+
+    /**
+     * Create OSM graph for routing
+     *
+     * @return
+     */
+    public void createGraph() {
+
+        logger.debug("Creating Graph...");
+        graph = new DirectedWeightedMultigraph<Node, OsmEdge>(OsmEdge.class);
+        rgDelegator=new RoutingGraphDelegator(graph);
+        rgDelegator.setRouteType(this.routeType);
+        // iterate all ways and segments for all nodes:
+        for (Way way : data.ways) {
+            if (way != null && !way.deleted && this.isvalidWay(way)) {
+                Node from = null;
+                for (Node to : way.nodes) {
+                    // Ignore the node if deleted
+                    if (!to.deleted) {
+                        graph.addVertex(to);
+                        if (from != null) {
+                            addEdge(way, from, to);
+                            if (!isOneWay(way)){
+                                addEdge(way, to, from);}
+                        }
+                        from = to;
+                    }
+                }
+            }
+        }
+//      graph.vertexSet().size();
+        logger.debug("End Create Graph");
+        logger.debug("Vertex: "+graph.vertexSet().size());
+        logger.debug("Edges: "+graph.edgeSet().size());
+    }
+
+    /**
+     * Compute weight and add edge to the graph
+     * @param way
+     * @param from
+     * @param to
+     */
+    private void addEdge(Way way,Node from, Node to) {
+        double length = from.coor.greatCircleDistance(to.coor);
+
+        OsmEdge edge = new OsmEdge(way, from, to);
+        edge.setSpeed(12.1);
+        graph.addEdge(from, to, edge);
+        // weight = getWeight(way);
+        double weight = getWeight(way, length);
+        setWeight(edge, length);
+        logger.debug("edge for way " + way.id
+                     + "(from node " + from.id + " to node "
+                     + to.id + ") has weight: " + weight);
+        //((GraphDelegator<Node,OsmEdge>) graph).setEdgeWeight(edge, weight);
+        ((DirectedWeightedMultigraph<Node,OsmEdge>)graph).setEdgeWeight(edge, weight);
+    }
+
+    /**
+     * Set the weight for the given segment depending on the highway type
+     * and the length of the segment. The higher the value, the less it is used
+     * in routing.
+     *
+     * @param way
+     *            the way.
+     * @return
+     */
+    private void setWeight(OsmEdge osmedge, double length) {
+
+        osmedge.setLength(length);
+        if (this.waySpeeds.containsKey(osmedge.getWay().get("highway")))
+            osmedge.setSpeed(this.waySpeeds.get(osmedge.getWay().get("highway")));
+
+    }
+
+    /**
+     * Returns the weight for the given segment depending on the highway type
+     * and the length of the segment. The higher the value, the less it is used
+     * in routing.
+     *
+     * @param way
+     *            the way.
+     * @return
+     */
+    private double getWeight(Way way, double length) {
+        // Default speed if no setting is found
+        double speed = 1;
+
+        switch (routeType) {
+        case SHORTEST:
+            // Same speed for all types of ways
+            if (this.waySpeeds.containsKey("residential"))
+                speed=this.waySpeeds.get("residential");
+            break;
+        case FASTEST:
+            // Each type of way may have a different speed
+            if (this.waySpeeds.containsKey(way.get("highway")))
+                speed=this.waySpeeds.get(way.get("highway"));
+            logger.debug("Speed="+speed);
+            break;
+        default:
+            break;
+        }
+        // Return the time spent to traverse the way
+        return length / speed;
+    }
+
+    /**
+     * Check is One Way.
+     *
+     * @param way
+     *            the way.
+     * @return <code>true</code> is a one way. <code>false</code> is not a one
+     *         way.
+     */
+    private boolean isOneWay(Way way) {
+        // FIXME: oneway=-1 is ignored for the moment!
+        return way.get("oneway") != null
+                || "motorway".equals(way.get("highway"));
+    }
+
+    /**
+     * Check if a Way is correct.
+     *
+     * @param way
+     *            The way.
+     * @return <code>true</code> is valid. <code>false</code> is not valid.
+     */
+    public boolean isvalidWay(Way way) {
+        if (!way.isTagged())
+            return false;
+
+        return way.get("highway") != null || way.get("junction") != null
+                || way.get("service") != null;
+
+    }
+
+    public boolean isvalidNode(Node node) {
+        return true;
+    }
+
+    /**
+     * Apply selected routing algorithm to the graph.
+     *
+     * @param nodes
+     *            Nodes used to calculate path.
+     * @param algorithm
+     *            Algorithm used to compute the path,
+     *            RoutingGraph.Algorithm.ROUTING_ALG_DIJKSTRA or
+     *            RoutingGraph.Algorithm.ROUTING_ALG_BELLMANFORD
+     * @return new path.
+     */
+    public List<OsmEdge> applyAlgorithm(List<Node> nodes, Algorithm algorithm) {
+        List<OsmEdge> path = new ArrayList<OsmEdge>();
+        Graph<Node,OsmEdge> g;
+        double totalWeight = 0;
+
+        if (graph == null)
+            this.createGraph();
+        logger.debug("apply algorithm between nodes ");
+
+        for (Node node : nodes) {
+            logger.debug(node.id);
+        }
+        logger.debug("-----------------------------------");
+
+        // Assign the graph or an undirected view of the graph to g,
+        // depending on whether oneway tags are used or not
+        if (routingProfile.isOnewayUsed())
+            g = graph;
+        else
+            g = new AsUndirectedGraph<Node, OsmEdge>((DirectedWeightedMultigraph<Node,OsmEdge>)graph);
+        //TODO: Problemas no tiene encuenta el tema de oneway.
+        switch (algorithm) {
+        case ROUTING_ALG_DIJKSTRA:
+            logger.debug("Using Dijkstra algorithm");
+            DijkstraShortestPath<Node, OsmEdge> routingk = null;
+            for (int index = 1; index < nodes.size(); ++index) {
+                routingk = new DijkstraShortestPath<Node, OsmEdge>(rgDelegator, nodes
+                        .get(index - 1), nodes.get(index));
+                if (routingk.getPathEdgeList() == null) {
+                    logger.debug("no path found!");
+                    break;
+                }
+                path.addAll(routingk.getPathEdgeList());
+                totalWeight += routingk.getPathLength();
+            }
+            break;
+        case ROUTING_ALG_BELLMANFORD:
+            logger.debug("Using Bellman Ford algorithm");
+            for (int index = 1; index < nodes.size(); ++index) {
+                path = BellmanFordShortestPath.findPathBetween(rgDelegator, nodes
+                        .get(index - 1), nodes.get(index));
+                if (path == null) {
+                    logger.debug("no path found!");
+                    return null;
+                }
+            }
+            break;
+        default:
+            logger.debug("Wrong algorithm");
+            break;
+        }
+
+        logger.debug("shortest path found: " + path + "\nweight: "
+                        + totalWeight);
+        return path;
+    }
+
+    /**
+     * Return the number of vertices.
+     * @return the number of vertices.
+     */
+    public int getVertexCount(){
+        int value=0;
+        if (graph!=null) value=graph.vertexSet().size();
+        return value;
+    }
+
+    /**
+     * Return the number of edges.
+     * @return the number of edges.
+     */
+    public int getEdgeCount(){
+        int value=0;
+        if (graph!=null) value=graph.edgeSet().size();
+        return value;
+    }
+
+    /**
+     * @param routeType the routeType to set
+     */
+    public void setTypeRoute(RouteType routetype) {
+        this.routeType = routetype;
+        this.rgDelegator.setRouteType(routetype);
+    }
+
+    /**
+     * @return the routeType
+     */
+    public RouteType getTypeRoute() {
+        return routeType;
+    }
+
+    public Map<String, Double> getWaySpeeds() {
+        return waySpeeds;
+    }
+
+    public void setWaySpeeds(Map<String, Double> waySpeeds) {
+        this.waySpeeds = waySpeeds;
+    }
+
+    public void resetGraph() {
+        graph=null;
+    }
+
+    public RoutingProfile getRoutingProfile() {
+        return routingProfile;
+    }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraphDelegator.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraphDelegator.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraphDelegator.java	(revision 15707)
@@ -19,42 +19,42 @@
 public class RoutingGraphDelegator extends GraphDelegator<Node, OsmEdge> {
 
-	/**
-	 * Logger.
-	 */
-	static Logger logger = Logger.getLogger(RoutingGraphDelegator.class);
-	
-	/**
-	 *
-	 */
-	private RouteType routeType;
-	
-	public RoutingGraphDelegator(Graph<Node, OsmEdge> arg0) {
-		super(arg0);
-	}
-	
+    /**
+     * Logger.
+     */
+    static Logger logger = Logger.getLogger(RoutingGraphDelegator.class);
+    
+    /**
+     *
+     */
+    private RouteType routeType;
+    
+    public RoutingGraphDelegator(Graph<Node, OsmEdge> arg0) {
+        super(arg0);
+    }
+    
 
-	public RouteType getRouteType() {
-		return routeType;
-	}
+    public RouteType getRouteType() {
+        return routeType;
+    }
 
-	public void setRouteType(RouteType routeType) {
-		this.routeType = routeType;
-	}
+    public void setRouteType(RouteType routeType) {
+        this.routeType = routeType;
+    }
 
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
 
-	@Override
-	public double getEdgeWeight(OsmEdge edge) {
-		double weight=Double.MAX_VALUE;
-		
-		if (routeType==RouteType.SHORTEST) weight=edge.getLength();
-		if (routeType==RouteType.FASTEST) weight=edge.getLength() / edge.getSpeed();
-		// Return the time spent to traverse the way
-		return weight;
-	}
+    @Override
+    public double getEdgeWeight(OsmEdge edge) {
+        double weight=Double.MAX_VALUE;
+        
+        if (routeType==RouteType.SHORTEST) weight=edge.getLength();
+        if (routeType==RouteType.FASTEST) weight=edge.getLength() / edge.getSpeed();
+        // Return the time spent to traverse the way
+        return weight;
+    }
 
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingProfile.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingProfile.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingProfile.java	(revision 15707)
@@ -29,133 +29,133 @@
  */
 public class RoutingProfile {
-	/**
-	 * logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingProfile.class);
-	/**
-	 * True if oneway is used for routing (i.e. for cars).
-	 */
-	private boolean useOneway;
+    /**
+     * logger
+     */
+    static Logger logger = Logger.getLogger(RoutingProfile.class);
+    /**
+     * True if oneway is used for routing (i.e. for cars).
+     */
+    private boolean useOneway;
 
-	/**
-	 * True if turn restrictions are used for routing (i.e. for cars).
-	 */
-	private boolean useRestrictions;
+    /**
+     * True if turn restrictions are used for routing (i.e. for cars).
+     */
+    private boolean useRestrictions;
 
-	/**
-	 * True if maximum allowed speed of ways is considered for routing (i.e. for cars).
-	 */
-	private boolean useMaxAllowedSpeed;
+    /**
+     * True if maximum allowed speed of ways is considered for routing (i.e. for cars).
+     */
+    private boolean useMaxAllowedSpeed;
 
-	/**
-	 * Name of the routing profile, for identification issues (i.e. "pedestrian").
-	 */
-	private String name;
+    /**
+     * Name of the routing profile, for identification issues (i.e. "pedestrian").
+     */
+    private String name;
 
-	/**
-	 * Holds traverse speed for each type of way, using the type as key.
-	 * A speed of zero means that this type of way cannot be traversed.
-	 */
-	private Map<String,Double> waySpeeds;
+    /**
+     * Holds traverse speed for each type of way, using the type as key.
+     * A speed of zero means that this type of way cannot be traversed.
+     */
+    private Map<String,Double> waySpeeds;
 
 
 
-	/**
-	 * Holds permission of use for each type of transport mode, using the mode as key.
-	 */
-	private Map<String,Boolean> allowedModes;
+    /**
+     * Holds permission of use for each type of transport mode, using the mode as key.
+     */
+    private Map<String,Boolean> allowedModes;
 
-	/**
-	 * Constructor
-	 * @param name The name for the routing profile. Please use a name that is
-	 * self descriptive, i.e., something that an application user would
-	 * understand (like "pedestrian", "motorbike", "bicycle", etc.)
-	 */
-	public RoutingProfile(String name) {
-		logger.debug("Init RoutingProfile with name: "+name);
-		this.name = name;
-		waySpeeds=new HashMap<String,Double>();
-		Map<String,String> prefs=Main.pref.getAllPrefix("routing.profile."+name+".speed");
-		for(String key:prefs.keySet()){
-			waySpeeds.put((key.split("\\.")[4]), Double.valueOf(prefs.get(key)));
-		}
-		for (String key:waySpeeds.keySet())
-			logger.debug(key+ "-- speed: "+waySpeeds.get(key));
-		logger.debug("End init RoutingProfile with name: "+name);
-	}
+    /**
+     * Constructor
+     * @param name The name for the routing profile. Please use a name that is
+     * self descriptive, i.e., something that an application user would
+     * understand (like "pedestrian", "motorbike", "bicycle", etc.)
+     */
+    public RoutingProfile(String name) {
+        logger.debug("Init RoutingProfile with name: "+name);
+        this.name = name;
+        waySpeeds=new HashMap<String,Double>();
+        Map<String,String> prefs=Main.pref.getAllPrefix("routing.profile."+name+".speed");
+        for(String key:prefs.keySet()){
+            waySpeeds.put((key.split("\\.")[4]), Double.valueOf(prefs.get(key)));
+        }
+        for (String key:waySpeeds.keySet())
+            logger.debug(key+ "-- speed: "+waySpeeds.get(key));
+        logger.debug("End init RoutingProfile with name: "+name);
+    }
 
-	public void setName(String name) {
-		this.name = name;
-	}
+    public void setName(String name) {
+        this.name = name;
+    }
 
-	public String getName() {
-		return name;
-	}
+    public String getName() {
+        return name;
+    }
 
-	public void setOnewayUse(boolean useOneway) {
-		this.useOneway = useOneway;
-	}
+    public void setOnewayUse(boolean useOneway) {
+        this.useOneway = useOneway;
+    }
 
-	public boolean isOnewayUsed() {
-		return useOneway;
-	}
+    public boolean isOnewayUsed() {
+        return useOneway;
+    }
 
-	public void setRestrictionsUse(boolean useRestrictions) {
-		this.useRestrictions = useRestrictions;
-	}
+    public void setRestrictionsUse(boolean useRestrictions) {
+        this.useRestrictions = useRestrictions;
+    }
 
-	public boolean isRestrictionsUsed() {
-		return useRestrictions;
-	}
+    public boolean isRestrictionsUsed() {
+        return useRestrictions;
+    }
 
-	public void setMaxAllowedSpeedUse(boolean useMaxAllowedSpeed) {
-		this.useMaxAllowedSpeed = useMaxAllowedSpeed;
-	}
+    public void setMaxAllowedSpeedUse(boolean useMaxAllowedSpeed) {
+        this.useMaxAllowedSpeed = useMaxAllowedSpeed;
+    }
 
-	public boolean isMaxAllowedSpeedUsed() {
-		return useMaxAllowedSpeed;
-	}
+    public boolean isMaxAllowedSpeedUsed() {
+        return useMaxAllowedSpeed;
+    }
 
-	public void setWayTypeSpeed(String type, double speed) {
-		waySpeeds.put(type, speed);
-	}
+    public void setWayTypeSpeed(String type, double speed) {
+        waySpeeds.put(type, speed);
+    }
 
-	public void setTransportModePermission(String mode, boolean permission) {
-		allowedModes.put(mode, permission);
-	}
+    public void setTransportModePermission(String mode, boolean permission) {
+        allowedModes.put(mode, permission);
+    }
 
-	/**
-	 * Return whether the driving profile specifies that a particular type of way
-	 * can be traversed
-	 * @param type Key for the way type
-	 * @return True if the way type can be traversed
-	 */
-	public boolean isWayTypeAllowed(String type) {
-		if (waySpeeds.get(type) != 0.0)
-			return true;
-		return false;
-	}
+    /**
+     * Return whether the driving profile specifies that a particular type of way
+     * can be traversed
+     * @param type Key for the way type
+     * @return True if the way type can be traversed
+     */
+    public boolean isWayTypeAllowed(String type) {
+        if (waySpeeds.get(type) != 0.0)
+            return true;
+        return false;
+    }
 
-	/**
-	 * Return whether the driving profile specifies that a particular type of transport
-	 * mode can be used
-	 * @param mode Key for the way type
-	 * @return True if the way type can be traversed
-	 */
-	public boolean isTransportModeAllowed(String mode) {
-		return allowedModes.get(mode);
-	}
+    /**
+     * Return whether the driving profile specifies that a particular type of transport
+     * mode can be used
+     * @param mode Key for the way type
+     * @return True if the way type can be traversed
+     */
+    public boolean isTransportModeAllowed(String mode) {
+        return allowedModes.get(mode);
+    }
 
-	public double getSpeed(String key){
-		if(!waySpeeds.containsKey(key)) return 0.0;
-		return waySpeeds.get(key);
-	}
+    public double getSpeed(String key){
+        if(!waySpeeds.containsKey(key)) return 0.0;
+        return waySpeeds.get(key);
+    }
 
-	public Map<String, Double> getWaySpeeds() {
-		return waySpeeds;
-	}
+    public Map<String, Double> getWaySpeeds() {
+        return waySpeeds;
+    }
 
-	public void setWaySpeeds(Map<String, Double> waySpeeds) {
-		this.waySpeeds = waySpeeds;
-	}
+    public void setWaySpeeds(Map<String, Double> waySpeeds) {
+        this.waySpeeds = waySpeeds;
+    }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/gtfs/GTFSTransportModes.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/gtfs/GTFSTransportModes.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/gtfs/GTFSTransportModes.java	(revision 15707)
@@ -9,49 +9,49 @@
 public class GTFSTransportModes {
 
-	/**
-	 * 0 - Tram, Streetcar, Light rail. Any light rail or street level system within
-	 *     a metropolitan area.
-	 */
-	public static final int TRAM = 0;
-	public static final int STREETCAR = 0;
-	public static final int LIGHT_RAIL = 0;
+    /**
+     * 0 - Tram, Streetcar, Light rail. Any light rail or street level system within
+     *     a metropolitan area.
+     */
+    public static final int TRAM = 0;
+    public static final int STREETCAR = 0;
+    public static final int LIGHT_RAIL = 0;
 
-	/**
-	 * 1 - Subway, Metro. Any underground rail system within a metropolitan area.
-	 */
-	public static final int SUBWAY = 1;
-	public static final int METRO = 1;
+    /**
+     * 1 - Subway, Metro. Any underground rail system within a metropolitan area.
+     */
+    public static final int SUBWAY = 1;
+    public static final int METRO = 1;
 
     /**
      * 2 - Rail. Used for intercity or long-distance travel.
      */
-	public static final int RAIL = 2;
+    public static final int RAIL = 2;
 
     /**
      * 3 - Bus. Used for short- and long-distance bus routes.
      */
-	public static final int BUS = 3;
+    public static final int BUS = 3;
 
     /**
      * 4 - Ferry. Used for short- and long-distance boat service.
      */
-	public static final int FERRY = 4;
+    public static final int FERRY = 4;
 
-	/**
-	 * 5 - Cable car. Used for street-level cable cars where the cable runs beneath the car.
-	 */
-	public static final int CABLE_CAR = 5;
+    /**
+     * 5 - Cable car. Used for street-level cable cars where the cable runs beneath the car.
+     */
+    public static final int CABLE_CAR = 5;
 
-	/**
-	 * 6 - Gondola, Suspended cable car. Typically used for aerial cable cars where
-	 *     the car is suspended from the cable.
-	 */
-	public static final int GONDOLA = 6;
-	public static final int SUSPENDED_CABLE_CAR = 6;
+    /**
+     * 6 - Gondola, Suspended cable car. Typically used for aerial cable cars where
+     *     the car is suspended from the cable.
+     */
+    public static final int GONDOLA = 6;
+    public static final int SUSPENDED_CABLE_CAR = 6;
 
     /**
      * 7 - Funicular. Any rail system designed for steep inclines.
      */
-	public static final int FUNICULAR = 7;
+    public static final int FUNICULAR = 7;
 
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmEdge.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmEdge.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmEdge.java	(revision 15707)
@@ -65,10 +65,10 @@
    */
   public OsmEdge(Way way, Node from, Node to) {
-	  	super();
-	  	this.way = way;
-	  	this.from = from;
-	  	this.to = to;
-	  	this.length = from.coor.greatCircleDistance(to.coor);
-	  }
+        super();
+        this.way = way;
+        this.from = from;
+        this.to = to;
+        this.length = from.coor.greatCircleDistance(to.coor);
+      }
 
   /**
@@ -92,17 +92,17 @@
    */
   public double getLength() {
-  	return length;
+    return length;
   }
   
   public void setLength(double length) {
-	this.length = length;
+    this.length = length;
 }
 
 public double getSpeed() {
-		return speed;
+        return speed;
   }
 
   public void setSpeed(double speed) {
-		this.speed = speed;
+        this.speed = speed;
   }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmWayTypes.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmWayTypes.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmWayTypes.java	(revision 15707)
@@ -34,46 +34,46 @@
  */
 public enum OsmWayTypes {
-	MOTORWAY ("motorway",120),
-	MOTORWAY_LINK ("motorway_link",120),
-	TRUNK ("trunk",120),
-	TRUNK_LINK ("trunk_link",120),
-	PRIMARY  ("primary",100),
-	PRIMARY_LINK ("primary_link",100),
-	SECONDARY ("secondary",90),
-	TERTIARY ("tertiary",90),
-	UNCLASSIFIED ("unclassified",50),
-	ROAD ("road",100),
+    MOTORWAY ("motorway",120),
+    MOTORWAY_LINK ("motorway_link",120),
+    TRUNK ("trunk",120),
+    TRUNK_LINK ("trunk_link",120),
+    PRIMARY  ("primary",100),
+    PRIMARY_LINK ("primary_link",100),
+    SECONDARY ("secondary",90),
+    TERTIARY ("tertiary",90),
+    UNCLASSIFIED ("unclassified",50),
+    ROAD ("road",100),
     RESIDENTIAL ("residential",50),
-	LIVING_STREET ("living_street",30),
-	SERVICE ("service",30),
-	TRACK ("track",50),
-	PEDESTRIAN ("pedestrian",30),
-	BUS_GUIDEWAY ("bus_guideway",50),
-	PATH ("path",40),
-	CYCLEWAY ("cycleway",40),
-	FOOTWAY ("footway",20),
-	BRIDLEWAY ("bridleway",40),
-	BYWAY ("byway",50),
-	STEPS ("steps",10);
+    LIVING_STREET ("living_street",30),
+    SERVICE ("service",30),
+    TRACK ("track",50),
+    PEDESTRIAN ("pedestrian",30),
+    BUS_GUIDEWAY ("bus_guideway",50),
+    PATH ("path",40),
+    CYCLEWAY ("cycleway",40),
+    FOOTWAY ("footway",20),
+    BRIDLEWAY ("bridleway",40),
+    BYWAY ("byway",50),
+    STEPS ("steps",10);
 
-	/**
-	 * Default Constructor
-	 * @param tag
-	 */
-	OsmWayTypes(String tag,int speed) {
-		this.tag = tag;
-		this.speed = speed;
-	}
+    /**
+     * Default Constructor
+     * @param tag
+     */
+    OsmWayTypes(String tag,int speed) {
+        this.tag = tag;
+        this.speed = speed;
+    }
 
-	/**
-	 * Tag
-	 */
-	private final String tag;
-	private final int speed;
+    /**
+     * Tag
+     */
+    private final String tag;
+    private final int speed;
 
-	/**
-	 * @return
-	 */
-	public String getTag() {return tag;};
-	public int getSpeed() {return speed;};
+    /**
+     * @return
+     */
+    public String getTag() {return tag;};
+    public int getSpeed() {return speed;};
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java	(revision 15707)
@@ -70,8 +70,8 @@
 public class RoutingLayer extends Layer {
 
-	/**
-	 * Logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingLayer.class);
+    /**
+     * Logger
+     */
+    static Logger logger = Logger.getLogger(RoutingLayer.class);
 
     /**
@@ -99,7 +99,7 @@
      * @param name Layer name.
      */
-	public RoutingLayer(String name, OsmDataLayer dataLayer) {
-		super(name);
-		logger.debug("Creating Routing Layer...");
+    public RoutingLayer(String name, OsmDataLayer dataLayer) {
+        super(name);
+        logger.debug("Creating Routing Layer...");
         if(startIcon == null) startIcon = ImageProvider.get("routing", "startflag");
         if(middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag");
@@ -108,30 +108,30 @@
         this.routingModel = new RoutingModel(dataLayer.data);
         logger.debug("Routing Layer created.");
-	}
-
-	/**
-	 * Getter Routing Model.
-	 * @return the routingModel
-	 */
-	public RoutingModel getRoutingModel() {
-		return this.routingModel;
-	}
-
-	/**
-	 * Gets associated data layer
-	 * @return OsmDataLayer associated to the RoutingLayer
-	 */
-	public OsmDataLayer getDataLayer() {
-		return dataLayer;
-	}
-
-	/**
-	 * Gets nearest node belonging to a highway tagged way
-	 * @param p Point on the screen
-	 * @return The nearest highway node, in the range of the snap distance
-	 */
+    }
+
+    /**
+     * Getter Routing Model.
+     * @return the routingModel
+     */
+    public RoutingModel getRoutingModel() {
+        return this.routingModel;
+    }
+
+    /**
+     * Gets associated data layer
+     * @return OsmDataLayer associated to the RoutingLayer
+     */
+    public OsmDataLayer getDataLayer() {
+        return dataLayer;
+    }
+
+    /**
+     * Gets nearest node belonging to a highway tagged way
+     * @param p Point on the screen
+     * @return The nearest highway node, in the range of the snap distance
+     */
     public final Node getNearestHighwayNode(Point p) {
-    	Node nearest = null;
-    	double minDist = 0;
+        Node nearest = null;
+        double minDist = 0;
         for (Way w : dataLayer.data.ways) {
             if (w.deleted || w.incomplete || w.get("highway")==null) continue;
@@ -142,8 +142,8 @@
                 double dist = p.distanceSq(P);
                 if (dist < NavigatableComponent.snapDistance) {
-                	if ((nearest == null) || (dist < minDist)) {
-                		nearest = n;
-                		minDist = dist;
-                	}
+                    if ((nearest == null) || (dist < minDist)) {
+                        nearest = n;
+                        minDist = dist;
+                    }
                 }
             }
@@ -152,35 +152,35 @@
     }
 
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#getIcon()
-	 */
-	@Override
-	public Icon getIcon() {
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#getIcon()
+     */
+    @Override
+    public Icon getIcon() {
         Icon icon = ImageProvider.get("layer", "routing_small");
         return icon;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent()
-	 */
-	@Override
-	public Object getInfoComponent() {
-		String info = "<html>"
-						+ "<body>"
-							+"Graph Vertex: "+this.routingModel.routingGraph.getVertexCount()+"<br/>"
-							+"Graph Edges: "+this.routingModel.routingGraph.getEdgeCount()+"<br/>"
-						+ "</body>"
-					+ "</html>";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent()
+     */
+    @Override
+    public Object getInfoComponent() {
+        String info = "<html>"
+                        + "<body>"
+                            +"Graph Vertex: "+this.routingModel.routingGraph.getVertexCount()+"<br/>"
+                            +"Graph Edges: "+this.routingModel.routingGraph.getEdgeCount()+"<br/>"
+                        + "</body>"
+                    + "</html>";
         return info;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries()
-	 */
-	@Override
-	public Component[] getMenuEntries() {
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries()
+     */
+    @Override
+    public Component[] getMenuEntries() {
         Collection<Component> components = new ArrayList<Component>();
         components.add(new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)));
@@ -188,50 +188,50 @@
         components.add(new JMenuItem(new LayerListDialog.DeleteLayerAction(this)));
         components.add(new JSeparator());
-        components.add(new JMenuItem(new RenameLayerAction(associatedFile, this)));
+        components.add(new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)));
         components.add(new JSeparator());
         components.add(new JMenuItem(new LayerListPopup.InfoAction(this)));
         return components.toArray(new Component[0]);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText()
-	 */
-	@Override
-	public String getToolTipText() {
-		String tooltip = this.routingModel.routingGraph.getVertexCount() + " vertices, "
-				+ this.routingModel.routingGraph.getEdgeCount() + " edges";
-		return tooltip;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm.gui.layer.Layer)
-	 */
-	@Override
-	public boolean isMergable(Layer other) {
-		return false;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm.gui.layer.Layer)
-	 */
-	@Override
-	public void mergeFrom(Layer from) {
-		// This layer is not mergable, so do nothing
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics, org.openstreetmap.josm.gui.MapView)
-	 */
-	@Override
-	public void paint(Graphics g, MapView mv) {
-		boolean isActiveLayer = (mv.getActiveLayer().equals(this));
-		// Get routing nodes (start, middle, end)
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText()
+     */
+    @Override
+    public String getToolTipText() {
+        String tooltip = this.routingModel.routingGraph.getVertexCount() + " vertices, "
+                + this.routingModel.routingGraph.getEdgeCount() + " edges";
+        return tooltip;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm.gui.layer.Layer)
+     */
+    @Override
+    public boolean isMergable(Layer other) {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm.gui.layer.Layer)
+     */
+    @Override
+    public void mergeFrom(Layer from) {
+        // This layer is not mergable, so do nothing
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics, org.openstreetmap.josm.gui.MapView)
+     */
+    @Override
+    public void paint(Graphics g, MapView mv) {
+        boolean isActiveLayer = (mv.getActiveLayer().equals(this));
+        // Get routing nodes (start, middle, end)
         List<Node> nodes = routingModel.getSelectedNodes();
         if(nodes == null || nodes.size() == 0) {
-        	logger.debug("no nodes selected");
+            logger.debug("no nodes selected");
             return;
         }
@@ -241,17 +241,17 @@
         String colorString;
         if (isActiveLayer) {
-        	if (Main.pref.hasKey(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key))
-        			colorString = Main.pref.get(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key);
-        	else {
-        		colorString = ColorHelper.color2html(Color.RED);
-        		Main.pref.put(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key, colorString);
-        	}
+            if (Main.pref.hasKey(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key))
+                    colorString = Main.pref.get(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key);
+            else {
+                colorString = ColorHelper.color2html(Color.RED);
+                Main.pref.put(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key, colorString);
+            }
         } else {
-        	if (Main.pref.hasKey(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key))
-        		colorString = Main.pref.get(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key);
-        	else {
-        		colorString = ColorHelper.color2html(Color.decode("#dd2222"));
-        		Main.pref.put(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key, colorString);
-        	}
+            if (Main.pref.hasKey(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key))
+                colorString = Main.pref.get(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key);
+            else {
+                colorString = ColorHelper.color2html(Color.decode("#dd2222"));
+                Main.pref.put(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key, colorString);
+            }
         }
         Color color = ColorHelper.html2color(colorString);
@@ -277,5 +277,5 @@
         Point screen = mv.getPoint(node.eastNorth);
         startIcon.paintIcon(mv, g, screen.x - startIcon.getIconWidth()/2,
-        		screen.y - startIcon.getIconHeight());
+                screen.y - startIcon.getIconHeight());
 
         // paint middle icons
@@ -284,5 +284,5 @@
             screen = mv.getPoint(node.eastNorth);
             middleIcon.paintIcon(mv, g, screen.x - startIcon.getIconWidth()/2,
-            		screen.y - middleIcon.getIconHeight());
+                    screen.y - middleIcon.getIconHeight());
         }
         // paint end icon
@@ -291,28 +291,28 @@
             screen = mv.getPoint(node.eastNorth);
             endIcon.paintIcon(mv, g, screen.x - startIcon.getIconWidth()/2,
-            		screen.y - endIcon.getIconHeight());
-        }
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor)
-	 */
-	@Override
-	public void visitBoundingBox(BoundingXYVisitor v) {
+                    screen.y - endIcon.getIconHeight());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor)
+     */
+    @Override
+    public void visitBoundingBox(BoundingXYVisitor v) {
         for (Node node : routingModel.getSelectedNodes()) {
             v.visit(node);
         }
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer#destroy()
-	 */
-	@Override
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer#destroy()
+     */
+    @Override
     public void destroy() {
-		routingModel.reset();
-//		layerAdded = false;
-	}
+        routingModel.reset();
+//      layerAdded = false;
+    }
 
     /**
@@ -320,5 +320,5 @@
      */
     private void drawEdge(Graphics g, MapView mv, OsmEdge edge, Color col, int width,
-    		boolean showDirection) {
+            boolean showDirection) {
         g.setColor(col);
         Point from;
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 15707)
@@ -48,13 +48,13 @@
 public class RoutingModel {
 
-	/**
-	 * Logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingModel.class);
+    /**
+     * Logger
+     */
+    static Logger logger = Logger.getLogger(RoutingModel.class);
 
     /**
      * Graph to calculate route
      */
-	public RoutingGraph routingGraph=null;
+    public RoutingGraph routingGraph=null;
 
     /**
@@ -71,8 +71,9 @@
      * Default Constructor.
      */
-	public RoutingModel(DataSet data) {
+    public RoutingModel(DataSet data) {
         nodes = new ArrayList<Node>();
+System.out.println("gr " + data);
         routingGraph = new RoutingGraph(data);
-	}
+    }
 
     /**
@@ -98,8 +99,8 @@
      */
     public void removeNode(int index) {
-    	if (nodes.size()>index)	{
-    		nodes.remove(index);
-    		this.changeNodes=true;
-    	}
+        if (nodes.size()>index) {
+            nodes.remove(index);
+            this.changeNodes=true;
+        }
     }
 
@@ -110,8 +111,8 @@
      */
     public void insertNode(int index, Node node) {
-    	if (nodes.size()>=index) {
-    		nodes.add(index, node);
-    		this.changeNodes=true;
-    	}
+        if (nodes.size()>=index) {
+            nodes.add(index, node);
+            this.changeNodes=true;
+        }
     }
 
@@ -120,10 +121,10 @@
      */
     public void reverseNodes() {
-    	List<Node> aux = new ArrayList<Node>();
-    	for (Node n : nodes) {
-    		aux.add(0,n);
-    	}
-    	nodes = aux;
-    	this.changeNodes=true;
+        List<Node> aux = new ArrayList<Node>();
+        for (Node n : nodes) {
+            aux.add(0,n);
+        }
+        nodes = aux;
+        this.changeNodes=true;
     }
 
@@ -133,10 +134,10 @@
      */
     public List<OsmEdge> getRouteEdges() {
-    	if (this.changeNodes || path==null)
-    	{
-    		path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA);
-    		this.changeNodes=false;
-    	}
-    	return path;
+        if (this.changeNodes || path==null)
+        {
+            path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA);
+            this.changeNodes=false;
+        }
+        return path;
     }
 
@@ -145,5 +146,5 @@
      */
     public void setNodesChanged() {
-    	this.changeNodes = true;
+        this.changeNodes = true;
     }
 
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 15707)
@@ -26,7 +26,7 @@
  */
 
-
 package com.innovant.josm.plugin.routing;
 
+import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
 
@@ -60,8 +60,8 @@
  */
 public class RoutingPlugin extends Plugin implements LayerChangeListener {
-	/**
-	 * Logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingPlugin.class);
+    /**
+     * Logger
+     */
+    static Logger logger = Logger.getLogger(RoutingPlugin.class);
 
     /**
@@ -126,60 +126,59 @@
      * Default Constructor
      */
-	public RoutingPlugin() {
-		super();
-		plugin = this; // Assign reference to the plugin class
-		DOMConfigurator.configure("log4j.xml");
-		logger.debug("Loading routing plugin...");
-		preferenceSettings=new RoutingPreferenceDialog();
-		// Create side dialog
-		routingDialog = new RoutingDialog();
-		// Initialize layers list
-		layers = new ArrayList<RoutingLayer>();
+    public RoutingPlugin() {
+        super();
+        plugin = this; // Assign reference to the plugin class
+        DOMConfigurator.configure("log4j.xml");
+        logger.debug("Loading routing plugin...");
+        preferenceSettings=new RoutingPreferenceDialog();
+        // Create side dialog
+        routingDialog = new RoutingDialog();
+        // Initialize layers list
+        layers = new ArrayList<RoutingLayer>();
         // Add menu
-        menu = new RoutingMenu(tr("Routing"));
-        Main.main.menu.add(menu);
+        menu = new RoutingMenu(marktr("Routing"));
         // Register this class as LayerChangeListener
         Layer.listeners.add(this);
         logger.debug("Finished loading plugin");
-	}
-
-	/**
-	 * Provides static access to the plugin instance, to enable access to the plugin methods
-	 * @return the instance of the plugin
-	 */
-	public static RoutingPlugin getInstance() {
-		return plugin;
-	}
-
-	/**
-	 * Get the routing side dialog
-	 * @return The instance of the routing side dialog
-	 */
-	public RoutingDialog getRoutingDialog() {
-		return routingDialog;
-	}
-
-	public void addLayer() {
-		OsmDataLayer osmLayer = Main.main.editLayer();
-		RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.name + "]", osmLayer);
-		layers.add(layer);
-		Main.main.addLayer(layer);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.Plugin#mapFrameInitialized(org.openstreetmap.josm.gui.MapFrame, org.openstreetmap.josm.gui.MapFrame)
-	 */
+    }
+
+    /**
+     * Provides static access to the plugin instance, to enable access to the plugin methods
+     * @return the instance of the plugin
+     */
+    public static RoutingPlugin getInstance() {
+        return plugin;
+    }
+
+    /**
+     * Get the routing side dialog
+     * @return The instance of the routing side dialog
+     */
+    public RoutingDialog getRoutingDialog() {
+        return routingDialog;
+    }
+
+    public void addLayer() {
+        OsmDataLayer osmLayer = Main.main.editLayer();
+        RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.name + "]", osmLayer);
+        layers.add(layer);
+        Main.main.addLayer(layer);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.plugins.Plugin#mapFrameInitialized(org.openstreetmap.josm.gui.MapFrame, org.openstreetmap.josm.gui.MapFrame)
+     */
     @Override
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
         if(newFrame != null) {
-        	// Create plugin map modes
-        	addRouteNodeAction = new AddRouteNodeAction(newFrame);
-        	removeRouteNodeAction = new RemoveRouteNodeAction(newFrame);
-        	moveRouteNodeAction = new MoveRouteNodeAction(newFrame);
-        	// Create plugin buttons and add them to the toolbar
-        	addRouteNodeButton = new IconToggleButton(addRouteNodeAction);
-        	removeRouteNodeButton = new IconToggleButton(removeRouteNodeAction);
-        	moveRouteNodeButton = new IconToggleButton(moveRouteNodeAction);
+            // Create plugin map modes
+            addRouteNodeAction = new AddRouteNodeAction(newFrame);
+            removeRouteNodeAction = new RemoveRouteNodeAction(newFrame);
+            moveRouteNodeAction = new MoveRouteNodeAction(newFrame);
+            // Create plugin buttons and add them to the toolbar
+            addRouteNodeButton = new IconToggleButton(addRouteNodeAction);
+            removeRouteNodeButton = new IconToggleButton(removeRouteNodeAction);
+            moveRouteNodeButton = new IconToggleButton(moveRouteNodeAction);
             newFrame.addMapMode(addRouteNodeButton);
             newFrame.addMapMode(removeRouteNodeButton);
@@ -189,9 +188,9 @@
             newFrame.toolGroup.add(moveRouteNodeButton);
             // Hide them by default
-			addRouteNodeButton.setVisible(false);
-			removeRouteNodeButton.setVisible(false);
-			moveRouteNodeButton.setVisible(false);
-			// Enable menu
-			menu.enableStartItem();
+            addRouteNodeButton.setVisible(false);
+            removeRouteNodeButton.setVisible(false);
+            moveRouteNodeButton.setVisible(false);
+            // Enable menu
+            menu.enableStartItem();
             newFrame.addToggleDialog(routingDialog);
         }
@@ -202,63 +201,63 @@
      * @see org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener#activeLayerChange(org.openstreetmap.josm.gui.layer.Layer, org.openstreetmap.josm.gui.layer.Layer)
      */
-	public void activeLayerChange(Layer oldLayer, Layer newLayer) {
-		routingDialog.refresh();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener#layerAdded(org.openstreetmap.josm.gui.layer.Layer)
-	 */
-	public void layerAdded(Layer newLayer) {
-		// Add button(s) to the tool bar when the routing layer is added
-		if (newLayer instanceof RoutingLayer) {
-			addRouteNodeButton.setVisible(true);
-			removeRouteNodeButton.setVisible(true);
-			moveRouteNodeButton.setVisible(true);
-			menu.enableRestOfItems();
-			// Set layer on top and select layer, also refresh toggleDialog to reflect selection
-			Main.map.mapView.moveLayer(newLayer, 0);
-			logger.debug("Added routing layer.");
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener#layerRemoved(org.openstreetmap.josm.gui.layer.Layer)
-	 */
-	public void layerRemoved(Layer oldLayer) {
-		if ((oldLayer instanceof RoutingLayer) & (layers.size()==1)) {
-			// Remove button(s) from the tool bar when the last routing layer is removed
-			addRouteNodeButton.setVisible(false);
-			removeRouteNodeButton.setVisible(false);
-			moveRouteNodeButton.setVisible(false);
-			menu.disableRestOfItems();
-			layers.remove(oldLayer);
-    		logger.debug("Removed routing layer.");
-		} else if (oldLayer instanceof OsmDataLayer) {
-			// Remove all associated routing layers
-			// Convert to Array to prevent ConcurrentModificationException when removing layers from ArrayList
-			// FIXME: can't remove associated routing layers without triggering exceptions in some cases
-			RoutingLayer[] layersArray = layers.toArray(new RoutingLayer[0]);
-			for (int i=0;i<layersArray.length;i++) {
-				if (layersArray[i].getDataLayer().equals(oldLayer)) {
-					try {
-						// Remove layer
-						Main.map.mapView.removeLayer(layersArray[i]);
-					} catch (IllegalArgumentException e) {
-					}
-				}
-			}
-		}
-		// Reload RoutingDialog table model
-		routingDialog.refresh();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.Plugin#getPreferenceSetting()
-	 */
-	@Override
-	public PreferenceSetting getPreferenceSetting() {
-		return preferenceSettings;
-	}
+    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+        routingDialog.refresh();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener#layerAdded(org.openstreetmap.josm.gui.layer.Layer)
+     */
+    public void layerAdded(Layer newLayer) {
+        // Add button(s) to the tool bar when the routing layer is added
+        if (newLayer instanceof RoutingLayer) {
+            addRouteNodeButton.setVisible(true);
+            removeRouteNodeButton.setVisible(true);
+            moveRouteNodeButton.setVisible(true);
+            menu.enableRestOfItems();
+            // Set layer on top and select layer, also refresh toggleDialog to reflect selection
+            Main.map.mapView.moveLayer(newLayer, 0);
+            logger.debug("Added routing layer.");
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener#layerRemoved(org.openstreetmap.josm.gui.layer.Layer)
+     */
+    public void layerRemoved(Layer oldLayer) {
+        if ((oldLayer instanceof RoutingLayer) & (layers.size()==1)) {
+            // Remove button(s) from the tool bar when the last routing layer is removed
+            addRouteNodeButton.setVisible(false);
+            removeRouteNodeButton.setVisible(false);
+            moveRouteNodeButton.setVisible(false);
+            menu.disableRestOfItems();
+            layers.remove(oldLayer);
+            logger.debug("Removed routing layer.");
+        } else if (oldLayer instanceof OsmDataLayer) {
+            // Remove all associated routing layers
+            // Convert to Array to prevent ConcurrentModificationException when removing layers from ArrayList
+            // FIXME: can't remove associated routing layers without triggering exceptions in some cases
+            RoutingLayer[] layersArray = layers.toArray(new RoutingLayer[0]);
+            for (int i=0;i<layersArray.length;i++) {
+                if (layersArray[i].getDataLayer().equals(oldLayer)) {
+                    try {
+                        // Remove layer
+                        Main.map.mapView.removeLayer(layersArray[i]);
+                    } catch (IllegalArgumentException e) {
+                    }
+                }
+            }
+        }
+        // Reload RoutingDialog table model
+        routingDialog.refresh();
+    }
+
+    /* (non-Javadoc)
+     * @see org.openstreetmap.josm.plugins.Plugin#getPreferenceSetting()
+     */
+    @Override
+    public PreferenceSetting getPreferenceSetting() {
+        return preferenceSettings;
+    }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java	(revision 15707)
@@ -51,15 +51,15 @@
  */
 public class AddRouteNodeAction extends MapMode {
-	/**
-	 * Serial.
-	 */
-	private static final long serialVersionUID = 1L;
-	/**
-	 * Logger.
-	 */
-	static Logger logger = Logger.getLogger(AddRouteNodeAction.class);
-	/**
-	 * Routing Dialog.
-	 */
+    /**
+     * Serial.
+     */
+    private static final long serialVersionUID = 1L;
+    /**
+     * Logger.
+     */
+    static Logger logger = Logger.getLogger(AddRouteNodeAction.class);
+    /**
+     * Routing Dialog.
+     */
     private RoutingDialog routingDialog;
 
@@ -68,11 +68,11 @@
      * @param mapFrame
      */
-	public AddRouteNodeAction(MapFrame mapFrame) {
-		// TODO Use constructor with shortcut
-		super(tr("Routing"), "add",
-				tr("Click to add destination."),
-				mapFrame, ImageProvider.getCursor("crosshair", null));
+    public AddRouteNodeAction(MapFrame mapFrame) {
+        // TODO Use constructor with shortcut
+        super(tr("Routing"), "add",
+                tr("Click to add destination."),
+                mapFrame, ImageProvider.getCursor("crosshair", null));
         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
-	}
+    }
 
     @Override public void enterMode() {
@@ -89,11 +89,11 @@
         // If left button is clicked
         if (e.getButton() == MouseEvent.BUTTON1) {
-        	// Search for nearest highway node
-        	Node node = null;
-        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-        		node = layer.getNearestHighwayNode(e.getPoint());
+            // Search for nearest highway node
+            Node node = null;
+            if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                node = layer.getNearestHighwayNode(e.getPoint());
                 if(node == null) {
-                	logger.debug("no selected node");
+                    logger.debug("no selected node");
                     return;
                 }
@@ -101,5 +101,5 @@
                 layer.getRoutingModel().addNode(node);
                 routingDialog.addNode(node);
-        	}
+            }
         }
         Main.map.repaint();
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java	(revision 15707)
@@ -54,22 +54,22 @@
  */
 public class MoveRouteNodeAction extends MapMode {
-	/**
-	 * Serial.
-	 */
-	private static final long serialVersionUID = 1L;
+    /**
+     * Serial.
+     */
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * Square of the distance radius where route nodes can be selected for dragging
-	 */
-	private static final int DRAG_SQR_RADIUS = 100;
+    /**
+     * Square of the distance radius where route nodes can be selected for dragging
+     */
+    private static final int DRAG_SQR_RADIUS = 100;
 
-	/**
-	 * Logger.
-	 */
-	static Logger logger = Logger.getLogger(RoutingLayer.class);
+    /**
+     * Logger.
+     */
+    static Logger logger = Logger.getLogger(RoutingLayer.class);
 
-	/**
-	 * Routing Dialog.
-	 */
+    /**
+     * Routing Dialog.
+     */
     private RoutingDialog routingDialog;
 
@@ -83,11 +83,11 @@
      * @param mapFrame
      */
-	public MoveRouteNodeAction(MapFrame mapFrame) {
-		// TODO Use constructor with shortcut
-		super(tr("Routing"), "move",
-				tr("Click and drag to move destination"),
-				mapFrame, ImageProvider.getCursor("normal", "move"));
+    public MoveRouteNodeAction(MapFrame mapFrame) {
+        // TODO Use constructor with shortcut
+        super(tr("Routing"), "move",
+                tr("Click and drag to move destination"),
+                mapFrame, ImageProvider.getCursor("normal", "move"));
         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
-	}
+    }
 
     @Override public void enterMode() {
@@ -104,29 +104,29 @@
         // If left button is pressed
         if (e.getButton() == MouseEvent.BUTTON1) {
-        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-        		RoutingModel routingModel = layer.getRoutingModel();
-            	// Search for the nearest node in the list
-            	List<Node> nl = routingModel.getSelectedNodes();
-            	index = -1;
-            	double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
-               	for (int i=0;i<nl.size();i++) {
-               		Node node = nl.get(i);
-            		double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
-            		if (d < dmax) {
-            			dmax = d;
-            			index = i;
-            		}
-            	}
-               	if (index>=0)
+            if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                RoutingModel routingModel = layer.getRoutingModel();
+                // Search for the nearest node in the list
+                List<Node> nl = routingModel.getSelectedNodes();
+                index = -1;
+                double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
+                for (int i=0;i<nl.size();i++) {
+                    Node node = nl.get(i);
+                    double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
+                    if (d < dmax) {
+                        dmax = d;
+                        index = i;
+                    }
+                }
+                if (index>=0)
                     logger.debug("Moved from node " + nl.get(index));
-        	}
+            }
         }
     }
 
     @Override public void mouseReleased(MouseEvent e) {
-    	// If left button is released and a route node is being dragged
-    	if ((e.getButton() == MouseEvent.BUTTON1) && (index>=0)) {
-    		searchAndReplaceNode(e.getPoint());
+        // If left button is released and a route node is being dragged
+        if ((e.getButton() == MouseEvent.BUTTON1) && (index>=0)) {
+            searchAndReplaceNode(e.getPoint());
         }
     }
@@ -136,21 +136,21 @@
 
     private void searchAndReplaceNode(Point point) {
-    	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-    		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-    		RoutingModel routingModel = layer.getRoutingModel();
-        	// Search for nearest highway node
-        	Node node = null;
-    		node = layer.getNearestHighwayNode(point);
+        if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+            RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+            RoutingModel routingModel = layer.getRoutingModel();
+            // Search for nearest highway node
+            Node node = null;
+            node = layer.getNearestHighwayNode(point);
             if (node == null) {
-            	logger.debug("Didn't found a close node to move to.");
+                logger.debug("Didn't found a close node to move to.");
                 return;
             }
             logger.debug("Moved to node " + node);
             routingModel.removeNode(index);
-    		routingDialog.removeNode(index);
+            routingDialog.removeNode(index);
             routingModel.insertNode(index, node);
-    		routingDialog.insertNode(index, node);
+            routingDialog.insertNode(index, node);
             Main.map.repaint();
-    	}
+        }
     }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java	(revision 15707)
@@ -53,30 +53,30 @@
  */
 public class RemoveRouteNodeAction extends MapMode {
-	/**
-	 * Serial.
-	 */
-	private static final long serialVersionUID = 1L;
+    /**
+     * Serial.
+     */
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * Square of the distance radius where route nodes can be removed
-	 */
-	private static final int REMOVE_SQR_RADIUS = 100;
+    /**
+     * Square of the distance radius where route nodes can be removed
+     */
+    private static final int REMOVE_SQR_RADIUS = 100;
 
-	/**
-	 * Logger.
-	 */
-	static Logger logger = Logger.getLogger(RoutingLayer.class);
-	/**
-	 * Routing Dialog.
-	 */
+    /**
+     * Logger.
+     */
+    static Logger logger = Logger.getLogger(RoutingLayer.class);
+    /**
+     * Routing Dialog.
+     */
     private RoutingDialog routingDialog;
 
-	public RemoveRouteNodeAction(MapFrame mapFrame) {
-		// TODO Use constructor with shortcut
-		super(tr("Routing"), "remove",
-				tr("Click to remove destination"),
-				mapFrame, ImageProvider.getCursor("normal", "delete"));
+    public RemoveRouteNodeAction(MapFrame mapFrame) {
+        // TODO Use constructor with shortcut
+        super(tr("Routing"), "remove",
+                tr("Click to remove destination"),
+                mapFrame, ImageProvider.getCursor("normal", "delete"));
         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
-	}
+    }
 
     @Override public void enterMode() {
@@ -93,30 +93,30 @@
         // If left button is clicked
         if (e.getButton() == MouseEvent.BUTTON1) {
-        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-        		RoutingModel routingModel = layer.getRoutingModel();
-            	// Search for the nearest node in the list
-            	List<Node> nl = routingModel.getSelectedNodes();
-            	int index = -1;
-            	double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
-               	for (int i=0;i<nl.size();i++) {
-               		Node node = nl.get(i);
-            		double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
-            		if (d < dmax) {
-            			dmax = d;
-            			index = i;
-            		}
-            	}
-               	// If found a close node, remove it and recalculate route
+            if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                RoutingModel routingModel = layer.getRoutingModel();
+                // Search for the nearest node in the list
+                List<Node> nl = routingModel.getSelectedNodes();
+                int index = -1;
+                double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
+                for (int i=0;i<nl.size();i++) {
+                    Node node = nl.get(i);
+                    double d = Main.map.mapView.getPoint(node.eastNorth).distanceSq(e.getPoint());
+                    if (d < dmax) {
+                        dmax = d;
+                        index = i;
+                    }
+                }
+                // If found a close node, remove it and recalculate route
                 if (index >= 0) {
-                	// Remove node
-                	logger.debug("Removing node " + nl.get(index));
+                    // Remove node
+                    logger.debug("Removing node " + nl.get(index));
                     routingModel.removeNode(index);
-            		routingDialog.removeNode(index);
+                    routingDialog.removeNode(index);
                     Main.map.repaint();
                 } else {
-                	logger.debug("Can't find a node to remove.");
+                    logger.debug("Can't find a node to remove.");
                 }
-        	}
+            }
         }
     }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 15707)
@@ -56,101 +56,101 @@
 public class RoutingDialog extends ToggleDialog {
 
-	private DefaultListModel model;
-	private JList jList = null;
-	private JScrollPane jScrollPane = null;
+    private DefaultListModel model;
+    private JList jList = null;
+    private JScrollPane jScrollPane = null;
 
-	/**
-	 * Serial UID
-	 */
-	private static final long serialVersionUID = 8625615652900341987L;
+    /**
+     * Serial UID
+     */
+    private static final long serialVersionUID = 8625615652900341987L;
 
-	public RoutingDialog() {
-		super(tr("Routing"), "routing", tr("Open a list of routing nodes"),
-				Shortcut.registerShortcut("subwindow:relations", tr("Toggle: {0}", tr("Routing")), KeyEvent.VK_R, Shortcut.GROUP_LAYER), 150);
-		model= new DefaultListModel();
-		this.setSize(456, 292);
-		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
-		this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
-		this.setName("PrincipalDialog");
-		this.setFont(new Font("Dialog", Font.PLAIN, 12));
-		this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
-		this.add(getJScrollPane(), null);
+    public RoutingDialog() {
+        super(tr("Routing"), "routing", tr("Open a list of routing nodes"),
+                Shortcut.registerShortcut("subwindow:relations", tr("Toggle: {0}", tr("Routing")), KeyEvent.VK_R, Shortcut.GROUP_LAYER), 150);
+        model= new DefaultListModel();
+        this.setSize(456, 292);
+        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+        this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
+        this.setName("PrincipalDialog");
+        this.setFont(new Font("Dialog", Font.PLAIN, 12));
+        this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+        this.add(getJScrollPane(), null);
 
-	}
+    }
 
-	/**
-	 * This method initializes jScrollPane
-	 *
-	 * @return javax.swing.JScrollPane
-	 */
-	private JScrollPane getJScrollPane() {
-		if (jScrollPane == null) {
-			jScrollPane = new JScrollPane();
-			jScrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
-			jScrollPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
-			jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-			jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
-			jScrollPane.setName("nList");
-			jScrollPane.setViewportBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
-			jScrollPane.setViewportView(getJList());
-		}
-		return jScrollPane;
-	}
+    /**
+     * This method initializes jScrollPane
+     *
+     * @return javax.swing.JScrollPane
+     */
+    private JScrollPane getJScrollPane() {
+        if (jScrollPane == null) {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+            jScrollPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+            jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane.setName("nList");
+            jScrollPane.setViewportBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+            jScrollPane.setViewportView(getJList());
+        }
+        return jScrollPane;
+    }
 
-	/**
-	 * This method initializes jList
-	 *
-	 * @return javax.swing.JList
-	 */
-	private JList getJList() {
-		if (jList == null) {
-			jList = new JList();
-			jList.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
-			jList.setModel(model);
-		}
-		return jList;
-	}
+    /**
+     * This method initializes jList
+     *
+     * @return javax.swing.JList
+     */
+    private JList getJList() {
+        if (jList == null) {
+            jList = new JList();
+            jList.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+            jList.setModel(model);
+        }
+        return jList;
+    }
 
-	/**
-	 * Remove item from the list of nodes
-	 * @param index
-	 */
-	public void removeNode(int index) {
-		model.remove(index);
-	}
+    /**
+     * Remove item from the list of nodes
+     * @param index
+     */
+    public void removeNode(int index) {
+        model.remove(index);
+    }
 
-	/**
-	 * Add item to the list of nodes
-	 * @param obj
-	 */
-	public void addNode(Node n) {
-		model.addElement(n.id+" ["+n.coor.toDisplayString()+"]");
-	}
+    /**
+     * Add item to the list of nodes
+     * @param obj
+     */
+    public void addNode(Node n) {
+        model.addElement(n.id+" ["+n.coor.toDisplayString()+"]");
+    }
 
-	/**
-	 * Insert item to the list of nodes
-	 * @param index
-	 * @param obj
-	 */
-	public void insertNode(int index, Node n) {
-		model.insertElementAt(n.id+" ["+n.coor.toDisplayString()+"]", index);
-	}
+    /**
+     * Insert item to the list of nodes
+     * @param index
+     * @param obj
+     */
+    public void insertNode(int index, Node n) {
+        model.insertElementAt(n.id+" ["+n.coor.toDisplayString()+"]", index);
+    }
 
-	/**
-	 * Clear list of nodes
-	 */
-	public void clearNodes() {
-		model.clear();
-	}
+    /**
+     * Clear list of nodes
+     */
+    public void clearNodes() {
+        model.clear();
+    }
 
-	public void refresh() {
-		clearNodes();
-    	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-    		RoutingLayer routingLayer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-    		RoutingModel routingModel = routingLayer.getRoutingModel();
-    		for (Node n : routingModel.getSelectedNodes()) {
-    			addNode(n);
-    		}
-    	}
-	}
+    public void refresh() {
+        clearNodes();
+        if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+            RoutingLayer routingLayer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+            RoutingModel routingModel = routingLayer.getRoutingModel();
+            for (Node n : routingModel.getSelectedNodes()) {
+                addNode(n);
+            }
+        }
+    }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java	(revision 15707)
@@ -34,4 +34,5 @@
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
 
 import javax.swing.ButtonGroup;
@@ -42,4 +43,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MainMenu;
 
 import com.innovant.josm.jrt.core.RoutingGraph.RouteType;
@@ -55,138 +57,137 @@
 public class RoutingMenu extends JMenu {
 
-	/**
-	 * Default serial version UID
-	 */
-	private static final long serialVersionUID = 3559922048225708480L;
+    /**
+     * Default serial version UID
+     */
+    private static final long serialVersionUID = 3559922048225708480L;
 
-	private JMenuItem startMI;
-	private JMenuItem reverseMI;
-	private JMenuItem clearMI;
-	private JMenu criteriaM;
+    private JMenuItem startMI;
+    private JMenuItem reverseMI;
+    private JMenuItem clearMI;
+    private JMenu criteriaM;
+    private JMenu menu;
 
-	/**
-	 * @param s
-	 */
-	public RoutingMenu(final String name) {
-		super(name);
+    /**
+     * @param s
+     */
+    public RoutingMenu(final String name) {
+        MainMenu mm = Main.main.menu;
+        menu = mm.addMenu(name, KeyEvent.VK_R, mm.defaultMenuPos);
 
-		JMenuItem mi;
-		JMenu m;
+        startMI = new JMenuItem(tr("Add routing layer"));
+        startMI.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                RoutingPlugin.getInstance().addLayer();
+            }
+        });
+        menu.add(startMI);
 
-		startMI = new JMenuItem(tr("Add routing layer"));
-		startMI.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				RoutingPlugin.getInstance().addLayer();
-			}
-		});
-		this.add(startMI);
+        menu.addSeparator();
+        ButtonGroup group = new ButtonGroup();
 
-		this.addSeparator();
-		ButtonGroup group = new ButtonGroup();
+        criteriaM = new JMenu(tr("Criteria"));
 
-		criteriaM = new JMenu(tr("Criteria"));
+        JRadioButtonMenuItem rshorter = new JRadioButtonMenuItem(tr("Shortest"));
+        rshorter.setSelected(true);
+        rshorter.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                    RoutingModel routingModel = layer.getRoutingModel();
+                    if (e.getStateChange()==ItemEvent.SELECTED) {
+                        routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
+                    } else {
+                        routingModel.routingGraph.setTypeRoute(RouteType.FASTEST);
+                    }
+                //  routingModel.routingGraph.resetGraph();
+                //  routingModel.routingGraph.createGraph();
+                    //TODO: Change this way
+                    //FIXME: do not change node but recalculate routing.
+                    routingModel.setNodesChanged();
+                    Main.map.repaint();
+                }
+            }
 
-		JRadioButtonMenuItem rshorter = new JRadioButtonMenuItem(tr("Shortest"));
-		rshorter.setSelected(true);
-		rshorter.addItemListener(new ItemListener() {
-			public void itemStateChanged(ItemEvent e) {
-	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-	        		RoutingModel routingModel = layer.getRoutingModel();
-					if (e.getStateChange()==ItemEvent.SELECTED) {
-						routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
-					} else {
-						routingModel.routingGraph.setTypeRoute(RouteType.FASTEST);
-					}
-				//	routingModel.routingGraph.resetGraph();
-				//	routingModel.routingGraph.createGraph();
-					//TODO: Change this way
-					//FIXME: do not change node but recalculate routing.
-					routingModel.setNodesChanged();
-					Main.map.repaint();
-	        	}
-			}
+        });
 
-		});
+        JRadioButtonMenuItem rfaster = new JRadioButtonMenuItem(tr("Fastest"));
+        group.add(rshorter);
+        group.add(rfaster);
+        criteriaM.add(rshorter);
+        criteriaM.add(rfaster);
 
-		JRadioButtonMenuItem rfaster = new JRadioButtonMenuItem(tr("Fastest"));
-		group.add(rshorter);
-		group.add(rfaster);
-		criteriaM.add(rshorter);
-		criteriaM.add(rfaster);
+        criteriaM.addSeparator();
+        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Ignore oneways");
+        cbmi.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                    RoutingModel routingModel = layer.getRoutingModel();
+                    if (e.getStateChange()==ItemEvent.SELECTED)
+                        routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
+                    else
+                        routingModel.routingGraph.getRoutingProfile().setOnewayUse(true);
+                    routingModel.setNodesChanged();
+                    Main.map.repaint();
+                }
+            }
+        });
+        criteriaM.add(cbmi);
+        menu.add(criteriaM);
 
-		criteriaM.addSeparator();
-		JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Ignore oneways");
-		cbmi.addItemListener(new ItemListener() {
-			public void itemStateChanged(ItemEvent e) {
-	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-	        		RoutingModel routingModel = layer.getRoutingModel();
-					if (e.getStateChange()==ItemEvent.SELECTED)
-						routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
-					else
-						routingModel.routingGraph.getRoutingProfile().setOnewayUse(true);
-					routingModel.setNodesChanged();
-					Main.map.repaint();
-	        	}
-			}
-		});
-		criteriaM.add(cbmi);
-		this.add(criteriaM);
+        menu.addSeparator();
+        reverseMI = new JMenuItem(tr("Reverse route"));
+        reverseMI.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                    RoutingModel routingModel = layer.getRoutingModel();
+                    routingModel.reverseNodes();
+                    Main.map.repaint();
+                }
+            }
+        });
+        menu.add(reverseMI);
 
-		this.addSeparator();
-		reverseMI = new JMenuItem(tr("Reverse route"));
-		reverseMI.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-	        		RoutingModel routingModel = layer.getRoutingModel();
-					routingModel.reverseNodes();
-					Main.map.repaint();
-	        	}
-			}
-		});
-		this.add(reverseMI);
+        clearMI = new JMenuItem(tr("Clear route"));
+        clearMI.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
+                    RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+                    RoutingModel routingModel = layer.getRoutingModel();
+                    // Reset routing nodes and paths
+                    routingModel.reset();
+                    RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
+                    Main.map.repaint();
+                }
+            }
+        });
+        menu.add(clearMI);
 
-		clearMI = new JMenuItem(tr("Clear route"));
-		clearMI.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-	        	if (Main.map.mapView.getActiveLayer() instanceof RoutingLayer) {
-	        		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-	        		RoutingModel routingModel = layer.getRoutingModel();
-					// Reset routing nodes and paths
-					routingModel.reset();
-					RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
-					Main.map.repaint();
-	        	}
-			}
-		});
-		this.add(clearMI);
+        // Initially disabled
+        disableAllItems();
+    }
 
-		// Initially disabled
-		disableAllItems();
-	}
+    public void disableAllItems() {
+        startMI.setEnabled(false);
+        reverseMI.setEnabled(false);
+        clearMI.setEnabled(false);
+        criteriaM.setEnabled(false);
+    }
 
-	public void disableAllItems() {
-		startMI.setEnabled(false);
-		reverseMI.setEnabled(false);
-		clearMI.setEnabled(false);
-		criteriaM.setEnabled(false);
-	}
+    public void enableStartItem() {
+        startMI.setEnabled(true);
+    }
 
-	public void enableStartItem() {
-		startMI.setEnabled(true);
-	}
+    public void enableRestOfItems() {
+        reverseMI.setEnabled(true);
+        clearMI.setEnabled(true);
+        criteriaM.setEnabled(true);
+    }
 
-	public void enableRestOfItems() {
-		reverseMI.setEnabled(true);
-		clearMI.setEnabled(true);
-		criteriaM.setEnabled(true);
-	}
-
-	public void disableRestOfItems() {
-		reverseMI.setEnabled(false);
-		clearMI.setEnabled(false);
-		criteriaM.setEnabled(false);
-	}
+    public void disableRestOfItems() {
+        reverseMI.setEnabled(false);
+        clearMI.setEnabled(false);
+        criteriaM.setEnabled(false);
+    }
 }
Index: /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java	(revision 15706)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java	(revision 15707)
@@ -64,172 +64,172 @@
 public class RoutingPreferenceDialog implements PreferenceSetting {
 
-	/**
-	 * Logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingPreferenceDialog.class);
-
-	private Map<String, String> orig;
-	private DefaultTableModel model;
-
-	/**
-	 * Constructor
-	 */
-	public RoutingPreferenceDialog() {
-		super();
-		readPreferences();
-	}
-
-	public void addGui(final PreferenceDialog gui) {
-
-		JPanel principal = gui.createPreferenceTab("routing",
-				tr("Routing Plugin Preferences"), tr("Configure routing preferences."));
-
-		JPanel p = new JPanel();
-		p.setLayout(new GridBagLayout());
-
-		model = new DefaultTableModel(new String[] { tr("Highway type"),
-				tr("Speed (Km/h)") }, 0) {
-			private static final long serialVersionUID = 4253339034781567453L;
-
-			@Override
-			public boolean isCellEditable(int row, int column) {
-				return column != 0;
-			}
-		};
-		final JTable list = new JTable(model);
-		loadSpeeds(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("Weight")), GBC.std().insets(0, 0, 5, 0));
-				JComboBox key = new JComboBox();
-				for (OsmWayTypes pk : OsmWayTypes.values())
-					key.addItem(pk.getTag());
-				JTextField value = new JTextField(10);
-				p.add(key, GBC.eop().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
-				p.add(new JLabel(tr("Value")), 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 weight values"),
-						JOptionPane.OK_CANCEL_OPTION);
-				if (answer == JOptionPane.OK_OPTION) {
-					model
-					.addRow(new String[] {
-							key.getSelectedItem().toString(),
-							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 edit = new JButton(tr("Edit"));
-		p.add(edit, GBC.std().insets(5, 5, 5, 0));
-		edit.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				edit(gui, list);
-			}
-		});
-
-		JTabbedPane Opciones = new JTabbedPane();
-		Opciones.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
-
-		Opciones.addTab("Profile", null, p, null);
-//		Opciones.addTab("Preferences", new JPanel());
-
-		list.addMouseListener(new MouseAdapter(){
-			@Override public void mouseClicked(MouseEvent e) {
-				if (e.getClickCount() == 2)
-					edit(gui, list);
-			}
-		});
-
-		principal.add(Opciones, GBC.eol().fill(GBC.BOTH));
-
-	}
-
-	public boolean ok() {
-		for (int i = 0; i < model.getRowCount(); ++i) {
-			String value = model.getValueAt(i, 1).toString();
-			if (value.length() != 0) {
-				String key = model.getValueAt(i, 0).toString();
-				String origValue = orig.get(key);
-				if (origValue == null || !origValue.equals(value))
-					Main.pref.put(key, value);
-				orig.remove(key); // processed.
-			}
-		}
-		for (Entry<String, String> e : orig.entrySet())
-			Main.pref.put(e.getKey(), null);
-		return false;
-	}
-
-	private void edit(final PreferenceDialog gui, final JTable list) {
-		if (list.getSelectedRowCount() != 1) {
-			JOptionPane.showMessageDialog(gui,
-					tr("Please select the row to edit."));
-			return;
-		}
-		String v = JOptionPane.showInputDialog(tr("New value for {0}", model
-				.getValueAt(list.getSelectedRow(), 0)), model.getValueAt(list
-						.getSelectedRow(), 1));
-		if (v != null)
-			model.setValueAt(v, list.getSelectedRow(), 1);
-	}
-
-	private void loadSpeeds(DefaultTableModel model) {
-		// Read dialog values from preferences
-		readPreferences();
-		// Put these values in the model
-		for (String tag : orig.keySet()) {
-			model.addRow(new String[] { tag, orig.get(tag) });
-		}
-	}
-
-	private void readPreferences() {
-		orig = Main.pref.getAllPrefix("routing.profile.default.speed");
-		if (orig.size() == 0) { // defaults
-			logger.debug("Loading Default Preferences.");
-			for (OsmWayTypes owt : OsmWayTypes.values()) {
-				Main.pref.putInteger("routing.profile.default.speed."
-						+ owt.getTag(), owt.getSpeed());
-			}
-			orig = Main.pref.getAllPrefix("routing.profile.default.speed");
-		}
-		else logger.debug("Default preferences already exist.");
-	}
-
-	private String getKeyTag(String tag) {
-		return tag.split(".", 5)[4];
-	}
-
-	private String getTypeTag(String tag) {
-		return tag.split(".", 5)[3];
-	}
-
-	private String getNameTag(String tag) {
-		return tag.split(".", 5)[2];
-	}
+    /**
+     * Logger
+     */
+    static Logger logger = Logger.getLogger(RoutingPreferenceDialog.class);
+
+    private Map<String, String> orig;
+    private DefaultTableModel model;
+
+    /**
+     * Constructor
+     */
+    public RoutingPreferenceDialog() {
+        super();
+        readPreferences();
+    }
+
+    public void addGui(final PreferenceDialog gui) {
+
+        JPanel principal = gui.createPreferenceTab("routing",
+                tr("Routing Plugin Preferences"), tr("Configure routing preferences."));
+
+        JPanel p = new JPanel();
+        p.setLayout(new GridBagLayout());
+
+        model = new DefaultTableModel(new String[] { tr("Highway type"),
+                tr("Speed (Km/h)") }, 0) {
+            private static final long serialVersionUID = 4253339034781567453L;
+
+            @Override
+            public boolean isCellEditable(int row, int column) {
+                return column != 0;
+            }
+        };
+        final JTable list = new JTable(model);
+        loadSpeeds(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("Weight")), GBC.std().insets(0, 0, 5, 0));
+                JComboBox key = new JComboBox();
+                for (OsmWayTypes pk : OsmWayTypes.values())
+                    key.addItem(pk.getTag());
+                JTextField value = new JTextField(10);
+                p.add(key, GBC.eop().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
+                p.add(new JLabel(tr("Value")), 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 weight values"),
+                        JOptionPane.OK_CANCEL_OPTION);
+                if (answer == JOptionPane.OK_OPTION) {
+                    model
+                    .addRow(new String[] {
+                            key.getSelectedItem().toString(),
+                            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 edit = new JButton(tr("Edit"));
+        p.add(edit, GBC.std().insets(5, 5, 5, 0));
+        edit.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                edit(gui, list);
+            }
+        });
+
+        JTabbedPane Opciones = new JTabbedPane();
+        Opciones.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+
+        Opciones.addTab("Profile", null, p, null);
+//      Opciones.addTab("Preferences", new JPanel());
+
+        list.addMouseListener(new MouseAdapter(){
+            @Override public void mouseClicked(MouseEvent e) {
+                if (e.getClickCount() == 2)
+                    edit(gui, list);
+            }
+        });
+
+        principal.add(Opciones, GBC.eol().fill(GBC.BOTH));
+
+    }
+
+    public boolean ok() {
+        for (int i = 0; i < model.getRowCount(); ++i) {
+            String value = model.getValueAt(i, 1).toString();
+            if (value.length() != 0) {
+                String key = model.getValueAt(i, 0).toString();
+                String origValue = orig.get(key);
+                if (origValue == null || !origValue.equals(value))
+                    Main.pref.put(key, value);
+                orig.remove(key); // processed.
+            }
+        }
+        for (Entry<String, String> e : orig.entrySet())
+            Main.pref.put(e.getKey(), null);
+        return false;
+    }
+
+    private void edit(final PreferenceDialog gui, final JTable list) {
+        if (list.getSelectedRowCount() != 1) {
+            JOptionPane.showMessageDialog(gui,
+                    tr("Please select the row to edit."));
+            return;
+        }
+        String v = JOptionPane.showInputDialog(tr("New value for {0}", model
+                .getValueAt(list.getSelectedRow(), 0)), model.getValueAt(list
+                        .getSelectedRow(), 1));
+        if (v != null)
+            model.setValueAt(v, list.getSelectedRow(), 1);
+    }
+
+    private void loadSpeeds(DefaultTableModel model) {
+        // Read dialog values from preferences
+        readPreferences();
+        // Put these values in the model
+        for (String tag : orig.keySet()) {
+            model.addRow(new String[] { tag, orig.get(tag) });
+        }
+    }
+
+    private void readPreferences() {
+        orig = Main.pref.getAllPrefix("routing.profile.default.speed");
+        if (orig.size() == 0) { // defaults
+            logger.debug("Loading Default Preferences.");
+            for (OsmWayTypes owt : OsmWayTypes.values()) {
+                Main.pref.putInteger("routing.profile.default.speed."
+                        + owt.getTag(), owt.getSpeed());
+            }
+            orig = Main.pref.getAllPrefix("routing.profile.default.speed");
+        }
+        else logger.debug("Default preferences already exist.");
+    }
+
+    private String getKeyTag(String tag) {
+        return tag.split(".", 5)[4];
+    }
+
+    private String getTypeTag(String tag) {
+        return tag.split(".", 5)[3];
+    }
+
+    private String getNameTag(String tag) {
+        return tag.split(".", 5)[2];
+    }
 }
Index: /applications/editors/josm/plugins/slippymap/build.xml
===================================================================
--- /applications/editors/josm/plugins/slippymap/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/slippymap/build.xml	(revision 15707)
@@ -26,5 +26,5 @@
                 <attribute name="Plugin-Description" value="Displays a slippy map grid in JOSM. Can load tiles from slippy map as background and request updates."/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/SlippyMap"/>
-                <attribute name="Plugin-Mainversion" value="1465"/>
+                <attribute name="Plugin-Mainversion" value="1646"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
             </manifest>
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java	(revision 15706)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java	(revision 15707)
@@ -36,616 +36,616 @@
 /**
  * Class that displays a slippy map layer.
- * 
+ *
  * @author Frederik Ramm <frederik@remote.org>
  * @author LuVar <lubomir.varga@freemap.sk>
  * @author Dave Hansen <dave@sr71.net>
- * 
+ *
  */
 public class SlippyMapLayer extends Layer implements ImageObserver,
-		PreferenceChangedListener {
-	/**
-	 * Actual zoom lvl. Initial zoom lvl is set to
-	 * {@link SlippyMapPreferences#getMinZoomLvl()}.
-	 */
-	public int currentZoomLevel = SlippyMapPreferences.getMinZoomLvl();
-	private HashMap<SlippyMapKey, SlippyMapTile> tileStorage = null;
-
-	Point[][] pixelpos = new Point[21][21];
-	LatLon lastTopLeft;
-	LatLon lastBotRight;
-	int z12x0, z12x1, z12y0, z12y1;
-	private Image bufferImage;
-	private SlippyMapTile clickedTile;
-	private boolean needRedraw;
-	private JPopupMenu tileOptionMenu;
-
-	@SuppressWarnings("serial")
-	public SlippyMapLayer() {
-		super(tr("Slippy Map"));
-		background = true;
-
-		clearTileStorage();
-
-		tileOptionMenu = new JPopupMenu();
-		tileOptionMenu.add(new JMenuItem(new AbstractAction(tr("Load Tile")) {
-			public void actionPerformed(ActionEvent ae) {
-				if (clickedTile != null) {
-					loadSingleTile(clickedTile);
-					needRedraw = true;
-					Main.map.repaint();
-				}
-			}
-		}));
-
-		tileOptionMenu.add(new JMenuItem(new AbstractAction(
-				tr("Show Tile Status")) {
-			public void actionPerformed(ActionEvent ae) {
-				if (clickedTile != null) {
-					clickedTile.loadMetadata();
-					needRedraw = true;
-					Main.map.repaint();
-				}
-			}
-		}));
-
-		tileOptionMenu.add(new JMenuItem(new AbstractAction(
-				tr("Request Update")) {
-			public void actionPerformed(ActionEvent ae) {
-				if (clickedTile != null) {
-					clickedTile.requestUpdate();
-					needRedraw = true;
-					Main.map.repaint();
-				}
-			}
-		}));
-
-		tileOptionMenu.add(new JMenuItem(new AbstractAction(
-				tr("Load All Tiles")) {
-			public void actionPerformed(ActionEvent ae) {
-				loadAllTiles();
-				needRedraw = true;
-				Main.map.repaint();
-			}
-		}));
-
-		// increase and decrease commands
-		tileOptionMenu.add(new JMenuItem(
-				new AbstractAction(tr("Increase zoom")) {
-					public void actionPerformed(ActionEvent ae) {
-						increaseZoomLevel();
-						needRedraw = true;
-						Main.map.repaint();
-					}
-				}));
-
-		tileOptionMenu.add(new JMenuItem(
-				new AbstractAction(tr("Decrease zoom")) {
-					public void actionPerformed(ActionEvent ae) {
-						decreaseZoomLevel();
-						Main.map.repaint();
-					}
-				}));
-		// end of adding menu commands
-
-		SwingUtilities.invokeLater(new Runnable() {
-			public void run() {
-				Main.map.mapView.addMouseListener(new MouseAdapter() {
-					@Override
-					public void mouseClicked(MouseEvent e) {
-						if (e.getButton() != MouseEvent.BUTTON3)
-							return;
-						clickedTile = getTileForPixelpos(e.getX(), e.getY());
-						tileOptionMenu.show(e.getComponent(), e.getX(), e
-								.getY());
-					}
-				});
-
-				listeners.add(new LayerChangeListener() {
-					public void activeLayerChange(Layer oldLayer, Layer newLayer) {
-					}
-
-					public void layerAdded(Layer newLayer) {
-					}
-
-					public void layerRemoved(Layer oldLayer) {
-						Main.pref.listener.remove(SlippyMapLayer.this);
-					}
-				});
-			}
-		});
-
-		Main.pref.listener.add(this);
-	}
-
-	/**
-	 * Zoom in, go closer to map.
-	 */
-	public void increaseZoomLevel() {
-		if (currentZoomLevel < SlippyMapPreferences.getMaxZoomLvl()) {
-			currentZoomLevel++;
-			Main.debug("increasing zoom level to: " + currentZoomLevel);
-			needRedraw = true;
-		} else {
-			System.err.println("current zoom lvl ("+currentZoomLevel+") couldnt be increased. "+
-							 "MaxZoomLvl ("+SlippyMapPreferences.getMaxZoomLvl()+") reached.");
-		}
-	}
-
-	/**
-	 * Zoom out from map.
-	 */
-	public void decreaseZoomLevel() {
-		if (currentZoomLevel > SlippyMapPreferences.getMinZoomLvl()) {
-			Main.debug("decreasing zoom level to: " + currentZoomLevel);
-			currentZoomLevel--;
-			needRedraw = true;
-		} else {
-			System.err.println("current zoom lvl couldnt be decreased. MinZoomLvl reached.");
-		}
-	}
-
-	public void clearTileStorage() {
-		// when max zoom lvl is begin saved, this method is called and probably
-		// the setting isnt saved yet.
-		int maxZoom = 30; // SlippyMapPreferences.getMaxZoomLvl();
-		tileStorage = new HashMap<SlippyMapKey, SlippyMapTile>();
-
-		checkTileStorage();
-	}
-
-	class TileTimeComp implements Comparator<SlippyMapTile> {
-			public int compare(SlippyMapTile s1, SlippyMapTile s2) {
-					long t1 = s1.access_time();
-					long t2 = s2.access_time();
-					if (s1 == s2)
-							return 0;
-					if (t1 == t2) {
-							t1 = s1.hashCode();
-							t2 = s2.hashCode();
-					}
-					if (t1 < t2)
-							return -1;
-					return 1;
-			}
-	}
-
-	long lastCheck = 0;
-	/**
-	 * <p>
-	 * Check if tiles.size() is not more than max_nr_tiles. If yes, oldest tiles by timestamp
-	 * are fired out from cache.
-	 * </p>
-	 */
-	public void checkTileStorage() {
-		int maxZoom = 30; // SlippyMapPreferences.getMaxZoomLvl();
-		long now = System.currentTimeMillis();
-		if (now - lastCheck < 1000)
-				return;
-		lastCheck = now;
-		TreeSet<SlippyMapTile> tiles = new TreeSet<SlippyMapTile>(new TileTimeComp());
-		tiles.addAll(tileStorage.values());
-		int max_nr_tiles = 100;
-		if (tiles.size() < max_nr_tiles) {
-			Main.debug("total of " + tiles.size() + " loaded tiles, size OK " + now);
-			return;
-		}
-		int nr_to_drop = tiles.size() - max_nr_tiles;;
-		Main.debug("total of " + tiles.size() + " tiles, need to flush " + nr_to_drop + " tiles");
-		for (SlippyMapTile t : tiles) {
-			if (nr_to_drop <= 0)
-					break;
-			t.dropImage();
-			nr_to_drop--;
-		}
-	}
-
-	void loadSingleTile(SlippyMapTile tile)
-	{
-		tile.loadImage();
-		this.checkTileStorage();
-	}
-
-	void loadAllTiles() {
-		MapView mv = Main.map.mapView;
-		LatLon topLeft = mv.getLatLon(0, 0);
-		LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
-		z12x0 = lonToTileX(topLeft.lon());
-		z12x1 = lonToTileX(botRight.lon());
-		z12y0 = latToTileY(topLeft.lat());
-		z12y1 = latToTileY(botRight.lat());
-		if (z12x0 > z12x1) {
-			int tmp = z12x0;
-			z12x0 = z12x1;
-			z12x1 = tmp;
-		}
-		if (z12y0 > z12y1) {
-			int tmp = z12y0;
-			z12y0 = z12y1;
-			z12y1 = tmp;
-		}
-		// if there is more than 18 tiles on screen in any direction, do not
-		// load all tiles!
-		if (z12x1 - z12x0 > 18) {
-			System.out
-					.println("Not downloading all tiles because there is more than 18 tiles on X axis!");
-			return;
-		}
-		if (z12y1 - z12y0 > 18) {
-			System.out
-					.println("Not downloading all tiles because there is more than 18 tiles on Y axis!");
-			return;
-		}
-
-		for (int x = z12x0 - 1; x <= z12x1; x++) {
-			for (int y = z12y0 - 1; y <= z12y1; y++) {
-				SlippyMapKey key = new SlippyMapKey(currentZoomLevel, x, y);
-				SlippyMapTile tile = tileStorage.get(key);
-				if (!key.valid) {
-						System.out.println("paint-1() made invalid key");
-						continue;
-				}
-				if (tile == null)
-					tileStorage.put(key,
-							tile = new SlippyMapTile(x, y, currentZoomLevel));
-				if (tile.getImage() == null) {
-					this.loadSingleTile(tile);
-				}
-			}
-		}
-	}
-
-	/*
-	 * Attempt to approximate how much the image is
-	 * being scaled.  For instance, a 100x100 image
-	 * being scaled to 50x50 would return 0.25.
-	 */
-	double getImageScaling(Image img, Point p0, Point p1)
-	{
-		int realWidth = img.getWidth(this);
-		int realHeight = img.getHeight(this);
-		if (realWidth == -1 || realHeight == -1)
-				return 1.0;
-		int drawWidth = p1.x - p0.x;
-		int drawHeight = p1.x - p0.x;
-
-		double drawArea = drawWidth * drawHeight;
-		double realArea = realWidth * realHeight;
-
-		return drawArea / realArea;
-	}
-
-	/**
+    PreferenceChangedListener {
+    /**
+     * Actual zoom lvl. Initial zoom lvl is set to
+     * {@link SlippyMapPreferences#getMinZoomLvl()}.
      */
-	@Override
-	public void paint(Graphics g, MapView mv) {
-		long start = System.currentTimeMillis();
-		LatLon topLeft = mv.getLatLon(0, 0);
-		LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
-		Graphics oldg = g;
-
-		if (botRight.lon() == 0.0 || botRight.lat() == 0) {
-				// probably still initializing
-				return;
-		}
-		if (lastTopLeft != null && lastBotRight != null
-				&& topLeft.equalsEpsilon(lastTopLeft)
-				&& botRight.equalsEpsilon(lastBotRight) && bufferImage != null
-				&& mv.getWidth() == bufferImage.getWidth(null)
-				&& mv.getHeight() == bufferImage.getHeight(null) && !needRedraw) {
-
-			g.drawImage(bufferImage, 0, 0, null);
-			return;
-		}
-
-		needRedraw = false;
-		lastTopLeft = topLeft;
-		lastBotRight = botRight;
-		bufferImage = mv.createImage(mv.getWidth(), mv.getHeight());
-		g = bufferImage.getGraphics();
-
-		z12x0 = lonToTileX(topLeft.lon());
-		z12x1 = lonToTileX(botRight.lon());
-		z12y0 = latToTileY(topLeft.lat());
-		z12y1 = latToTileY(botRight.lat());
-
-		if (z12x0 > z12x1) {
-			int tmp = z12x0;
-			z12x0 = z12x1;
-			z12x1 = tmp;
-		}
-		if (z12y0 > z12y1) {
-			int tmp = z12y0;
-			z12y0 = z12y1;
-			z12y1 = tmp;
-		}
-
-		if (z12x1 - z12x0 > 18)
-			return;
-		if (z12y1 - z12y0 > 18)
-			return;
-
-		for (int x = z12x0 - 1; x <= z12x1 + 1; x++) {
-			double lon = tileXToLon(x);
-			for (int y = z12y0 - 1; y <= z12y1 + 1; y++) {
-				LatLon tmpLL = new LatLon(tileYToLat(y), lon);
-				pixelpos[x - z12x0 + 1][y - z12y0 + 1] = mv.getPoint(Main.proj
-						.latlon2eastNorth(tmpLL));
-			}
-		}
-
-		int fontHeight = g.getFontMetrics().getHeight();
-
-		g.setColor(Color.DARK_GRAY);
-
-		float fadeBackground = SlippyMapPreferences.getFadeBackground();
-
-		Double imageScale = null;
-		int count = 0;
-		for (int x = z12x0 - 1; x <= z12x1; x++) {
-			for (int y = z12y0 - 1; y <= z12y1; y++) {
-				SlippyMapKey key = new SlippyMapKey(currentZoomLevel, x, y);
-				SlippyMapTile tile;
-				tile = tileStorage.get(key);
-				if (!key.valid) {
-						System.out.println("loadAllTiles() made invalid key");
-						continue;
-				}
-				if (tile == null) {
-					tile = new SlippyMapTile(x, y, currentZoomLevel);
-					tileStorage.put(key, tile);
-					if (SlippyMapPreferences.getAutoloadTiles()) {
-						// TODO probably do on background
-						loadSingleTile(tile);
-					}
-					checkTileStorage();
-				}
-				Image img = tile.getImage();
-
-				if (img != null) {
-					Point p = pixelpos[x - z12x0 + 1][y - z12y0 + 1];
-					Point p2 = pixelpos[x - z12x0 + 2][y - z12y0 + 2];
-					g.drawImage(img, p.x, p.y, p2.x - p.x, p2.y - p.y, this);
-					if (imageScale == null)
-						imageScale = new Double(getImageScaling(img, p, p2));
-					count++;
-					if (fadeBackground != 0f) {
-						// dimm by painting opaque rect...
-						g.setColor(new Color(1f, 1f, 1f, fadeBackground));
-						g.fillRect(p.x, p.y, p2.x - p.x, p2.y - p.y);
-					}// end of if dim != 0
-				}// end of if img != null
-			}// end of for
-		}// end of for
-		g.setColor(Color.red);
-		for (int x = z12x0 - 1; x <= z12x1; x++) {
-			Point p = pixelpos[x - z12x0 + 1][0];
-
-			if(SlippyMapPreferences.getDrawDebug()) {
-				if (x % 32 == 0) {
-					// level 7 tile boundary
-					g.fillRect(p.x - 1, 0, 3, mv.getHeight());
-				} else {
-					g.drawLine(p.x, 0, p.x, mv.getHeight());
-				}
-			}//end of if draw debug
-
-			for (int y = z12y0 - 1; y <= z12y1; y++) {
-				SlippyMapKey key = new SlippyMapKey(currentZoomLevel, x, y);
-				int texty = p.y + 2 + fontHeight;
-				SlippyMapTile tile = tileStorage.get(key);
-				if (tile == null) {
-					continue;
-				}
-				if (!key.valid) {
-						System.out.println("paint-0() made invalid key");
-						continue;
-				}
-				if (tile.getImage() == null) {
-						loadSingleTile(tile);
-				}
-				p = pixelpos[x - z12x0 + 1][y - z12y0 + 2];
-				
-				if(SlippyMapPreferences.getDrawDebug()) {
-					g.drawString("x=" + x + " y=" + y + " z=" + currentZoomLevel
-							+ "", p.x + 2, texty);
-					texty += 1 + fontHeight;
-					if ((x % 32 == 0) && (y % 32 == 0)) {
-						g.drawString("x=" + x / 32 + " y=" + y / 32 + " z=7",
-								p.x + 2, texty);
-						texty += 1 + fontHeight;
-					}
-				}//end of if draw debug
-
-				String md = tile.getMetadata();
-				if (md != null) {
-					g.drawString(md, p.x + 2, texty);
-					texty += 1 + fontHeight;
-				}
-
-				if (tile.getImage() == null) {
-					g.drawString(tr("image not loaded"), p.x + 2, texty);
-					texty += 1 + fontHeight;
-				}
-
-				if(SlippyMapPreferences.getDrawDebug()) {
-					if (x == z12x0 - 1) {
-						if (y % 32 == 31) {
-							g.fillRect(0, p.y - 1, mv.getWidth(), 3);
-						} else {
-							g.drawLine(0, p.y, mv.getWidth(), p.y);
-						}
-					}
-				}//end of if draw debug
-			} // end of for
-		}
-
-		oldg.drawImage(bufferImage, 0, 0, null);
-
-		if (imageScale != null) {
-			// If each source image pixel is being stretched into > 3
-			// drawn pixels, zoom in... getting too pixelated
-			if (imageScale > 3) {
-				if (SlippyMapPreferences.getAutozoom()) {
-				    Main.debug("autozoom increase: "+z12x1+" " + z12x0 + " " + z12y1 + " " + z12y0
-									+ topLeft + " " + botRight + " scale: " + imageScale);
-					increaseZoomLevel();
-				}
-				this.paint(oldg, mv);
-			}
-
-			// If each source image pixel is being squished into > 0.32
-			// of a drawn pixels, zoom out.
-			if (imageScale < 0.32) {
-				if (SlippyMapPreferences.getAutozoom()) {
-				    Main.debug("autozoom decrease: "+z12x1+" " + z12x0 + " " + z12y1 + " " + z12y0
-									+ topLeft + " " + botRight + " scale: " + imageScale);
-					decreaseZoomLevel();
-				}
-				this.paint(oldg, mv);
-			}
-		}	
-		g.setColor(Color.black);
-		g.drawString("currentZoomLevel=" + currentZoomLevel, 120, 120);
-	}// end of paint metod
-
-	SlippyMapTile getTileForPixelpos(int px, int py) {
-		int tilex = z12x1;
-		int tiley = z12y1;
-		for (int x = z12x0; x <= z12x1; x++) {
-
-			if (pixelpos[x - z12x0 + 1][0].x > px) {
-				tilex = x - 1;
-				break;
-			}
-		}
-		if (tilex == -1)
-			return null;
-		for (int y = z12y0; y <= z12y1; y++) {
-
-			if (pixelpos[0][y - z12y0 + 1].y > py) {
-				tiley = y - 1;
-				break;
-			}
-		}
-		if (tiley == -1) {
-			return null;
-		}
-
-		SlippyMapKey key = new SlippyMapKey(currentZoomLevel, tilex, tiley);
-		if (!key.valid) {
-			System.err.println("getTileForPixelpos("+px+","+py+") made invalid key");
-			return null;
-		}
-		SlippyMapTile tile = tileStorage.get(key);
-		if (tile == null)
-			tileStorage.put(key, tile = new SlippyMapTile(tilex, tiley, currentZoomLevel));
-		checkTileStorage();
-		return tile;
-	}
-
-	@Override
-	public Icon getIcon() {
-		return ImageProvider.get("slippymap");
-	}
-
-	@Override
-	public Object getInfoComponent() {
-		return null;
-	}
-
-	@Override
-	public Component[] getMenuEntries() {
-		return new Component[] {
-				new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
-				new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),
-				new JSeparator(),
-				// color,
-				new JMenuItem(new RenameLayerAction(associatedFile, this)),
-				new JSeparator(),
-				new JMenuItem(new LayerListPopup.InfoAction(this)) };
-	}
-
-	@Override
-	public String getToolTipText() {
-		return null;
-	}
-
-	@Override
-	public boolean isMergable(Layer other) {
-		return false;
-	}
-
-	@Override
-	public void mergeFrom(Layer from) {
-	}
-
-	@Override
-	public void visitBoundingBox(BoundingXYVisitor v) {
-	}
-
-	private int latToTileY(double lat) {
-		double l = lat / 180 * Math.PI;
-		double pf = Math.log(Math.tan(l) + (1 / Math.cos(l)));
-		return (int) (Math.pow(2.0, currentZoomLevel - 1) * (Math.PI - pf) / Math.PI);
-	}
-
-	private int lonToTileX(double lon) {
-		return (int) (Math.pow(2.0, currentZoomLevel - 3) * (lon + 180.0) / 45.0);
-	}
-
-	private double tileYToLat(int y) {
-		return Math.atan(Math.sinh(Math.PI
-				- (Math.PI * y / Math.pow(2.0, currentZoomLevel - 1))))
-				* 180 / Math.PI;
-	}
-
-	private double tileXToLon(int x) {
-		return x * 45.0 / Math.pow(2.0, currentZoomLevel - 3) - 180.0;
-	}
-
-	public boolean imageUpdate(Image img, int infoflags, int x, int y,
-			int width, int height) {
-		boolean done = ((infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0);
-		if ((infoflags & ERROR) != 0) {
-				String url = "unknown";
-				for (SlippyMapTile tile : tileStorage.values()) {
-						if (tile.getImage() != img)
-								continue;
-						url = tile.getImageURL().toString();
-				}
-				System.err.println("imageUpdate(" + img + ") error " + url +")");
-		}
-		if ((infoflags & SOMEBITS) != 0) {
-				//if (y%100 == 0)
-				//	System.out.println("imageUpdate("+img+") SOMEBITS ("+x+","+y+")");
-		}
-		// Repaint immediately if we are done, otherwise batch up
-		// repaint requests every 100 milliseconds
-		needRedraw = true;
-		Main.map.repaint(done ? 0 : 100);
-		return !done;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seeorg.openstreetmap.josm.data.Preferences.PreferenceChangedListener#
-	 * preferenceChanged(java.lang.String, java.lang.String)
-	 */
-	public void preferenceChanged(String key, String newValue) {
-		if (key.startsWith(SlippyMapPreferences.PREFERENCE_PREFIX)) {
-			// System.err.println(this + ".preferenceChanged('" + key + "', '"
-			// + newValue + "') called");
-			// when fade background changed, no need to clear tile storage
-			// TODO move this code to SlippyMapPreferences class.
-			if (!key.equals(SlippyMapPreferences.PREFERENCE_FADE_BACKGROUND)) {
-				clearTileStorage();
-			}
-		}
-	}
-
-	@Override
-	public void destroy() {
-		Main.pref.listener.remove(SlippyMapLayer.this);
-	}
+    public int currentZoomLevel = SlippyMapPreferences.getMinZoomLvl();
+    private HashMap<SlippyMapKey, SlippyMapTile> tileStorage = null;
+
+    Point[][] pixelpos = new Point[21][21];
+    LatLon lastTopLeft;
+    LatLon lastBotRight;
+    int z12x0, z12x1, z12y0, z12y1;
+    private Image bufferImage;
+    private SlippyMapTile clickedTile;
+    private boolean needRedraw;
+    private JPopupMenu tileOptionMenu;
+
+    @SuppressWarnings("serial")
+    public SlippyMapLayer() {
+        super(tr("Slippy Map"));
+        background = true;
+
+        clearTileStorage();
+
+        tileOptionMenu = new JPopupMenu();
+        tileOptionMenu.add(new JMenuItem(new AbstractAction(tr("Load Tile")) {
+            public void actionPerformed(ActionEvent ae) {
+                if (clickedTile != null) {
+                    loadSingleTile(clickedTile);
+                    needRedraw = true;
+                    Main.map.repaint();
+                }
+            }
+        }));
+
+        tileOptionMenu.add(new JMenuItem(new AbstractAction(
+                tr("Show Tile Status")) {
+            public void actionPerformed(ActionEvent ae) {
+                if (clickedTile != null) {
+                    clickedTile.loadMetadata();
+                    needRedraw = true;
+                    Main.map.repaint();
+                }
+            }
+        }));
+
+        tileOptionMenu.add(new JMenuItem(new AbstractAction(
+                tr("Request Update")) {
+            public void actionPerformed(ActionEvent ae) {
+                if (clickedTile != null) {
+                    clickedTile.requestUpdate();
+                    needRedraw = true;
+                    Main.map.repaint();
+                }
+            }
+        }));
+
+        tileOptionMenu.add(new JMenuItem(new AbstractAction(
+                tr("Load All Tiles")) {
+            public void actionPerformed(ActionEvent ae) {
+                loadAllTiles();
+                needRedraw = true;
+                Main.map.repaint();
+            }
+        }));
+
+        // increase and decrease commands
+        tileOptionMenu.add(new JMenuItem(
+                new AbstractAction(tr("Increase zoom")) {
+                    public void actionPerformed(ActionEvent ae) {
+                        increaseZoomLevel();
+                        needRedraw = true;
+                        Main.map.repaint();
+                    }
+                }));
+
+        tileOptionMenu.add(new JMenuItem(
+                new AbstractAction(tr("Decrease zoom")) {
+                    public void actionPerformed(ActionEvent ae) {
+                        decreaseZoomLevel();
+                        Main.map.repaint();
+                    }
+                }));
+        // end of adding menu commands
+
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                Main.map.mapView.addMouseListener(new MouseAdapter() {
+                    @Override
+                    public void mouseClicked(MouseEvent e) {
+                        if (e.getButton() != MouseEvent.BUTTON3)
+                            return;
+                        clickedTile = getTileForPixelpos(e.getX(), e.getY());
+                        tileOptionMenu.show(e.getComponent(), e.getX(), e
+                                .getY());
+                    }
+                });
+
+                listeners.add(new LayerChangeListener() {
+                    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+                    }
+
+                    public void layerAdded(Layer newLayer) {
+                    }
+
+                    public void layerRemoved(Layer oldLayer) {
+                        Main.pref.listener.remove(SlippyMapLayer.this);
+                    }
+                });
+            }
+        });
+
+        Main.pref.listener.add(this);
+    }
+
+    /**
+     * Zoom in, go closer to map.
+     */
+    public void increaseZoomLevel() {
+        if (currentZoomLevel < SlippyMapPreferences.getMaxZoomLvl()) {
+            currentZoomLevel++;
+            Main.debug("increasing zoom level to: " + currentZoomLevel);
+            needRedraw = true;
+        } else {
+            System.err.println("current zoom lvl ("+currentZoomLevel+") couldnt be increased. "+
+                             "MaxZoomLvl ("+SlippyMapPreferences.getMaxZoomLvl()+") reached.");
+        }
+    }
+
+    /**
+     * Zoom out from map.
+     */
+    public void decreaseZoomLevel() {
+        if (currentZoomLevel > SlippyMapPreferences.getMinZoomLvl()) {
+            Main.debug("decreasing zoom level to: " + currentZoomLevel);
+            currentZoomLevel--;
+            needRedraw = true;
+        } else {
+            System.err.println("current zoom lvl couldnt be decreased. MinZoomLvl reached.");
+        }
+    }
+
+    public void clearTileStorage() {
+        // when max zoom lvl is begin saved, this method is called and probably
+        // the setting isnt saved yet.
+        int maxZoom = 30; // SlippyMapPreferences.getMaxZoomLvl();
+        tileStorage = new HashMap<SlippyMapKey, SlippyMapTile>();
+
+        checkTileStorage();
+    }
+
+    class TileTimeComp implements Comparator<SlippyMapTile> {
+            public int compare(SlippyMapTile s1, SlippyMapTile s2) {
+                    long t1 = s1.access_time();
+                    long t2 = s2.access_time();
+                    if (s1 == s2)
+                            return 0;
+                    if (t1 == t2) {
+                            t1 = s1.hashCode();
+                            t2 = s2.hashCode();
+                    }
+                    if (t1 < t2)
+                            return -1;
+                    return 1;
+            }
+    }
+
+    long lastCheck = 0;
+    /**
+     * <p>
+     * Check if tiles.size() is not more than max_nr_tiles. If yes, oldest tiles by timestamp
+     * are fired out from cache.
+     * </p>
+     */
+    public void checkTileStorage() {
+        int maxZoom = 30; // SlippyMapPreferences.getMaxZoomLvl();
+        long now = System.currentTimeMillis();
+        if (now - lastCheck < 1000)
+                return;
+        lastCheck = now;
+        TreeSet<SlippyMapTile> tiles = new TreeSet<SlippyMapTile>(new TileTimeComp());
+        tiles.addAll(tileStorage.values());
+        int max_nr_tiles = 100;
+        if (tiles.size() < max_nr_tiles) {
+            Main.debug("total of " + tiles.size() + " loaded tiles, size OK " + now);
+            return;
+        }
+        int nr_to_drop = tiles.size() - max_nr_tiles;;
+        Main.debug("total of " + tiles.size() + " tiles, need to flush " + nr_to_drop + " tiles");
+        for (SlippyMapTile t : tiles) {
+            if (nr_to_drop <= 0)
+                    break;
+            t.dropImage();
+            nr_to_drop--;
+        }
+    }
+
+    void loadSingleTile(SlippyMapTile tile)
+    {
+        tile.loadImage();
+        this.checkTileStorage();
+    }
+
+    void loadAllTiles() {
+        MapView mv = Main.map.mapView;
+        LatLon topLeft = mv.getLatLon(0, 0);
+        LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
+        z12x0 = lonToTileX(topLeft.lon());
+        z12x1 = lonToTileX(botRight.lon());
+        z12y0 = latToTileY(topLeft.lat());
+        z12y1 = latToTileY(botRight.lat());
+        if (z12x0 > z12x1) {
+            int tmp = z12x0;
+            z12x0 = z12x1;
+            z12x1 = tmp;
+        }
+        if (z12y0 > z12y1) {
+            int tmp = z12y0;
+            z12y0 = z12y1;
+            z12y1 = tmp;
+        }
+        // if there is more than 18 tiles on screen in any direction, do not
+        // load all tiles!
+        if (z12x1 - z12x0 > 18) {
+            System.out
+                    .println("Not downloading all tiles because there is more than 18 tiles on X axis!");
+            return;
+        }
+        if (z12y1 - z12y0 > 18) {
+            System.out
+                    .println("Not downloading all tiles because there is more than 18 tiles on Y axis!");
+            return;
+        }
+
+        for (int x = z12x0 - 1; x <= z12x1; x++) {
+            for (int y = z12y0 - 1; y <= z12y1; y++) {
+                SlippyMapKey key = new SlippyMapKey(currentZoomLevel, x, y);
+                SlippyMapTile tile = tileStorage.get(key);
+                if (!key.valid) {
+                        System.out.println("paint-1() made invalid key");
+                        continue;
+                }
+                if (tile == null)
+                    tileStorage.put(key,
+                            tile = new SlippyMapTile(x, y, currentZoomLevel));
+                if (tile.getImage() == null) {
+                    this.loadSingleTile(tile);
+                }
+            }
+        }
+    }
+
+    /*
+     * Attempt to approximate how much the image is
+     * being scaled.  For instance, a 100x100 image
+     * being scaled to 50x50 would return 0.25.
+     */
+    double getImageScaling(Image img, Point p0, Point p1)
+    {
+        int realWidth = img.getWidth(this);
+        int realHeight = img.getHeight(this);
+        if (realWidth == -1 || realHeight == -1)
+                return 1.0;
+        int drawWidth = p1.x - p0.x;
+        int drawHeight = p1.x - p0.x;
+
+        double drawArea = drawWidth * drawHeight;
+        double realArea = realWidth * realHeight;
+
+        return drawArea / realArea;
+    }
+
+    /**
+     */
+    @Override
+    public void paint(Graphics g, MapView mv) {
+        long start = System.currentTimeMillis();
+        LatLon topLeft = mv.getLatLon(0, 0);
+        LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
+        Graphics oldg = g;
+
+        if (botRight.lon() == 0.0 || botRight.lat() == 0) {
+                // probably still initializing
+                return;
+        }
+        if (lastTopLeft != null && lastBotRight != null
+                && topLeft.equalsEpsilon(lastTopLeft)
+                && botRight.equalsEpsilon(lastBotRight) && bufferImage != null
+                && mv.getWidth() == bufferImage.getWidth(null)
+                && mv.getHeight() == bufferImage.getHeight(null) && !needRedraw) {
+
+            g.drawImage(bufferImage, 0, 0, null);
+            return;
+        }
+
+        needRedraw = false;
+        lastTopLeft = topLeft;
+        lastBotRight = botRight;
+        bufferImage = mv.createImage(mv.getWidth(), mv.getHeight());
+        g = bufferImage.getGraphics();
+
+        z12x0 = lonToTileX(topLeft.lon());
+        z12x1 = lonToTileX(botRight.lon());
+        z12y0 = latToTileY(topLeft.lat());
+        z12y1 = latToTileY(botRight.lat());
+
+        if (z12x0 > z12x1) {
+            int tmp = z12x0;
+            z12x0 = z12x1;
+            z12x1 = tmp;
+        }
+        if (z12y0 > z12y1) {
+            int tmp = z12y0;
+            z12y0 = z12y1;
+            z12y1 = tmp;
+        }
+
+        if (z12x1 - z12x0 > 18)
+            return;
+        if (z12y1 - z12y0 > 18)
+            return;
+
+        for (int x = z12x0 - 1; x <= z12x1 + 1; x++) {
+            double lon = tileXToLon(x);
+            for (int y = z12y0 - 1; y <= z12y1 + 1; y++) {
+                LatLon tmpLL = new LatLon(tileYToLat(y), lon);
+                pixelpos[x - z12x0 + 1][y - z12y0 + 1] = mv.getPoint(Main.proj
+                        .latlon2eastNorth(tmpLL));
+            }
+        }
+
+        int fontHeight = g.getFontMetrics().getHeight();
+
+        g.setColor(Color.DARK_GRAY);
+
+        float fadeBackground = SlippyMapPreferences.getFadeBackground();
+
+        Double imageScale = null;
+        int count = 0;
+        for (int x = z12x0 - 1; x <= z12x1; x++) {
+            for (int y = z12y0 - 1; y <= z12y1; y++) {
+                SlippyMapKey key = new SlippyMapKey(currentZoomLevel, x, y);
+                SlippyMapTile tile;
+                tile = tileStorage.get(key);
+                if (!key.valid) {
+                        System.out.println("loadAllTiles() made invalid key");
+                        continue;
+                }
+                if (tile == null) {
+                    tile = new SlippyMapTile(x, y, currentZoomLevel);
+                    tileStorage.put(key, tile);
+                    if (SlippyMapPreferences.getAutoloadTiles()) {
+                        // TODO probably do on background
+                        loadSingleTile(tile);
+                    }
+                    checkTileStorage();
+                }
+                Image img = tile.getImage();
+
+                if (img != null) {
+                    Point p = pixelpos[x - z12x0 + 1][y - z12y0 + 1];
+                    Point p2 = pixelpos[x - z12x0 + 2][y - z12y0 + 2];
+                    g.drawImage(img, p.x, p.y, p2.x - p.x, p2.y - p.y, this);
+                    if (imageScale == null)
+                        imageScale = new Double(getImageScaling(img, p, p2));
+                    count++;
+                    if (fadeBackground != 0f) {
+                        // dimm by painting opaque rect...
+                        g.setColor(new Color(1f, 1f, 1f, fadeBackground));
+                        g.fillRect(p.x, p.y, p2.x - p.x, p2.y - p.y);
+                    }// end of if dim != 0
+                }// end of if img != null
+            }// end of for
+        }// end of for
+        g.setColor(Color.red);
+        for (int x = z12x0 - 1; x <= z12x1; x++) {
+            Point p = pixelpos[x - z12x0 + 1][0];
+
+            if(SlippyMapPreferences.getDrawDebug()) {
+                if (x % 32 == 0) {
+                    // level 7 tile boundary
+                    g.fillRect(p.x - 1, 0, 3, mv.getHeight());
+                } else {
+                    g.drawLine(p.x, 0, p.x, mv.getHeight());
+                }
+            }//end of if draw debug
+
+            for (int y = z12y0 - 1; y <= z12y1; y++) {
+                SlippyMapKey key = new SlippyMapKey(currentZoomLevel, x, y);
+                int texty = p.y + 2 + fontHeight;
+                SlippyMapTile tile = tileStorage.get(key);
+                if (tile == null) {
+                    continue;
+                }
+                if (!key.valid) {
+                        System.out.println("paint-0() made invalid key");
+                        continue;
+                }
+                if (tile.getImage() == null) {
+                        loadSingleTile(tile);
+                }
+                p = pixelpos[x - z12x0 + 1][y - z12y0 + 2];
+
+                if(SlippyMapPreferences.getDrawDebug()) {
+                    g.drawString("x=" + x + " y=" + y + " z=" + currentZoomLevel
+                            + "", p.x + 2, texty);
+                    texty += 1 + fontHeight;
+                    if ((x % 32 == 0) && (y % 32 == 0)) {
+                        g.drawString("x=" + x / 32 + " y=" + y / 32 + " z=7",
+                                p.x + 2, texty);
+                        texty += 1 + fontHeight;
+                    }
+                }//end of if draw debug
+
+                String md = tile.getMetadata();
+                if (md != null) {
+                    g.drawString(md, p.x + 2, texty);
+                    texty += 1 + fontHeight;
+                }
+
+                if (tile.getImage() == null) {
+                    g.drawString(tr("image not loaded"), p.x + 2, texty);
+                    texty += 1 + fontHeight;
+                }
+
+                if(SlippyMapPreferences.getDrawDebug()) {
+                    if (x == z12x0 - 1) {
+                        if (y % 32 == 31) {
+                            g.fillRect(0, p.y - 1, mv.getWidth(), 3);
+                        } else {
+                            g.drawLine(0, p.y, mv.getWidth(), p.y);
+                        }
+                    }
+                }//end of if draw debug
+            } // end of for
+        }
+
+        oldg.drawImage(bufferImage, 0, 0, null);
+
+        if (imageScale != null) {
+            // If each source image pixel is being stretched into > 3
+            // drawn pixels, zoom in... getting too pixelated
+            if (imageScale > 3) {
+                if (SlippyMapPreferences.getAutozoom()) {
+                    Main.debug("autozoom increase: "+z12x1+" " + z12x0 + " " + z12y1 + " " + z12y0
+                                    + topLeft + " " + botRight + " scale: " + imageScale);
+                    increaseZoomLevel();
+                }
+                this.paint(oldg, mv);
+            }
+
+            // If each source image pixel is being squished into > 0.32
+            // of a drawn pixels, zoom out.
+            if (imageScale < 0.32) {
+                if (SlippyMapPreferences.getAutozoom()) {
+                    Main.debug("autozoom decrease: "+z12x1+" " + z12x0 + " " + z12y1 + " " + z12y0
+                                    + topLeft + " " + botRight + " scale: " + imageScale);
+                    decreaseZoomLevel();
+                }
+                this.paint(oldg, mv);
+            }
+        }
+        g.setColor(Color.black);
+        g.drawString("currentZoomLevel=" + currentZoomLevel, 120, 120);
+    }// end of paint metod
+
+    SlippyMapTile getTileForPixelpos(int px, int py) {
+        int tilex = z12x1;
+        int tiley = z12y1;
+        for (int x = z12x0; x <= z12x1; x++) {
+
+            if (pixelpos[x - z12x0 + 1][0].x > px) {
+                tilex = x - 1;
+                break;
+            }
+        }
+        if (tilex == -1)
+            return null;
+        for (int y = z12y0; y <= z12y1; y++) {
+
+            if (pixelpos[0][y - z12y0 + 1].y > py) {
+                tiley = y - 1;
+                break;
+            }
+        }
+        if (tiley == -1) {
+            return null;
+        }
+
+        SlippyMapKey key = new SlippyMapKey(currentZoomLevel, tilex, tiley);
+        if (!key.valid) {
+            System.err.println("getTileForPixelpos("+px+","+py+") made invalid key");
+            return null;
+        }
+        SlippyMapTile tile = tileStorage.get(key);
+        if (tile == null)
+            tileStorage.put(key, tile = new SlippyMapTile(tilex, tiley, currentZoomLevel));
+        checkTileStorage();
+        return tile;
+    }
+
+    @Override
+    public Icon getIcon() {
+        return ImageProvider.get("slippymap");
+    }
+
+    @Override
+    public Object getInfoComponent() {
+        return null;
+    }
+
+    @Override
+    public Component[] getMenuEntries() {
+        return new Component[] {
+                new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),
+                new JMenuItem(new LayerListDialog.DeleteLayerAction(this)),
+                new JSeparator(),
+                // color,
+                new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
+                new JSeparator(),
+                new JMenuItem(new LayerListPopup.InfoAction(this)) };
+    }
+
+    @Override
+    public String getToolTipText() {
+        return null;
+    }
+
+    @Override
+    public boolean isMergable(Layer other) {
+        return false;
+    }
+
+    @Override
+    public void mergeFrom(Layer from) {
+    }
+
+    @Override
+    public void visitBoundingBox(BoundingXYVisitor v) {
+    }
+
+    private int latToTileY(double lat) {
+        double l = lat / 180 * Math.PI;
+        double pf = Math.log(Math.tan(l) + (1 / Math.cos(l)));
+        return (int) (Math.pow(2.0, currentZoomLevel - 1) * (Math.PI - pf) / Math.PI);
+    }
+
+    private int lonToTileX(double lon) {
+        return (int) (Math.pow(2.0, currentZoomLevel - 3) * (lon + 180.0) / 45.0);
+    }
+
+    private double tileYToLat(int y) {
+        return Math.atan(Math.sinh(Math.PI
+                - (Math.PI * y / Math.pow(2.0, currentZoomLevel - 1))))
+                * 180 / Math.PI;
+    }
+
+    private double tileXToLon(int x) {
+        return x * 45.0 / Math.pow(2.0, currentZoomLevel - 3) - 180.0;
+    }
+
+    public boolean imageUpdate(Image img, int infoflags, int x, int y,
+            int width, int height) {
+        boolean done = ((infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0);
+        if ((infoflags & ERROR) != 0) {
+                String url = "unknown";
+                for (SlippyMapTile tile : tileStorage.values()) {
+                        if (tile.getImage() != img)
+                                continue;
+                        url = tile.getImageURL().toString();
+                }
+                System.err.println("imageUpdate(" + img + ") error " + url +")");
+        }
+        if ((infoflags & SOMEBITS) != 0) {
+                //if (y%100 == 0)
+                //    System.out.println("imageUpdate("+img+") SOMEBITS ("+x+","+y+")");
+        }
+        // Repaint immediately if we are done, otherwise batch up
+        // repaint requests every 100 milliseconds
+        needRedraw = true;
+        Main.map.repaint(done ? 0 : 100);
+        return !done;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @seeorg.openstreetmap.josm.data.Preferences.PreferenceChangedListener#
+     * preferenceChanged(java.lang.String, java.lang.String)
+     */
+    public void preferenceChanged(String key, String newValue) {
+        if (key.startsWith(SlippyMapPreferences.PREFERENCE_PREFIX)) {
+            // System.err.println(this + ".preferenceChanged('" + key + "', '"
+            // + newValue + "') called");
+            // when fade background changed, no need to clear tile storage
+            // TODO move this code to SlippyMapPreferences class.
+            if (!key.equals(SlippyMapPreferences.PREFERENCE_FADE_BACKGROUND)) {
+                clearTileStorage();
+            }
+        }
+    }
+
+    @Override
+    public void destroy() {
+        Main.pref.listener.remove(SlippyMapLayer.this);
+    }
 }
Index: /applications/editors/josm/plugins/tageditor/build.xml
===================================================================
--- /applications/editors/josm/plugins/tageditor/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/tageditor/build.xml	(revision 15707)
@@ -50,5 +50,5 @@
     -->
     <target name="compile" depends="init">
-        <echo message="compiling sources for  ${plugin.jar.name} ... "/>
+        <echo message="compiling sources for  ${plugin.jar} ... "/>
         <javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}">
             <compilerarg value="-Xlint:deprecation"/>
Index: /applications/editors/josm/plugins/wmsplugin/build.xml
===================================================================
--- /applications/editors/josm/plugins/wmsplugin/build.xml	(revision 15706)
+++ /applications/editors/josm/plugins/wmsplugin/build.xml	(revision 15707)
@@ -29,5 +29,5 @@
                 <attribute name="Plugin-Description" value="Display georeferenced images as background in JOSM (WMS servers, Yahoo, ...)."/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin"/>
-                <attribute name="Plugin-Mainversion" value="1610"/>
+                <attribute name="Plugin-Mainversion" value="1646"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
                 <attribute name="de_Plugin-Link" value="http://wiki.openstreetmap.org/wiki/DE:JOSM/Plugins/WMSPlugin"/>
Index: plications/editors/josm/plugins/wmsplugin/src/wmsplugin/OSGBGrabber.java
===================================================================
--- /applications/editors/josm/plugins/wmsplugin/src/wmsplugin/OSGBGrabber.java	(revision 15706)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
-package wmsplugin;
-
-import uk.me.jstott.jcoord.OSRef;
-import uk.me.jstott.jcoord.LatLng;
-
-import java.io.IOException;
-
-import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.coor.EastNorth;
-import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.projection.Projection;
-import org.openstreetmap.josm.data.projection.Epsg4326;
-
-// FIXME: Remove this hack when we have proper projection support.
-public class OSGBGrabber extends WMSGrabber {
-    public OSGBGrabber(String baseURL) {
-        super(baseURL);
-    }
-
-    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());
-
-        GeorefImage img = super.grab(bnew, latlonProj, pixelPerDegreeNew);
-
-        img.min = proj.latlon2eastNorth(fromOSGB(img.min));
-        img.max = proj.latlon2eastNorth(fromOSGB(img.max));
-
-        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()) };
-
-        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();
-
-        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;
-    }
-
-    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/WMSGrabber.java
===================================================================
--- /applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 15706)
+++ /applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 15707)
@@ -85,5 +85,5 @@
         if (urlWithPatterns) {
             String proj = Main.proj.toCode();
-            if(proj.equals("EPSG:3785")) // don't use mercator code
+            if(Main.proj instanceof org.openstreetmap.josm.data.projection.Mercator) // don't use mercator code directly
                 proj = "EPSG:4326";
 
Index: /applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
===================================================================
--- /applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java	(revision 15706)
+++ /applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java	(revision 15707)
@@ -23,8 +23,7 @@
 import javax.swing.JOptionPane;
 import javax.swing.JSeparator;
-import javax.swing.filechooser.FileFilter;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.ExtensionFileFilter;
+import org.openstreetmap.josm.actions.DiskAccessAction;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.EastNorth;
@@ -295,5 +294,6 @@
         }
         public void actionPerformed(ActionEvent ev) {
-            File f = openFileDialog(false);
+            File f = DiskAccessAction.createAndOpenSaveFileChooser(
+            tr("Save WMS layer"), ".wms");
             try
             {
@@ -322,5 +322,8 @@
         }
         public void actionPerformed(ActionEvent ev) {
-            File f = openFileDialog(true);
+            JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true,
+            false, tr("Load WMS layer"));
+            if(fc == null) return;
+            File f = fc.getSelectedFile();
             if (f == null) return;
             try
@@ -359,49 +362,3 @@
         }
     }
-
-    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;
-    }
 }
