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 28137)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java	(revision 28138)
@@ -36,6 +36,6 @@
 import org.jgrapht.alg.BellmanFordShortestPath;
 import org.jgrapht.alg.DijkstraShortestPath;
-import org.jgrapht.graph.AsUndirectedGraph;
 import org.jgrapht.graph.DirectedWeightedMultigraph;
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
@@ -43,4 +43,6 @@
 
 import com.innovant.josm.jrt.osm.OsmEdge;
+import com.innovant.josm.plugin.routing.RoutingLayer;
+import com.innovant.josm.plugin.routing.RoutingModel;
 
 /**
@@ -53,383 +55,385 @@
 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;
-
-    /**
-     * 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;
-
-    
-    /**
-     * Graph getter
-     */
-    public Graph<Node, OsmEdge> getGraph(){
-    	return graph;
-    
-    }
-    
-    
+	/**
+	 * 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);
+
+	/**
+	 * 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);
-	}
-	
+		addEdge(way,from,to);
+		addEdge(way,to,from);
+	}
+
 	private void addEdgeReverseOneway( Way way, Node from, Node to){
-	    addEdge(way,to,from);
-	}
-	
+		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 (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) {
-        double length = from.getCoor().greatCircleDistance(to.getCoor());
-
-        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);
-        //((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 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;
-
-        return way.get("highway") != null || 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;
-
-        if (graph == null)
-            this.createGraph();
-        logger.debug("apply algorithm between nodes ");
-
-        for (Node node : nodes) {
-            logger.debug(node.getId());
-        }
-        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>(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;
-    }
+		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) {
+		double length = from.getCoor().greatCircleDistance(to.getCoor());
+
+		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);
+		//((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 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;
+
+		return way.get("highway") != null || 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/RoutingModel.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 28137)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java	(revision 28138)
@@ -48,112 +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;
-    /**
-     * Flag to advise about changes in the selected nodes.
-     */
-    private boolean changeNodes=false;
-    /**
-     * Default Constructor.
-     */
-    public RoutingModel(DataSet data) {
-        nodes = new ArrayList<Node>();
-System.out.println("gr " + data);
-        routingGraph = new RoutingGraph(data);
-    }
+	private List<OsmEdge> path=null;
 
-    /**
-     * Method that returns the selected nodes to calculate route.
-     * @return the selectedNodes
-     */
-    public List<Node> getSelectedNodes() {
-        return nodes;
-    }
+	/**
+	 * Flag to advise about changes in the selected nodes.
+	 */
+	private boolean changeNodes=false;
 
-    /**
-     * 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;
-    }
+	/**
+	 * Flag to advise about changes in ways.
+	 */
+	private boolean changeOneway=false;
 
-    /**
-     * 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;
-        }
-    }
+	/**
+	 * Default Constructor.
+	 */
+	public RoutingModel(DataSet data) {
+		nodes = new ArrayList<Node>();
+		System.out.println("gr " + data);
+		routingGraph = new RoutingGraph(data);
+	}
 
-    /**
-     * 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;
-        }
-    }
+	/**
+	 * Method that returns the selected nodes to calculate route.
+	 * @return the selectedNodes
+	 */
+	public List<Node> getSelectedNodes() {
+		return nodes;
+	}
 
-    /**
-     * 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;
-    }
+	/**
+	 * 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;
+	}
 
-    /**
-     * 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;
-        }
-        return path;
-    }
+	/**
+	 * 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;
+		}
+	}
 
-    /**
-     * Marks that some node or the node order has changed so the path should be computed again
-     */
-    public void setNodesChanged() {
-        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;
+		}
+	}
 
