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 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java	(revision 30361)
@@ -58,35 +58,35 @@
 public class RoutingGraph {
 
-	/**
-	 * Routing Profile
-	 */
-	private final 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;
-
-	/**
-	 * Associated Osm DataSet
-	 */
-	private final DataSet data;
-
-	/**
-	 * Logger.
-	 */
-	static Logger logger = Logger.getLogger(RoutingGraph.class);
+    /**
+     * Routing Profile
+     */
+    private final 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;
+
+    /**
+     * Associated Osm DataSet
+     */
+    private final DataSet data;
+
+    /**
+     * Logger.
+     */
+    static Logger logger = Logger.getLogger(RoutingGraph.class);
 
     private static Collection<String> excludedHighwayValues = Arrays.asList(new String[]{
@@ -94,360 +94,360 @@
         "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned"
     });
-	
-	/**
-	 * 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;
-
-
-	/**
-	 * Graph getter
-	 */
-	public Graph<Node, OsmEdge> getGraph(){
-		return graph;
-
-	}
-
-
-	private void addEdgeBidirectional( Way way, Node from, Node to){
-		addEdge(way,from,to);
-		addEdge(way,to,from);
-	}
-
-	private void addEdgeReverseOneway( Way way, Node from, Node to){
-		addEdge(way,to,from);
-	}
-
-	private void addEdgeNormalOneway( Way way, Node from, Node to){
-		addEdge(way,from,to);
-	}
-
-	/**
-	 * 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.getWays()) {
-
-			// skip way if not suitable for routing.
-			if (way == null || way.isDeleted() || !this.isvalidWay(way)
-					|| way.getNodes().size() < 1) continue;
-
-			// INIT
-			Node from = null;
-			Node to = null;
-			List<Node> nodes = way.getNodes();
-			int nodes_count = nodes.size();
-
-			/*
-			 * Assume node is A B C D E. The procedure should be
-			 * 
-			 *  case 1 - bidirectional ways:
-			 *  1) Add vertex A B C D E
-			 *  2) Link A<->B, B<->C, C<->D, D<->E as Edges
-			 * 
-			 *  case 2 - oneway reverse:
-			 *  1) Add vertex A B C D E
-			 *  2) Link B->A,C->B,D->C,E->D as Edges. result: A<-B<-C<-D<-E
-			 * 
-			 *  case 3 - oneway normal:
-			 *  1) Add vertex A B C D E
-			 *  2) Link A->B, B->C, C->D, D->E as Edges. result: A->B->C->D->E
-			 * 
-			 * 
-			 */
-
-			String oneway_val = way.get("oneway");   /*   get (oneway=?) tag for this way.   */
-			String junction_val = way.get("junction");   /*   get (junction=?) tag for this way.   */
-
-			from = nodes.get(0);                   /*   1st node A  */
-			graph.addVertex(from);                 /*   add vertex A */
-
-			for (int i = 1; i < nodes_count; i++) { /*   loop from B until E */
-
-				to = nodes.get(i);                   /*   2nd node B   */
-
-				if (to != null && !to.isDeleted()) {
-					graph.addVertex(to);               /*   add vertex B */
-
-
-					//this is where we link the vertices
-					if (!routingProfile.isOnewayUsed()) {
-						//"Ignore oneways" is selected
-						addEdgeBidirectional(way, from, to);
-
-					} else if (oneway_val == null && junction_val == "roundabout") {
-						//Case (roundabout): oneway=implicit yes
-						addEdgeNormalOneway(way, from, to);
-
-					} else if (oneway_val == null || oneway_val == "false" || oneway_val == "no" || oneway_val == "0") {
-						//Case (bi-way): oneway=false OR oneway=unset OR oneway=0 OR oneway=no
-						addEdgeBidirectional(way, from, to);
-
-					} else if (oneway_val == "-1") {
-						//Case (oneway reverse): oneway=-1
-						addEdgeReverseOneway(way, from, to);
-
-					} else if (oneway_val == "1" || oneway_val == "yes" || oneway_val == "true") {
-						//Case (oneway normal): oneway=yes OR 1 OR true
-						addEdgeNormalOneway(way, from, to);
-
-					}
-
-					from = to;                         /*   we did A<->B, next loop we will do B<->C, so from=B,to=C for next loop. */
-				}
-
-			} // end of looping thru nodes
-		} // end of looping thru ways
-
-		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) {
-	    LatLon fromLL = from.getCoor();
-	    LatLon toLL = from.getCoor();
-	    if (fromLL == null || toLL == null) {
-	        return;
-	    }
-		double length = fromLL.greatCircleDistance(toLL);
-
-		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.getId()
-				+ "(from node " + from.getId() + " to node "
-				+ to.getId() + ") has weight: " + 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 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())            <---not needed me thinks
-		//    return false;
-	    
-	    String highway = way.get("highway");
-
-		return (highway != null && !excludedHighwayValues.contains(highway)) || way.get("junction") != null
-				|| way.get("service") != null;
-
-	}
-
-	/**
-	 * 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;
-		RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
-		RoutingModel routingModel = layer.getRoutingModel();
-
-		if (graph == null || routingModel.getOnewayChanged())
-			this.createGraph();
-		logger.debug("apply algorithm between nodes ");
-
-		for (Node node : nodes) {
-			logger.debug(node.getId());
-		}
-		logger.debug("-----------------------------------");
-
-		// Assign the graph to g
-		g = graph;
-
-		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>(g, 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;
-	}
+    
+    /**
+     * 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;
+
+
+    /**
+     * Graph getter
+     */
+    public Graph<Node, OsmEdge> getGraph(){
+        return graph;
+
+    }
+
+
+    private void addEdgeBidirectional( Way way, Node from, Node to){
+        addEdge(way,from,to);
+        addEdge(way,to,from);
+    }
+
+    private void addEdgeReverseOneway( Way way, Node from, Node to){
+        addEdge(way,to,from);
+    }
+
+    private void addEdgeNormalOneway( Way way, Node from, Node to){
+        addEdge(way,from,to);
+    }
+
+    /**
+     * 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.getWays()) {
+
+            // skip way if not suitable for routing.
+            if (way == null || way.isDeleted() || !this.isvalidWay(way)
+                    || way.getNodes().size() < 1) continue;
+
+            // INIT
+            Node from = null;
+            Node to = null;
+            List<Node> nodes = way.getNodes();
+            int nodes_count = nodes.size();
+
+            /*
+             * Assume node is A B C D E. The procedure should be
+             * 
+             *  case 1 - bidirectional ways:
+             *  1) Add vertex A B C D E
+             *  2) Link A<->B, B<->C, C<->D, D<->E as Edges
+             * 
+             *  case 2 - oneway reverse:
+             *  1) Add vertex A B C D E
+             *  2) Link B->A,C->B,D->C,E->D as Edges. result: A<-B<-C<-D<-E
+             * 
+             *  case 3 - oneway normal:
+             *  1) Add vertex A B C D E
+             *  2) Link A->B, B->C, C->D, D->E as Edges. result: A->B->C->D->E
+             * 
+             * 
+             */
+
+            String oneway_val = way.get("oneway");   /*   get (oneway=?) tag for this way.   */
+            String junction_val = way.get("junction");   /*   get (junction=?) tag for this way.   */
+
+            from = nodes.get(0);                   /*   1st node A  */
+            graph.addVertex(from);                 /*   add vertex A */
+
+            for (int i = 1; i < nodes_count; i++) { /*   loop from B until E */
+
+                to = nodes.get(i);                   /*   2nd node B   */
+
+                if (to != null && !to.isDeleted()) {
+                    graph.addVertex(to);               /*   add vertex B */
+
+
+                    //this is where we link the vertices
+                    if (!routingProfile.isOnewayUsed()) {
+                        //"Ignore oneways" is selected
+                        addEdgeBidirectional(way, from, to);
+
+                    } else if (oneway_val == null && junction_val == "roundabout") {
+                        //Case (roundabout): oneway=implicit yes
+                        addEdgeNormalOneway(way, from, to);
+
+                    } else if (oneway_val == null || oneway_val == "false" || oneway_val == "no" || oneway_val == "0") {
+                        //Case (bi-way): oneway=false OR oneway=unset OR oneway=0 OR oneway=no
+                        addEdgeBidirectional(way, from, to);
+
+                    } else if (oneway_val == "-1") {
+                        //Case (oneway reverse): oneway=-1
+                        addEdgeReverseOneway(way, from, to);
+
+                    } else if (oneway_val == "1" || oneway_val == "yes" || oneway_val == "true") {
+                        //Case (oneway normal): oneway=yes OR 1 OR true
+                        addEdgeNormalOneway(way, from, to);
+
+                    }
+
+                    from = to;                         /*   we did A<->B, next loop we will do B<->C, so from=B,to=C for next loop. */
+                }
+
+            } // end of looping thru nodes
+        } // end of looping thru ways
+
+        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) {
+        LatLon fromLL = from.getCoor();
+        LatLon toLL = from.getCoor();
+        if (fromLL == null || toLL == null) {
+            return;
+        }
+        double length = fromLL.greatCircleDistance(toLL);
+
+        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.getId()
+                + "(from node " + from.getId() + " to node "
+                + to.getId() + ") has weight: " + 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 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())            <---not needed me thinks
+        //    return false;
+        
+        String highway = way.get("highway");
+
+        return (highway != null && !excludedHighwayValues.contains(highway)) || way.get("junction") != null
+                || way.get("service") != null;
+
+    }
+
+    /**
+     * 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;
+        RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
+        RoutingModel routingModel = layer.getRoutingModel();
+
+        if (graph == null || routingModel.getOnewayChanged())
+            this.createGraph();
+        logger.debug("apply algorithm between nodes ");
+
+        for (Node node : nodes) {
+            logger.debug(node.getId());
+        }
+        logger.debug("-----------------------------------");
+
+        // Assign the graph to g
+        g = graph;
+
+        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>(g, 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/plugin/routing/RoutingLayer.java
===================================================================
--- applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java	(revision 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java	(revision 30361)
@@ -125,6 +125,6 @@
         
 
-        this.routingModel.routingGraph.createGraph();	/* construct the graph right after we we create the layer */
-        Main.map.repaint();							/* update MapView */
+        this.routingModel.routingGraph.createGraph();    /* construct the graph right after we we create the layer */
+        Main.map.repaint();                            /* update MapView */
     }
 
