Index: /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 9233)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java	(revision 9234)
@@ -11,5 +11,7 @@
 import java.awt.RenderingHints;
 import java.awt.Stroke;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -224,4 +226,5 @@
         if (colorModeDynamic) {
             if (colored == ColorMode.VELOCITY) {
+                final List<Double> velocities = new ArrayList<>();
                 for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
                     if (!forceLines) {
@@ -236,4 +239,5 @@
                             double vel = c.greatCircleDistance(oldWp.getCoor())
                                     / (trkPnt.time - oldWp.time);
+                            velocities.add(vel);
                             if (vel > maxval) {
                                 maxval = vel;
@@ -246,4 +250,7 @@
                     }
                 }
+                Collections.sort(velocities);
+                minval = velocities.get(velocities.size() / 20); // 5% percentile to remove outliers
+                maxval = velocities.get(velocities.size() * 19 / 20); // 95% percentile to remove outliers
                 if (minval >= maxval) {
                     velocityScale.setRange(0, 120/3.6);
Index: /trunk/test/unit/org/openstreetmap/josm/tools/ColorScaleTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/ColorScaleTest.java	(revision 9234)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/ColorScaleTest.java	(revision 9234)
@@ -0,0 +1,33 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.awt.Color;
+
+import org.junit.Test;
+
+public class ColorScaleTest {
+
+    /**
+     * Test method for {@link ColorScale#createHSBScale(int)}.
+     */
+    @Test
+    public void testHSBScale() throws Exception {
+        final ColorScale scale = ColorScale.createHSBScale(256);
+        assertEquals(new Color(255, 0, 0), scale.getColor(0));
+        assertEquals(new Color(0, 255, 143), scale.getColor(128));
+        assertEquals(new Color(255, 0, 229), scale.getColor(255));
+
+        assertEquals(new Color(255, 0, 0), scale.getColor(-1000));
+        assertEquals(new Color(255, 0, 229), scale.getColor(1000));
+
+        assertNull(scale.getColor(Double.NaN));
+        assertNull(scale.getColor(null));
+        scale.setNoDataColor(new Color(12, 34, 56));
+        assertEquals(new Color(12, 34, 56), scale.getNoDataColor());
+        assertEquals(new Color(12, 34, 56), scale.getColor(Double.NaN));
+        assertEquals(new Color(12, 34, 56), scale.getColor(null));
+    }
+}