-    /**
-     * Resets all data.
-     */
-    public void reset() {
-        nodes.clear();
-        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;
+	}
+
+	/**
+	 * 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 boolean getOnewayChanged() {
+		return this.changeOneway;
+	}
+
+	/**
+	 * 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 28137)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java	(revision 28138)
@@ -35,9 +35,5 @@
 import org.apache.log4j.xml.DOMConfigurator;
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.event.DataChangedEvent;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
-import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent.DatasetEventType;
-import org.openstreetmap.josm.data.osm.event.DataSetListener;
 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
@@ -69,217 +65,217 @@
  */
 public class RoutingPlugin extends Plugin implements LayerChangeListener,DataSetListenerAdapter.Listener {
-    /**
-     * Logger
-     */
-    static Logger logger = Logger.getLogger(RoutingPlugin.class);
-
-    /**
-     * The list of routing layers
-     */
-    private ArrayList<RoutingLayer> layers;
-
-    /**
-     * The side dialog where nodes are listed
-     */
-    private RoutingDialog routingDialog;
-
-    /**
-     * Preferences Settings Dialog.
-     */
-    private 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 RoutingMenu menu;
-
-    /**
-     * Reference for the plugin class (as if it were a singleton)
-     */
-    private static RoutingPlugin plugin;
-    
-    private DataSetListenerAdapter datasetAdapter;
-
-    /**
-     * Default Constructor
-     */
-    public RoutingPlugin(PluginInformation info) {
-        super(info);
-        
-        datasetAdapter = new DataSetListenerAdapter(this);
-        plugin = this; // Assign reference to the plugin class
-	if (new java.io.File("log4j.xml").exists()) {
-            DOMConfigurator.configure("log4j.xml");
-        } else {
-            System.err.println("Routing plugin warning: log4j configuration not found"); 
-        }
-        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();
-        // 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.map.mapView.getEditLayer();
-        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);
-        }
-    }
-
-    /*
-     * (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();    		
-    		    routingDialog.showDialog();
-    		    routingDialog.refresh();
-    	   	}else{											/*   hide Routing toolbar and dialog window  */
-    		    menu.disableRestOfItems();
-    		    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.map.mapView.removeLayer(layersArray[i]);
-                    } catch (IllegalArgumentException e) {
-                    }
-                }
-            }
-        }
-        // Reload RoutingDialog table model
-        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 final 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
+		if (new java.io.File("log4j.xml").exists()) {
+			DOMConfigurator.configure("log4j.xml");
+		} else {
+			System.err.println("Routing plugin warning: log4j configuration not found");
+		}
+		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();
+		// 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.map.mapView.getEditLayer();
+		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);
+		}
+	}
+
+	/*
+	 * (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();
+			routingDialog.showDialog();
+			routingDialog.refresh();
+		}else{											/*   hide Routing toolbar and dialog window  */
+			menu.disableRestOfItems();
+			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.map.mapView.removeLayer(layersArray[i]);
+					} catch (IllegalArgumentException e) {
+					}
+				}
+			}
+		}
+		// Reload RoutingDialog table model
+		routingDialog.refresh();
+	}
+
+	public void processDatasetEvent(AbstractDatasetChangedEvent event){
+
+
+	}
+	/* (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/gui/RoutingDialog.java
===================================================================
--- /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 28137)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java	(revision 28138)
@@ -30,15 +30,10 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.BorderLayout;
 import java.awt.ComponentOrientation;
-import java.awt.Font;
 import java.awt.event.KeyEvent;
 
-import javax.swing.BorderFactory;
 import javax.swing.DefaultListModel;
 import javax.swing.JList;
-import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.border.EtchedBorder;
 
 import org.openstreetmap.josm.Main;
@@ -57,90 +52,90 @@
 public class RoutingDialog extends ToggleDialog {
 
-    private DefaultListModel model;
-    private JList jList = null;
-    private JScrollPane jScrollPane = null;
+	private final DefaultListModel<String> model;
+	private JList<String> 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<String>();
+		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<String> getJList() {
+		if (jList == null) {
+			jList = new JList<String>();
+			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 28137)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java	(revision 28138)
@@ -59,154 +59,155 @@
 public class RoutingMenu extends JMenu {
 
-    /**
-     * Default serial version UID
-     */
-    private static final long serialVersionUID = 3559922048225708480L;
-
-    private JMenuItem startMI;
-    private JMenuItem reverseMI;
-    private JMenuItem clearMI;
-    private JMenuItem regraphMI;
-    private JMenu criteriaM;
-    private JMenu menu;
-
-    /**
-     * @param s
-     */
-    public RoutingMenu() {
-        MainMenu mm = Main.main.menu;
-        menu = mm.addMenu(marktr("Routing"), KeyEvent.VK_O, mm.defaultMenuPos, 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();
-                    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);
-    }
-
-    public void enableStartItem() {
-        startMI.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);
-    }
+	/**
+	 * 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;
+
+	/**
+	 * @param s
+	 */
+	public RoutingMenu() {
+		MainMenu mm = Main.main.menu;
+		menu = mm.addMenu(marktr("Routing"), KeyEvent.VK_O, mm.defaultMenuPos, 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);
+	}
+
+	public void enableStartItem() {
+		startMI.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);
+	}
 }
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 28137)
+++ /applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java	(revision 28138)
@@ -63,171 +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<String> key = new JComboBox<String>();
+				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];
+	}
+	 */
 }
