Index: applications/editors/josm/plugins/build.xml
===================================================================
--- applications/editors/josm/plugins/build.xml	(revision 16420)
+++ applications/editors/josm/plugins/build.xml	(revision 16428)
@@ -28,4 +28,5 @@
         <ant antfile="build.xml" target="dist" dir="plastic_laf"/>
         <ant antfile="build.xml" target="dist" dir="remotecontrol"/>
+        <ant antfile="build.xml" target="dist" dir="routes"/>
         <ant antfile="build.xml" target="dist" dir="routing"/>
         <ant antfile="build.xml" target="dist" dir="slippymap"/>
Index: applications/editors/josm/plugins/routes/.classpath
===================================================================
--- applications/editors/josm/plugins/routes/.classpath	(revision 16428)
+++ applications/editors/josm/plugins/routes/.classpath	(revision 16428)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
+	<classpathentry kind="lib" path="lib/jaxb-api.jar"/>
+	<classpathentry kind="lib" path="lib/jaxb-impl.jar"/>
+	<classpathentry kind="lib" path="lib/jsr173-1.0_api.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: applications/editors/josm/plugins/routes/.project
===================================================================
--- applications/editors/josm/plugins/routes/.project	(revision 16428)
+++ applications/editors/josm/plugins/routes/.project	(revision 16428)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>josm-routes</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: applications/editors/josm/plugins/routes/build.xml
===================================================================
--- applications/editors/josm/plugins/routes/build.xml	(revision 16428)
+++ applications/editors/josm/plugins/routes/build.xml	(revision 16428)
@@ -0,0 +1,64 @@
+<project name="routes" default="dist" basedir=".">
+    <property name="josm"                   location="../../core/dist/josm-custom.jar"/>
+    <property name="plugin.dist.dir"        value="../../dist"/>
+    <property name="plugin.build.dir"       value="build"/>
+    <property name="plugin.jar"             value="${plugin.dist.dir}/${ant.project.name}.jar"/>
+    <property name="ant.build.javac.target" value="1.5"/>
+    <target name="init">
+        <mkdir dir="${plugin.build.dir}"/>
+    </target>
+    <target name="compile" depends="init">
+        <echo message="creating ${plugin.jar}"/>
+        <javac srcdir="src" debug="true" destdir="${plugin.build.dir}">
+            <compilerarg value="-Xlint:deprecation"/>
+            <compilerarg value="-Xlint:unchecked"/>
+            <classpath>
+                <pathelement location="${josm}"/>
+                <fileset dir="lib">
+                    <include name="**/*.jar"/>
+                </fileset>
+            </classpath>
+        </javac>
+        <copy file="src/org/openstreetmap/josm/plugins/routes/xml/routes.xml" todir="${plugin.build.dir}/org/openstreetmap/josm/plugins/routes/xml"/>
+        <copy file="src/org/openstreetmap/josm/plugins/routes/xml/routes.xsd" todir="${plugin.build.dir}/org/openstreetmap/josm/plugins/routes/xml"/>
+        
+    </target>
+    <target name="dist" depends="compile,revision">
+        <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
+            <zipfileset src="lib/jsr173-1.0_api.jar" includes="**/*"/>
+            <zipfileset src="lib/jaxb-api.jar" includes="**/*"/>
+            <zipfileset src="lib/jaxb-impl.jar" includes="**/*.class"/>
+            <manifest>
+                <attribute name="Author" value="Jiri Klement"/>
+                <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.routes.RoutesPlugin"/>
+                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
+                <attribute name="Plugin-Description" value="Renders routes (bus, hiking trails, bicycle routes, ..). Route types must be defined in routes.xml file in plugin directory"/>
+                <attribute name="Plugin-Mainversion" value="1725"/>
+                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
+            </manifest>
+        </jar>
+    </target>
+    <target name="revision">
+        <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
+            <env key="LANG" value="C"/>
+            <arg value="info"/>
+            <arg value="--xml"/>
+            <arg value="."/>
+        </exec>
+        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
+        <delete file="REVISION"/>
+    </target>
+    <target name="clean">
+        <delete dir="${plugin.build.dir}"/>
+        <delete file="${plugin.jar}"/>
+    </target>
+    <target name="install" depends="dist">
+        <property environment="env"/>
+        <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">
+            <and>
+                <os family="windows"/>
+            </and>
+        </condition>
+        <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
+    </target>
+</project>
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/ConvertedWay.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/ConvertedWay.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/ConvertedWay.java	(revision 16428)
@@ -0,0 +1,92 @@
+package org.openstreetmap.josm.plugins.routes;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.List;
+
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
+
+
+public class ConvertedWay {
+	
+	public class WayEnd {
+		private Node end;
+		
+		public WayEnd(Node end) {
+			this.end = end;
+		}
+		
+		@Override
+		public boolean equals(Object o) {
+			if (o instanceof WayEnd) {
+				WayEnd otherEnd = (WayEnd)o;
+				return end.equals(otherEnd.end) && routes.equals(otherEnd.getRoutes());
+			} else {
+				return false;
+			}
+		}
+		
+		@Override
+		public int hashCode() {
+			return end.hashCode() + routes.hashCode();
+		}
+		
+		public BitSet getRoutes() {
+			return routes;
+		}
+		
+		public ConvertedWay getWay() {
+			return ConvertedWay.this;
+		}
+	}
+	
+	private List<Node> nodes = new ArrayList<Node>();
+	private BitSet routes;
+	
+	public ConvertedWay(BitSet routes, Way way) {
+		this.routes = routes;
+		nodes.addAll(way.nodes);
+	}
+	
+	public WayEnd getStart() {
+		return new WayEnd(nodes.get(0));
+	}
+	
+	public WayEnd getStop() {
+		return new WayEnd(nodes.get(nodes.size() - 1));
+	}
+	
+	/**
+	 * Connects way to this way. Other ways internal representation is destroyed!!!
+	 * @param way
+	 */
+	public void connect(ConvertedWay way) {
+		for (int i=0; i<2; i++) {			
+			if (way.nodes.get(0).equals(nodes.get(nodes.size() - 1))) {
+				way.nodes.remove(0);
+				nodes.addAll(way.nodes);
+				return;
+			}
+			
+			if (way.nodes.get(way.nodes.size() - 1).equals(nodes.get(0))) {
+				nodes.remove(0);
+				way.nodes.addAll(nodes);
+				nodes = way.nodes;
+				return;
+			}
+			Collections.reverse(nodes);
+		}
+	}
+
+	public List<Node> getNodes() {
+		return nodes;
+	}
+
+	public BitSet getRoutes() {
+		return routes;
+	}
+
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/MANIFEST.MF
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/MANIFEST.MF	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/MANIFEST.MF	(revision 16428)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Plugin-Class: org.openstreetmap.josm.plugins.routes.RoutesPlugin
+Plugin-Description: Routes plug-in (Manifest for debugging in Eclipse, not to be used in deployement)
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/PathBuilder.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/PathBuilder.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/PathBuilder.java	(revision 16428)
@@ -0,0 +1,68 @@
+package org.openstreetmap.josm.plugins.routes;
+
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.plugins.routes.ConvertedWay.WayEnd;
+
+public class PathBuilder {
+
+	private Map<Way, BitSet> wayRoutes = new HashMap<Way, BitSet>(); 
+
+	public void addWay(Way way, RouteDefinition route) {
+
+		if (way.nodes.size() >= 2) {
+			BitSet routes = wayRoutes.get(way);
+			if (routes == null) {
+				routes = new BitSet();
+				wayRoutes.put(way, routes);
+			}
+			routes.set(route.getIndex());
+		}
+
+	}
+
+	public Collection<ConvertedWay> getConvertedWays() {
+		Map<WayEnd, ConvertedWay> ways = new HashMap<WayEnd, ConvertedWay>();
+
+		for (Entry<Way, BitSet> wayEntry:wayRoutes.entrySet()) {
+			ConvertedWay way = new ConvertedWay(wayEntry.getValue(), wayEntry.getKey());
+
+			ConvertedWay wayBefore = ways.get(way.getStart());
+			ConvertedWay wayAfter = ways.get(way.getStop());
+
+			if (wayBefore != null) {
+				removeWay(ways, wayBefore);
+				way.connect(wayBefore);
+			} 
+
+			if (wayAfter != null) {
+				removeWay(ways, wayAfter);
+				way.connect(wayAfter);
+			}
+
+			ways.put(way.getStart(), way);
+			ways.put(way.getStop(), way);
+		}
+
+		Set<ConvertedWay> uniqueWays = new HashSet<ConvertedWay>();
+		uniqueWays.addAll(ways.values());
+		return uniqueWays;
+	}
+
+	private void removeWay(Map<WayEnd, ConvertedWay> map, ConvertedWay wayInMap) {
+		map.remove(wayInMap.getStart());
+		map.remove(wayInMap.getStop());
+	}
+
+	public void clear() {
+		wayRoutes.clear();
+	}
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RelationEditMode.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RelationEditMode.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RelationEditMode.java	(revision 16428)
@@ -0,0 +1,98 @@
+package org.openstreetmap.josm.plugins.routes;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.Cursor;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.util.Collection;
+
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.mapmode.MapMode;
+import org.openstreetmap.josm.command.ChangeCommand;
+import org.openstreetmap.josm.command.RemoveRelationMemberCommand;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.tools.Shortcut;
+
+public class RelationEditMode extends MapMode {
+	private static final long serialVersionUID = -7767329767438266289L;
+	
+	private Way highlightedWay;
+	
+	public RelationEditMode(MapFrame mapFrame) {
+        super(tr("Edit relation"), "node/autonode", tr("Edit relations"),
+                Shortcut.registerShortcut("mapmode:editRelation", tr("Mode: {0}", tr("EditRelation")), KeyEvent.VK_H, Shortcut.GROUP_EDIT),
+                mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+	}
+	
+    @Override
+	public void enterMode() {
+    	super.enterMode();
+    	Main.map.mapView.addMouseListener(this);
+    	Main.map.mapView.addMouseMotionListener(this);
+    }
+    
+    @Override
+	public void exitMode() {
+    	super.exitMode();
+    	Main.map.mapView.removeMouseListener(this);
+    	Main.map.mapView.removeMouseMotionListener(this);
+    }
+    
+    @Override
+    public void mouseMoved(MouseEvent e) {
+    	Way nearestWay = Main.map.mapView.getNearestWay(e.getPoint());
+    	if (nearestWay != highlightedWay) {
+    		if (highlightedWay != null) {
+    			highlightedWay.highlighted = false;
+    		}
+    		if (nearestWay != null) {
+    			nearestWay.highlighted = true;
+    		}
+    		highlightedWay = nearestWay;
+			Main.map.mapView.repaint();	
+    	}
+    }
+    
+    @Override
+	public void mouseClicked(MouseEvent e) {
+    	Way way = Main.map.mapView.getNearestWay(e.getPoint());
+    	
+    	Collection<OsmPrimitive> selectedRelations = Main.ds.getSelectedRelations();
+    	
+    	if (way != null) {
+    		
+    		if (selectedRelations.isEmpty()) {
+    			JOptionPane.showMessageDialog(Main.parent, tr("No relation is selected"));
+    		}
+    		
+    		for (OsmPrimitive rel:selectedRelations) {
+    			Relation r = (Relation)rel;
+    			RelationMember foundMember = null;
+    			for (RelationMember member:r.members) {
+    				if (member.member == way) {
+    					foundMember = member;
+    					break;
+    				}
+    			}
+    			
+    			if (foundMember != null) {
+    				Main.main.undoRedo.add(new RemoveRelationMemberCommand(r, new RelationMember("", way)));
+    			} else {
+    				Relation newRelation = new Relation(r);
+    				newRelation.members.add(new RelationMember("", way));
+    	            Main.main.undoRedo.add(new ChangeCommand(r, newRelation));
+    			}
+    		}
+    	}
+    }
+
+	
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteDefinition.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteDefinition.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteDefinition.java	(revision 16428)
@@ -0,0 +1,46 @@
+package org.openstreetmap.josm.plugins.routes;
+
+import java.awt.Color;
+
+import org.openstreetmap.josm.actions.search.SearchCompiler;
+import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
+import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+
+public class RouteDefinition {
+	
+	private final Color color;
+	private final String matchString;
+	private Match match;
+	private final int index;
+	
+	public RouteDefinition(int index, Color color, String expression) {
+		this.color = color;
+		this.matchString = expression;
+		this.index = index;
+		try {
+			match = SearchCompiler.compile(expression, false, false);
+		} catch (ParseError e) {
+			match = null;
+			e.printStackTrace();
+		}
+	}
+			
+	public boolean matches(OsmPrimitive primitive) {
+		return match.match(primitive);
+	}
+	
+	public Color getColor() {
+		return color;
+	}
+	
+	public int getIndex() {
+		return index;
+	}
+	
+	@Override
+	public String toString() {
+		return color.toString() + " " + matchString;
+	}
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteLayer.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteLayer.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteLayer.java	(revision 16428)
@@ -0,0 +1,143 @@
+package org.openstreetmap.josm.plugins.routes;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.Icon;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.plugins.routes.paint.NarrowLinePainter;
+import org.openstreetmap.josm.plugins.routes.paint.PathPainter;
+import org.openstreetmap.josm.plugins.routes.paint.WideLinePainter;
+import org.openstreetmap.josm.plugins.routes.xml.RoutesXMLLayer;
+import org.openstreetmap.josm.plugins.routes.xml.RoutesXMLRoute;
+import org.openstreetmap.josm.tools.ColorHelper;
+import org.openstreetmap.josm.tools.ImageProvider;
+
+public class RouteLayer extends Layer {
+
+	private final PathPainter pathPainter;
+	private final PathBuilder pathBuilder = new PathBuilder();
+	private final List<RouteDefinition> routes = new ArrayList<RouteDefinition>();
+	
+	public RouteLayer(RoutesXMLLayer xmlLayer) {
+		super(xmlLayer.getName());
+		
+		int index = 0;
+		for (RoutesXMLRoute route:xmlLayer.getRoute()) {
+			Color color = ColorHelper.html2color(route.getColor());
+			if (color == null) {
+				color = Color.RED;
+				System.err.printf("Routes plugin - unable to convert color (%s)\n", route.getColor());
+			}
+			routes.add(new RouteDefinition(index++, color, route.getPattern()));
+		}
+		
+		/*routes.add(new RouteDefinition(Color.RED, 
+			"((type:relation | type:way) kct_red=*) | (color=red type=route route=hiking network=cz:kct)"));
+		
+		routes.add(new RouteDefinition(Color.YELLOW, 
+			"((type:relation | type:way) kct_yellow=*) | (color=yellow type=route route=hiking network=cz:kct)"));
+
+		routes.add(new RouteDefinition(Color.BLUE, 
+			"((type:relation | type:way) kct_blue=*) | (color=blue type=route route=hiking network=cz:kct)"));
+
+		routes.add(new RouteDefinition(Color.GREEN, 
+			"((type:relation | type:way) kct_green=*) | (color=green type=route route=hiking network=cz:kct)"));
+		
+		routes.add(new RouteDefinition(Color.MAGENTA,
+				"(type:way (ncn=* | (lcn=* | rcn=* ))) | (type:relation type=route route=bicycle)"));
+				
+				*/
+		if ("wide".equals(Main.pref.get("routes.painter"))) {
+			pathPainter = new WideLinePainter(this);
+		} else {
+			pathPainter = new NarrowLinePainter(this);
+		}
+	}
+
+	@Override
+	public Icon getIcon() {
+		return ImageProvider.get("layer", "osmdata_small");
+	}
+
+	@Override
+	public Object getInfoComponent() {
+		return null;
+	}
+
+	@Override
+	public Component[] getMenuEntries() {
+		return new Component[0];
+	}
+
+	@Override
+	public String getToolTipText() {
+		return "Hiking routes";
+	}
+
+	@Override
+	public boolean isMergable(Layer other) {
+		return false;
+	}
+
+	@Override
+	public void mergeFrom(Layer from) {
+
+	}
+
+	private void addRelation(Relation relation, RouteDefinition route) {
+		for (RelationMember member:relation.members) {
+			if (member.member instanceof Way) {
+				Way way = (Way)member.member;
+				pathBuilder.addWay(way, route);
+			}
+		}		
+	}
+
+	@Override
+	public void paint(Graphics g, MapView mv) {
+
+		pathBuilder.clear();
+
+		for (Relation relation:Main.ds.relations) {
+			for (RouteDefinition route:routes) {
+				if (route.matches(relation)) {
+					addRelation(relation, route);
+				}
+			}			
+		}
+
+		for (Way way:Main.ds.ways) {
+			for (RouteDefinition route:routes) {
+				if (route.matches(way)) {
+					pathBuilder.addWay(way, route);
+				}
+			}
+		}
+
+		for (ConvertedWay way:pathBuilder.getConvertedWays()) {
+			pathPainter.drawWay(way, mv, (Graphics2D) g);
+		}
+	}
+
+	@Override
+	public void visitBoundingBox(BoundingXYVisitor v) {
+
+	}
+	
+	public List<RouteDefinition> getRoutes() {
+		return routes;
+	}
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java	(revision 16428)
@@ -0,0 +1,115 @@
+package org.openstreetmap.josm.plugins.routes;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.SwingUtilities;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
+import org.openstreetmap.josm.plugins.Plugin;
+import org.openstreetmap.josm.plugins.routes.xml.Routes;
+import org.openstreetmap.josm.plugins.routes.xml.RoutesXMLLayer;
+
+public class RoutesPlugin extends Plugin implements LayerChangeListener {
+        
+    private final List<RouteLayer> routeLayers = new ArrayList<RouteLayer>();
+    private boolean isShown;
+    
+    public RoutesPlugin() {
+        Layer.listeners.add(this);
+        
+        
+        File routesFile = new File(getPluginDir() + File.separator + "routes.xml");
+        if (!routesFile.exists()) {
+            System.out.println("File with route definitions doesn't exist, using default");
+            
+            try {
+                routesFile.getParentFile().mkdir();
+                OutputStream outputStream = new FileOutputStream(routesFile);
+                InputStream inputStream = Routes.class.getResourceAsStream("routes.xml");
+                  
+                byte[] b = new byte[512];  
+                int read;  
+                while ((read = inputStream.read(b)) != -1) {  
+                    outputStream.write(b, 0, read);
+                }
+                
+                outputStream.close();               
+                inputStream.close();
+                    
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        
+        try {
+            JAXBContext context = JAXBContext.newInstance(
+                    Routes.class.getPackage().getName(), Routes.class.getClassLoader());
+            Unmarshaller unmarshaller = context.createUnmarshaller();
+            Routes routes = (Routes)unmarshaller.unmarshal(
+                new FileInputStream(getPluginDir() + File.separator + "routes.xml"));
+            for (RoutesXMLLayer layer:routes.getLayer()) {
+                routeLayers.add(new RouteLayer(layer));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } 
+
+        //new RelationEditMode(Main.map);
+        //Main.main.addLayer(new RouteLayer("Hiking trails"));
+    }
+
+    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+        // TODO Auto-generated method stub  
+    }
+    
+    private void checkLayers() {
+        if (Main.map != null && Main.map.mapView != null) {
+            for (Layer layer:Main.map.mapView.getAllLayers()) {
+                if (layer instanceof OsmDataLayer) {
+                    if (!isShown) {
+                        isShown = true;
+                        SwingUtilities.invokeLater(new Runnable() {
+                            public void run() {
+                                for (RouteLayer routeLayer:routeLayers) {
+                                    Main.main.addLayer(routeLayer);
+                                }
+                            }                           
+                        });
+                    }
+                    return;
+                } 
+            }
+            if (isShown) {
+                isShown = false;
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
+                        for (RouteLayer routeLayer:routeLayers) {
+                            Main.main.removeLayer(routeLayer);
+                        }
+                    }                   
+                });
+            }
+        }
+    }
+
+    public void layerAdded(Layer newLayer) {
+        checkLayers();
+    }
+
+    public void layerRemoved(Layer oldLayer) {
+        checkLayers();
+    }
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/AbstractLinePainter.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/AbstractLinePainter.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/AbstractLinePainter.java	(revision 16428)
@@ -0,0 +1,65 @@
+package org.openstreetmap.josm.plugins.routes.paint;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+
+public abstract class AbstractLinePainter implements PathPainter {
+	
+	// Following two method copied from http://blog.persistent.info/2004/03/java-lineline-intersections.html
+	protected boolean getLineLineIntersection(Line2D.Double l1,
+			Line2D.Double l2,
+			Point2D.Double intersection)
+	{
+		double  x1 = l1.getX1(), y1 = l1.getY1(),
+		x2 = l1.getX2(), y2 = l1.getY2(),
+		x3 = l2.getX1(), y3 = l2.getY1(),
+		x4 = l2.getX2(), y4 = l2.getY2();
+		
+		double ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3)*(y2 - y1));
+		intersection.x = x1 + ua * (x2 - x1);
+		intersection.y = y1 + ua * (y2 - y1);
+		 
+
+/*		intersection.x = det(det(x1, y1, x2, y2), x1 - x2,
+				det(x3, y3, x4, y4), x3 - x4)/
+				det(x1 - x2, y1 - y2, x3 - x4, y3 - y4);
+		intersection.y = det(det(x1, y1, x2, y2), y1 - y2,
+				det(x3, y3, x4, y4), y3 - y4)/
+				det(x1 - x2, y1 - y2, x3 - x4, y3 - y4);*/
+
+		return true;
+	}
+
+	protected double det(double a, double b, double c, double d)
+	{
+		return a * d - b * c;
+	}
+
+	protected Point2D shiftPoint(Point2D p1, Point2D p2, double shift) {
+		double dx = p2.getX() - p1.getX();
+		double dy = p2.getY() - p1.getY();
+		
+		// Perpendicular vector
+		double ndx = -dy;
+		double ndy = dx;
+		
+		// Normalize
+		double length = Math.sqrt(ndx * ndx + ndy * ndy);
+		ndx = ndx / length;
+		ndy = ndy / length;
+		
+		return new Point2D.Double(p1.getX() + shift * ndx, p1.getY() + shift * ndy);
+	}
+	
+	protected Line2D.Double shiftLine(Point2D p1, Point2D p2, double shift) {
+		double dx = p2.getX() - p1.getX();
+		double dy = p2.getY() - p1.getY();
+
+		Point2D point1 = shiftPoint(p1, p2, shift);
+		Point2D point2 = new Point2D.Double(point1.getX() + dx, point1.getY() + dy);
+	
+		return new Line2D.Double(
+				point1, point2);
+	}
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/NarrowLinePainter.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/NarrowLinePainter.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/NarrowLinePainter.java	(revision 16428)
@@ -0,0 +1,80 @@
+package org.openstreetmap.josm.plugins.routes.paint;
+
+import java.awt.BasicStroke;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.BitSet;
+import java.util.List;
+
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.plugins.routes.ConvertedWay;
+import org.openstreetmap.josm.plugins.routes.RouteDefinition;
+import org.openstreetmap.josm.plugins.routes.RouteLayer;
+
+public class NarrowLinePainter extends AbstractLinePainter {
+	
+	private static final float LINE_WIDTH = 5;
+	private final RouteLayer layer;
+	
+	public NarrowLinePainter(RouteLayer layer) {
+		this.layer = layer;
+	}
+
+	public void drawWay(ConvertedWay way, MapView mapView, Graphics2D g) {
+		List<Node> nodes = way.getNodes();
+		BitSet routes = way.getRoutes();
+		
+		if (nodes.size() < 2) {
+			return;
+		}
+		
+		//double totalWidth = LINE_WIDTH + (colors.size() - 1) * 4;
+		//double width = totalWidth / colors.size();
+		//double shift = -totalWidth / 2 + width / 2;
+		double width = LINE_WIDTH;
+		double shift = - (LINE_WIDTH * routes.cardinality()) / 2 + width / 2;
+		
+		for (int k=0; k<routes.length(); k++) {
+			
+			if (!routes.get(k)) {
+				continue;
+			}
+			
+			RouteDefinition route = layer.getRoutes().get(k);
+			
+			g.setColor(route.getColor());
+			g.setStroke(new BasicStroke((float) width));
+			
+			GeneralPath path = new GeneralPath();
+			Point2D start = shiftPoint(mapView.getPoint(nodes.get(0).getEastNorth()), 
+					mapView.getPoint(nodes.get(1).getEastNorth()), shift);
+			path.moveTo((float)start.getX(), (float)start.getY());
+			for (int i=1; i<nodes.size() - 1; i++) {
+				Point p1 = mapView.getPoint(nodes.get(i - 1).getEastNorth());
+				Point p2 = mapView.getPoint(nodes.get(i).getEastNorth());
+				Point p3 = mapView.getPoint(nodes.get(i + 1).getEastNorth());
+
+
+				Line2D.Double line1 = shiftLine(p1, p2, shift);
+				Line2D.Double line2 = shiftLine(p2, p3, shift);
+
+				Point2D.Double intersection = new Point2D.Double();
+				getLineLineIntersection(line1, line2, intersection);
+				if (!Double.isNaN(intersection.getX())  && !Double.isNaN(intersection.getY())) {
+					path.lineTo((float)intersection.getX(), (float)intersection.getY());
+				}
+			}
+			Point2D stop = shiftPoint(mapView.getPoint(nodes.get(nodes.size() - 1).getEastNorth()), 
+					mapView.getPoint(nodes.get(nodes.size() - 2).getEastNorth()), -shift);
+			path.lineTo((float)stop.getX(), (float)stop.getY());
+			g.draw(path);
+			
+			shift += width + 2;
+		}
+	}
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/PathPainter.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/PathPainter.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/PathPainter.java	(revision 16428)
@@ -0,0 +1,12 @@
+package org.openstreetmap.josm.plugins.routes.paint;
+
+import java.awt.Graphics2D;
+
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.plugins.routes.ConvertedWay;
+
+public interface PathPainter {
+	
+	public void drawWay(ConvertedWay way, MapView mapView, Graphics2D g);
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/WideLinePainter.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/WideLinePainter.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/paint/WideLinePainter.java	(revision 16428)
@@ -0,0 +1,80 @@
+package org.openstreetmap.josm.plugins.routes.paint;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.BitSet;
+import java.util.List;
+
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.plugins.routes.ConvertedWay;
+import org.openstreetmap.josm.plugins.routes.RouteDefinition;
+import org.openstreetmap.josm.plugins.routes.RouteLayer;
+
+public class WideLinePainter extends AbstractLinePainter {
+	
+	private static final float LINE_WIDTH = 10;
+	private final RouteLayer layer;
+	
+	public WideLinePainter(RouteLayer layer) {
+		this.layer = layer;
+	}
+
+	public void drawWay(ConvertedWay way, MapView mapView, Graphics2D g) {
+		List<Node> nodes = way.getNodes();
+		BitSet routes = way.getRoutes();
+		
+		if (nodes.size() < 2) {
+			return;
+		}
+		
+		double totalWidth = LINE_WIDTH + (routes.size() - 1) * 4;
+		double width = totalWidth / routes.cardinality();
+		double shift = -totalWidth / 2 + width / 2;
+		
+		for (int k=0; k<routes.length(); k++) {
+			
+			if (!routes.get(k)) {
+				continue;
+			}
+			
+			RouteDefinition route = layer.getRoutes().get(k);
+	
+			Color color = route.getColor();
+			g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 100));
+			g.setStroke(new BasicStroke((float) width));
+			
+			GeneralPath path = new GeneralPath();
+			Point2D start = shiftPoint(mapView.getPoint(nodes.get(0).getEastNorth()), 
+					mapView.getPoint(nodes.get(1).getEastNorth()), shift);
+			path.moveTo((float)start.getX(), (float)start.getY());
+			for (int i=1; i<nodes.size() - 1; i++) {
+				Point p1 = mapView.getPoint(nodes.get(i - 1).getEastNorth());
+				Point p2 = mapView.getPoint(nodes.get(i).getEastNorth());
+				Point p3 = mapView.getPoint(nodes.get(i + 1).getEastNorth());
+
+
+				Line2D.Double line1 = shiftLine(p1, p2, shift);
+				Line2D.Double line2 = shiftLine(p2, p3, shift);
+
+				Point2D.Double intersection = new Point2D.Double();
+				getLineLineIntersection(line1, line2, intersection);
+				if (!Double.isNaN(intersection.getX())  && !Double.isNaN(intersection.getY())) {
+					path.lineTo((float)intersection.getX(), (float)intersection.getY());
+				}
+			}
+			Point2D stop = shiftPoint(mapView.getPoint(nodes.get(nodes.size() - 1).getEastNorth()), 
+					mapView.getPoint(nodes.get(nodes.size() - 2).getEastNorth()), -shift);
+			path.lineTo((float)stop.getX(), (float)stop.getY());
+			g.draw(path);
+			
+			shift += width;
+		}
+	}
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/ObjectFactory.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/ObjectFactory.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/ObjectFactory.java	(revision 16428)
@@ -0,0 +1,63 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.09 at 08:14:28 odp. CEST 
+//
+
+
+package org.openstreetmap.josm.plugins.routes.xml;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+
+/**
+ * This object contains factory methods for each 
+ * Java content interface and Java element interface 
+ * generated in the org.openstreetmap.josm.plugins.routes.xml package. 
+ * <p>An ObjectFactory allows you to programatically 
+ * construct new instances of the Java representation 
+ * for XML content. The Java representation of XML 
+ * content can consist of schema derived interfaces 
+ * and classes representing the binding of schema 
+ * type definitions, element declarations and model 
+ * groups.  Factory methods for each of these are 
+ * provided in this class.
+ * 
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+
+    /**
+     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openstreetmap.josm.plugins.routes.xml
+     * 
+     */
+    public ObjectFactory() {
+    }
+
+    /**
+     * Create an instance of {@link RoutesXMLRoute }
+     * 
+     */
+    public RoutesXMLRoute createRoutesXMLRoute() {
+        return new RoutesXMLRoute();
+    }
+
+    /**
+     * Create an instance of {@link RoutesXMLLayer }
+     * 
+     */
+    public RoutesXMLLayer createRoutesXMLLayer() {
+        return new RoutesXMLLayer();
+    }
+
+    /**
+     * Create an instance of {@link Routes }
+     * 
+     */
+    public Routes createRoutes() {
+        return new Routes();
+    }
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/Routes.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/Routes.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/Routes.java	(revision 16428)
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.09 at 08:14:28 odp. CEST 
+//
+
+
+package org.openstreetmap.josm.plugins.routes.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType>
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="layer" type="{http://www.example.org/routes}layer" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+    "layer"
+})
+@XmlRootElement(name = "routes")
+public class Routes {
+
+    protected List<RoutesXMLLayer> layer;
+
+    /**
+     * Gets the value of the layer property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the layer property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getLayer().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link RoutesXMLLayer }
+     * 
+     * 
+     */
+    public List<RoutesXMLLayer> getLayer() {
+        if (layer == null) {
+            layer = new ArrayList<RoutesXMLLayer>();
+        }
+        return this.layer;
+    }
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/RoutesXMLLayer.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/RoutesXMLLayer.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/RoutesXMLLayer.java	(revision 16428)
@@ -0,0 +1,102 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.09 at 08:14:28 odp. CEST 
+//
+
+
+package org.openstreetmap.josm.plugins.routes.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for layer complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="layer">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="route" type="{http://www.example.org/routes}route" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "layer", propOrder = {
+    "route"
+})
+public class RoutesXMLLayer {
+
+    protected List<RoutesXMLRoute> route;
+    @XmlAttribute
+    protected String name;
+
+    /**
+     * Gets the value of the route property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the route property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getRoute().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link RoutesXMLRoute }
+     * 
+     * 
+     */
+    public List<RoutesXMLRoute> getRoute() {
+        if (route == null) {
+            route = new ArrayList<RoutesXMLRoute>();
+        }
+        return this.route;
+    }
+
+    /**
+     * Gets the value of the name property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the value of the name property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setName(String value) {
+        this.name = value;
+    }
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/RoutesXMLRoute.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/RoutesXMLRoute.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/RoutesXMLRoute.java	(revision 16428)
@@ -0,0 +1,97 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.09 at 08:14:28 odp. CEST 
+//
+
+
+package org.openstreetmap.josm.plugins.routes.xml;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for route complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="route">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="pattern" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="color" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "route", propOrder = {
+    "pattern"
+})
+public class RoutesXMLRoute {
+
+    @XmlElement(required = true)
+    protected String pattern;
+    @XmlAttribute
+    protected String color;
+
+    /**
+     * Gets the value of the pattern property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getPattern() {
+        return pattern;
+    }
+
+    /**
+     * Sets the value of the pattern property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setPattern(String value) {
+        this.pattern = value;
+    }
+
+    /**
+     * Gets the value of the color property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getColor() {
+        return color;
+    }
+
+    /**
+     * Sets the value of the color property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setColor(String value) {
+        this.color = value;
+    }
+
+}
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/package-info.java
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/package-info.java	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/package-info.java	(revision 16428)
@@ -0,0 +1,9 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2009.07.09 at 08:14:28 odp. CEST 
+//
+
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.org/routes", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.openstreetmap.josm.plugins.routes.xml;
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/routes.xml
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/routes.xml	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/routes.xml	(revision 16428)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<routes xmlns="http://www.example.org/routes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/routes routes.xsd ">
+<!-- pattern is the same pattern as used in SearchAction -->
+	<layer name="Czech hiking trails">
+		<route color="#FF0000">
+			<pattern>
+			((type:relation | type:way) kct_red=*) | (color=red type=route route=hiking network=cz:kct)
+			</pattern>
+		</route>
+		<route color="#FFFF00">
+			<pattern>
+			((type:relation | type:way) kct_yellow=*) | (color=yellow type=route route=hiking network=cz:kct)
+			</pattern>			
+		</route>
+		<route color="#0000FF">
+			<pattern>
+			((type:relation | type:way) kct_blue=*) | (color=blue type=route route=hiking network=cz:kct)
+			</pattern>
+		</route>
+		<route color="#00FF00">
+			<pattern>
+			((type:relation | type:way) kct_green=*) | (color=green type=route route=hiking network=cz:kct)
+			</pattern>		
+		</route>
+	</layer>
+	<layer name="Cycle routes">
+		<route color="#FF00FF">
+			<pattern>
+			(type:way (ncn=* | (lcn=* | rcn=* ))) | (type:relation type=route route=bicycle)
+			</pattern>
+		</route>
+	</layer>
+</routes>
Index: applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/routes.xsd
===================================================================
--- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/routes.xsd	(revision 16428)
+++ applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/xml/routes.xsd	(revision 16428)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema 
+xmlns="http://www.w3.org/2001/XMLSchema" 
+targetNamespace="http://www.example.org/routes" 
+xmlns:tns="http://www.example.org/routes" 
+elementFormDefault="qualified"
+xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
+jxb:version="1.0"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_1_0.xsd">
+
+<annotation>
+	<appinfo>
+		<jxb:schemaBindings>	
+			<jxb:nameXmlTransform>
+				<jxb:typeName prefix="RoutesXML"/>
+			</jxb:nameXmlTransform>
+		</jxb:schemaBindings>
+	</appinfo>
+</annotation>
+
+<element name="routes">
+	<complexType>
+		<sequence>
+			<element name="layer" type="tns:layer" minOccurs="0" maxOccurs="unbounded"/>
+		</sequence>
+	</complexType>
+</element>
+
+<complexType name="layer">
+	<sequence>
+		<element name="route" type="tns:route" minOccurs="0" maxOccurs="unbounded"/>
+	</sequence>
+	<attribute name="name" type="string"/>
+</complexType>
+
+<complexType name="route">
+	<sequence>
+		<element name="pattern" type="string"/>		
+	</sequence>
+	<attribute name="color" type="string"/>
+</complexType>
+
+</schema>
