Index: /trunk/src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MapView.java	(revision 3127)
+++ /trunk/src/org/openstreetmap/josm/gui/MapView.java	(revision 3128)
@@ -39,4 +39,6 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.SelectionChangedListener;
+import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
+import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -65,5 +67,5 @@
  * @author imi
  */
-public class MapView extends NavigatableComponent implements PropertyChangeListener {
+public class MapView extends NavigatableComponent implements PropertyChangeListener, PreferenceChangedListener {
 
     /**
@@ -183,6 +185,8 @@
     private final List<Layer> nonChangedLayers = new ArrayList<Layer>();
     private int lastViewID;
+    private boolean paintPreferencesChanged = true;
 
     public MapView() {
+        Main.pref.addPreferenceChangeListener(this);
         addComponentListener(new ComponentAdapter(){
             @Override public void componentResized(ComponentEvent e) {
@@ -472,5 +476,5 @@
         }
 
-        boolean canUseBuffer = nonChangedLayers.size() <= nonChangedLayersCount && lastViewID == getViewID();
+        boolean canUseBuffer = !paintPreferencesChanged && nonChangedLayers.size() <= nonChangedLayersCount && lastViewID == getViewID();
         if (canUseBuffer) {
             for (int i=0; i<nonChangedLayers.size(); i++) {
@@ -513,4 +517,5 @@
         }
         lastViewID = getViewID();
+        paintPreferencesChanged = false;
 
         tempG.drawImage(offscreenBuffer, 0, 0, null);
@@ -799,3 +804,7 @@
     }
 
+    public void preferenceChanged(PreferenceChangeEvent e) {
+        paintPreferencesChanged = true;
+    }
+
 }
Index: /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 3127)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 3128)
@@ -87,5 +87,4 @@
     private final List<GpxTrack> lastTracks = new ArrayList<GpxTrack>(); // List of tracks at last paint
     private int lastUpdateCount;
-    private PaintSettings lastPaintSettings;
 
     private static class Markers {
@@ -464,5 +463,5 @@
     @Override
     public boolean isChanged() {
-        if (data.tracks.equals(lastTracks) && new PaintSettings(isLocalFile).equals(lastPaintSettings))
+        if (data.tracks.equals(lastTracks))
             return sumUpdateCount() != lastUpdateCount;
         else
@@ -497,126 +496,4 @@
     }
 
-    private class PaintSettings {
-        final Color neutralColor;
-        final boolean forceLines;
-        final boolean direction;
-        final int lineWidth;
-        final int maxLineLength;
-        final boolean lines;
-        final boolean large;
-        final boolean hdopcircle;
-        final colorModes colored;
-        final boolean alternatedirection;
-        final int delta;
-        final int colorTracksTune;
-
-        public PaintSettings(boolean isLocalFile) {
-            neutralColor = getColor(getName());
-            // also draw lines between points belonging to different segments
-            forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");
-            // draw direction arrows on the lines
-            direction = Main.pref.getBoolean("draw.rawgps.direction");
-            // don't draw lines if longer than x meters
-            lineWidth = Main.pref.getInteger("draw.rawgps.linewidth",0);
-
-            if (isLocalFile) {
-                maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length.local", -1);
-            } else {
-                maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", 200);
-            }
-
-            // draw line between points, global setting
-            boolean lines = (Main.pref.getBoolean("draw.rawgps.lines", true) || (Main.pref
-                    .getBoolean("draw.rawgps.lines.localfiles") && isLocalFile));
-            String linesKey = "draw.rawgps.lines.layer " + getName();
-            // draw lines, per-layer setting
-            if (Main.pref.hasKey(linesKey)) {
-                lines = Main.pref.getBoolean(linesKey);
-            }
-            this.lines = lines;
-
-            // paint large dots for points
-            large = Main.pref.getBoolean("draw.rawgps.large");
-            hdopcircle = Main.pref.getBoolean("draw.rawgps.hdopcircle", true);
-            // color the lines
-            int colorIndex = Main.pref.getInteger("draw.rawgps.colors", 0);
-            colored = colorIndex >= 0 && colorIndex < colorModes.values().length?colorModes.values()[colorIndex]:colorModes.none;
-            // paint direction arrow with alternate math. may be faster
-            alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection");
-            // don't draw arrows nearer to each other than this
-            delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0);
-            // allows to tweak line coloring for different speed levels.
-            colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45);
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + getOuterType().hashCode();
-            result = prime * result + (alternatedirection ? 1231 : 1237);
-            result = prime * result + colorTracksTune;
-            result = prime * result + ((colored == null) ? 0 : colored.hashCode());
-            result = prime * result + delta;
-            result = prime * result + (direction ? 1231 : 1237);
-            result = prime * result + (forceLines ? 1231 : 1237);
-            result = prime * result + (hdopcircle ? 1231 : 1237);
-            result = prime * result + (large ? 1231 : 1237);
-            result = prime * result + lineWidth;
-            result = prime * result + (lines ? 1231 : 1237);
-            result = prime * result + maxLineLength;
-            result = prime * result + ((neutralColor == null) ? 0 : neutralColor.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj)
-                return true;
-            if (obj == null)
-                return false;
-            if (getClass() != obj.getClass())
-                return false;
-            PaintSettings other = (PaintSettings) obj;
-            if (!getOuterType().equals(other.getOuterType()))
-                return false;
-            if (alternatedirection != other.alternatedirection)
-                return false;
-            if (colorTracksTune != other.colorTracksTune)
-                return false;
-            if (colored == null) {
-                if (other.colored != null)
-                    return false;
-            } else if (!colored.equals(other.colored))
-                return false;
-            if (delta != other.delta)
-                return false;
-            if (direction != other.direction)
-                return false;
-            if (forceLines != other.forceLines)
-                return false;
-            if (hdopcircle != other.hdopcircle)
-                return false;
-            if (large != other.large)
-                return false;
-            if (lineWidth != other.lineWidth)
-                return false;
-            if (lines != other.lines)
-                return false;
-            if (maxLineLength != other.maxLineLength)
-                return false;
-            if (neutralColor == null) {
-                if (other.neutralColor != null)
-                    return false;
-            } else if (!neutralColor.equals(other.neutralColor))
-                return false;
-            return true;
-        }
-
-        private GpxLayer getOuterType() {
-            return GpxLayer.this;
-        }
-    }
-
     @Override
     public void paint(Graphics2D g, MapView mv, Bounds box) {
@@ -624,15 +501,50 @@
         lastTracks.clear();
         lastTracks.addAll(data.tracks);
-        lastPaintSettings = new PaintSettings(isLocalFile);
-
 
         /****************************************************************
          ********** STEP 1 - GET CONFIG VALUES **************************
          ****************************************************************/
-        PaintSettings ps =lastPaintSettings;
-
-        if(ps.lineWidth != 0)
+        // Long startTime = System.currentTimeMillis();
+        Color neutralColor = getColor(getName());
+        // also draw lines between points belonging to different segments
+        boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");
+        // draw direction arrows on the lines
+        boolean direction = Main.pref.getBoolean("draw.rawgps.direction");
+        // don't draw lines if longer than x meters
+        int lineWidth = Main.pref.getInteger("draw.rawgps.linewidth",0);
+
+        int maxLineLength;
+        if (this.isLocalFile) {
+            maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length.local", -1);
+        } else {
+            maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", 200);
+        }
+        // draw line between points, global setting
+        boolean lines = (Main.pref.getBoolean("draw.rawgps.lines", true) || (Main.pref
+                .getBoolean("draw.rawgps.lines.localfiles") && this.isLocalFile));
+        String linesKey = "draw.rawgps.lines.layer " + getName();
+        // draw lines, per-layer setting
+        if (Main.pref.hasKey(linesKey)) {
+            lines = Main.pref.getBoolean(linesKey);
+        }
+        // paint large dots for points
+        boolean large = Main.pref.getBoolean("draw.rawgps.large");
+        boolean hdopcircle = Main.pref.getBoolean("draw.rawgps.hdopcircle", true);
+        // color the lines
+        colorModes colored = colorModes.none;
+        try {
+            colored = colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", 0)];
+        } catch (Exception e) {
+        }
+        // paint direction arrow with alternate math. may be faster
+        boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection");
+        // don't draw arrows nearer to each other than this
+        int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0);
+        // allows to tweak line coloring for different speed levels.
+        int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45);
+
+        if(lineWidth != 0)
         {
-            g.setStroke(new BasicStroke(ps.lineWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
+            g.setStroke(new BasicStroke(lineWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
         }
 
@@ -640,15 +552,15 @@
          ********** STEP 2a - CHECK CACHE VALIDITY **********************
          ****************************************************************/
-        if ((computeCacheMaxLineLengthUsed != ps.maxLineLength) || (!ps.neutralColor.equals(computeCacheColorUsed))
-                || (computeCacheColored != ps.colored) || (computeCacheColorTracksTune != ps.colorTracksTune)) {
+        if ((computeCacheMaxLineLengthUsed != maxLineLength) || (!neutralColor.equals(computeCacheColorUsed))
+                || (computeCacheColored != colored) || (computeCacheColorTracksTune != colorTracksTune)) {
             // System.out.println("(re-)computing gpx line styles, reason: CCIS=" +
             // computeCacheInSync + " CCMLLU=" + (computeCacheMaxLineLengthUsed != maxLineLength) +
             // " CCCU=" + (!neutralColor.equals(computeCacheColorUsed)) + " CCC=" +
             // (computeCacheColored != colored));
-            computeCacheMaxLineLengthUsed = ps.maxLineLength;
+            computeCacheMaxLineLengthUsed = maxLineLength;
             computeCacheInSync = false;
-            computeCacheColorUsed = ps.neutralColor;
-            computeCacheColored = ps.colored;
-            computeCacheColorTracksTune = ps.colorTracksTune;
+            computeCacheColorUsed = neutralColor;
+            computeCacheColored = colored;
+            computeCacheColorTracksTune = colorTracksTune;
         }
 
@@ -660,5 +572,5 @@
             for (GpxTrack trk : data.tracks) {
                 for (GpxTrackSegment segment : trk.getSegments()) {
-                    if (!ps.forceLines) { // don't draw lines between segments, unless forced to
+                    if (!forceLines) { // don't draw lines between segments, unless forced to
                         oldWp = null;
                     }
@@ -668,13 +580,13 @@
                             continue;
                         }
-                        trkPnt.customColoring = ps.neutralColor;
+                        trkPnt.customColoring = neutralColor;
                         if (oldWp != null) {
                             double dist = c.greatCircleDistance(oldWp.getCoor());
 
-                            switch (ps.colored) {
+                            switch (colored) {
                             case velocity:
                                 double dtime = trkPnt.time - oldWp.time;
                                 double vel = dist / dtime;
-                                double velColor = vel / ps.colorTracksTune * 255;
+                                double velColor = vel / colorTracksTune * 255;
                                 // Bad case first
                                 if (dtime <= 0 || vel < 0 || velColor > 255) {
@@ -700,5 +612,5 @@
                             }
 
-                            if (ps.maxLineLength == -1 || dist <= ps.maxLineLength) {
+                            if (maxLineLength == -1 || dist <= maxLineLength) {
                                 trkPnt.drawLine = true;
                                 trkPnt.dir = (int) oldWp.getCoor().heading(trkPnt.getCoor());
@@ -728,5 +640,5 @@
          ********** STEP 3a - DRAW LINES ********************************
          ****************************************************************/
-        if (ps.lines) {
+        if (lines) {
             Point old = null;
             for (Collection<WayPoint> segment : visibleSegments) {
@@ -752,5 +664,5 @@
          ********** STEP 3b - DRAW NICE ARROWS **************************
          ****************************************************************/
-        if (ps.lines && ps.direction && !ps.alternatedirection) {
+        if (lines && direction && !alternatedirection) {
             Point old = null;
             Point oldA = null; // last arrow painted
@@ -765,6 +677,6 @@
                         // skip points that are on the same screenposition
                         if (old != null
-                                && (oldA == null || screen.x < oldA.x - ps.delta || screen.x > oldA.x + ps.delta
-                                        || screen.y < oldA.y - ps.delta || screen.y > oldA.y + ps.delta)) {
+                                && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta
+                                        || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) {
                             g.setColor(trkPnt.customColoring);
                             double t = Math.atan2(screen.y - old.y, screen.x - old.x) + Math.PI;
@@ -784,5 +696,5 @@
          ********** STEP 3c - DRAW FAST ARROWS **************************
          ****************************************************************/
-        if (ps.lines && ps.direction && ps.alternatedirection) {
+        if (lines && direction && alternatedirection) {
             Point old = null;
             Point oldA = null; // last arrow painted
@@ -797,6 +709,6 @@
                         // skip points that are on the same screenposition
                         if (old != null
-                                && (oldA == null || screen.x < oldA.x - ps.delta || screen.x > oldA.x + ps.delta
-                                        || screen.y < oldA.y - ps.delta || screen.y > oldA.y + ps.delta)) {
+                                && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta
+                                        || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) {
                             g.setColor(trkPnt.customColoring);
                             g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y
@@ -815,6 +727,6 @@
          ********** STEP 3d - DRAW LARGE POINTS AND HDOP CIRCLE *********
          ****************************************************************/
-        if (ps.large || ps.hdopcircle) {
-            g.setColor(ps.neutralColor);
+        if (large || hdopcircle) {
+            g.setColor(neutralColor);
             for (Collection<WayPoint> segment : visibleSegments) {
                 for (WayPoint trkPnt : segment) {
@@ -825,5 +737,5 @@
                     Point screen = mv.getPoint(trkPnt.getEastNorth());
                     g.setColor(trkPnt.customColoring);
-                    if (ps.hdopcircle && trkPnt.attr.get("hdop") != null) {
+                    if (hdopcircle && trkPnt.attr.get("hdop") != null) {
                         // hdop value
                         float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue();
@@ -835,5 +747,5 @@
                         g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360);
                     }
-                    if (ps.large) {
+                    if (large) {
                         g.fillRect(screen.x-1, screen.y-1, 3, 3);
                     }
@@ -845,6 +757,6 @@
          ********** STEP 3e - DRAW SMALL POINTS FOR LINES ***************
          ****************************************************************/
-        if (!ps.large && ps.lines) {
-            g.setColor(ps.neutralColor);
+        if (!large && lines) {
+            g.setColor(neutralColor);
             for (Collection<WayPoint> segment : visibleSegments) {
                 for (WayPoint trkPnt : segment) {
@@ -864,6 +776,6 @@
          ********** STEP 3f - DRAW SMALL POINTS INSTEAD OF LINES ********
          ****************************************************************/
-        if (!ps.large && !ps.lines) {
-            g.setColor(ps.neutralColor);
+        if (!large && !lines) {
+            g.setColor(neutralColor);
             for (Collection<WayPoint> segment : visibleSegments) {
                 for (WayPoint trkPnt : segment) {
