Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 2662)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 2663)
@@ -15,5 +15,4 @@
 import java.awt.Polygon;
 import java.awt.Rectangle;
-import java.awt.Stroke;
 import java.awt.geom.GeneralPath;
 import java.awt.geom.Point2D;
@@ -65,8 +64,4 @@
     protected Color textColor;
     protected Color areaTextColor;
-    protected float[] currentDashed = new float[0];
-    protected Color currentDashedColor;
-    protected int currentWidth = 0;
-    protected Stroke currentStroke = null;
     protected Font orderFont;
     protected ElemStyles.StyleSet styles;
@@ -294,12 +289,6 @@
             for(LineElemStyle s : l.overlays) {
                 if(!s.over) {
-                    lastN = null;
-                    for(Node n : w.getNodes()) {
-                        if(lastN != null) {
-                            drawSeg(lastN, n, s.color != null  && !data.isSelected(w) ? s.color : color,
-                                    false, s.getWidth(width), s.getDashed(), s.dashedColor);
-                        }
-                        lastN = n;
-                    }
+                    drawWay(w, s.color != null && !data.isSelected(w) ? s.color : color, s.getWidth(width),
+                            s.getDashed(), s.dashedColor, false, false);
                 }
             }
@@ -307,33 +296,12 @@
 
         /* draw the way */
-        lastN = null;
-        Iterator<Node> it = w.getNodes().iterator();
-        while (it.hasNext())
-        {
-            Node n = it.next();
-            if(lastN != null) {
-                drawSeg(lastN, n, color,
-                        showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor);
-            }
-            lastN = n;
-        }
+        drawWay(w, color, width, dashed, dashedColor, showDirection, showOnlyHeadArrowOnly);
 
         /* draw overlays above the way */
-        if(l != null && l.overlays != null)
-        {
-            for(LineElemStyle s : l.overlays)
-            {
-                if(s.over)
-                {
-                    lastN = null;
-                    for(Node n : w.getNodes())
-                    {
-                        if(lastN != null)
-                        {
-                            drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color,
-                                    false, s.getWidth(width), s.getDashed(), s.dashedColor);
-                        }
-                        lastN = n;
-                    }
+        if(l != null && l.overlays != null)  {
+            for(LineElemStyle s : l.overlays) {
+                if(s.over) {
+                    drawWay(w, s.color != null && !data.isSelected(w) ? s.color : color, s.getWidth(width),
+                            s.getDashed(), s.dashedColor, false, false);
                 }
             }
@@ -354,5 +322,53 @@
             }
         }
-        displaySegments();
+    }
+
+    public void drawWay(Way way, Color color, int width, float dashed[], Color dashedColor, boolean showDirection,
+            boolean showHeadArrowOnly) {
+
+        GeneralPath path = new GeneralPath();
+
+        Node lastN = null;
+        Iterator<Node> it = way.getNodes().iterator();
+        while (it.hasNext()) {
+            Node n = it.next();
+            if(lastN != null) {
+                drawSegment(path, nc.getPoint(lastN), nc.getPoint(n), (showHeadArrowOnly ? !it.hasNext() : showDirection));
+            }
+            lastN = n;
+        }
+        displaySegments(path, color, width, dashed, dashedColor);
+    }
+
+    private void displaySegments(GeneralPath path, Color color, int width, float dashed[], Color dashedColor) {
+        if (path != null) {
+            g.setColor(color);
+            if (useStrokes > dist) {
+                if (dashed.length > 0) {
+                    g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0, dashed,0));
+                } else {
+                    g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
+                }
+            }
+            g.draw(path);
+
+            if(useStrokes > dist && dashedColor != null) {
+                g.setColor(dashedColor);
+                if (dashed.length > 0) {
+                    float[] dashedOffset = new float[dashed.length];
+                    System.arraycopy(dashed, 1, dashedOffset, 0, dashed.length - 1);
+                    dashedOffset[dashed.length-1] = dashed[0];
+                    float offset = dashedOffset[0];
+                    g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashedOffset,offset));
+                } else {
+                    g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
+                }
+                g.draw(path);
+            }
+
+            if(useStrokes > dist) {
+                g.setStroke(new BasicStroke());
+            }
+        }
     }
 
@@ -1184,69 +1200,4 @@
     }
 
