Index: src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 314)
+++ src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 315)
@@ -4,6 +4,9 @@
 import java.awt.Color;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.Point;
+import java.awt.Polygon;
 import java.awt.Rectangle;
+import java.awt.geom.GeneralPath;
 import java.awt.geom.Line2D;
 
@@ -28,5 +31,5 @@
 	public final static Color darkblue = new Color(0,0,128);
 	public final static Color darkgreen = new Color(0,128,0);
-
+	
 	/**
 	 * The environment to paint to.
@@ -39,8 +42,37 @@
 	
 	public boolean inactive;
-
+	
 	protected static final double PHI = Math.toRadians(20);
 
+	/**
+	 * Preferences
+	 */
+	protected Color inactiveColor;
+	protected Color selectedColor;
+	protected Color nodeColor;
+	protected Color segmentColor;
+	protected Color dfltWayColor;
+	protected Color incompleteColor;
+	protected Color backgroundColor;
+	protected boolean showDirectionArrow;
+	protected boolean showOrderNumber;
+	
+	/**
+	 * Draw subsequent segments of same color as one Path
+	 */
+	protected Color currentColor = null;
+	protected GeneralPath currrentPath = new GeneralPath();
+	
 	public void visitAll(DataSet data) {
+		inactiveColor = getPreferencesColor("inactive", Color.DARK_GRAY);
+		selectedColor = getPreferencesColor("selected", Color.WHITE);
+		nodeColor = getPreferencesColor("node", Color.RED);
+		segmentColor = getPreferencesColor("segment", darkgreen);
+		dfltWayColor = getPreferencesColor("way", darkblue);
+		incompleteColor = getPreferencesColor("incomplete way", darkerblue);
+		backgroundColor = getPreferencesColor("background", Color.BLACK);
+		showDirectionArrow = Main.pref.getBoolean("draw.segment.direction");
+		showOrderNumber = Main.pref.getBoolean("draw.segment.order_number");
+		
 		for (final OsmPrimitive osm : data.segments)
 			if (!osm.deleted && !osm.selected)
@@ -49,4 +81,5 @@
 			if (!osm.deleted && !osm.selected)
 				osm.visit(this);
+		displaySegments(null);	// Flush segment cache before nodes
 		for (final OsmPrimitive osm : data.nodes)
 			if (!osm.deleted && !osm.selected)
@@ -55,4 +88,5 @@
 			if (!osm.deleted)
 				osm.visit(this);
+		displaySegments(null);
 	}
 
@@ -66,9 +100,9 @@
 		Color color = null;
 		if (inactive)
-			color = getPreferencesColor("inactive", Color.DARK_GRAY);
+			color = inactiveColor;
 		else if (n.selected)
-			color = getPreferencesColor("selected", Color.WHITE);
+			color = selectedColor;
 		else
-			color = getPreferencesColor("node", Color.RED);
+			color = nodeColor;
 		drawNode(n, color);
 	}
@@ -81,10 +115,10 @@
 		Color color;
 		if (inactive)
-			color = getPreferencesColor("inactive", Color.DARK_GRAY);
+			color = inactiveColor;
 		else if (ls.selected)
-			color = getPreferencesColor("selected", Color.WHITE);
+			color = selectedColor;
 		else
-			color = getPreferencesColor("segment", darkgreen);
-		drawSegment(ls, color, Main.pref.getBoolean("draw.segment.direction"));
+			color = segmentColor;
+		drawSegment(ls, color, showDirectionArrow);
 	}
 
@@ -96,10 +130,10 @@
 		Color wayColor;
 		if (inactive)
-			wayColor = getPreferencesColor("inactive", Color.DARK_GRAY);
+			wayColor = inactiveColor;
 		else {
-			wayColor = getPreferencesColor("way", darkblue);
+			wayColor = dfltWayColor;
 			for (Segment ls : w.segments) {
 				if (ls.incomplete) {
-					wayColor = getPreferencesColor("incomplete way", darkerblue);
+					wayColor = incompleteColor;
 					break;
 				}
@@ -107,11 +141,9 @@
 		}
 
-		boolean showDirectionArrow = Main.pref.getBoolean("draw.segment.direction");
-		boolean showOrderNumber = Main.pref.getBoolean("draw.segment.order_number");
 		int orderNumber = 0;
 		for (Segment ls : w.segments) {
 			orderNumber++;
 			if (!ls.selected) // selected already in good color
-				drawSegment(ls, w.selected && !inactive ? getPreferencesColor("selected", Color.WHITE) : wayColor, showDirectionArrow);
+				drawSegment(ls, w.selected && !inactive ? selectedColor : wayColor, showDirectionArrow);
 			if (!ls.incomplete && showOrderNumber)
 				drawOrderNumber(ls, orderNumber);
@@ -132,5 +164,5 @@
 		if (screen.contains(x,y)) {
 			Color c = g.getColor();
-			g.setColor(getPreferencesColor("background", Color.BLACK));
+			g.setColor(backgroundColor);
 			g.fillRect(x-1, y-12, 8*strlen+1, 14);
 			g.setColor(c);
@@ -160,19 +192,32 @@
 		if (ls.incomplete)
 			return;
-		g.setColor(col);
+		if (col != currentColor) {
+			displaySegments(col);
+		}
+		
 		Point p1 = nc.getPoint(ls.from.eastNorth);
 		Point p2 = nc.getPoint(ls.to.eastNorth);
 		
-		Rectangle screen = g.getClipBounds();
+		Rectangle screen = g.getClipBounds();		
 		Line2D line = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);
 		if (screen.contains(p1.x, p1.y, p2.x, p2.y) || screen.intersectsLine(line))
 		{
-			g.drawLine(p1.x, p1.y, p2.x, p2.y);
+			currrentPath.moveTo(p1.x, p1.y);
+			currrentPath.lineTo(p2.x, p2.y);
 	
 			if (showDirection) {
 				double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI;
-		        g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
-		        g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
-			}
+				currrentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
+				currrentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
+				currrentPath.lineTo(p2.x, p2.y);			}
+		}
+	}
+	
+	protected void displaySegments(Color newColor) {
+		if (currrentPath != null) {
+			g.setColor(currentColor);
+			((Graphics2D) g).draw(currrentPath);
+			currrentPath = new GeneralPath();
+			currentColor = newColor;
 		}
 	}