@@ -172,8 +172,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getIcon()
-     */
     @Override
     public Icon getIcon() {
@@ -182,8 +178,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent()
-     */
     @Override
     public Object getInfoComponent() {
@@ -197,8 +189,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries()
-     */
     @Override
     public Action[] getMenuEntries() {
@@ -214,8 +202,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText()
-     */
     @Override
     public String getToolTipText() {
@@ -225,8 +209,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm.gui.layer.Layer)
-     */
     @Override
     public boolean isMergable(Layer other) {
@@ -234,8 +214,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm.gui.layer.Layer)
-     */
     @Override
     public void mergeFrom(Layer from) {
@@ -243,8 +219,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics, org.openstreetmap.josm.gui.MapView)
-     */
     @Override
     public void paint(Graphics2D g, MapView mv, Bounds bounds) {
@@ -265,5 +237,5 @@
         String widthString = Main.pref.get(PreferencesKeys.KEY_ROUTE_WIDTH.key);
         if (widthString.length() == 0) {
-            widthString = "2";						/* I think 2 is better  */
+            widthString = "2";                        /* I think 2 is better  */
             // FIXME add after good width is found: Main.pref.put(KEY_ROUTE_WIDTH, widthString);
         }
@@ -273,20 +245,20 @@
         // draw our graph
         if (isActiveLayer) {
-        	if(routingModel != null) {
-        		if(routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
-        	        Set<OsmEdge> graphEdges =  routingModel.routingGraph.getGraph().edgeSet();
-        	        if (!graphEdges.isEmpty()) {
-            	    	Color color2 = ColorHelper.html2color("#00ff00");		/* just green for now  */
-	        	        OsmEdge firstedge = (OsmEdge) graphEdges.toArray()[0];
-	        	        Point from = mv.getPoint(firstedge.fromEastNorth());
-	        	        g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4);
-	        	        for(OsmEdge edge : graphEdges) {
-	        	        	drawGraph(g, mv, edge, color2, width);
-	        	        }
-        	        }
-        	     }
-        	 }
-        }
-        	        
+            if(routingModel != null) {
+                if(routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
+                    Set<OsmEdge> graphEdges =  routingModel.routingGraph.getGraph().edgeSet();
+                    if (!graphEdges.isEmpty()) {
+                        Color color2 = ColorHelper.html2color("#00ff00");        /* just green for now  */
+                        OsmEdge firstedge = (OsmEdge) graphEdges.toArray()[0];
+                        Point from = mv.getPoint(firstedge.fromEastNorth());
+                        g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4);
+                        for(OsmEdge edge : graphEdges) {
+                            drawGraph(g, mv, edge, color2, width);
+                        }
+                    }
+                 }
+             }
+        }
+                    
         
         if(nodes == null || nodes.size() == 0) return;
@@ -322,8 +294,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor)
-     */
     @Override
     public void visitBoundingBox(BoundingXYVisitor v) {
@@ -333,8 +301,4 @@
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#destroy()
-     */
     @Override
     public void destroy() {
@@ -381,5 +345,5 @@
 
             g2d.setStroke(oldStroke);
-	 }
-		
+     }
+        
 }
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 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 30361)
@@ -48,134 +48,134 @@
 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;