-    private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, float dashed[], Color dashedColor) {
-        if (col != currentColor || width != currentWidth || !Arrays.equals(dashed,currentDashed) || dashedColor != currentDashedColor) {
-            displaySegments(col, width, dashed, dashedColor);
-        }
-        Point p1 = nc.getPoint(n1);
-        Point p2 = nc.getPoint(n2);
-
-        if (!isSegmentVisible(p1, p2))
-            return;
-        currentPath.moveTo(p1.x, p1.y);
-        currentPath.lineTo(p2.x, p2.y);
-
-        if (showDirection) {
-            double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI;
-            currentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
-            currentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
-            currentPath.lineTo(p2.x, p2.y);
-        }
-    }
-
-    @Override
-    protected void displaySegments() {
-        displaySegments(null, 0, new float[0], null);
-    }
-
-    protected void displaySegments(Color newColor, int newWidth, float newDash[], Color newDashedColor) {
-        if (currentPath != null) {
-            g.setColor(inactive ? inactiveColor : currentColor);
-            if (currentStroke == null && useStrokes > dist) {
-                if (currentDashed.length > 0) {
-                    g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashed,0));
-                } else {
-                    g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
-                }
-            }
-            g.draw(currentPath);
-
-            if(currentDashedColor != null) {
-                g.setColor(currentDashedColor);
-                if (currentStroke == null && useStrokes > dist) {
-                    if (currentDashed.length > 0) {
-                        float[] currentDashedOffset = new float[currentDashed.length];
-                        System.arraycopy(currentDashed, 1, currentDashedOffset, 0, currentDashed.length - 1);
-                        currentDashedOffset[currentDashed.length-1] = currentDashed[0];
-                        float offset = currentDashedOffset[0];
-                        g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashedOffset,offset));
-                    } else {
-                        g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
-                    }
-                }
-                g.draw(currentPath);
-            }
-
-            if(useStrokes > dist) {
-                g.setStroke(new BasicStroke(1));
-            }
-
-            currentPath = new GeneralPath();
-            currentColor = newColor;
-            currentWidth = newWidth;
-            currentDashed = newDash;
-            currentDashedColor = newDashedColor;
-            currentStroke = null;
-        }
-    }
 
     /**
@@ -1402,6 +1353,5 @@
         /*** SELECTED  ***/
         for (final OsmPrimitive osm : data.getSelected()) {
-            if (osm.isUsable() && !(osm instanceof Node) && osm.mappaintDrawnCode != paintid
-            ) {
+            if (osm.isUsable() && !(osm instanceof Node) && osm.mappaintDrawnCode != paintid) {
                 osm.visit(new AbstractVisitor() {
                     public void visit(Way w) {
@@ -1410,9 +1360,11 @@
 
                     public void visit(Node n) {
-                        drawNode(n);
+                        // Selected nodes are painted in following part
                     }
 
                     public void visit(Relation r) {
                         /* TODO: is it possible to do this like the nodes/ways code? */
+                        // Only nodes are painted, ways was already painted before (this might cause that
+                        // way in selected relation is hidden by another way)
                         for (RelationMember m : r.getMembers()) {
                             if (m.isNode() && m.getMember().isDrawable()) {
@@ -1425,28 +1377,13 @@
         }
 
-        /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/
-        displaySegments();
-
         /*** NODES ***/
         for (final Node osm: data.searchNodes(bbox)) {
             if (!osm.isIncomplete() && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered())
-                    && osm.mappaintDrawnCode != paintid)
-            {
+                    && osm.mappaintDrawnCode != paintid) {
                 drawNode(osm);
             }
         }
 
-        /*** VIRTUAL  ***/
-        if (virtualNodeSize != 0) {
-            currentColor = nodeColor;
-            for (final OsmPrimitive osm: data.searchWays(bbox)) {
-                if (osm.isUsable() && !osm.isFiltered())
-                {
-                    /* TODO: move this into the SimplePaint code? */
-                    visitVirtual((Way)osm);
-                }
-            }
-            displaySegments(null);
-        }
+        drawVirtualNodes(data.searchWays(bbox));
     }
 
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 2662)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 2663)
@@ -15,4 +15,5 @@
 import java.awt.Stroke;
 import java.awt.geom.GeneralPath;
+import java.util.Collection;
 import java.util.Iterator;
 
@@ -215,21 +216,5 @@
         //}
 
-        if (virtualNodeSize != 0) {
-            //    profilerN = 0;
-            currentColor = nodeColor;
-            for (final OsmPrimitive osm:data.getWays()){
-                if (!osm.isDeleted() && !osm.isDisabled() && !osm.isFiltered()) {
-                    visitVirtual((Way) osm);
-                    //                profilerN++;
-                }
-            }
-            displaySegments();
-
-            //    if(profiler)
-            //    {
-            //        System.out.format("Virtual  : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
-            //        profilerLast = java.lang.System.currentTimeMillis();
-            //    }
-        }
+        drawVirtualNodes(data.getWays());
 
         //if(profiler)
@@ -272,5 +257,19 @@
     }
 
-    public void visitVirtual(Way w) {
+    public void drawVirtualNodes(Collection<Way> ways) {
+
+        if (virtualNodeSize != 0) {
+            GeneralPath path = new GeneralPath();
+            for (Way osm: ways){
+                if (osm.isUsable() && !osm.isFiltered()) {
+                    visitVirtual(path, osm);
+                }
+            }
+            g.setColor(nodeColor);
+            g.draw(path);
+        }
+    }
+
+    public void visitVirtual(GeneralPath path, Way w) {
         Iterator<Node> it = w.getNodes().iterator();
         if (it.hasNext()) {
@@ -283,8 +282,8 @@
                     int x = (p.x+lastP.x)/2;
                     int y = (p.y+lastP.y)/2;
-                    currentPath.moveTo(x-virtualNodeSize, y);
-                    currentPath.lineTo(x+virtualNodeSize, y);
-                    currentPath.moveTo(x, y-virtualNodeSize);
-                    currentPath.lineTo(x, y+virtualNodeSize);
+                    path.moveTo(x-virtualNodeSize, y);
+                    path.lineTo(x+virtualNodeSize, y);
+                    path.moveTo(x, y-virtualNodeSize);
+                    path.lineTo(x, y+virtualNodeSize);
                 }
                 lastP = p;
@@ -435,4 +434,18 @@
     }
 
+    protected void drawSegment(GeneralPath path, Point p1, Point p2, boolean showDirection) {
+        if (isSegmentVisible(p1, p2)) {
+            path.moveTo(p1.x, p1.y);
+            path.lineTo(p2.x, p2.y);
+
+            if (showDirection) {
+                double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI;
+                path.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
+                path.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
+                path.lineTo(p2.x, p2.y);
+            }
+        }
+    }
+
     /**
      * Draw a line with the given color.
@@ -442,16 +455,5 @@
             displaySegments(col);
         }
-
-        if (isSegmentVisible(p1, p2)) {
-            currentPath.moveTo(p1.x, p1.y);
-            currentPath.lineTo(p2.x, p2.y);
-
-            if (showDirection) {
-                double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI;
-                currentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));
-                currentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));
-                currentPath.lineTo(p2.x, p2.y);
-            }
-        }
+        drawSegment(currentPath, p1, p2, showDirection);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java	(revision 2662)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java	(revision 2663)
@@ -6,7 +6,7 @@
 package org.openstreetmap.josm.gui.layer.geoimage;
 
+import java.awt.Image;
 import java.io.File;
 import java.util.Date;
-import java.awt.Image;
 
 import org.openstreetmap.josm.data.coor.CachedLatLon;
@@ -29,23 +29,20 @@
 
     Image thumbnail;
-    
+
     ImageEntry tmp;
 
     public CachedLatLon getPos() {
-        if (tmp != null) {
+        if (tmp != null)
             return tmp.pos;
-        }
         return pos;
     }
     public Double getSpeed() {
-        if (tmp != null) {
+        if (tmp != null)
             return tmp.speed;
-        }
         return speed;
     }
     public Double getElevation() {
-        if (tmp != null) {
+        if (tmp != null)
             return tmp.elevation;
-        }
         return elevation;
     }
@@ -56,5 +53,5 @@
         this.speed = speed;
     }
-    public void setElevation(Double speed) {
+    public void setElevation(Double elevation) {
         this.elevation = elevation;
     }
@@ -70,5 +67,5 @@
         return (ImageEntry) c;
     }
-    
+
     public void setCoor(LatLon latlon)
     {
@@ -86,5 +83,5 @@
             return 1;
     }
-    
+
     public void applyTmp() {
         if (tmp != null) {
@@ -100,18 +97,19 @@
         tmp.tmp = null;
     }
-    
+
     public boolean isTagged() {
         return pos != null;
     }
-    
+
     /**
      * only partial info
      */
+    @Override
     public String toString() {
         String result = file.getName()+": "+
-            "pos = "+pos+" | "+
-            "exifCoor = "+exifCoor+" | "+
-            (tmp == null ? " tmp==null" :
-                " [tmp] pos = "+tmp.pos+"");
+        "pos = "+pos+" | "+
+        "exifCoor = "+exifCoor+" | "+
+        (tmp == null ? " tmp==null" :
+            " [tmp] pos = "+tmp.pos+"");
         return result;
     }
