Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 2658)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java	(revision 2659)
@@ -11,5 +11,4 @@
 import java.awt.Font;
 import java.awt.FontMetrics;
-import java.awt.Graphics2D;
 import java.awt.Image;
 import java.awt.Point;
@@ -92,13 +91,13 @@
     public ElemStyle getPrimitiveStyle(OsmPrimitive osm) {
         if(!useStyleCache)
-            return (styles != null) ? styles.get(osm) : null;
-
-            if(osm.mappaintStyle == null && styles != null) {
-                osm.mappaintStyle = styles.get(osm);
-                if(osm instanceof Way) {
-                    ((Way)osm).isMappaintArea = styles.isArea(osm);
-                }
-            }
-            return osm.mappaintStyle;
+            return ((styles != null) ? styles.get(osm) : null);
+
+        if(osm.mappaintStyle == null && styles != null) {
+            osm.mappaintStyle = styles.get(osm);
+            if(osm instanceof Way) {
+                ((Way)osm).isMappaintArea = styles.isArea(osm);
+            }
+        }
+        return osm.mappaintStyle;
     }
 
@@ -255,5 +254,5 @@
             width = l.width;
             realWidth = l.realWidth;
-            dashed = l.dashed;
+            dashed = l.getDashed();
             dashedColor = l.dashedColor;
         }
@@ -292,17 +291,12 @@
 
         /* draw overlays under the way */
-        if(l != null && l.overlays != null)
-        {
-            for(LineElemStyle s : l.overlays)
-            {
-                if(!s.over)
-                {
+        if(l != null && l.overlays != null) {
+            for(LineElemStyle s : l.overlays) {
+                if(!s.over) {
                     lastN = null;
-                    for(Node n : w.getNodes())
-                    {
-                        if(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.dashed, s.dashedColor);
+                                    false, s.getWidth(width), s.getDashed(), s.dashedColor);
                         }
                         lastN = n;
@@ -338,5 +332,5 @@
                         {
                             drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color,
-                                    false, s.getWidth(width), s.dashed, s.dashedColor);
+                                    false, s.getWidth(width), s.getDashed(), s.dashedColor);
                         }
                         lastN = n;
@@ -1156,9 +1150,7 @@
         int w = icon.getIconWidth(), h=icon.getIconHeight();
         icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 );
-        if(showNames > dist)
-        {
+        if(showNames > dist && annotate) {
             String name = getNodeName(n);
-            if (name!=null && annotate)
-            {
+            if (name!=null) {
                 if (inactive || n.isDisabled()) {
                     g.setColor(inactiveColor);
@@ -1219,21 +1211,16 @@
     protected void displaySegments(Color newColor, int newWidth, float newDash[], Color newDashedColor) {
         if (currentPath != null) {
-            Graphics2D g2d = (Graphics2D)g;
-            g2d.setColor(inactive ? inactiveColor : currentColor);
+            g.setColor(inactive ? inactiveColor : currentColor);
             if (currentStroke == null && useStrokes > dist) {
                 if (currentDashed.length > 0) {
-                    try {
-                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashed,0));
-                    } catch (IllegalArgumentException e) {
-                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
-                    }
+                    g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashed,0));
                 } else {
-                    g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
-                }
-            }
-            g2d.draw(currentPath);
+                    g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
+                }
+            }
+            g.draw(currentPath);
 
             if(currentDashedColor != null) {
-                g2d.setColor(currentDashedColor);
+                g.setColor(currentDashedColor);
                 if (currentStroke == null && useStrokes > dist) {
                     if (currentDashed.length > 0) {
@@ -1242,18 +1229,14 @@
                         currentDashedOffset[currentDashed.length-1] = currentDashed[0];
                         float offset = currentDashedOffset[0];
-                        try {
-                            g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashedOffset,offset));
-                        } catch (IllegalArgumentException e) {
-                            g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
-                        }
+                        g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashedOffset,offset));
                     } else {
-                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
-                    }
-                }
-                g2d.draw(currentPath);
+                        g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
+                    }
+                }
+                g.draw(currentPath);
             }
 
             if(useStrokes > dist) {
-                g2d.setStroke(new BasicStroke(1));
+                g.setStroke(new BasicStroke(1));
             }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 2658)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java	(revision 2659)
@@ -8,5 +8,4 @@
 import java.awt.BasicStroke;
 import java.awt.Color;
-import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.Point;
@@ -45,5 +44,5 @@
      * The environment to paint to.
      */