+    /**
+     * Graph to calculate route
+     */
+    public RoutingGraph routingGraph=null;
 
-	/**
-	 * List of nodes that the route has to traverse
-	 */
-	private List<Node> nodes=null;
+    /**
+     * List of nodes that the route has to traverse
+     */
+    private List<Node> nodes=null;
 
-	private List<OsmEdge> path=null;
+    private List<OsmEdge> path=null;
 
-	/**
-	 * Flag to advise about changes in the selected nodes.
-	 */
-	private boolean changeNodes=false;
+    /**
+     * Flag to advise about changes in the selected nodes.
+     */
+    private boolean changeNodes=false;
 
-	/**
-	 * Flag to advise about changes in ways.
-	 */
-	private boolean changeOneway=false;
+    /**
+     * Flag to advise about changes in ways.
+     */
+    private boolean changeOneway=false;
 
-	/**
-	 * Default Constructor.
-	 */
-	public RoutingModel(DataSet data) {
-		nodes = new ArrayList<Node>();
-		System.out.println("gr " + data);
-		routingGraph = new RoutingGraph(data);
-	}
+    /**
+     * Default Constructor.
+     */
+    public RoutingModel(DataSet data) {
+        nodes = new ArrayList<Node>();
+        System.out.println("gr " + data);
+        routingGraph = new RoutingGraph(data);
+    }
 
-	/**
-	 * Method that returns the selected nodes to calculate route.
-	 * @return the selectedNodes
-	 */
-	public List<Node> getSelectedNodes() {
-		return nodes;
-	}
+    /**
+     * Method that returns the selected nodes to calculate route.
+     * @return the selectedNodes
+     */
+    public List<Node> getSelectedNodes() {
+        return nodes;
+    }
 
-	/**
-	 * Adds a node to the route node list.
-	 * @param node the node to add.
-	 */
-	public void addNode(Node node) {
-		nodes.add(node);
-		this.changeNodes=true;
-	}
+    /**
+     * Adds a node to the route node list.
+     * @param node the node to add.
+     */
+    public void addNode(Node node) {
+        nodes.add(node);
+        this.changeNodes=true;
+    }
 
-	/**
-	 * Removes a node from the route node list.
-	 * @param index the index of the node to remove.
-	 */
-	public void removeNode(int index) {
-		if (nodes.size()>index) {
-			nodes.remove(index);
-			this.changeNodes=true;
-		}
-	}
+    /**
+     * Removes a node from the route node list.
+     * @param index the index of the node to remove.
+     */
+    public void removeNode(int index) {
+        if (nodes.size()>index) {
+            nodes.remove(index);
+            this.changeNodes=true;
+        }
+    }
 
-	/**
-	 * Inserts a node in the route node list.
-	 * @param index the index where the node will be inserted
-	 * @param node the node to be inserted
-	 */
-	public void insertNode(int index, Node node) {
-		if (nodes.size()>=index) {
-			nodes.add(index, node);
-			this.changeNodes=true;
-		}
-	}
+    /**
+     * Inserts a node in the route node list.
+     * @param index the index where the node will be inserted
+     * @param node the node to be inserted
+     */
+    public void insertNode(int index, Node node) {
+        if (nodes.size()>=index) {
+            nodes.add(index, node);
+            this.changeNodes=true;
+        }
+    }
 
-	/**
-	 * Reverse list of nodes
-	 */
-	public void reverseNodes() {
-		List<Node> aux = new ArrayList<Node>();
-		for (Node n : nodes) {
-			aux.add(0,n);
-		}
-		nodes = aux;
-		this.changeNodes=true;
-	}
+    /**
+     * Reverse list of nodes
+     */
+    public void reverseNodes() {
+        List<Node> aux = new ArrayList<Node>();
+        for (Node n : nodes) {
+            aux.add(0,n);
+        }
+        nodes = aux;
+        this.changeNodes=true;
+    }
 
-	/**
-	 * Get the edges of the route.
-	 * @return A list of edges forming the shortest path
-	 */
-	public List<OsmEdge> getRouteEdges() {
-		if (this.changeNodes || path==null)
-		{
-			path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA);
-			this.changeNodes=false;
-			this.changeOneway=false;
-		}
-		return path;
-	}
+    /**
+     * Get the edges of the route.
+     * @return A list of edges forming the shortest path
+     */
+    public List<OsmEdge> getRouteEdges() {
+        if (this.changeNodes || path==null)
+        {
+            path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA);
+            this.changeNodes=false;
+            this.changeOneway=false;
+        }
+        return path;
+    }
 
-	/**
-	 * Marks that some node or the node order has changed so the path should be computed again
-	 */
-	public void setNodesChanged() {
-		this.changeNodes = true;
-	}
+    /**
+     * Marks that some node or the node order has changed so the path should be computed again
+     */
+    public void setNodesChanged() {
+        this.changeNodes = true;
+    }
 
-	/**
-	 * Marks that "Ignore oneway" option has changed so the path should be computed again
-	 */
-	public void setOnewayChanged() {
-		this.changeOneway = true;
-	}
+    /**
+     * Marks that "Ignore oneway" option has changed so the path should be computed again
+     */
+    public void setOnewayChanged() {
+        this.changeOneway = true;
+    }
 