-    protected Graphics g;
+    protected Graphics2D g;
     /**
      * MapView to get screen coordinates.
@@ -90,6 +89,4 @@
     protected GeneralPath currentPath = new GeneralPath();
 
-    Rectangle bbox = new Rectangle();
-
     public void getColors()
     {
@@ -124,5 +121,5 @@
         getColors();
 
-        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                 Main.pref.getBoolean("mappaint.use-antialiasing", false) ?
                         RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
@@ -386,5 +383,5 @@
                 }
 
-                ((Graphics2D) g).draw(relatedWayStroke.createStrokedShape(path));
+                g.draw(relatedWayStroke.createStrokedShape(path));
             }
         }
@@ -477,5 +474,5 @@
     }
 
-    public void setGraphics(Graphics g) {
+    public void setGraphics(Graphics2D g) {
         this.g = g;
     }
@@ -491,5 +488,5 @@
         if (currentPath != null) {
             g.setColor(currentColor);
-            ((Graphics2D) g).draw(currentPath);
+            g.draw(currentPath);
             currentPath = new GeneralPath();
             currentColor = newColor;
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java	(revision 2658)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java	(revision 2659)
@@ -14,5 +14,5 @@
 public class ElemStyleHandler extends DefaultHandler
 {
-    boolean inDoc, inRule, inCondition, inElemStyle, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin;
+    boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin;
     boolean hadLine, hadLineMod, hadIcon, hadArea;
     ElemStyles styles;
@@ -44,5 +44,5 @@
     public ElemStyleHandler(String name) {
         styleName = name;
-        inDoc=inRule=inCondition=inElemStyle=inLine=inIcon=inArea=false;
+        inDoc=inRule=inCondition=inLine=inIcon=inArea=false;
         rule.init();
         styles = MapPaintStyles.getStyles();
@@ -105,17 +105,20 @@
                 line.realWidth=Integer.parseInt(atts.getValue(count));
             } else if (atts.getQName(count).equals("dashed")) {
-                try
-                {
+                float[] dashed;
+                try {
                     String[] parts = atts.getValue(count).split(",");
-                    line.dashed = new float[parts.length];
+                    dashed = new float[parts.length];
                     for (int i = 0; i < parts.length; i++) {
-                        line.dashed[i] = (Integer.parseInt(parts[i]));
+                        dashed[i] = (Integer.parseInt(parts[i]));
                     }
                 } catch (NumberFormatException nfe) {
-                    boolean dashed=Boolean.parseBoolean(atts.getValue(count));
-                    if(dashed) {
-                        line.dashed = new float[]{9};
-                    }
-                }
+                    boolean isDashed = Boolean.parseBoolean(atts.getValue(count));
+                    if(isDashed) {
+                        dashed = new float[]{9};
+                    } else {
+                        dashed = new float[0];
+                    }
+                }
+                line.setDashed(dashed);
             } else if (atts.getQName(count).equals("dashedcolour")) {
                 line.dashedColor=convertColor(atts.getValue(count));
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java	(revision 2658)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java	(revision 2659)
@@ -3,4 +3,6 @@
 import java.awt.Color;
 import java.util.Collection;
+
+import org.openstreetmap.josm.tools.I18n;
 
 public class LineElemStyle extends ElemStyle implements Comparable<LineElemStyle>
@@ -9,5 +11,5 @@
     public int realWidth; //the real width of this line in meter
     public Color color;
-    public float[] dashed;
+    private float[] dashed;
     public Color dashedColor;
 
@@ -49,6 +51,7 @@
         this.overlays = overlays;
         this.code = s.code;
-        for (LineElemStyle o : overlays)
+        for (LineElemStyle o : overlays) {
             this.code += o.code;
+        }
     }
 
@@ -72,26 +75,52 @@
     {
         int res;
-        if(widthMode == WidthMode.ABSOLUTE)
+        if(widthMode == WidthMode.ABSOLUTE) {
             res = width;
-        else if(widthMode == WidthMode.OFFSET)
+        } else if(widthMode == WidthMode.OFFSET) {
             res = ref + width;
-        else
+        } else
         {
-            if(width < 0)
+            if(width < 0) {
                 res = 0;
-            else
+            } else {
                 res = ref*width/100;
+            }
         }
         return res <= 0 ? 1 : res;
     }
 
-    public int compareTo(LineElemStyle s)
-    {
+    public int compareTo(LineElemStyle s) {
         if(s.priority != priority)
             return s.priority > priority ? 1 : -1;
-        if(!over && s.over)
-            return -1;
-        // we have no idea how to order other objects :-)
-        return 0;
+            if(!over && s.over)
+                return -1;
+            // we have no idea how to order other objects :-)
+            return 0;
+    }
+
+    public float[] getDashed() {
+        return dashed;
+    }
+
+    public void setDashed(float[] dashed) {
+        if (dashed.length == 0) {
+            this.dashed = dashed;
+            return;
+        }
+
+        boolean found = false;
+        for (int i=0; i<dashed.length; i++) {
+            if (dashed[i] > 0) {
+                found = true;
+            }
+            if (dashed[i] < 0) {
+                System.out.println(I18n.tr("Illegal dash pattern, values must be positive"));
+            }
+        }
+        if (found) {
+            this.dashed = dashed;
+        } else {
+            System.out.println(I18n.tr("Illegal dash pattern, at least one value must be > 0"));
+        }
     }
 }