-	/**
-	 * Marks that "Ignore oneway" option has changed so the path should be computed again
-	 */
-	public boolean getOnewayChanged() {
-		return this.changeOneway;
-	}
+    /**
+     * Marks that "Ignore oneway" option has changed so the path should be computed again
+     */
+    public boolean getOnewayChanged() {
+        return this.changeOneway;
+    }
 
-	/**
-	 * Resets all data.
-	 */
-	public void reset() {
-		nodes.clear();
-		this.changeNodes=true;
-	}
+    /**
+     * Resets all data.
+     */
+    public void reset() {
+        nodes.clear();
+        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 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 30361)
@@ -66,232 +66,213 @@
  */
 public class RoutingPlugin extends Plugin implements LayerChangeListener,DataSetListenerAdapter.Listener {
-	/**
-	 * Logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingPlugin.class);
-
-	/**
-	 * The list of routing layers
-	 */
-	private final ArrayList<RoutingLayer> layers;
-
-	/**
-	 * The side dialog where nodes are listed
-	 */
-	private RoutingDialog routingDialog;
-
-	/**
-	 * Preferences Settings Dialog.
-	 */
-	private final PreferenceSetting preferenceSettings;
-
-	/**
-	 * MapMode for adding route nodes.
-	 * We use this field to enable or disable the mode automatically.
-	 */
-	private AddRouteNodeAction addRouteNodeAction;
-
-	/**
-	 * MapMode for removing route nodes.
-	 * We use this field to enable or disable the mode automatically.
-	 */
-	private RemoveRouteNodeAction removeRouteNodeAction;
-
-	/**
-	 * MapMode for moving route nodes.
-	 * We use this field to enable or disable the mode automatically.
-	 */
-	private MoveRouteNodeAction moveRouteNodeAction;
-
-	/**
-	 * IconToggleButton for adding route nodes, we use this field to show or hide the button.
-	 */
-	private IconToggleButton addRouteNodeButton;
-
-	/**
-	 * IconToggleButton for removing route nodes, we use this field to show or hide the button.
-	 */
-	private IconToggleButton removeRouteNodeButton;
-
-	/**
-	 * IconToggleButton for moving route nodes, we use this field to show or hide the button.
-	 */
-	private IconToggleButton moveRouteNodeButton;
-
-	/**
-	 * IconToggleButton for moving route nodes, we use this field to show or hide the button.
-	 */
-	private final RoutingMenu menu;
-
-	/**
-	 * Reference for the plugin class (as if it were a singleton)
-	 */
-	private static RoutingPlugin plugin;
-
-	private final DataSetListenerAdapter datasetAdapter;
-
-	/**
-	 * Default Constructor
-	 */
-	public RoutingPlugin(PluginInformation info) {
-		super(info);
-
-		datasetAdapter = new DataSetListenerAdapter(this);
-		plugin = this; // Assign reference to the plugin class
-		File log4jConfigFile = new java.io.File("log4j.xml");
-		if (log4jConfigFile.exists()) {
-			DOMConfigurator.configure(log4jConfigFile.getPath());
-		} else {
-			System.err.println("Routing plugin warning: log4j configuration not found");
-		}
-		logger.debug("Loading routing plugin...");
-		preferenceSettings=new RoutingPreferenceDialog();
-		// Initialize layers list
-		layers = new ArrayList<RoutingLayer>();
-		// Add menu
-		menu = new RoutingMenu();
-		// Register this class as LayerChangeListener
-		MapView.addLayerChangeListener(this);
-		DatasetEventManager.getInstance().addDatasetListener(datasetAdapter, FireMode.IN_EDT_CONSOLIDATED);
-		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.getEditLayer();
-		if (osmLayer != null) {
-			RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", 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);
-			addRouteNodeButton.setAutoHideDisabledButton(true);
-			removeRouteNodeButton.setAutoHideDisabledButton(true);
-			moveRouteNodeButton.setAutoHideDisabledButton(true);
-			newFrame.addMapMode(addRouteNodeButton);
-			newFrame.addMapMode(removeRouteNodeButton);
-			newFrame.addMapMode(moveRouteNodeButton);
-			// Enable menu
-			menu.enableStartItem();
-			newFrame.addToggleDialog(routingDialog = new RoutingDialog());
-		} else {
-			addRouteNodeAction = null;
-			removeRouteNodeAction = null;
-			moveRouteNodeAction = null;
-			addRouteNodeButton = null;
-			removeRouteNodeButton = null;
-			moveRouteNodeButton = null;
-			routingDialog = null;
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @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) {
-		if (newLayer instanceof RoutingLayer) {			/*   show Routing toolbar and dialog window  */
-			menu.enableRestOfItems();
-			if (routingDialog != null) {
-				routingDialog.showDialog();
-				routingDialog.refresh();
-			}
-		}else{											/*   hide Routing toolbar and dialog window  */
-			menu.disableRestOfItems();
-			if (routingDialog != null) {
-				routingDialog.hideDialog();
-			}
-		}
-	}
-
-	/*
-	 * (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) {
-			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.main.removeLayer(layersArray[i]);
-					} catch (IllegalArgumentException e) {
-					}
-				}
-			}
-		}
-		// Reload RoutingDialog table model
-		if (routingDialog != null) {
-			routingDialog.refresh();
-		}
-	}
-
-	public void processDatasetEvent(AbstractDatasetChangedEvent event){
-
-
-	}
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.Plugin#getPreferenceSetting()
-	 */
-	@Override
-	public PreferenceSetting getPreferenceSetting() {
-		return preferenceSettings;
-	}
+    /**
+     * Logger
+     */
+    static Logger logger = Logger.getLogger(RoutingPlugin.class);
+
+    /**
+     * The list of routing layers
+     */
+    private final ArrayList<RoutingLayer> layers;
+
+    /**
+     * The side dialog where nodes are listed
+     */
+    private RoutingDialog routingDialog;
+
+    /**
+     * Preferences Settings Dialog.
+     */
+    private final PreferenceSetting preferenceSettings;
+
+    /**
+     * MapMode for adding route nodes.
+     * We use this field to enable or disable the mode automatically.
+     */
+    private AddRouteNodeAction addRouteNodeAction;
+
+    /**
+     * MapMode for removing route nodes.
+     * We use this field to enable or disable the mode automatically.
+     */
+    private RemoveRouteNodeAction removeRouteNodeAction;
+
+    /**
+     * MapMode for moving route nodes.
+     * We use this field to enable or disable the mode automatically.
+     */
+    private MoveRouteNodeAction moveRouteNodeAction;
+
+    /**
+     * IconToggleButton for adding route nodes, we use this field to show or hide the button.
+     */
+    private IconToggleButton addRouteNodeButton;
+
+    /**
+     * IconToggleButton for removing route nodes, we use this field to show or hide the button.
+     */
+    private IconToggleButton removeRouteNodeButton;
+
+    /**
+     * IconToggleButton for moving route nodes, we use this field to show or hide the button.
+     */
+    private IconToggleButton moveRouteNodeButton;
+
+    /**
+     * IconToggleButton for moving route nodes, we use this field to show or hide the button.
+     */
+    private final RoutingMenu menu;
+
+    /**
+     * Reference for the plugin class (as if it were a singleton)
+     */
+    private static RoutingPlugin plugin;
+
+    private final DataSetListenerAdapter datasetAdapter;
+
+    /**
+     * Default Constructor
+     */
+    public RoutingPlugin(PluginInformation info) {
+        super(info);
+
+        datasetAdapter = new DataSetListenerAdapter(this);
+        plugin = this; // Assign reference to the plugin class
+        File log4jConfigFile = new java.io.File("log4j.xml");
+        if (log4jConfigFile.exists()) {
+            DOMConfigurator.configure(log4jConfigFile.getPath());
+        } else {
+            System.err.println("Routing plugin warning: log4j configuration not found");
+        }
+        logger.debug("Loading routing plugin...");
+        preferenceSettings=new RoutingPreferenceDialog();
+        // Initialize layers list
+        layers = new ArrayList<RoutingLayer>();
+        // Add menu
+        menu = new RoutingMenu();
+        // Register this class as LayerChangeListener
+        MapView.addLayerChangeListener(this);
+        DatasetEventManager.getInstance().addDatasetListener(datasetAdapter, FireMode.IN_EDT_CONSOLIDATED);
+        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.getEditLayer();
+        if (osmLayer != null) {
+            RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", osmLayer);
+            layers.add(layer);
+            Main.main.addLayer(layer);
+        }
+    }
+
+    @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);
+            addRouteNodeButton.setAutoHideDisabledButton(true);
+            removeRouteNodeButton.setAutoHideDisabledButton(true);
+            moveRouteNodeButton.setAutoHideDisabledButton(true);
+            newFrame.addMapMode(addRouteNodeButton);
+            newFrame.addMapMode(removeRouteNodeButton);
+            newFrame.addMapMode(moveRouteNodeButton);
+            // Enable menu
+            menu.enableStartItem();
+            newFrame.addToggleDialog(routingDialog = new RoutingDialog());
+        } else {
+            addRouteNodeAction = null;
+            removeRouteNodeAction = null;
+            moveRouteNodeAction = null;
+            addRouteNodeButton = null;
+            removeRouteNodeButton = null;
+            moveRouteNodeButton = null;
+            routingDialog = null;
+        }
+    }
+
+    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+        if (newLayer instanceof RoutingLayer) {            /*   show Routing toolbar and dialog window  */
+            menu.enableRestOfItems();
+            if (routingDialog != null) {
+                routingDialog.showDialog();
+                routingDialog.refresh();
+            }
+        }else{                                            /*   hide Routing toolbar and dialog window  */
+            menu.disableRestOfItems();
+            if (routingDialog != null) {
+                routingDialog.hideDialog();
+            }
+        }
+    }
+
+    public void layerAdded(Layer newLayer) {
+        // Add button(s) to the tool bar when the routing layer is added
+        if (newLayer instanceof RoutingLayer) {
+            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.");
+        }
+    }
+
+    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.main.removeLayer(layersArray[i]);
+                    } catch (IllegalArgumentException e) {
+                    }
+                }
+            }
+        }
+        // Reload RoutingDialog table model
+        if (routingDialog != null) {
+            routingDialog.refresh();
+        }
+    }
+
+    public void processDatasetEvent(AbstractDatasetChangedEvent event){
+
+    }
+
+    @Override
+    public PreferenceSetting getPreferenceSetting() {
+        return preferenceSettings;
+    }
 }
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 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 30361)
@@ -52,90 +52,90 @@
 public class RoutingDialog extends ToggleDialog {
 
-	private final DefaultListModel model;
-	private JList jList = null;
-	private JScrollPane jScrollPane = null;
+    private final 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:routing", tr("Toggle: {0}", tr("Routing")), KeyEvent.VK_R, Shortcut.ALT_CTRL_SHIFT), 150);
-		model = new DefaultListModel();
-		createLayout(getJScrollPane(), false, null);
-	}
+    public RoutingDialog() {
+        super(tr("Routing"), "routing", tr("Open a list of routing nodes"),
+                Shortcut.registerShortcut("subwindow:routing", tr("Toggle: {0}", tr("Routing")), KeyEvent.VK_R, Shortcut.ALT_CTRL_SHIFT), 150);
+        model = new DefaultListModel();
+        createLayout(getJScrollPane(), false, null);
+    }
 
-	/**
-	 * This method initializes jScrollPane
-	 *
-	 * @return javax.swing.JScrollPane
-	 */
-	private JScrollPane getJScrollPane() {
-		if (jScrollPane == null) {
-			jScrollPane = new JScrollPane();
-			jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-			jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
-			jScrollPane.setViewportView(getJList());
-		}
-		return jScrollPane;
-	}
+    /**
+     * This method initializes jScrollPane
+     *
+     * @return javax.swing.JScrollPane
+     */
+    private JScrollPane getJScrollPane() {
+        if (jScrollPane == null) {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+            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.getId()+" ["+n.getCoor().toDisplayString()+"]");
-	}
+    /**
+     * Add item to the list of nodes
+     * @param obj
+     */
+    public void addNode(Node n) {
+        model.addElement(n.getId()+" ["+n.getCoor().toDisplayString()+"]");
+    }
 
-	/**
-	 * Insert item to the list of nodes
-	 * @param index
-	 * @param obj
-	 */
-	public void insertNode(int index, Node n) {
-		model.insertElementAt(n.getId()+" ["+n.getCoor().toDisplayString()+"]", index);
-	}
+    /**
+     * Insert item to the list of nodes
+     * @param index
+     * @param obj
+     */
+    public void insertNode(int index, Node n) {
+        model.insertElementAt(n.getId()+" ["+n.getCoor().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 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java	(revision 30361)
@@ -59,157 +59,157 @@
 public class RoutingMenu extends JMenu {
 
-	/**
-	 * Default serial version UID
-	 */
-	private static final long serialVersionUID = 3559922048225708480L;
-
-	private final JMenuItem startMI;
-	private final JMenuItem reverseMI;
-	private final JMenuItem clearMI;
-	private final JMenuItem regraphMI;
-	private final JMenu criteriaM;
-	private final JMenu menu;
-
-	/**
-	 */
-	public RoutingMenu() {
-		MainMenu mm = Main.main.menu;
-		menu = mm.addMenu(marktr("Routing"), KeyEvent.VK_O, mm.getDefaultMenuPos(), ht("/Plugin/Routing"));
-
-		startMI = new JMenuItem(tr("Add routing layer"));
-		startMI.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				RoutingPlugin.getInstance().addLayer();
-			}
-		});
-		menu.add(startMI);
-
-		menu.addSeparator();
-		ButtonGroup group = new ButtonGroup();
-
-		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 rfaster = new JRadioButtonMenuItem(tr("Fastest"));
-		group.add(rshorter);
-		group.add(rfaster);
-		criteriaM.add(rshorter);
-		criteriaM.add(rfaster);
-
-		criteriaM.addSeparator();
-		JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("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();
-					routingModel.setOnewayChanged();
-					Main.map.repaint();
-				}
-			}
-		});
-		criteriaM.add(cbmi);
-		menu.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);
-
-		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);
-
-		regraphMI = new JMenuItem(tr("Reconstruct Graph"));
-		regraphMI.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.routingGraph.resetGraph();
-					routingModel.routingGraph.createGraph();
-				}
-
-			}
-		});
-		menu.add(regraphMI);
-
-
-		// Initially disabled
-		disableAllItems();
-	}
-
-	public void disableAllItems() {
-		startMI.setEnabled(false);
-		reverseMI.setEnabled(false);
-		clearMI.setEnabled(false);
-		criteriaM.setEnabled(false);
-		regraphMI.setEnabled(false);
-	}
-
-	public void enableStartItem() {
-		startMI.setEnabled(true);
-	}
-
-	public void enableRestOfItems() {
-		reverseMI.setEnabled(true);
-		clearMI.setEnabled(true);
-		criteriaM.setEnabled(true);
-		regraphMI.setEnabled(true);
-	}
-
-	public void disableRestOfItems() {
-		reverseMI.setEnabled(false);
-		clearMI.setEnabled(false);
-		criteriaM.setEnabled(false);
-		regraphMI.setEnabled(false);
-	}
+    /**
+     * Default serial version UID
+     */
+    private static final long serialVersionUID = 3559922048225708480L;
+
+    private final JMenuItem startMI;
+    private final JMenuItem reverseMI;
+    private final JMenuItem clearMI;
+    private final JMenuItem regraphMI;
+    private final JMenu criteriaM;
+    private final JMenu menu;
+
+    /**
+     */
+    public RoutingMenu() {
+        MainMenu mm = Main.main.menu;
+        menu = mm.addMenu(marktr("Routing"), KeyEvent.VK_O, mm.getDefaultMenuPos(), ht("/Plugin/Routing"));
+
+        startMI = new JMenuItem(tr("Add routing layer"));
+        startMI.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                RoutingPlugin.getInstance().addLayer();
+            }
+        });
+        menu.add(startMI);
+
+        menu.addSeparator();
+        ButtonGroup group = new ButtonGroup();
+
+        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 rfaster = new JRadioButtonMenuItem(tr("Fastest"));
+        group.add(rshorter);
+        group.add(rfaster);
+        criteriaM.add(rshorter);
+        criteriaM.add(rfaster);
+
+        criteriaM.addSeparator();
+        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("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();
+                    routingModel.setOnewayChanged();
+                    Main.map.repaint();
+                }
+            }
+        });
+        criteriaM.add(cbmi);
+        menu.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);
+
+        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);
+
+        regraphMI = new JMenuItem(tr("Reconstruct Graph"));
+        regraphMI.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.routingGraph.resetGraph();
+                    routingModel.routingGraph.createGraph();
+                }
+
+            }
+        });
+        menu.add(regraphMI);
+
+
+        // Initially disabled
+        disableAllItems();
+    }
+
+    public void disableAllItems() {
+        startMI.setEnabled(false);
+        reverseMI.setEnabled(false);
+        clearMI.setEnabled(false);
+        criteriaM.setEnabled(false);
+        regraphMI.setEnabled(false);
+    }
+
+    public void enableStartItem() {
+        startMI.setEnabled(true);
+    }
+
+    public void enableRestOfItems() {
+        reverseMI.setEnabled(true);
+        clearMI.setEnabled(true);
+        criteriaM.setEnabled(true);
+        regraphMI.setEnabled(true);
+    }
+
+    public void disableRestOfItems() {
+        reverseMI.setEnabled(false);
+        clearMI.setEnabled(false);
+        criteriaM.setEnabled(false);
+        regraphMI.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 30360)
+++ applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java	(revision 30361)
@@ -63,172 +63,172 @@
 public class RoutingPreferenceDialog extends DefaultTabPreferenceSetting {
 
-	/**
-	 * Logger
-	 */
-	static Logger logger = Logger.getLogger(RoutingPreferenceDialog.class);
-
-	private Map<String, String> orig;
-	private DefaultTableModel model;
-
-	/**
-	 * Constructor
-	 */
-	public RoutingPreferenceDialog() {
-		super("routing", tr("Routing Plugin Preferences"), tr("Configure routing preferences."));
-		readPreferences();
-	}
-
-	public void addGui(final PreferenceTabbedPane gui) {
-
-		JPanel principal = gui.createPreferenceTab(this);
-
-		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 PreferenceTabbedPane 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("routing", tr("Routing Plugin Preferences"), tr("Configure routing preferences."));
+        readPreferences();
+    }
+
+    public void addGui(final PreferenceTabbedPane gui) {
+
+        JPanel principal = gui.createPreferenceTab(this);
+
+        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 PreferenceTabbedPane 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];
+    }
+     */
 }
