Index: applications/editors/josm/plugins/ElevationProfile/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/.settings/org.eclipse.jdt.ui.prefs	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/.settings/org.eclipse.jdt.ui.prefs	(revision 30344)
@@ -1,3 +1,2 @@
-#Sat Jan 29 19:56:56 CET 2011
 eclipse.preferences.version=1
 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
@@ -39,5 +38,5 @@
 sp_cleanup.remove_unnecessary_casts=true
 sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_imports=true
 sp_cleanup.remove_unused_local_variables=false
 sp_cleanup.remove_unused_private_fields=true
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ColorMap.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ColorMap.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ColorMap.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -33,5 +21,5 @@
 
     static {
-	colorMaps = new HashMap<String, ColorMap>();
+        colorMaps = new HashMap<String, ColorMap>();
     }
 
@@ -41,9 +29,9 @@
 
     public String getName() {
-	return name;
+        return name;
     }
 
     public void setName(String name) {
-	this.name = name;
+        this.name = name;
     }
 
@@ -55,35 +43,35 @@
      */
     public Color getColor(int elevation) {
-	// empty color map?
-	if (colorList == null || colorList.size() == 0) {
-	    return Color.white;
-	}
+        // empty color map?
+        if (colorList == null || colorList.size() == 0) {
+            return Color.white;
+        }
 
-	// out of range?
-	if (elevation < colorList.get(0).ele) {
-	    return colorList.get(0).getColor();
-	}
+        // out of range?
+        if (elevation < colorList.get(0).ele) {
+            return colorList.get(0).getColor();
+        }
 
-	int last = colorList.size() - 1;
-	if (elevation > colorList.get(last).ele) {
-	    return colorList.get(last).getColor();
-	}
+        int last = colorList.size() - 1;
+        if (elevation > colorList.get(last).ele) {
+            return colorList.get(last).getColor();
+        }
 
-	// find elevation section
-	for (int i = 0; i < last; i++) {
-	    ColorMapEntry e1 = colorList.get(i);
-	    ColorMapEntry e2 = colorList.get(i + 1);
+        // find elevation section
+        for (int i = 0; i < last; i++) {
+            ColorMapEntry e1 = colorList.get(i);
+            ColorMapEntry e2 = colorList.get(i + 1);
 
-	    // elevation within range?
-	    if (e1.getEle() <= elevation && e2.getEle() >= elevation) {
+            // elevation within range?
+            if (e1.getEle() <= elevation && e2.getEle() >= elevation) {
 
-		// interpolate color between both
-		double val = (elevation - e1.getEle()) / (double)(e2.getEle() - e1.getEle());
-		return interpolate(e1.getColor(), e2.getColor(), val);
-	    }
-	}
+                // interpolate color between both
+                double val = (elevation - e1.getEle()) / (double)(e2.getEle() - e1.getEle());
+                return interpolate(e1.getColor(), e2.getColor(), val);
+            }
+        }
 
-	// here we should never end!
-	throw new RuntimeException("Inconsistent color map - found no entry for elevation " + elevation);
+        // here we should never end!
+        throw new RuntimeException("Inconsistent color map - found no entry for elevation " + elevation);
     }
 
@@ -96,8 +84,8 @@
      */
     public static ColorMap getMap(String name) {
-	if (colorMaps.containsKey(name)) {
-	    return colorMaps.get(name);
-	}
-	return null;
+        if (colorMaps.containsKey(name)) {
+            return colorMaps.get(name);
+        }
+        return null;
     }
 
@@ -108,5 +96,5 @@
      */
     public static int size() {
-	return colorMaps != null ? colorMaps.size() : 0;
+        return colorMaps != null ? colorMaps.size() : 0;
     }
 
@@ -119,29 +107,29 @@
      */
     public static String[] getNames() {
-	return colorMaps.keySet().toArray(new String[size()]);
+        return colorMaps.keySet().toArray(new String[size()]);
     }
 
     private static void registerColorMap(ColorMap newMap) {
-	CheckParameterUtil.ensureParameterNotNull(newMap);
-	colorMaps.put(newMap.getName(), newMap);
+        CheckParameterUtil.ensureParameterNotNull(newMap);
+        colorMaps.put(newMap.getName(), newMap);
     }
 
     public static void unregisterColorMap(String name) {
-	if (colorMaps.containsKey(name)) {
-	    colorMaps.remove(name);
-	}
+        if (colorMaps.containsKey(name)) {
+            colorMaps.remove(name);
+        }
     }
 
     public static Color interpolate(java.awt.Color c1, java.awt.Color c2, double ratio) {
-	double r1 = 1 -ratio;
-	// clip
-	if (r1 < 0) r1 = 0d;
-	if (r1 > 1) r1 = 1d;
-	double r2 = 1 - r1;
+        double r1 = 1 -ratio;
+        // clip
+        if (r1 < 0) r1 = 0d;
+        if (r1 > 1) r1 = 1d;
+        double r2 = 1 - r1;
 
-	int r = (int) Math.round((r1 * c1.getRed()) + (r2 * c2.getRed()));
-	int g = (int) Math.round((r1 * c1.getGreen()) + (r2 * c2.getGreen()));
-	int b = (int) Math.round((r1 * c1.getBlue()) + (r2 * c2.getBlue()));
-	return new Color(r, g, b);
+        int r = (int) Math.round((r1 * c1.getRed()) + (r2 * c2.getRed()));
+        int g = (int) Math.round((r1 * c1.getGreen()) + (r2 * c2.getGreen()));
+        int b = (int) Math.round((r1 * c1.getBlue()) + (r2 * c2.getBlue()));
+        return new Color(r, g, b);
     }
 
@@ -156,48 +144,48 @@
      */
     public static ColorMap create(String name, Color[] colors, int[] ele) {
-	CheckParameterUtil.ensureParameterNotNull(colors);
-	CheckParameterUtil.ensureParameterNotNull(ele);
+        CheckParameterUtil.ensureParameterNotNull(colors);
+        CheckParameterUtil.ensureParameterNotNull(ele);
 
-	if (colors.length != ele.length) {
-	    throw new IllegalArgumentException("Arrays colors and ele must have same length: " + colors.length + " vs " + ele.length);
-	}
+        if (colors.length != ele.length) {
+            throw new IllegalArgumentException("Arrays colors and ele must have same length: " + colors.length + " vs " + ele.length);
+        }
 
-	ColorMap map = new ColorMap();
-	map.colorList = new ArrayList<ColorMap.ColorMapEntry>();
-	map.name = name;
-	for (int i = 0; i < ele.length; i++) {
-	    map.colorList.add(map.new ColorMapEntry(colors[i], ele[i]));
-	}
+        ColorMap map = new ColorMap();
+        map.colorList = new ArrayList<ColorMap.ColorMapEntry>();
+        map.name = name;
+        for (int i = 0; i < ele.length; i++) {
+            map.colorList.add(map.new ColorMapEntry(colors[i], ele[i]));
+        }
 
-	// sort by elevation
-	Collections.sort(map.colorList);
+        // sort by elevation
+        Collections.sort(map.colorList);
 
-	registerColorMap(map);
-	return map;
+        registerColorMap(map);
+        return map;
     }
 
 
     class ColorMapEntry implements Comparable<ColorMapEntry> {
-	private final int ele; // limit
-	private final Color color;
+        private final int ele; // limit
+        private final Color color;
 
-	public ColorMapEntry(Color color, int ele) {
-	    super();
-	    this.color = color;
-	    this.ele = ele;
-	}
+        public ColorMapEntry(Color color, int ele) {
+            super();
+            this.color = color;
+            this.ele = ele;
+        }
 
-	public int getEle() {
-	    return ele;
-	}
+        public int getEle() {
+            return ele;
+        }
 
-	public Color getColor() {
-	    return color;
-	}
+        public Color getColor() {
+            return color;
+        }
 
-	@Override
-	public int compareTo(ColorMapEntry o) {
-	    return this.ele - o.ele;
-	}
+        @Override
+        public int compareTo(ColorMapEntry o) {
+            return this.ele - o.ele;
+        }
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationHelper.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationHelper.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationHelper.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -36,10 +23,10 @@
     /* Countries which use the imperial system instead of the metric system. */
     private static String IMPERIAL_SYSTEM_COUNTRIES[] = {
-	"en_US", 	/* USA */
-	"en_CA",	/* Canada */
-	"en_AU",	/* Australia */
-	"en_NZ",	/* New Zealand */
-	//		"de_DE",	/* for testing only */
-	"en_ZA"	/* South Africa */
+        "en_US",     /* USA */
+        "en_CA",    /* Canada */
+        "en_AU",    /* Australia */
+        "en_NZ",    /* New Zealand */
+        //        "de_DE",    /* for testing only */
+        "en_ZA"    /* South Africa */
     };
 
@@ -64,9 +51,9 @@
      */
     public static GeoidCorrectionKind getGeoidKind() {
-	return geoidKind;
+        return geoidKind;
     }
 
     public static void setGeoidKind(GeoidCorrectionKind geoidKind) {
-	ElevationHelper.geoidKind = geoidKind;
+        ElevationHelper.geoidKind = geoidKind;
     }
 
@@ -76,25 +63,25 @@
      */
     public static UnitMode getUnitMode() {
-	//TODO: Use this until /JOSM/src/org/openstreetmap/josm/gui/NavigatableComponent.java
-	// has a an appropriate method
-
-	// unit mode already determined?
-	if (unitMode != UnitMode.NotSelected) {
-	    return unitMode;
-	}
-
-	// Set default
-	unitMode = UnitMode.Metric;
-
-	// Check if user could prefer imperial system
-	Locale l = Locale.getDefault();
-	for (int i = 0; i < IMPERIAL_SYSTEM_COUNTRIES.length; i++) {
-	    String ctry = l.toString();
-	    if (IMPERIAL_SYSTEM_COUNTRIES[i].equals(ctry)) {
-		unitMode = UnitMode.Imperial;
-	    }
-	}
-
-	return unitMode;
+        //TODO: Use this until /JOSM/src/org/openstreetmap/josm/gui/NavigatableComponent.java
+        // has a an appropriate method
+
+        // unit mode already determined?
+        if (unitMode != UnitMode.NotSelected) {
+            return unitMode;
+        }
+
+        // Set default
+        unitMode = UnitMode.Metric;
+
+        // Check if user could prefer imperial system
+        Locale l = Locale.getDefault();
+        for (int i = 0; i < IMPERIAL_SYSTEM_COUNTRIES.length; i++) {
+            String ctry = l.toString();
+            if (IMPERIAL_SYSTEM_COUNTRIES[i].equals(ctry)) {
+                unitMode = UnitMode.Imperial;
+            }
+        }
+
+        return unitMode;
     }
 
@@ -104,12 +91,12 @@
      */
     public static String getUnit() {
-	switch (getUnitMode()) {
-	case Metric:
-	    return "m";
-	case Imperial:
-	    return "ft";
-	default:
-	    throw new RuntimeException("Invalid or unsupported unit mode: " + unitMode);
-	}
+        switch (getUnitMode()) {
+        case Metric:
+            return "m";
+        case Imperial:
+            return "ft";
+        default:
+            throw new RuntimeException("Invalid or unsupported unit mode: " + unitMode);
+        }
     }
 
@@ -121,5 +108,5 @@
      */
     public static boolean isValidElevation(double ele) {
-	return !Double.isNaN(ele);
+        return !Double.isNaN(ele);
     }
 
@@ -134,37 +121,37 @@
      */
     public static double getElevation(WayPoint wpt) {
-	if (wpt == null) return NO_ELEVATION;
-
-	// try to get elevation from HGT file
-	double eleInt = getSrtmElevation(wpt.getCoor());
-	if (isValidElevation(eleInt)) {
-	    return convert(eleInt);
-	}
-
-	// no HGT, check for elevation data in GPX
-	if (!wpt.attr.containsKey(HEIGHT_ATTRIBUTE)) {
-	    // GPX has no elevation data :-(
-	    return NO_ELEVATION;
-	}
-
-	// Parse elevation from GPX data
-	String height = wpt.getString(ElevationHelper.HEIGHT_ATTRIBUTE);
-	try {
-	    double z = Double.parseDouble(height);
-
-	    return convert(z);
-	} catch (NumberFormatException e) {
-	    System.err.println(String.format(
-		    "Cannot parse double from '%s': %s", height, e
-		    .getMessage()));
-	    return NO_ELEVATION;
-	}
+        if (wpt == null) return NO_ELEVATION;
+
+        // try to get elevation from HGT file
+        double eleInt = getSrtmElevation(wpt.getCoor());
+        if (isValidElevation(eleInt)) {
+            return convert(eleInt);
+        }
+
+        // no HGT, check for elevation data in GPX
+        if (!wpt.attr.containsKey(HEIGHT_ATTRIBUTE)) {
+            // GPX has no elevation data :-(
+            return NO_ELEVATION;
+        }
+
+        // Parse elevation from GPX data
+        String height = wpt.getString(ElevationHelper.HEIGHT_ATTRIBUTE);
+        try {
+            double z = Double.parseDouble(height);
+
+            return convert(z);
+        } catch (NumberFormatException e) {
+            System.err.println(String.format(
+                    "Cannot parse double from '%s': %s", height, e
+                    .getMessage()));
+            return NO_ELEVATION;
+        }
     }
 
 
     private static double getElevation(LatLon ll) {
-	double ele = getSrtmElevation(ll);
-	//System.out.println("Get elevation " + ll + " => " + ele);
-	return convert(ele);
+        double ele = getSrtmElevation(ll);
+        //System.out.println("Get elevation " + ll + " => " + ele);
+        return convert(ele);
     }
 
@@ -176,14 +163,14 @@
      */
     private static double convert(double ele) {
-	if (isValidElevation(ele)) {
-	    if (getUnitMode() == UnitMode.Imperial) {
-		// translate to feet
-		return meter2Feet(ele);
-	    } else {
-		// keep 'as is'
-		return ele;
-	    }
-	}
-	return NO_ELEVATION;
+        if (isValidElevation(ele)) {
+            if (getUnitMode() == UnitMode.Imperial) {
+                // translate to feet
+                return meter2Feet(ele);
+            } else {
+                // keep 'as is'
+                return ele;
+            }
+        }
+        return NO_ELEVATION;
     }
 
@@ -197,17 +184,17 @@
      */
     public static double computeSlope(LatLon w1, LatLon w2) {
-	// same coordinates? -> return 0, if yes
-	if (w1.equals(w2)) return 0;
-
-	// get distance in meters and divide it by 100 in advance
-	double distInMeter = convert(w1.greatCircleDistance(w2) / 100.0);
-
-	// get elevation (difference) - is converted automatically to feet
-	int ele1 = (int) ElevationHelper.getElevation(w1);
-	int ele2 = (int) ElevationHelper.getElevation(w2);
-	int dH = ele2 - ele1;
-
-	// Slope in percent is define as elevation gain/loss in meters related to a distance of 100m
-	return dH / distInMeter;
+        // same coordinates? -> return 0, if yes
+        if (w1.equals(w2)) return 0;
+
+        // get distance in meters and divide it by 100 in advance
+        double distInMeter = convert(w1.greatCircleDistance(w2) / 100.0);
+
+        // get elevation (difference) - is converted automatically to feet
+        int ele1 = (int) ElevationHelper.getElevation(w1);
+        int ele2 = (int) ElevationHelper.getElevation(w2);
+        int dH = ele2 - ele1;
+
+        // Slope in percent is define as elevation gain/loss in meters related to a distance of 100m
+        return dH / distInMeter;
     }
 
@@ -219,5 +206,5 @@
      */
     public static double meter2Feet(double meter) {
-	return meter * METER_TO_FEET;
+        return meter * METER_TO_FEET;
     }
 
@@ -228,5 +215,5 @@
      */
     public static String getElevationText(int elevation) {
-	return String.format("%d %s", elevation, getUnit());
+        return String.format("%d %s", elevation, getUnit());
     }
 
@@ -237,5 +224,5 @@
      */
     public static String getElevationText(double elevation) {
-	return String.format("%d %s", (int)Math.round(elevation), getUnit());
+        return String.format("%d %s", (int)Math.round(elevation), getUnit());
     }
 
@@ -247,8 +234,8 @@
      */
     public static String getElevationText(WayPoint wpt) {
-	if (wpt == null) return "-";
-
-	int elevation = (int)Math.round(ElevationHelper.getElevation(wpt));
-	return String.format("%d %s", elevation, getUnit());
+        if (wpt == null) return "-";
+
+        int elevation = (int)Math.round(ElevationHelper.getElevation(wpt));
+        return String.format("%d %s", elevation, getUnit());
     }
 
@@ -259,9 +246,9 @@
      */
     public static String getTimeText(WayPoint wpt) {
-	if (wpt == null) return null;
-
-	int hour = ElevationHelper.getHourOfWayPoint(wpt);
-	int min = ElevationHelper.getMinuteOfWayPoint(wpt);
-	return String.format("%02d:%02d", hour, min);
+        if (wpt == null) return null;
+
+        int hour = ElevationHelper.getHourOfWayPoint(wpt);
+        int min = ElevationHelper.getMinuteOfWayPoint(wpt);
+        return String.format("%02d:%02d", hour, min);
     }
 
@@ -275,15 +262,15 @@
      */
     public static double getSrtmElevation(LatLon ll) {
-	if (ll != null) {
-	    // Try to read data from SRTM file
-	    // TODO: Option to switch this off
-	    double eleHgt = hgt.getElevationFromHgt(ll);
-
-	    //System.out.println("Get elevation from HGT " + ll + " => " + eleHgt);
-	    if (isValidElevation(eleHgt)) {
-		return eleHgt;
-	    }
-	}
-	return NO_ELEVATION;
+        if (ll != null) {
+            // Try to read data from SRTM file
+            // TODO: Option to switch this off
+            double eleHgt = hgt.getElevationFromHgt(ll);
+
+            //System.out.println("Get elevation from HGT " + ll + " => " + eleHgt);
+            if (isValidElevation(eleHgt)) {
+                return eleHgt;
+            }
+        }
+        return NO_ELEVATION;
     }
 
@@ -295,11 +282,11 @@
      */
     public static boolean hasSrtmData(Bounds bounds) {
-	if (bounds == null) return false;
-
-	LatLon tl = bounds.getMin();
-	LatLon br = bounds.getMax();
-
-	return 	isValidElevation(getSrtmElevation(tl)) &&
-		isValidElevation(getSrtmElevation(br));
+        if (bounds == null) return false;
+
+        LatLon tl = bounds.getMin();
+        LatLon br = bounds.getMax();
+
+        return     isValidElevation(getSrtmElevation(tl)) &&
+                isValidElevation(getSrtmElevation(br));
     }
 
@@ -309,13 +296,13 @@
      */
     public static byte getGeoidCorrection(WayPoint wpt) {
-	/*
-		int lat = (int)Math.round(wpt.getCoor().lat());
-		int lon = (int)Math.round(wpt.getCoor().lon());
-		byte geoid = GeoidData.getGeoid(lat, lon);
-
-		System.out.println(
-				String.format("Geoid(%d, %d) = %d", lat, lon, geoid));
-	 */
-	return 0;
+        /*
+        int lat = (int)Math.round(wpt.getCoor().lat());
+        int lon = (int)Math.round(wpt.getCoor().lon());
+        byte geoid = GeoidData.getGeoid(lat, lon);
+
+        System.out.println(
+                String.format("Geoid(%d, %d) = %d", lat, lon, geoid));
+         */
+        return 0;
     }
 
@@ -332,24 +319,24 @@
      */
     public static List<WayPoint> downsampleWayPoints(List<WayPoint> origList,
-	    int targetSize) {
-	if (origList == null)
-	    return null;
-	if (targetSize <= 0)
-	    throw new IllegalArgumentException(
-		    "targetSize must be greater than zero");
-
-	int origSize = origList.size();
-	if (origSize <= targetSize) {
-	    return origList;
-	}
-
-	int delta = (int) Math.max(Math.ceil(origSize / targetSize), 2);
-
-	List<WayPoint> res = new ArrayList<WayPoint>(targetSize);
-	for (int i = 0; i < origSize; i += delta) {
-	    res.add(origList.get(i));
-	}
-
-	return res;
+            int targetSize) {
+        if (origList == null)
+            return null;
+        if (targetSize <= 0)
+            throw new IllegalArgumentException(
+                    "targetSize must be greater than zero");
+
+        int origSize = origList.size();
+        if (origSize <= targetSize) {
+            return origList;
+        }
+
+        int delta = (int) Math.max(Math.ceil(origSize / targetSize), 2);
+
+        List<WayPoint> res = new ArrayList<WayPoint>(targetSize);
+        for (int i = 0; i < origSize; i += delta) {
+            res.add(origList.get(i));
+        }
+
+        return res;
     }
 
@@ -360,9 +347,9 @@
      */
     public static int getHourOfWayPoint(WayPoint wpt) {
-	if (wpt == null) return -1;
-
-	Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
-	calendar.setTime(wpt.getTime());   // assigns calendar to given date
-	return calendar.get(Calendar.HOUR_OF_DAY);
+        if (wpt == null) return -1;
+
+        Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
+        calendar.setTime(wpt.getTime());   // assigns calendar to given date
+        return calendar.get(Calendar.HOUR_OF_DAY);
     }
 
@@ -373,9 +360,9 @@
      */
     public static int getMinuteOfWayPoint(WayPoint wpt) {
-	if (wpt == null) return -1;
-
-	Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
-	calendar.setTime(wpt.getTime());   // assigns calendar to given date
-	return calendar.get(Calendar.MINUTE);
+        if (wpt == null) return -1;
+
+        Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
+        calendar.setTime(wpt.getTime());   // assigns calendar to given date
+        return calendar.get(Calendar.MINUTE);
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -27,35 +14,33 @@
  */
 public class ElevationMapMode extends MapMode implements IElevationModelListener {
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -1011179566962655639L;
-	
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -1011179566962655639L;
 
-	public ElevationMapMode(String name, MapFrame mapFrame) {		
-		super(name, 
-				"elevation.png", 
-				tr("Shows elevation profile"), 
-				mapFrame, 
-				Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));		
-	}
 
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationModelListener#elevationProfileChanged(org.openstreetmap.josm.plugins.elevation.IElevationProfile)
-	 */
-	public void elevationProfileChanged(IElevationProfile profile) {
-		ElevationProfilePlugin.getCurrentLayer().setProfile(profile);
-	}
+    public ElevationMapMode(String name, MapFrame mapFrame) {
+        super(name,
+                "elevation.png",
+                tr("Shows elevation profile"),
+                mapFrame,
+                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+    }
 
-	@Override
-	public void enterMode() {
-		super.enterMode();
-		ElevationProfilePlugin.getCurrentLayer().setVisible(true);
-	}
+    @Override
+    public void elevationProfileChanged(IElevationProfile profile) {
+        ElevationProfilePlugin.getCurrentLayer().setProfile(profile);
+    }
 
-	@Override
-	public void exitMode() {
-		super.exitMode();
-		ElevationProfilePlugin.getCurrentLayer().setVisible(false);
-	}
+    @Override
+    public void enterMode() {
+        super.enterMode();
+        ElevationProfilePlugin.getCurrentLayer().setVisible(true);
+    }
+
+    @Override
+    public void exitMode() {
+        super.exitMode();
+        ElevationProfilePlugin.getCurrentLayer().setVisible(false);
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -46,20 +33,20 @@
      */
     public ElevationProfilePlugin(PluginInformation info) {
-	super(info);
+        super(info);
 
-	try {
-	    eleMode = new ElevationMapMode("Elevation profile", Main.map);
-	    eleModeButton = new IconToggleButton(eleMode);
-	    
-	    JosmAction action = new AddElevationLayerAction();
-	    
-	    createColorMaps();
-	    
-	    // TODO: Disable this view as long as it is not stable
-	    MainMenu.add(Main.main.menu.imagerySubMenu, action, false, 0);
-	} catch (Exception e1) {
-	    System.err.println("Init of ElevationProfilePlugin failed: " + e1);
-	    e1.printStackTrace();
-	}
+        try {
+            eleMode = new ElevationMapMode("Elevation profile", Main.map);
+            eleModeButton = new IconToggleButton(eleMode);
+
+            JosmAction action = new AddElevationLayerAction();
+
+            createColorMaps();
+
+            // TODO: Disable this view as long as it is not stable
+            MainMenu.add(Main.main.menu.imagerySubMenu, action, false, 0);
+        } catch (Exception e1) {
+            System.err.println("Init of ElevationProfilePlugin failed: " + e1);
+            e1.printStackTrace();
+        }
     }
 
@@ -69,15 +56,15 @@
      * an alternative Painter.
      */
-    @Override	
+    @Override
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-	super.mapFrameInitialized(oldFrame, newFrame);
+        super.mapFrameInitialized(oldFrame, newFrame);
 
-	if (newFrame != null) {
-	    newFrame.addMapMode(eleModeButton);
-	    ElevationProfileDialog eleProfileDlg = new ElevationProfileDialog();
-	    eleProfileDlg.addModelListener(eleMode);
-	    eleProfileDlg.setProfileLayer(getCurrentLayer());
-	    newFrame.addToggleDialog(eleProfileDlg);
-	}
+        if (newFrame != null) {
+            newFrame.addMapMode(eleModeButton);
+            ElevationProfileDialog eleProfileDlg = new ElevationProfileDialog();
+            eleProfileDlg.addModelListener(eleMode);
+            eleProfileDlg.setProfileLayer(getCurrentLayer());
+            newFrame.addToggleDialog(eleProfileDlg);
+        }
     }
 
@@ -88,64 +75,64 @@
      */
     public static ElevationProfileLayer getCurrentLayer(){
-	if(currentLayer == null){
-	    currentLayer = new ElevationProfileLayer(tr("Elevation Profile"));
-	    Main.main.addLayer(currentLayer);			
-	}
-	return currentLayer;
+        if(currentLayer == null){
+            currentLayer = new ElevationProfileLayer(tr("Elevation Profile"));
+            Main.main.addLayer(currentLayer);
+        }
+        return currentLayer;
     }
-    
+
     private void createColorMaps() {
-	// Data taken from http://proceedings.esri.com/library/userconf/proc98/proceed/to850/pap842/p842.htm
-	ColorMap.create("Physical_US",
-		new Color[]{
-		new Color(18,129,242),
-		new Color(113,153,89),
-		new Color(117,170,101),
-		new Color(149,190,113),
-		new Color(178,214,117),
-		new Color(202,226,149),
-		new Color(222,238,161),
-		new Color(242,238,161),
-		new Color(238,222,153),
-		new Color(242,206,133),
-		new Color(234,182,129),
-		new Color(218,157,121),
-		new Color(194,141,125),
-		new Color(214,157,145),
-		new Color(226,174,165),
-		new Color(222,186,182),
-		new Color(238,198,210),
-		new Color(255,206,226),
-		new Color(250,218,234),
-		new Color(255,222,230),
-		new Color(255,230,242),
-		new Color(255,242,255)
-		}, 
-		// elevation in meters - the page above uses feet, so these values differs slightly
-		new int[]{
-		-3000,
-		0,
-		150,
-		300,
-		450,
-		600,
-		750,
-		900,
-		1050,
-		1200,
-		1350,
-		1500,
-		1650,
-		1800,
-		1950,
-		2100,
-		2250,
-		2400,
-		2550,
-		2700,
-		2750,
-		3000		
-		}
-		);
+        // Data taken from http://proceedings.esri.com/library/userconf/proc98/proceed/to850/pap842/p842.htm
+        ColorMap.create("Physical_US",
+                new Color[]{
+                new Color(18,129,242),
+                new Color(113,153,89),
+                new Color(117,170,101),
+                new Color(149,190,113),
+                new Color(178,214,117),
+                new Color(202,226,149),
+                new Color(222,238,161),
+                new Color(242,238,161),
+                new Color(238,222,153),
+                new Color(242,206,133),
+                new Color(234,182,129),
+                new Color(218,157,121),
+                new Color(194,141,125),
+                new Color(214,157,145),
+                new Color(226,174,165),
+                new Color(222,186,182),
+                new Color(238,198,210),
+                new Color(255,206,226),
+                new Color(250,218,234),
+                new Color(255,222,230),
+                new Color(255,230,242),
+                new Color(255,242,255)
+        },
+        // elevation in meters - the page above uses feet, so these values differs slightly
+        new int[]{
+                -3000,
+                0,
+                150,
+                300,
+                450,
+                600,
+                750,
+                900,
+                1050,
+                1200,
+                1350,
+                1500,
+                1650,
+                1800,
+                1950,
+                2100,
+                2250,
+                2400,
+                2550,
+                2700,
+                2750,
+                3000
+        }
+                );
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -27,8 +15,7 @@
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 
-
 /**
  *  Class HgtReader reads data from SRTM HGT files. Currently this class is restricted to a resolution of 3 arc seconds.
- *  
+ * 
  *  SRTM data files are available at the <a href="http://dds.cr.usgs.gov/srtm/version2_1/SRTM3">NASA SRTM site</a>
  *  @author Oliver Wieland <oliver.wieland@online.de>
@@ -38,74 +25,74 @@
 
     public static final String HGT_EXT = ".hgt";
-    
+
     // alter these values for different SRTM resolutions
     public static final int HGT_RES = 3; // resolution in arc seconds
     public static final int HGT_ROW_LENGTH = 1201; // number of elevation values per line
     public static final int HGT_VOID = -32768; // magic number which indicates 'void data' in HGT file
-    
-    private HashMap<String, ShortBuffer> cache = new HashMap<String, ShortBuffer>(); 
-    
+
+    private final HashMap<String, ShortBuffer> cache = new HashMap<String, ShortBuffer>();
+
     public double getElevationFromHgt(LatLon coor) {
-	try {
-	    String file = getHgtFileName(coor);
-	    // given area in cache?
-	    if (!cache.containsKey(file)) {
-			
-		// fill initial cache value. If no file is found, then
-		// we use it as a marker to indicate 'file has been searched
-		// but is not there'
-		cache.put(file, null);
-		 // Try all resource directories
-	        for (String location : Main.pref.getAllPossiblePreferenceDirs()) {	            
-	    		String fullPath = new File(location + File.separator + "elevation", file).getPath();
-    	    		File f = new File(fullPath);
-    	    		if (f.exists()) {
-    	    		    // found something: read HGT file...
-    	    		    ShortBuffer data = readHgtFile(fullPath);    	    		    
-    	    		    // ... and store result in cache
-    	    		    cache.put(file, data);
-    	    		    break;
-    	    		}
-	        }
-	    } 
-	    
-	    // read elevation value
-	    return readElevation(coor);
-	} catch (FileNotFoundException e) {
-	    System.err.println("Get elevation from HGT " + coor + " failed: => " + e.getMessage());
-	    // no problem... file not there
-	    return ElevationHelper.NO_ELEVATION;
-	} catch (Exception ioe) {
-	    // oops...
-	    ioe.printStackTrace(System.err);	    
-	    // fallback
-	    return ElevationHelper.NO_ELEVATION;	    
-	} 
+        try {
+            String file = getHgtFileName(coor);
+            // given area in cache?
+            if (!cache.containsKey(file)) {
+
+                // fill initial cache value. If no file is found, then
+                // we use it as a marker to indicate 'file has been searched
+                // but is not there'
+                cache.put(file, null);
+                // Try all resource directories
+                for (String location : Main.pref.getAllPossiblePreferenceDirs()) {
+                    String fullPath = new File(location + File.separator + "elevation", file).getPath();
+                    File f = new File(fullPath);
+                    if (f.exists()) {
+                        // found something: read HGT file...
+                        ShortBuffer data = readHgtFile(fullPath);
+                        // ... and store result in cache
+                        cache.put(file, data);
+                        break;
+                    }
+                }
+            }
+
+            // read elevation value
+            return readElevation(coor);
+        } catch (FileNotFoundException e) {
+            System.err.println("Get elevation from HGT " + coor + " failed: => " + e.getMessage());
+            // no problem... file not there
+            return ElevationHelper.NO_ELEVATION;
+        } catch (Exception ioe) {
+            // oops...
+            ioe.printStackTrace(System.err);
+            // fallback
+            return ElevationHelper.NO_ELEVATION;
+        }
     }
-    
+
     @SuppressWarnings("resource")
     private ShortBuffer readHgtFile(String file) throws Exception {
-	CheckParameterUtil.ensureParameterNotNull(file);
+        CheckParameterUtil.ensureParameterNotNull(file);
 
-	FileChannel fc = null;
-	ShortBuffer sb = null;
-	try {	    
-	    // Eclipse complains here about resource leak on 'fc' - even with 'finally' clause???
-	    fc = new FileInputStream(file).getChannel();
-	    // choose the right endianness
-	    
-	    ByteBuffer bb = ByteBuffer.allocateDirect((int) fc.size());
-	    while (bb.remaining() > 0) fc.read(bb);
-	    
-	    bb.flip();
-	    //sb = bb.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();	
-	    sb = bb.order(ByteOrder.BIG_ENDIAN).asShortBuffer();
-	} finally {
-	    if (fc != null) fc.close();
-	}
-		    
-	return sb;	
+        FileChannel fc = null;
+        ShortBuffer sb = null;
+        try {
+            // Eclipse complains here about resource leak on 'fc' - even with 'finally' clause???
+            fc = new FileInputStream(file).getChannel();
+            // choose the right endianness
+
+            ByteBuffer bb = ByteBuffer.allocateDirect((int) fc.size());
+            while (bb.remaining() > 0) fc.read(bb);
+
+            bb.flip();
+            //sb = bb.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();
+            sb = bb.order(ByteOrder.BIG_ENDIAN).asShortBuffer();
+        } finally {
+            if (fc != null) fc.close();
+        }
+
+        return sb;
     }
-    
+
     /**
      * Reads the elevation value for the given coordinate.
@@ -116,40 +103,40 @@
      */
     public double readElevation(LatLon coor) {
-	String tag = getHgtFileName(coor);
-		
-	ShortBuffer sb = cache.get(tag);
-	
-	if (sb == null) {
-	    return ElevationHelper.NO_ELEVATION;
-	}
-	
-	// see http://gis.stackexchange.com/questions/43743/how-to-extract-elevation-from-hgt-file
-	double fLat = frac(coor.lat()) * SECONDS_PER_MINUTE;
-	double fLon = frac(coor.lon()) * SECONDS_PER_MINUTE;
-	
-	// compute offset within HGT file
-	int row = (int)Math.round(fLat * SECONDS_PER_MINUTE / HGT_RES); 
-	int col = (int)Math.round(fLon * SECONDS_PER_MINUTE / HGT_RES);
-	
-	row = HGT_ROW_LENGTH - row;
-	int cell = (HGT_ROW_LENGTH*  (row - 1)) + col;
-	
-	//System.out.println("Read SRTM elevation data from row/col/cell " + row + "," + col + ", " + cell + ", " + sb.limit());
+        String tag = getHgtFileName(coor);
 
-	// valid position in buffer?
-	if (cell < sb.limit()) {
-	    short ele = sb.get(cell);
-	    //System.out.println("==> Read SRTM elevation data from row/col/cell " + row + "," + col + ", " + cell + " = " + ele);
-	    // check for data voids 
-	    if (ele == HGT_VOID) {
-		return ElevationHelper.NO_ELEVATION;
-	    } else {
-		return ele;
-	    }
-	} else {
-	    return ElevationHelper.NO_ELEVATION;
-	}
+        ShortBuffer sb = cache.get(tag);
+
+        if (sb == null) {
+            return ElevationHelper.NO_ELEVATION;
+        }
+
+        // see http://gis.stackexchange.com/questions/43743/how-to-extract-elevation-from-hgt-file
+        double fLat = frac(coor.lat()) * SECONDS_PER_MINUTE;
+        double fLon = frac(coor.lon()) * SECONDS_PER_MINUTE;
+
+        // compute offset within HGT file
+        int row = (int)Math.round(fLat * SECONDS_PER_MINUTE / HGT_RES);
+        int col = (int)Math.round(fLon * SECONDS_PER_MINUTE / HGT_RES);
+
+        row = HGT_ROW_LENGTH - row;
+        int cell = (HGT_ROW_LENGTH*  (row - 1)) + col;
+
+        //System.out.println("Read SRTM elevation data from row/col/cell " + row + "," + col + ", " + cell + ", " + sb.limit());
+
+        // valid position in buffer?
+        if (cell < sb.limit()) {
+            short ele = sb.get(cell);
+            //System.out.println("==> Read SRTM elevation data from row/col/cell " + row + "," + col + ", " + cell + " = " + ele);
+            // check for data voids
+            if (ele == HGT_VOID) {
+                return ElevationHelper.NO_ELEVATION;
+            } else {
+                return ele;
+            }
+        } else {
+            return ElevationHelper.NO_ELEVATION;
+        }
     }
-    
+
     /**
      * Gets the associated HGT file name for the given way point. Usually the
@@ -161,26 +148,26 @@
      */
     public String getHgtFileName(LatLon latLon) {
-	int lat = (int) latLon.lat();
-	int lon = (int) latLon.lon();
-	
-	String latPref = "N";
-	if (lat < 0) latPref = "S";
-	
-	String lonPref = "E";
-	if (lon < 0) {
-	    lonPref = "W";
-	}
-	
-	return String.format("%s%02d%s%03d%s", latPref, lat, lonPref, lon, HGT_EXT);
+        int lat = (int) latLon.lat();
+        int lon = (int) latLon.lon();
+
+        String latPref = "N";
+        if (lat < 0) latPref = "S";
+
+        String lonPref = "E";
+        if (lon < 0) {
+            lonPref = "W";
+        }
+
+        return String.format("%s%02d%s%03d%s", latPref, lat, lonPref, lon, HGT_EXT);
     }
-    
+
     public static double frac(double d) {
-	long iPart;
-	double fPart;
+        long iPart;
+        double fPart;
 
-	// Get user input
-	iPart = (long) d;
-	fPart = d - iPart;
-	return fPart;
+        // Get user input
+        iPart = (long) d;
+        fPart = d - iPart;
+        return fPart;
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IEleRenderingListener.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IEleRenderingListener.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IEleRenderingListener.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -17,5 +5,5 @@
 
 public interface IEleRenderingListener {
-    
+
     /**
      * Notifies client that an elevation vertex has been finished for rendering.
@@ -24,5 +12,5 @@
      */
     public void finished(EleVertex vertex);
-    
+
     /**
      * Notifies a client that all vertices can be rendered now.
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModel.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModel.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModel.java	(revision 30344)
@@ -1,6 +1,6 @@
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
 import java.util.List;
-
 
 public interface IElevationModel {
@@ -33,5 +33,5 @@
      */
     public abstract List<IElevationProfile> getProfiles();
-    
+
     /**
      * Gets the current profile.
@@ -40,5 +40,5 @@
      */
     public abstract IElevationProfile getCurrentProfile();
-    
+
     /**
      * Sets the current profile.
@@ -47,5 +47,5 @@
      */
     public abstract void setCurrentProfile(IElevationProfile newProfile);
-    
+
     /**
      * Sets the current profile by index.
@@ -54,5 +54,5 @@
      */
     public abstract void setCurrentProfile(int index);
-    
+
     /**
      * Gets the number of elevation profiles within the model.
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -18,5 +5,5 @@
 
 /**
- * This interface is intended to allow clients reaction on changes in the elevation model changes (e. g. 
+ * This interface is intended to allow clients reaction on changes in the elevation model changes (e. g.
  * repaint UI widgets).
  * {@link ElevationModel}
@@ -24,8 +11,8 @@
  */
 public interface IElevationModelListener {
-	/**
-	 * Notifies listeners that the selected track has been changed.
-	 * @param model The model changed.
-	 */
-	void elevationProfileChanged(IElevationProfile model);
+    /**
+     * Notifies listeners that the selected track has been changed.
+     * @param model The model changed.
+     */
+    void elevationProfileChanged(IElevationProfile model);
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -26,133 +13,133 @@
  */
 public interface IElevationProfile {
-	/**
-	 * Gets the name of the elevation profile.
-	 * @return
-	 */
-	public abstract String getName();
-	
-	/**
-	 * Gets the time stamp of first recorded track point.
-	 * @return
-	 */
-	public abstract Date getStart();
+    /**
+     * Gets the name of the elevation profile.
+     * @return
+     */
+    public abstract String getName();
 
-	/**
-	 * Gets the time stamp of last recorded track point.
-	 * @return
-	 */
-	public abstract Date getEnd();
-	
-	/**
-	 * Gets the minimum elevation height of all tracks and routes.
-	 * @return
-	 */
-	public abstract int getMinHeight();
+    /**
+     * Gets the time stamp of first recorded track point.
+     * @return
+     */
+    public abstract Date getStart();
 
-	/**
-	 * Gets the maximum elevation height of all tracks and routes.
-	 * @return
-	 */
-	public abstract int getMaxHeight();
-	
-	/**
-	 * Gets the distance of the track in kilometers.
-	 */
-	public abstract double getDistance();
-	
-	/**
-	 * Gets the average elevation height of all tracks and routes.
-	 * @return
-	 */
-	public abstract int getAverageHeight();
-	
-	/**
-	 * Gets the difference between min and max elevation.
-	 * @return
-	 */
-	public int getHeightDifference();
-	
-	/**
-	 * Gets the elevation gain.
-	 * 
-	 * @return
-	 */
-	public int getGain();
+    /**
+     * Gets the time stamp of last recorded track point.
+     * @return
+     */
+    public abstract Date getEnd();
 
-	/**
-	 * Gets the total number of way points (sum of all way points of all tracks and routes). 
-	 * @return
-	 */
-	public abstract int getNumberOfWayPoints();
-	
-	/**
-	 * Gets the list containing the way points.
-	 * @return
-	 */
-	public List<WayPoint> getWayPoints();
-	
-	/**
-	 * Gets the first recorded way point.
-	 * @return
-	 */
-	public WayPoint getStartWayPoint();
-	
-	/**
-	 * Gets the last recorded way point.
-	 * @return
-	 */
-	public WayPoint getEndWayPoint();
-	
-	/**
-	 * Gets the way point with the highest elevation value.
-	 * @return
-	 */
-	public WayPoint getMaxWayPoint();
-	
-	/**
-	 * Gets the way point with the lowest elevation value.
-	 * @return
-	 */
-	public WayPoint getMinWayPoint();
-	
-	/**
-	 * Gets a flag indicating whether the associated way points 
-	 * contained elevation data or not. This is the case if min
-	 * and max height are equal.
-	 * @return
-	 */
-	public boolean hasElevationData();
+    /**
+     * Gets the minimum elevation height of all tracks and routes.
+     * @return
+     */
+    public abstract int getMinHeight();
 
-	/**
-	 * Returns the time between start and end of the track.
-	 * @return
-	 */
-	public long getTimeDifference();
-	
-	/**
-	 * Gets the elevation value for at the given data index point.
-	 */
-	public int elevationValueAt(int i);
-	
-	/**
-	 * Gets the coordinate bounds of the elevation profile.
-	 *
-	 * @return the bounds
-	 */
-	public Bounds getBounds();
-	
-	/**
-	 * Gets the children of the segment (maybe null).
-	 */
-	public List<IElevationProfile> getChildren();
-	
-	/**
-	 * Gets the parent of the elevation profile.
-	 */
-	public IElevationProfile getParent();
-	
-	/**
-	 * Triggers model refresh.
-	 */
-	public void updateElevationData();
+    /**
+     * Gets the maximum elevation height of all tracks and routes.
+     * @return
+     */
+    public abstract int getMaxHeight();
+
+    /**
+     * Gets the distance of the track in kilometers.
+     */
+    public abstract double getDistance();
+
+    /**
+     * Gets the average elevation height of all tracks and routes.
+     * @return
+     */
+    public abstract int getAverageHeight();
+
+    /**
+     * Gets the difference between min and max elevation.
+     * @return
+     */
+    public int getHeightDifference();
+
+    /**
+     * Gets the elevation gain.
+     * 
+     * @return
+     */
+    public int getGain();
+
+    /**
+     * Gets the total number of way points (sum of all way points of all tracks and routes).
+     * @return
+     */
+    public abstract int getNumberOfWayPoints();
+
+    /**
+     * Gets the list containing the way points.
+     * @return
+     */
+    public List<WayPoint> getWayPoints();
+
+    /**
+     * Gets the first recorded way point.
+     * @return
+     */
+    public WayPoint getStartWayPoint();
+
+    /**
+     * Gets the last recorded way point.
+     * @return
+     */
+    public WayPoint getEndWayPoint();
+
+    /**
+     * Gets the way point with the highest elevation value.
+     * @return
+     */
+    public WayPoint getMaxWayPoint();
+
+    /**
+     * Gets the way point with the lowest elevation value.
+     * @return
+     */
+    public WayPoint getMinWayPoint();
+
+    /**
+     * Gets a flag indicating whether the associated way points
+     * contained elevation data or not. This is the case if min
+     * and max height are equal.
+     * @return
+     */
+    public boolean hasElevationData();
+
+    /**
+     * Returns the time between start and end of the track.
+     * @return
+     */
+    public long getTimeDifference();
+
+    /**
+     * Gets the elevation value for at the given data index point.
+     */
+    public int elevationValueAt(int i);
+
+    /**
+     * Gets the coordinate bounds of the elevation profile.
+     *
+     * @return the bounds
+     */
+    public Bounds getBounds();
+
+    /**
+     * Gets the children of the segment (maybe null).
+     */
+    public List<IElevationProfile> getChildren();
+
+    /**
+     * Gets the parent of the elevation profile.
+     */
+    public IElevationProfile getParent();
+
+    /**
+     * Triggers model refresh.
+     */
+    public void updateElevationData();
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IVertexRenderer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IVertexRenderer.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IVertexRenderer.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -24,5 +12,5 @@
  */
 public interface IVertexRenderer {
-    
+
     /**
      * Gets the color according to the given elevation.
@@ -32,5 +20,5 @@
      */
     public Color getElevationColor(EleVertex vertex);
-    
+
     /**
      * Selects color map with the given name. If no
@@ -40,4 +28,4 @@
      */
     public void selectColorMap(String name);
-   
+
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/UnitMode.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/UnitMode.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/UnitMode.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation;
 
@@ -20,7 +7,7 @@
  */
 public enum UnitMode {
-	NotSelected,
-	Metric,
-	Imperial
-	// Chinese system missing 
+    NotSelected,
+    Metric,
+    Imperial
+    // Chinese system missing
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/actions/AddElevationLayerAction.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/actions/AddElevationLayerAction.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/actions/AddElevationLayerAction.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.actions;
 
@@ -25,22 +13,20 @@
 public class AddElevationLayerAction extends JosmAction {
 
-    /**
-     * 
-     */
-    private static final long serialVersionUID = -745642875640041385L;
-    private Layer currentLayer;
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -745642875640041385L;
+	private Layer currentLayer;
 
-    public AddElevationLayerAction() {
-	super(tr("Elevation Grid Layer (experimental!)"), "elevation", tr("Shows elevation grid layer"), null, true);
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent arg0) {
-	if (currentLayer == null) {
-	    currentLayer = new ElevationGridLayer(tr("Elevation Grid")); // TODO: Better name
-	    Main.main.addLayer(currentLayer);
+	public AddElevationLayerAction() {
+		super(tr("Elevation Grid Layer (experimental!)"), "elevation", tr("Shows elevation grid layer"), null, true);
 	}
 
-    }
-
+	@Override
+	public void actionPerformed(ActionEvent arg0) {
+		if (currentLayer == null) {
+			currentLayer = new ElevationGridLayer(tr("Elevation Grid")); // TODO: Better name
+			Main.main.addLayer(currentLayer);
+		}
+	}
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
@@ -37,278 +24,222 @@
  */
 public class ElevationModel implements IGpxVisitor, IElevationModel {
-	// private int sliceSize;
-	private int trackCounter;
-	private GpxData gpxData;
-	private String name;
-	private WayPointMap profiles = new WayPointMap(); 
-	private List<IElevationModelListener> listeners = new ArrayList<IElevationModelListener>();
-	private List<WayPoint> buffer = new ArrayList<WayPoint>();
-	private int currentProfileIndex = 0;
-	private ElevationProfile curProfile = null;
-
-	/**
-	 * Instantiates a new elevation model.
-	 */
-	public ElevationModel() {
-		this("", null);
-	}
-
-	/**
-	 * Instantiates a new elevation model.
-	 *
-	 * @param name the name of the model
-	 * @param data the GPX data
-	 */
-	public ElevationModel(String name, GpxData data) {
-		gpxData = data;
-		this.name = name;
-		GpxIterator.visit(data, this);		
-	}
-
-	/**
-	 * Gets the GPX data instance used by this model.
-	 * 
-	 * @return
-	 */
-	public GpxData getGpxData() {
-		return gpxData;
-	}
-	
-	/**
-	 * @return the tracks
-	 */
-	protected WayPointMap getTracks() {
-		return profiles;
-	}
-
-	/**
-	 * Fires the 'model changed' event to all listeners.
-	 */
-	protected void fireModelChanged() {	    	
-		for (IElevationModelListener listener : listeners) {
-		    if (profiles != null && profiles.size() > 0)
-			listener.elevationProfileChanged(getCurrentProfile());
-		}
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#addModelListener(org.openstreetmap.josm.plugins.elevation.IElevationModelListener)
-	 */
-	@Override
-	public void addModelListener(IElevationModelListener listener) {
-		this.listeners.add(listener);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#removeModelListener(org.openstreetmap.josm.plugins.elevation.IElevationModelListener)
-	 */
-	@Override
-	public void removeModelListener(IElevationModelListener listener) {
-		this.listeners.remove(listener);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#removeAllListeners()
-	 */
-	@Override
-	public void removeAllListeners() {
-		this.listeners.clear();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#getProfiles()
-	 */
-	@Override
-	public List<IElevationProfile> getProfiles() {
-		return profiles;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationModel#getCurrentProfile()
-	 */
-	@Override
-	public IElevationProfile getCurrentProfile() {
-	    if (currentProfileIndex < 0 || currentProfileIndex >= profileCount()) return null;
-	    
-	    return profiles.get(currentProfileIndex);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationModel#setCurrentProfile(org.openstreetmap.josm.plugins.elevation.IElevationProfile)
-	 */
-	@Override
-	public void setCurrentProfile(IElevationProfile newProfile) {
-	    CheckParameterUtil.ensureParameterNotNull(newProfile);
-	    
-	    if (!profiles.contains(newProfile)) {
-		profiles.add(newProfile);
-	    }
-	    
-	    setCurrentProfile(profiles.indexOf(newProfile)); 
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationModel#setCurrentProfile(int)
-	 */
-	@Override
-	public void setCurrentProfile(int index) {
-	    if (index < 0 || index >= profileCount()) throw new RuntimeException("Invalid arg for setCurrentProfile: " + index + ", value must be 0.." + profileCount());
-	    
-	    currentProfileIndex = index;
-	    fireModelChanged();	    
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationModel#profileCount()
-	 */
-	@Override
-	public int profileCount() {
-	    return profiles != null ? profiles.size() : 0;
-	}
-
-	// Visitor stuff starts here...
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#beginWayPoints()
-	 */
-	public void beginWayPoints() {
-	    // we ignore single way points (elevation profile is quite meaningless...)
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#endWayPoints()
-	 */
-	public void endWayPoints() {		
-	    // we ignore single way points (elevation profile is quite meaningless...)
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.ElevationProfileBase#visit(org.openstreetmap.josm.data.gpx.WayPoint)
-	 */
-	@Override
-	public void visitWayPoint(WayPoint wp) {
-	    // we ignore single way points (elevation profile is quite meaningless...)
-	}
-
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#beginTrack(org.openstreetmap.josm.data.gpx.GpxTrack)
-	 */
-	@Override
-	public void beginTrack(GpxTrack track) {
-	    createProfile(track);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#endTrack(org.openstreetmap.josm.data.gpx.GpxTrack)
-	 */
-	@Override
-	public void endTrack(GpxTrack track) {
-	    if (curProfile == null) throw new RuntimeException("Internal error: No elevation profile");
-	    
-	    curProfile.setDistance(track.length());
-	    commitProfile();
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#beginTrackSegment(org.openstreetmap.josm.data.gpx.GpxTrack, org.openstreetmap.josm.data.gpx.GpxTrackSegment)
-	 */
-	@Override
-	public void beginTrackSegment(GpxTrack track, GpxTrackSegment segment) {
-	    // Nothing to do here for now
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#endTrackSegment(org.openstreetmap.josm.data.gpx.GpxTrack, org.openstreetmap.josm.data.gpx.GpxTrackSegment)
-	 */
-	@Override
-	public void endTrackSegment(GpxTrack track, GpxTrackSegment segment) {
-	    // Nothing to do here for now
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#visitTrackPoint(org.openstreetmap.josm.data.gpx.WayPoint, org.openstreetmap.josm.data.gpx.GpxTrack, org.openstreetmap.josm.data.gpx.GpxTrackSegment)
-	 */
-	@Override
-	public void visitTrackPoint(WayPoint wp, GpxTrack track,
-		GpxTrackSegment segment) {
-	    
-	    processWayPoint(wp);	    
-	}
-	
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#beginRoute(org.openstreetmap.josm.data.gpx.GpxRoute)
-	 */
-	@Override
-	public void beginRoute(GpxRoute route) {
-	    createProfile(route);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#endRoute(org.openstreetmap.josm.data.gpx.GpxRoute)
-	 */
-	@Override
-	public void endRoute(GpxRoute route) {
-	    if (curProfile == null) throw new RuntimeException("Internal error: No elevation profile");
-	    // a GpxRoute has no 'length' property 
-	    curProfile.setDistance(0);
-	    commitProfile();
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IGpxVisitor#visitRoutePoint(org.openstreetmap.josm.data.gpx.WayPoint, org.openstreetmap.josm.data.gpx.GpxRoute)
-	 */
-	@Override
-	public void visitRoutePoint(WayPoint wp, GpxRoute route) {
-	    processWayPoint(wp);	    
-	}
-	
-	/**
-	 * Creates a new profile.
-	 *
-	 * @param trackOrRoute the track or route
-	 */
-	private void createProfile(IWithAttributes trackOrRoute) {
-	    // check GPX data 
-	    String trackName = (String) trackOrRoute.get("name");
-	    
-	    if (trackName == null) {
-		trackName = (String) trackOrRoute.get(GpxData.META_NAME);
-		if (trackName == null) {
-		    // no name given, build artificial one
-		    trackName = name + "." + trackCounter;
-		}
-	    }
-	    
-	    curProfile = new ElevationProfile(trackName);
-	}
-	
-	/**
-	 * Adds a track or route to the internal track list.
-	 *
-	 * @param trackName the track name
-	 */
-	private void commitProfile() {
-	    	if (buffer.size() > 0) {    
-	    	    	// assign way points to profile...
-        		curProfile.setWayPoints(buffer);
-        		// ... and add to profile list
-        		profiles.add(curProfile);
-        		buffer.clear();
-	    	}
-	}
-
-	/**
-	 * Adds the given way point to the current buffer.
-	 *
-	 * @param wp the wp
-	 */
-	private void processWayPoint(WayPoint wp) {
-		if (wp == null) {
-			throw new RuntimeException("WPT must not be null!");
-		}
-		
-		buffer.add(wp);
-	}
+    // private int sliceSize;
+    private int trackCounter;
+    private final GpxData gpxData;
+    private final String name;
+    private final WayPointMap profiles = new WayPointMap();
+    private final List<IElevationModelListener> listeners = new ArrayList<IElevationModelListener>();
+    private final List<WayPoint> buffer = new ArrayList<WayPoint>();
+    private int currentProfileIndex = 0;
+    private ElevationProfile curProfile = null;
+
+    /**
+     * Instantiates a new elevation model.
+     */
+    public ElevationModel() {
+        this("", null);
+    }
+
+    /**
+     * Instantiates a new elevation model.
+     *
+     * @param name the name of the model
+     * @param data the GPX data
+     */
+    public ElevationModel(String name, GpxData data) {
+        gpxData = data;
+        this.name = name;
+        GpxIterator.visit(data, this);
+    }
+
+    /**
+     * Gets the GPX data instance used by this model.
+     * 
+     * @return
+     */
+    public GpxData getGpxData() {
+        return gpxData;
+    }
+
+    /**
+     * @return the tracks
+     */
+    protected WayPointMap getTracks() {
+        return profiles;
+    }
+
+    /**
+     * Fires the 'model changed' event to all listeners.
+     */
+    protected void fireModelChanged() {
+        for (IElevationModelListener listener : listeners) {
+            if (profiles != null && profiles.size() > 0)
+                listener.elevationProfileChanged(getCurrentProfile());
+        }
+    }
+
+    @Override
+    public void addModelListener(IElevationModelListener listener) {
+        this.listeners.add(listener);
+    }
+
+    @Override
+    public void removeModelListener(IElevationModelListener listener) {
+        this.listeners.remove(listener);
+    }
+
+    @Override
+    public void removeAllListeners() {
+        this.listeners.clear();
+    }
+
+    @Override
+    public List<IElevationProfile> getProfiles() {
+        return profiles;
+    }
+
+    @Override
+    public IElevationProfile getCurrentProfile() {
+        if (currentProfileIndex < 0 || currentProfileIndex >= profileCount()) return null;
+
+        return profiles.get(currentProfileIndex);
+    }
+
+    @Override
+    public void setCurrentProfile(IElevationProfile newProfile) {
+        CheckParameterUtil.ensureParameterNotNull(newProfile);
+
+        if (!profiles.contains(newProfile)) {
+            profiles.add(newProfile);
+        }
+
+        setCurrentProfile(profiles.indexOf(newProfile));
+    }
+
+    @Override
+    public void setCurrentProfile(int index) {
+        if (index < 0 || index >= profileCount()) throw new RuntimeException("Invalid arg for setCurrentProfile: " + index + ", value must be 0.." + profileCount());
+
+        currentProfileIndex = index;
+        fireModelChanged();
+    }
+
+    @Override
+    public int profileCount() {
+        return profiles != null ? profiles.size() : 0;
+    }
+
+    // Visitor stuff starts here...
+
+    @Override
+    public void beginWayPoints() {
+        // we ignore single way points (elevation profile is quite meaningless...)
+    }
+
+    @Override
+    public void endWayPoints() {
+        // we ignore single way points (elevation profile is quite meaningless...)
+    }
+
+    @Override
+    public void visitWayPoint(WayPoint wp) {
+        // we ignore single way points (elevation profile is quite meaningless...)
+    }
+
+
+    @Override
+    public void beginTrack(GpxTrack track) {
+        createProfile(track);
+    }
+
+    @Override
+    public void endTrack(GpxTrack track) {
+        if (curProfile == null) throw new RuntimeException("Internal error: No elevation profile");
+
+        curProfile.setDistance(track.length());
+        commitProfile();
+    }
+
+    @Override
+    public void beginTrackSegment(GpxTrack track, GpxTrackSegment segment) {
+        // Nothing to do here for now
+    }
+
+    @Override
+    public void endTrackSegment(GpxTrack track, GpxTrackSegment segment) {
+        // Nothing to do here for now
+    }
+
+    @Override
+    public void visitTrackPoint(WayPoint wp, GpxTrack track,
+            GpxTrackSegment segment) {
+
+        processWayPoint(wp);
+    }
+
+    @Override
+    public void beginRoute(GpxRoute route) {
+        createProfile(route);
+    }
+
+    @Override
+    public void endRoute(GpxRoute route) {
+        if (curProfile == null) throw new RuntimeException("Internal error: No elevation profile");
+        // a GpxRoute has no 'length' property
+        curProfile.setDistance(0);
+        commitProfile();
+    }
+
+    @Override
+    public void visitRoutePoint(WayPoint wp, GpxRoute route) {
+        processWayPoint(wp);
+    }
+
+    /**
+     * Creates a new profile.
+     *
+     * @param trackOrRoute the track or route
+     */
+    private void createProfile(IWithAttributes trackOrRoute) {
+        // check GPX data
+        String trackName = (String) trackOrRoute.get("name");
+
+        if (trackName == null) {
+            trackName = (String) trackOrRoute.get(GpxData.META_NAME);
+            if (trackName == null) {
+                // no name given, build artificial one
+                trackName = name + "." + trackCounter;
+            }
+        }
+
+        curProfile = new ElevationProfile(trackName);
+    }
+
+    /**
+     * Adds a track or route to the internal track list.
+     *
+     * @param trackName the track name
+     */
+    private void commitProfile() {
+        if (buffer.size() > 0) {
+            // assign way points to profile...
+            curProfile.setWayPoints(buffer);
+            // ... and add to profile list
+            profiles.add(curProfile);
+            buffer.clear();
+        }
+    }
+
+    /**
+     * Adds the given way point to the current buffer.
+     *
+     * @param wp the wp
+     */
+    private void processWayPoint(WayPoint wp) {
+        if (wp == null) {
+            throw new RuntimeException("WPT must not be null!");
+        }
+
+        buffer.add(wp);
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfile.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfile.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfile.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
@@ -23,4 +10,5 @@
 import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
+
 
 /**
@@ -45,485 +33,404 @@
  */
 public class ElevationProfile implements IElevationProfile,
-		IGpxWaypointVisitor {
-	public static final int WAYPOINT_START = 0;
-	public static final int WAYPOINT_END = 1;
-	public static final int WAYPOINT_MIN = 2;
-	public static final int WAYPOINT_MAX = 3;
-
-	private String name;
-	private int minHeight;
-	private int maxHeight;
-	private int avrgHeight;
-	private double dist;
-	private Date start = new Date();
-	private Date end = new Date();
-	private WayPoint[] importantWayPoints = new WayPoint[4];
-	private IElevationProfile parent;
-	private int sumEle; // temp var for average height
-	private List<WayPoint> wayPoints;
-	private int numWayPoints; // cached value
-	private int gain;
-	private int lastEle;
-	private Bounds bounds;
-	
-	private static boolean ignoreZeroHeight = true;
-
-	/**
-	 * Creates a name elevation profile without any way points.
-	 * 
-	 * @param name
-	 */
-	public ElevationProfile(String name) {
-		this(name, null, null, 0);
-	}
-
-	/**
-	 * Creates a name elevation profile with a given set of way points.
-	 * 
-	 * @param name
-	 *            The name of the profile.
-	 * @param parent
-	 *            The (optional) parent profile.
-	 * @param wayPoints
-	 *            The list containing the way points of the profile.
-	 * @param sliceSize
-	 *            The requested target size of the profile.
-	 */
-	public ElevationProfile(String name, IElevationProfile parent,
-			List<WayPoint> wayPoints, int sliceSize) {
-		super();
-		this.name = name;
-		this.parent = parent;
-		
-		setWayPoints(wayPoints);
-	}
-
-	/**
-	 * Checks if zero elevation should be ignored or not.
-	 *
-	 * @return true, if is ignore zero height
-	 */
-	public static boolean isIgnoreZeroHeight() {
-		return ignoreZeroHeight;
-	}
-
-	/**
-	 * Sets the ignore zero height.
-	 *
-	 * @param ignoreZeroHeight the new ignore zero height
-	 */
-	public static void setIgnoreZeroHeight(boolean ignoreZeroHeight) {
-		ElevationProfile.ignoreZeroHeight = ignoreZeroHeight;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#invalidateModel
-	 * (int)
-	 */
-	public void updateElevationData() {
-		updateValues();
-	}
-
-	/**
-	 * Revisits all way points and recomputes the characteristic values like
-	 * min/max elevation.
-	 */
-	protected void updateValues() {
-		if (wayPoints == null)
-			return;
-		
-		int n = this.wayPoints.size(); 
-		if (n == 0)
-			return;
-
-		start = new Date();		
-		end = new Date(0L);
-		this.minHeight = Integer.MAX_VALUE;
-		this.maxHeight = Integer.MIN_VALUE;
-		sumEle = 0;
-		gain = 0;
-		lastEle = 0;
-		
-		for (WayPoint wayPoint : this.wayPoints) {
-			visitWayPoint(wayPoint);
-		}
-		
-		if (this.minHeight == Integer.MAX_VALUE && this.maxHeight == Integer.MIN_VALUE) {
-			// file does not contain elevation data	at all
-			minHeight = 0;
-			maxHeight = 0;
-			setMinWayPoint(wayPoints.get(0));
-			setMaxWayPoint(wayPoints.get(n-1));
-		}		
-		
-		//if (start.after(end) || start.equals(end)) {
-			// GPX does not contain time stamps -> use sequential order
-			setStart(wayPoints.get(0));
-			setEnd(wayPoints.get(n-1));
-		//}
-		
-		avrgHeight = sumEle / n;
-	}
-
-	/**
-	 * Gets the name of the profile. 
-	 */
-	public String getName() {
-		return name;
-	}
-
-	/**
-	 * Sets the name of the profile.
-	 * @param name The new name of the profile.
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	/**
-	 * Sets the way point with the lowest elevation.
-	 * @param wp The way point instance having the lowest elevation.
-	 */
-	protected void setMinWayPoint(WayPoint wp) {
-		importantWayPoints[WAYPOINT_MIN] = wp;
-		this.minHeight = (int) ElevationHelper.getElevation(wp);
-	}
-
-	/**
-	 * Sets the way point with the highest elevation.
-	 * @param wp The way point instance having the highest elevation.
-	 */
-	protected void setMaxWayPoint(WayPoint wp) {
-		importantWayPoints[WAYPOINT_MAX] = wp;
-		this.maxHeight = (int) ElevationHelper.getElevation(wp);
-	}
-
-	/**
-	 * Sets the average height.
-	 * @param avrgHeight
-	 */
-	protected void setAvrgHeight(int avrgHeight) {
-		this.avrgHeight = avrgHeight;
-	}
-
-	/**
-	 * Sets the very first way point. 
-	 * @param wp
-	 */
-	protected void setStart(WayPoint wp) {
-		importantWayPoints[WAYPOINT_START] = wp;
-		this.start = wp.getTime();
-	}
-
-	/**
-	 * Sets the very last way point.
-	 * @param wp
-	 */
-	protected void setEnd(WayPoint wp) {
-		importantWayPoints[WAYPOINT_END] = wp;
-		this.end = wp.getTime();
-	}
-
-	public void setParent(IElevationProfile parent) {
-		this.parent = parent;
-	}
-
-	/**
-	 * Sets the way points of this profile.
-	 * 
-	 * @param wayPoints
-	 */
-	public void setWayPoints(List<WayPoint> wayPoints) {
-		if (this.wayPoints != wayPoints) {
-			this.wayPoints = new ArrayList<WayPoint>(wayPoints);
-			numWayPoints = wayPoints != null ? wayPoints.size() : 0;
-			updateValues();
-			
-		}
-	}
-
-	/**
-	 * Checks if the given index is valid or not.
-	 * 
-	 * @param index
-	 *            The index to check.
-	 * @return true, if the given index is valid; otherwise false.
-	 */
-	protected boolean checkIndex(int index) {
-		return index >= 0 && index < getNumberOfWayPoints();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#elevationValueAt
-	 * (int)
-	 */
-	public int elevationValueAt(int i) {
-		if (checkIndex(i)) {
-			return (int) ElevationHelper.getElevation(wayPoints.get(i));
-		} else {
-			throw new IndexOutOfBoundsException(String.format(
-					"Invalid index: %d, expected 0..%d", i,
-					getNumberOfWayPoints()));
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getAverageHeight
-	 * ()
-	 */
-	public int getAverageHeight() {
-		return avrgHeight;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getChildren()
-	 */
-	public List<IElevationProfile> getChildren() {
-	    return null;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationProfile#getEnd()
-	 */
-	public Date getEnd() {
-		return end;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getMaxHeight()
-	 */
-	public int getMaxHeight() {
-		return maxHeight;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getMinHeight()
-	 */
-	public int getMinHeight() {
-		return minHeight;
-	}
-
-	/**
-	 * Gets the difference between min and max elevation.
-	 * 
-	 * @return
-	 */
-	public int getHeightDifference() {
-		return maxHeight - minHeight;		
-	}
-	
-	/**
-	 * Gets the elevation gain.
-	 * 
-	 * @return
-	 */
-	public int getGain() {
-		return gain;
-	}
-	
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationProfile#getDistance()
-	 */
-	@Override
-	public double getDistance() {
-		return dist; // dist is in meters
-	}
-	
-	/**
-	 * Sets the distance of the elevation profile.
-	 * @param dist
-	 */
-	protected void setDistance(double dist) {
-		this.dist = dist; 
-	}
-
-	/**
-	 * Returns the time between start and end of the track.
-	 * @return
-	 */
-	public long getTimeDifference() {
-		WayPoint wp1 = getStartWayPoint();
-		WayPoint wp2 = getEndWayPoint();
-		
-		if (wp1 != null && wp2 != null) {
-			long diff = wp2.getTime().getTime() - wp1.getTime().getTime();
-			return diff;
-		}
-		
-		return 0L;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getParent()
-	 */
-	public IElevationProfile getParent() {
-		return parent;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getStart()
-	 */
-
-	public Date getStart() {
-		return start;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getEndWayPoint
-	 * ()
-	 */
-
-	public WayPoint getEndWayPoint() {
-		return importantWayPoints[WAYPOINT_END];
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getMaxWayPoint
-	 * ()
-	 */
-
-	public WayPoint getMaxWayPoint() {
-		return importantWayPoints[WAYPOINT_MAX];
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getMinWayPoint
-	 * ()
-	 */
-
-	public WayPoint getMinWayPoint() {
-		return importantWayPoints[WAYPOINT_MIN];
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getStartWayPoint
-	 * ()
-	 */
-	public WayPoint getStartWayPoint() {
-		return importantWayPoints[WAYPOINT_START];
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getWayPoints()
-	 */
-	public List<WayPoint> getWayPoints() {
-		return wayPoints;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seeorg.openstreetmap.josm.plugins.elevation.ElevationProfileBase#
-	 * getNumberOfWayPoints()
-	 */
-	public int getNumberOfWayPoints() {
-		return numWayPoints;// wayPoints != null ? wayPoints.size() : 0;
-	}
-	
-	/**
-	 * Gets the coordinate bounds of this profile. See {@link Bounds} for details.
-	 *
-	 * @return the bounds of this elevation profile
-	 */
-	public Bounds getBounds() {
-	    return bounds;
-	}
-
-	/**
-	 * Gets a flag indicating whether the associated way points contained
-	 * elevation data or not. This is the case if min and max height or both
-	 * zero.
-	 * 
-	 * @return
-	 */
-	public boolean hasElevationData() {
-		return minHeight != maxHeight;
-	}
-
-	/**
-	 * Visits a way point in order to update statistical values about the given
-	 * way point list.
-	 */
-	public void visitWayPoint(WayPoint wp) {
-		if (wp.getTime().after(end)) {
-			setEnd(wp);
-		}
-
-		if (wp.getTime().before(start)) {
-			setStart(wp);
-		}
-
-		// update boundaries
-		if (bounds == null) {
-		    bounds = new Bounds(wp.getCoor());
-		} else {
-		    bounds.extend(wp.getCoor());
-		}
-		
-		int ele = (int) ElevationHelper.getElevation(wp);
-
-		if (!isIgnoreZeroHeight() || ele > 0) {
-			if (ele > maxHeight) {
-				setMaxWayPoint(wp);
-			}
-			if (ele < minHeight) {
-				setMinWayPoint(wp);
-			}
-			
-			if (ele > lastEle) {
-				gain += ele - lastEle;
-			}
-
-			sumEle += ele;
-			lastEle = ele;			
-		}
-	}
-	
-	public String toString() {
-		return name; /*"ElevationProfileBase [start=" + getStart() + ", end=" + getEnd()
-				+ ", minHeight=" + getMinHeight() + ", maxHeight="
-				+ getMaxHeight() + "]";*/
-	}
+IGpxWaypointVisitor {
+    public static final int WAYPOINT_START = 0;
+    public static final int WAYPOINT_END = 1;
+    public static final int WAYPOINT_MIN = 2;
+    public static final int WAYPOINT_MAX = 3;
+
+    private String name;
+    private int minHeight;
+    private int maxHeight;
+    private int avrgHeight;
+    private double dist;
+    private Date start = new Date();
+    private Date end = new Date();
+    private final WayPoint[] importantWayPoints = new WayPoint[4];
+    private IElevationProfile parent;
+    private int sumEle; // temp var for average height
+    private List<WayPoint> wayPoints;
+    private int numWayPoints; // cached value
+    private int gain;
+    private int lastEle;
+    private Bounds bounds;
+
+    private static boolean ignoreZeroHeight = true;
+
+    /**
+     * Creates a name elevation profile without any way points.
+     * 
+     * @param name
+     */
+    public ElevationProfile(String name) {
+        this(name, null, null, 0);
+    }
+
+    /**
+     * Creates a name elevation profile with a given set of way points.
+     * 
+     * @param name
+     *            The name of the profile.
+     * @param parent
+     *            The (optional) parent profile.
+     * @param wayPoints
+     *            The list containing the way points of the profile.
+     * @param sliceSize
+     *            The requested target size of the profile.
+     */
+    public ElevationProfile(String name, IElevationProfile parent,
+            List<WayPoint> wayPoints, int sliceSize) {
+        super();
+        this.name = name;
+        this.parent = parent;
+
+        setWayPoints(wayPoints);
+    }
+
+    /**
+     * Checks if zero elevation should be ignored or not.
+     *
+     * @return true, if is ignore zero height
+     */
+    public static boolean isIgnoreZeroHeight() {
+        return ignoreZeroHeight;
+    }
+
+    /**
+     * Sets the ignore zero height.
+     *
+     * @param ignoreZeroHeight the new ignore zero height
+     */
+    public static void setIgnoreZeroHeight(boolean ignoreZeroHeight) {
+        ElevationProfile.ignoreZeroHeight = ignoreZeroHeight;
+    }
+
+    @Override
+    public void updateElevationData() {
+        updateValues();
+    }
+
+    /**
+     * Revisits all way points and recomputes the characteristic values like
+     * min/max elevation.
+     */
+    protected void updateValues() {
+        if (wayPoints == null)
+            return;
+
+        int n = this.wayPoints.size();
+        if (n == 0)
+            return;
+
+        start = new Date();
+        end = new Date(0L);
+        this.minHeight = Integer.MAX_VALUE;
+        this.maxHeight = Integer.MIN_VALUE;
+        sumEle = 0;
+        gain = 0;
+        lastEle = 0;
+
+        for (WayPoint wayPoint : this.wayPoints) {
+            visitWayPoint(wayPoint);
+        }
+
+        if (this.minHeight == Integer.MAX_VALUE && this.maxHeight == Integer.MIN_VALUE) {
+            // file does not contain elevation data    at all
+            minHeight = 0;
+            maxHeight = 0;
+            setMinWayPoint(wayPoints.get(0));
+            setMaxWayPoint(wayPoints.get(n-1));
+        }
+
+        //if (start.after(end) || start.equals(end)) {
+        // GPX does not contain time stamps -> use sequential order
+        setStart(wayPoints.get(0));
+        setEnd(wayPoints.get(n-1));
+        //}
+
+        avrgHeight = sumEle / n;
+    }
+
+    /**
+     * Gets the name of the profile.
+     */
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the name of the profile.
+     * @param name The new name of the profile.
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Sets the way point with the lowest elevation.
+     * @param wp The way point instance having the lowest elevation.
+     */
+    protected void setMinWayPoint(WayPoint wp) {
+        importantWayPoints[WAYPOINT_MIN] = wp;
+        this.minHeight = (int) ElevationHelper.getElevation(wp);
+    }
+
+    /**
+     * Sets the way point with the highest elevation.
+     * @param wp The way point instance having the highest elevation.
+     */
+    protected void setMaxWayPoint(WayPoint wp) {
+        importantWayPoints[WAYPOINT_MAX] = wp;
+        this.maxHeight = (int) ElevationHelper.getElevation(wp);
+    }
+
+    /**
+     * Sets the average height.
+     * @param avrgHeight
+     */
+    protected void setAvrgHeight(int avrgHeight) {
+        this.avrgHeight = avrgHeight;
+    }
+
+    /**
+     * Sets the very first way point.
+     * @param wp
+     */
+    protected void setStart(WayPoint wp) {
+        importantWayPoints[WAYPOINT_START] = wp;
+        this.start = wp.getTime();
+    }
+
+    /**
+     * Sets the very last way point.
+     * @param wp
+     */
+    protected void setEnd(WayPoint wp) {
+        importantWayPoints[WAYPOINT_END] = wp;
+        this.end = wp.getTime();
+    }
+
+    public void setParent(IElevationProfile parent) {
+        this.parent = parent;
+    }
+
+    /**
+     * Sets the way points of this profile.
+     * 
+     * @param wayPoints
+     */
+    public void setWayPoints(List<WayPoint> wayPoints) {
+        if (this.wayPoints != wayPoints) {
+            this.wayPoints = new ArrayList<WayPoint>(wayPoints);
+            numWayPoints = wayPoints != null ? wayPoints.size() : 0;
+            updateValues();
+
+        }
+    }
+
+    /**
+     * Checks if the given index is valid or not.
+     * 
+     * @param index
+     *            The index to check.
+     * @return true, if the given index is valid; otherwise false.
+     */
+    protected boolean checkIndex(int index) {
+        return index >= 0 && index < getNumberOfWayPoints();
+    }
+
+    @Override
+    public int elevationValueAt(int i) {
+        if (checkIndex(i)) {
+            return (int) ElevationHelper.getElevation(wayPoints.get(i));
+        } else {
+            throw new IndexOutOfBoundsException(String.format(
+                    "Invalid index: %d, expected 0..%d", i,
+                    getNumberOfWayPoints()));
+        }
+    }
+
+    @Override
+    public int getAverageHeight() {
+        return avrgHeight;
+    }
+
+    @Override
+    public List<IElevationProfile> getChildren() {
+        return null;
+    }
+
+    @Override
+    public Date getEnd() {
+        return end;
+    }
+
+    @Override
+    public int getMaxHeight() {
+        return maxHeight;
+    }
+
+    @Override
+    public int getMinHeight() {
+        return minHeight;
+    }
+
+    /**
+     * Gets the difference between min and max elevation.
+     * 
+     * @return
+     */
+    @Override
+    public int getHeightDifference() {
+        return maxHeight - minHeight;
+    }
+
+    /**
+     * Gets the elevation gain.
+     * 
+     * @return
+     */
+    @Override
+    public int getGain() {
+        return gain;
+    }
+
+    @Override
+    public double getDistance() {
+        return dist; // dist is in meters
+    }
+
+    /**
+     * Sets the distance of the elevation profile.
+     * @param dist
+     */
+    protected void setDistance(double dist) {
+        this.dist = dist;
+    }
+
+    /**
+     * Returns the time between start and end of the track.
+     * @return
+     */
+    @Override
+    public long getTimeDifference() {
+        WayPoint wp1 = getStartWayPoint();
+        WayPoint wp2 = getEndWayPoint();
+
+        if (wp1 != null && wp2 != null) {
+            long diff = wp2.getTime().getTime() - wp1.getTime().getTime();
+            return diff;
+        }
+
+        return 0L;
+    }
+
+    @Override
+    public IElevationProfile getParent() {
+        return parent;
+    }
+
+    @Override
+    public Date getStart() {
+        return start;
+    }
+
+    @Override
+    public WayPoint getEndWayPoint() {
+        return importantWayPoints[WAYPOINT_END];
+    }
+
+    @Override
+    public WayPoint getMaxWayPoint() {
+        return importantWayPoints[WAYPOINT_MAX];
+    }
+
+    @Override
+    public WayPoint getMinWayPoint() {
+        return importantWayPoints[WAYPOINT_MIN];
+    }
+
+    @Override
+    public WayPoint getStartWayPoint() {
+        return importantWayPoints[WAYPOINT_START];
+    }
+
+    @Override
+    public List<WayPoint> getWayPoints() {
+        return wayPoints;
+    }
+
+    @Override
+    public int getNumberOfWayPoints() {
+        return numWayPoints;// wayPoints != null ? wayPoints.size() : 0;
+    }
+
+    /**
+     * Gets the coordinate bounds of this profile. See {@link Bounds} for details.
+     *
+     * @return the bounds of this elevation profile
+     */
+    @Override
+    public Bounds getBounds() {
+        return bounds;
+    }
+
+    /**
+     * Gets a flag indicating whether the associated way points contained
+     * elevation data or not. This is the case if min and max height or both
+     * zero.
+     * 
+     * @return
+     */
+    @Override
+    public boolean hasElevationData() {
+        return minHeight != maxHeight;
+    }
+
+    /**
+     * Visits a way point in order to update statistical values about the given
+     * way point list.
+     */
+    @Override
+    public void visitWayPoint(WayPoint wp) {
+        if (wp.getTime().after(end)) {
+            setEnd(wp);
+        }
+
+        if (wp.getTime().before(start)) {
+            setStart(wp);
+        }
+
+        // update boundaries
+        if (bounds == null) {
+            bounds = new Bounds(wp.getCoor());
+        } else {
+            bounds.extend(wp.getCoor());
+        }
+
+        int ele = (int) ElevationHelper.getElevation(wp);
+
+        if (!isIgnoreZeroHeight() || ele > 0) {
+            if (ele > maxHeight) {
+                setMaxWayPoint(wp);
+            }
+            if (ele < minHeight) {
+                setMinWayPoint(wp);
+            }
+
+            if (ele > lastEle) {
+                gain += ele - lastEle;
+            }
+
+            sumEle += ele;
+            lastEle = ele;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return name; /*"ElevationProfileBase [start=" + getStart() + ", end=" + getEnd()
+                + ", minHeight=" + getMinHeight() + ", maxHeight="
+                + getMaxHeight() + "]";*/
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationWayPointKind.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationWayPointKind.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationWayPointKind.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
@@ -20,16 +7,16 @@
  */
 public enum ElevationWayPointKind {
-	Plain, 				// Simple way point (equal to no or low slope)
-	Highlighted,			// Highlighted waypoint
-	StartPoint,			// First way point
-	EndPoint,			// Last way point
-	MaxElevation,			// Highest way point
-	MinElevation,			// Lowest way point 
-	ElevationGainHigh,		// Elevation gain (high slope 15-25%)
-	ElevationLossHigh,		// Elevation loss (high downward slope)
-	ElevationGainLow,		// Elevation gain (low slope, 5-14.9%)
-	ElevationLossLow,		// Elevation loss (low downward slope)
-	ElevationLevelGain,		// Elevation level gain (e. g. crossed 300m from lower elevation)
-	ElevationLevelLoss,		// Elevation level (e. g. crossed 300m from higher elevation)
-	FullHour			// Full Hour	
+    Plain,                 // Simple way point (equal to no or low slope)
+    Highlighted,            // Highlighted waypoint
+    StartPoint,            // First way point
+    EndPoint,            // Last way point
+    MaxElevation,            // Highest way point
+    MinElevation,            // Lowest way point
+    ElevationGainHigh,        // Elevation gain (high slope 15-25%)
+    ElevationLossHigh,        // Elevation loss (high downward slope)
+    ElevationGainLow,        // Elevation gain (low slope, 5-14.9%)
+    ElevationLossLow,        // Elevation loss (low downward slope)
+    ElevationLevelGain,        // Elevation level gain (e. g. crossed 300m from lower elevation)
+    ElevationLevelLoss,        // Elevation level (e. g. crossed 300m from higher elevation)
+    FullHour            // Full Hour
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GeoidCorrectionKind.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GeoidCorrectionKind.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GeoidCorrectionKind.java	(revision 30344)
@@ -1,28 +1,15 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
 /**
  * @author Oliver Wieland <oliver.wieland@online.de>
- * Enumeration for available elevation correction modes. 
+ * Enumeration for available elevation correction modes.
  */
 public enum GeoidCorrectionKind {
-	/** Elevation values remain unchanged */
-	None,
-	/** Automatic correction by geoid lookup table */
-	Auto,
-	/** Fixed value */
-	Fixed
+    /** Elevation values remain unchanged */
+    None,
+    /** Automatic correction by geoid lookup table */
+    Auto,
+    /** Fixed value */
+    Fixed
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GpxIterator.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GpxIterator.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GpxIterator.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
@@ -28,121 +15,121 @@
  */
 public class GpxIterator {
-	/**
-	 * Static class, no need to instantiate me.
-	 */
-	private GpxIterator() {}
-	
-	/**
-	 * Runs the given visitor on a GPX data instance. If one or both 
-	 * arguments are null, this method will return immediately. 
-	 * 
-	 * @param data
-	 *            The GPX data instance.
-	 * @param visitor
-	 *            The visitor which inspects all GPX entities.
-	 */
-	public static void visit(GpxData data, IGpxVisitor visitor) {
-		if (data == null) return;
-		if (visitor == null) return;
-		
-		if (data.isEmpty()) return;
-		
-		visitor.beginWayPoints();
-		visitSingleWaypoints(data, visitor);
-		visitor.endWayPoints();
+    /**
+     * Static class, no need to instantiate me.
+     */
+    private GpxIterator() {}
 
-		// routes
-		if (data.hasRoutePoints()) {
-			for (GpxRoute rte : data.routes) {
-				visitRoute(visitor, rte);
-			}
-		}
+    /**
+     * Runs the given visitor on a GPX data instance. If one or both
+     * arguments are null, this method will return immediately.
+     * 
+     * @param data
+     *            The GPX data instance.
+     * @param visitor
+     *            The visitor which inspects all GPX entities.
+     */
+    public static void visit(GpxData data, IGpxVisitor visitor) {
+        if (data == null) return;
+        if (visitor == null) return;
 
-		// tracks
-		for (GpxTrack trk : data.tracks) {
-			visitTrack(visitor, trk);
-		}
-	}
-	
-	/**
-	 * Visits a single GPX track. 
-	 * @param track The track to visit.
-	 * @param visitor
-	 *            The visitor which inspects all GPX entities.
-	 */
-	public static void visit(GpxTrack track, IGpxVisitor visitor) {
-		visitTrack(visitor, track);
-	}
-	
-	/**
-	 * Visits a single GPX route. 
-	 * @param route The route to visit.
-	 * @param visitor
-	 *            The visitor which inspects all GPX entities.
-	 */
-	public static void visit(GpxRoute route, IGpxVisitor visitor) {
-		visitRoute(visitor, route);
-	}
+        if (data.isEmpty()) return;
 
-	// ---------------------- Helper methods ----------------
-	
-	/**
-	 * @param visitor
-	 * @param trk
-	 */
-	private static void visitTrack(IGpxVisitor visitor, GpxTrack trk) {
-		if (trk == null) return;
-		if (visitor == null) return;
-		
-		Collection<GpxTrackSegment> segments = trk.getSegments();
-		
-		if (segments != null) {
-		    	visitor.beginTrack(trk);
-		    	// visit all segments
-			for (GpxTrackSegment segment : segments) {
-			    Collection<WayPoint> waypts = segment.getWayPoints();
-			    	// no visitor here...
-				if (waypts == null)
-					continue;
-				
-			        visitor.beginTrackSegment(trk, segment);
-			        
-				for (WayPoint wayPoint : waypts) {
-					visitor.visitTrackPoint(wayPoint, trk, segment);
-				}
-				
-				visitor.endTrackSegment(trk, segment);
-			}
-			visitor.endTrack(trk);
-		}		
-		
-	}
+        visitor.beginWayPoints();
+        visitSingleWaypoints(data, visitor);
+        visitor.endWayPoints();
 
-	/**
-	 * @param visitor
-	 * @param route
-	 */
-	private static void visitRoute(IGpxVisitor visitor, GpxRoute route) {
-		if (route == null) return;
-		if (visitor == null) return;
-		
-		visitor.beginWayPoints();
-		for (WayPoint wpt : route.routePoints) {
-			visitor.visitRoutePoint(wpt, route);
-		}
-		visitor.endWayPoints();
-	}
+        // routes
+        if (data.hasRoutePoints()) {
+            for (GpxRoute rte : data.routes) {
+                visitRoute(visitor, rte);
+            }
+        }
 
-	/**
-	 * @param data
-	 * @param visitor
-	 */
-	private static void visitSingleWaypoints(GpxData data, IGpxVisitor visitor) {
-		// isolated way points
-		if (data.waypoints != null) { // better with an hasWaypoints method!?
-			for (WayPoint wpt : data.waypoints) {
-				visitor.visitWayPoint(wpt);
-			}
-		}
-	}
+        // tracks
+        for (GpxTrack trk : data.tracks) {
+            visitTrack(visitor, trk);
+        }
+    }
+
+    /**
+     * Visits a single GPX track.
+     * @param track The track to visit.
+     * @param visitor
+     *            The visitor which inspects all GPX entities.
+     */
+    public static void visit(GpxTrack track, IGpxVisitor visitor) {
+        visitTrack(visitor, track);
+    }
+
+    /**
+     * Visits a single GPX route.
+     * @param route The route to visit.
+     * @param visitor
+     *            The visitor which inspects all GPX entities.
+     */
+    public static void visit(GpxRoute route, IGpxVisitor visitor) {
+        visitRoute(visitor, route);
+    }
+
+    // ---------------------- Helper methods ----------------
+
+    /**
+     * @param visitor
+     * @param trk
+     */
+    private static void visitTrack(IGpxVisitor visitor, GpxTrack trk) {
+        if (trk == null) return;
+        if (visitor == null) return;
+
+        Collection<GpxTrackSegment> segments = trk.getSegments();
+
+        if (segments != null) {
+            visitor.beginTrack(trk);
+            // visit all segments
+            for (GpxTrackSegment segment : segments) {
+                Collection<WayPoint> waypts = segment.getWayPoints();
+                // no visitor here...
+                if (waypts == null)
+                    continue;
+
+                visitor.beginTrackSegment(trk, segment);
+
+                for (WayPoint wayPoint : waypts) {
+                    visitor.visitTrackPoint(wayPoint, trk, segment);
+                }
+
+                visitor.endTrackSegment(trk, segment);
+            }
+            visitor.endTrack(trk);
+        }
+
+    }
+
+    /**
+     * @param visitor
+     * @param route
+     */
+    private static void visitRoute(IGpxVisitor visitor, GpxRoute route) {
+        if (route == null) return;
+        if (visitor == null) return;
+
+        visitor.beginWayPoints();
+        for (WayPoint wpt : route.routePoints) {
+            visitor.visitRoutePoint(wpt, route);
+        }
+        visitor.endWayPoints();
+    }
+
+    /**
+     * @param data
+     * @param visitor
+     */
+    private static void visitSingleWaypoints(GpxData data, IGpxVisitor visitor) {
+        // isolated way points
+        if (data.waypoints != null) { // better with an hasWaypoints method!?
+            for (WayPoint wpt : data.waypoints) {
+                visitor.visitWayPoint(wpt);
+            }
+        }
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxVisitor.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxVisitor.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxVisitor.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
@@ -25,66 +12,67 @@
  */
 public interface IGpxVisitor extends IGpxWaypointVisitor {
-	/**
-	 * Starts a GPX way point collection.
-	 */
-	void beginWayPoints();
-	
-	/**
-	 * Ends a GPX way point collection.
-	 */
-	void endWayPoints();
-	
-	/**
-	 * Starts a GPX track.
-	 */
-	void beginTrack(GpxTrack track);
-	
-	/**
-	 * Ends a GPX track.
-	 */
-	void endTrack(GpxTrack track);
-	
-	/**
-	 * Starts a GPX route.
-	 */
-	void beginRoute(GpxRoute track);
-	
-	/**
-	 * Ends a GPX route.
-	 */
-	void endRoute(GpxRoute track);
+    /**
+     * Starts a GPX way point collection.
+     */
+    void beginWayPoints();
 
-	
-	/**
-	 * Starts a segment within a GPX track.
-	 */
-	void beginTrackSegment(GpxTrack track, GpxTrackSegment segment);
-	
-	/**
-	 * Ends a segment within a GPX track.
-	 */
-	void endTrackSegment(GpxTrack track, GpxTrackSegment segment);
-	
-	/**
-	 * Visits a way point within a GPX route.
-	 * @param route The route containing the way point.
-	 * @param wp The way point to visit.
-	 */
-	void visitWayPoint(WayPoint wp);
-	
-	/**
-	 * Visits a way point within a GPX track.
-	 *
-	 * @param wp The way point to visit.
-	 * @param track the track containing the way point.
-	 * @param segment the track segment
-	 */
-	void visitTrackPoint(WayPoint wp, GpxTrack track, GpxTrackSegment segment);
-	
-	/**
-	 * Visits a way point within a GPX route.
-	 * @param route the route containing the way point.
-	 * @param wp the way point to visit.
-	 */
-	void visitRoutePoint(WayPoint wp, GpxRoute route);
+    /**
+     * Ends a GPX way point collection.
+     */
+    void endWayPoints();
+
+    /**
+     * Starts a GPX track.
+     */
+    void beginTrack(GpxTrack track);
+
+    /**
+     * Ends a GPX track.
+     */
+    void endTrack(GpxTrack track);
+
+    /**
+     * Starts a GPX route.
+     */
+    void beginRoute(GpxRoute track);
+
+    /**
+     * Ends a GPX route.
+     */
+    void endRoute(GpxRoute track);
+
+
+    /**
+     * Starts a segment within a GPX track.
+     */
+    void beginTrackSegment(GpxTrack track, GpxTrackSegment segment);
+
+    /**
+     * Ends a segment within a GPX track.
+     */
+    void endTrackSegment(GpxTrack track, GpxTrackSegment segment);
+
+    /**
+     * Visits a way point within a GPX route.
+     * @param route The route containing the way point.
+     * @param wp The way point to visit.
+     */
+    @Override
+    void visitWayPoint(WayPoint wp);
+
+    /**
+     * Visits a way point within a GPX track.
+     *
+     * @param wp The way point to visit.
+     * @param track the track containing the way point.
+     * @param segment the track segment
+     */
+    void visitTrackPoint(WayPoint wp, GpxTrack track, GpxTrackSegment segment);
+
+    /**
+     * Visits a way point within a GPX route.
+     * @param route the route containing the way point.
+     * @param wp the way point to visit.
+     */
+    void visitRoutePoint(WayPoint wp, GpxRoute route);
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxWaypointVisitor.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxWaypointVisitor.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxWaypointVisitor.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
@@ -22,9 +9,9 @@
  */
 public interface IGpxWaypointVisitor {
-	/**
-	 * Visits a way point. This method is called for isolated way points, i. e. way points
-	 * without an associated route or track. 
-	 * @param wp The way point to visit.
-	 */
-	void visitWayPoint(WayPoint wp);
+    /**
+     * Visits a way point. This method is called for isolated way points, i. e. way points
+     * without an associated route or track.
+     * @param wp The way point to visit.
+     */
+    void visitWayPoint(WayPoint wp);
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java	(revision 30344)
@@ -1,2 +1,3 @@
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gpx;
 
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleCoordinate.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleCoordinate.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleCoordinate.java	(revision 30344)
@@ -1,38 +1,26 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
 import org.openstreetmap.josm.data.coor.LatLon;
 
-public class EleCoordinate extends LatLon {    
+public class EleCoordinate extends LatLon {
     /**
      * 
      */
     private static final long serialVersionUID = 9121465585197496570L;
-    
-    private double ele = Double.NaN; 
+
+    private double ele = Double.NaN;
 
     public EleCoordinate() {
-	this(Double.NaN, Double.NaN, Double.NaN);
+        this(Double.NaN, Double.NaN, Double.NaN);
     }
-    
+
     public EleCoordinate(double lat, double lon, double ele) {
-	super(lat, lon);
-	this.ele = ele;
+        super(lat, lon);
+        this.ele = ele;
     }
-    
+
     public EleCoordinate(LatLon latLon, double ele) {
-	this(latLon.lat(), latLon.lon(), ele);	
+        this(latLon.lat(), latLon.lon(), ele);
     }
 
@@ -45,5 +33,6 @@
         return ele;
     }
-  
+
+    @Override
     public String toString() {
         return "EleCoordinate[" + lat() + ", " + lon() + ", " + getEle() + "]";
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleVertex.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleVertex.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleVertex.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -30,78 +18,78 @@
 
     public EleVertex(EleCoordinate p1, EleCoordinate p2, EleCoordinate p3) {
-	points[0] = p1;
-	points[1] = p2;
-	points[2] = p3;
-
-	// compute elevation
-	double z = 0D;
-	boolean eleValid = true;
-	for (EleCoordinate point : points) {
-	    if (ElevationHelper.isValidElevation(p1.getEle())) {
-		z += point.getEle();
-	    } else {
-		eleValid = false;
-		break;
-	    }
-	}
-
-	if (eleValid) {
-	    avrgEle = z / NPOINTS;
-	} else {
-	    avrgEle = ElevationHelper.NO_ELEVATION;
-	}
-
-	// compute the (approx.!) area of the vertex using heron's formula
-	double a = p1.greatCircleDistance(p2);
-	double b = p2.greatCircleDistance(p3);
-	double c = p1.greatCircleDistance(p3);
-
-	double s = (a + b + c) / 2D;
-	double sq = s * (s - a) * (s - b) * (s - c);
-	area = Math.sqrt(sq);
+        points[0] = p1;
+        points[1] = p2;
+        points[2] = p3;
+
+        // compute elevation
+        double z = 0D;
+        boolean eleValid = true;
+        for (EleCoordinate point : points) {
+            if (ElevationHelper.isValidElevation(p1.getEle())) {
+                z += point.getEle();
+            } else {
+                eleValid = false;
+                break;
+            }
+        }
+
+        if (eleValid) {
+            avrgEle = z / NPOINTS;
+        } else {
+            avrgEle = ElevationHelper.NO_ELEVATION;
+        }
+
+        // compute the (approx.!) area of the vertex using heron's formula
+        double a = p1.greatCircleDistance(p2);
+        double b = p2.greatCircleDistance(p3);
+        double c = p1.greatCircleDistance(p3);
+
+        double s = (a + b + c) / 2D;
+        double sq = s * (s - a) * (s - b) * (s - c);
+        area = Math.sqrt(sq);
     }
 
     public List<EleVertex> divide() {
-	TriangleEdge[] edges = new TriangleEdge[NPOINTS];
-
-	int k = 0;
-	for (int i = 0; i < points.length; i++) {
-	    EleCoordinate c1 = points[i];
-
-	    for (int j = i + 1; j < points.length; j++) {
-		EleCoordinate c2 = points[j];
-
-		edges[k++] = new TriangleEdge(i, j, c1.greatCircleDistance(c2));
-	    }
-	}
-
-	/*
-	for (int i = 0; i < edges.length; i++) {
-	    TriangleEdge triangleEdge = edges[i];
-	    System.out.println("#" + i + ": " +triangleEdge);
-	}*/
-
-	// sort by distance
-	Arrays.sort(edges);
-	// pick the longest edge
-	TriangleEdge longest = edges[0];
-
-
-	//System.out.println("Longest " + longest);
-	EleCoordinate pI = points[longest.getI()];
-	EleCoordinate pJ = points[longest.getJ()];
-	EleCoordinate pK = points[longest.getK()];
-	EleCoordinate newP = getMid(pI, pJ);
-	/*
-	System.out.println(pI);
-	System.out.println(pJ);
-	System.out.println(pK);
-	System.out.println(newP);
-	 */
-	List<EleVertex> res = new ArrayList<EleVertex>();
-	res.add(new EleVertex(pI, pK, newP));
-	res.add(new EleVertex(pJ, pK, newP));
-
-	return res;
+        TriangleEdge[] edges = new TriangleEdge[NPOINTS];
+
+        int k = 0;
+        for (int i = 0; i < points.length; i++) {
+            EleCoordinate c1 = points[i];
+
+            for (int j = i + 1; j < points.length; j++) {
+                EleCoordinate c2 = points[j];
+
+                edges[k++] = new TriangleEdge(i, j, c1.greatCircleDistance(c2));
+            }
+        }
+
+        /*
+    for (int i = 0; i < edges.length; i++) {
+        TriangleEdge triangleEdge = edges[i];
+        System.out.println("#" + i + ": " +triangleEdge);
+    }*/
+
+        // sort by distance
+        Arrays.sort(edges);
+        // pick the longest edge
+        TriangleEdge longest = edges[0];
+
+
+        //System.out.println("Longest " + longest);
+        EleCoordinate pI = points[longest.getI()];
+        EleCoordinate pJ = points[longest.getJ()];
+        EleCoordinate pK = points[longest.getK()];
+        EleCoordinate newP = getMid(pI, pJ);
+        /*
+    System.out.println(pI);
+    System.out.println(pJ);
+    System.out.println(pK);
+    System.out.println(newP);
+         */
+        List<EleVertex> res = new ArrayList<EleVertex>();
+        res.add(new EleVertex(pI, pK, newP));
+        res.add(new EleVertex(pJ, pK, newP));
+
+        return res;
     }
 
@@ -113,13 +101,13 @@
      */
     public boolean isFinished() {
-	double z = 0D;
-	double avrgEle = getEle();
-
-	for (EleCoordinate point : points) {
-	    z += (avrgEle - point.getEle()) * (avrgEle - point.getEle());
-	}
-
-	// TODO: Check for proper limit
-	return /*z < 75 || */getArea() < (30 * 30); // = 3 * 25
+        double z = 0D;
+        double avrgEle = getEle();
+
+        for (EleCoordinate point : points) {
+            z += (avrgEle - point.getEle()) * (avrgEle - point.getEle());
+        }
+
+        // TODO: Check for proper limit
+        return /*z < 75 || */getArea() < (30 * 30); // = 3 * 25
     }
 
@@ -130,5 +118,5 @@
      */
     public double getArea() {
-	return area;
+        return area;
     }
 
@@ -141,17 +129,17 @@
      */
     public EleCoordinate getMid(EleCoordinate c1, EleCoordinate c2) {
-	double x = (c1.getX() + c2.getX()) / 2.0;
-	double y = (c1.getY() + c2.getY()) / 2.0;
-
-	double z = (c1.getEle() + c2.getEle()) / 2.0;
-	if (c1.greatCircleDistance(c2) > MIN_DIST) {
-	    double hgtZ = ElevationHelper.getSrtmElevation(new LatLon(y, x));
-
-	    if (ElevationHelper.isValidElevation(hgtZ)) {
-		z = hgtZ;
-	    }
-	}
-
-	return new EleCoordinate(y, x, z);
+        double x = (c1.getX() + c2.getX()) / 2.0;
+        double y = (c1.getY() + c2.getY()) / 2.0;
+
+        double z = (c1.getEle() + c2.getEle()) / 2.0;
+        if (c1.greatCircleDistance(c2) > MIN_DIST) {
+            double hgtZ = ElevationHelper.getSrtmElevation(new LatLon(y, x));
+
+            if (ElevationHelper.isValidElevation(hgtZ)) {
+                z = hgtZ;
+            }
+        }
+
+        return new EleCoordinate(y, x, z);
     }
 
@@ -164,7 +152,7 @@
      */
     public EleCoordinate get(int index) {
-	if (index < 0 || index >= NPOINTS) throw new IllegalArgumentException("Invalid index: " + index);
-
-	return points[index];
+        if (index < 0 || index >= NPOINTS) throw new IllegalArgumentException("Invalid index: " + index);
+
+        return points[index];
     }
 
@@ -176,11 +164,11 @@
     public double getEle() {
 
-	return avrgEle;
+        return avrgEle;
     }
 
     @Override
     public String toString() {
-	return "EleVertex [avrgEle=" + avrgEle + ", area=" + area + ", points="
-		+ Arrays.toString(points) + "]";
+        return "EleVertex [avrgEle=" + avrgEle + ", area=" + area + ", points="
+                + Arrays.toString(points) + "]";
     }
 
@@ -189,46 +177,46 @@
 
     class TriangleEdge implements Comparable<TriangleEdge> {
-	private final int i;
-	private final int j;
-	private final double dist;
-
-	public TriangleEdge(int i, int j, double dist) {
-	    super();
-	    this.i = i;
-	    this.j = j;
-	    this.dist = dist;
-	}
-
-	public int getI() {
-	    return i;
-	}
-
-	public int getJ() {
-	    return j;
-	}
-
-	public int getK() {
-	    if (i == 0) {
-		return j == 1 ? 2 : 1;
-	    } else if (i == 1) {
-		return j == 0 ? 2 : 0;
-	    } else {
-		return j == 0 ? 1 : 0;
-	    }
-	}
-
-	public double getDist() {
-	    return dist;
-	}
-
-	@Override
-	public int compareTo(TriangleEdge o) {
-	    return (int) (o.getDist() - dist);
-	}
-
-	@Override
-	public String toString() {
-	    return "TriangleEdge [i=" + i + ", j=" + j + ", dist=" + dist + "]";
-	}
+        private final int i;
+        private final int j;
+        private final double dist;
+
+        public TriangleEdge(int i, int j, double dist) {
+            super();
+            this.i = i;
+            this.j = j;
+            this.dist = dist;
+        }
+
+        public int getI() {
+            return i;
+        }
+
+        public int getJ() {
+            return j;
+        }
+
+        public int getK() {
+            if (i == 0) {
+                return j == 1 ? 2 : 1;
+            } else if (i == 1) {
+                return j == 0 ? 2 : 0;
+            } else {
+                return j == 0 ? 1 : 0;
+            }
+        }
+
+        public double getDist() {
+            return dist;
+        }
+
+        @Override
+        public int compareTo(TriangleEdge o) {
+            return (int) (o.getDist() - dist);
+        }
+
+        @Override
+        public String toString() {
+            return "TriangleEdge [i=" + i + ", j=" + j + ", dist=" + dist + "]";
+        }
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridLayer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridLayer.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridLayer.java	(revision 30344)
@@ -1,16 +1,3 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -46,10 +33,10 @@
 public class ElevationGridLayer extends Layer implements TileLoaderListener {
     private static final int ELE_ZOOM_LEVEL = 13;
-    private IVertexRenderer vertexRenderer;    
-    private MemoryTileCache tileCache;
+    private final IVertexRenderer vertexRenderer;
+    private final MemoryTileCache tileCache;
     protected TileSource tileSource;
     protected ElevationGridTileLoader tileLoader;
     protected TileController tileController;
-    
+
     private Bounds lastBounds;
     private TileSet tileSet;
@@ -59,31 +46,28 @@
      */
     public ElevationGridLayer(String name) {
-	super(name);
-	
-	setOpacity(0.8);
-	setBackgroundLayer(true);
-	vertexRenderer = new SimpleVertexRenderer();
-	
-	tileCache = new MemoryTileCache();
-	tileCache.setCacheSize(500);
-	tileSource = new ElevationGridTileSource(name);
-	tileLoader = new ElevationGridTileLoader(this);
-	tileController = new ElevationGridTileController(tileSource, tileCache, this, tileLoader);
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics2D, org.openstreetmap.josm.gui.MapView, org.openstreetmap.josm.data.Bounds)
-     */
+        super(name);
+
+        setOpacity(0.8);
+        setBackgroundLayer(true);
+        vertexRenderer = new SimpleVertexRenderer();
+
+        tileCache = new MemoryTileCache();
+        tileCache.setCacheSize(500);
+        tileSource = new ElevationGridTileSource(name);
+        tileLoader = new ElevationGridTileLoader(this);
+        tileController = new ElevationGridTileController(tileSource, tileCache, this, tileLoader);
+    }
+
     @Override
     public void paint(Graphics2D g, MapView mv, Bounds box) {
-	boolean needsNewTileSet = tileSet == null || (lastBounds == null || !lastBounds.equals(box)); 
-	
-	if (needsNewTileSet) {
-	    tileSet = new TileSet(box.getMin(), box.getMax(), ELE_ZOOM_LEVEL); // we use a vector format with constant zoom level
-	    lastBounds = box;
-	    System.out.println("paint " + tileSet);
-	}
-	
-	if (tileSet.insane()) {
+        boolean needsNewTileSet = tileSet == null || (lastBounds == null || !lastBounds.equals(box));
+
+        if (needsNewTileSet) {
+            tileSet = new TileSet(box.getMin(), box.getMax(), ELE_ZOOM_LEVEL); // we use a vector format with constant zoom level
+            lastBounds = box;
+            System.out.println("paint " + tileSet);
+        }
+
+        if (tileSet.insane()) {
             myDrawString(g, tr("zoom in to load any tiles"), 120, 120);
             return;
@@ -95,107 +79,82 @@
             return;
         }
-	
-	for(int x = tileSet.x0; x <= tileSet.x1; x++) {
-	    for(int y = tileSet.y0; y <= tileSet.y1; y++) {	
-		Tile t = tileController.getTile(x, y, ELE_ZOOM_LEVEL);
-		
-		if (t != null && t.isLoaded() && t instanceof ElevationGridTile) {
-		    ((ElevationGridTile)t).paintTile(g, mv, vertexRenderer);        		
-		} else {
-		    // give some consolation...
-		    Point topLeft = mv.getPoint(
-			    new LatLon(tileSource.tileYToLat(y, ELE_ZOOM_LEVEL),
-				       tileSource.tileXToLon(x, ELE_ZOOM_LEVEL)));
-		    t.paint(g, topLeft.x, topLeft.y);		    
-		}
-	    }
-	}
-    }
-    
-    
-    
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText()
-     */
+
+        for(int x = tileSet.x0; x <= tileSet.x1; x++) {
+            for(int y = tileSet.y0; y <= tileSet.y1; y++) {
+                Tile t = tileController.getTile(x, y, ELE_ZOOM_LEVEL);
+
+                if (t != null && t.isLoaded() && t instanceof ElevationGridTile) {
+                    ((ElevationGridTile)t).paintTile(g, mv, vertexRenderer);
+                } else {
+                    // give some consolation...
+                    Point topLeft = mv.getPoint(
+                            new LatLon(tileSource.tileYToLat(y, ELE_ZOOM_LEVEL),
+                                    tileSource.tileXToLon(x, ELE_ZOOM_LEVEL)));
+                    t.paint(g, topLeft.x, topLeft.y);
+                }
+            }
+        }
+    }
+
     @Override
     public String getToolTipText() {
-	// TODO Auto-generated method stub
-	return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor)
-     */
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     @Override
     public void visitBoundingBox(BoundingXYVisitor v) {
-	// TODO Auto-generated method stub
-
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries()
-     */
+        // TODO Auto-generated method stub
+
+    }
+
     @Override
     public Action[] getMenuEntries() {
-	// TODO Auto-generated method stub
-	return null;
-    }
-   
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     @Override
     public void tileLoadingFinished(Tile tile, boolean success) {
-	try {
-	    //System.out.println("tileLoadingFinished " + tile + ", success = " + success);
-	    if (Main.map != null) {
-		Main.map.repaint(100);
-	    }
-	} catch(Exception ex) {
-	    System.err.println(ex);
-	    ex.printStackTrace(System.err);
-	}
+        try {
+            if (Main.map != null) {
+                Main.map.repaint(100);
+            }
+        } catch(Exception ex) {
+            System.err.println(ex);
+            ex.printStackTrace(System.err);
+        }
     }
 
     @Override
     public TileCache getTileCache() {
-	// TODO Auto-generated method stub
-	return tileCache;
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getIcon()
-     */
-    @Override
-    public Icon getIcon() {	
-	return ImageProvider.get("layer", "elevation");
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm.gui.layer.Layer)
-     */
+        // TODO Auto-generated method stub
+        return tileCache;
+    }
+
+    @Override
+    public Icon getIcon() {
+        return ImageProvider.get("layer", "elevation");
+    }
+
     @Override
     public void mergeFrom(Layer from) {
-	// TODO Auto-generated method stub
-	
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm.gui.layer.Layer)
-     */
+        // TODO Auto-generated method stub
+
+    }
+
     @Override
     public boolean isMergable(Layer other) {
-	// TODO Auto-generated method stub
-	return false;
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent()
-     */
+        // TODO Auto-generated method stub
+        return false;
+    }
+
     @Override
     public Object getInfoComponent() {
-	// TODO Auto-generated method stub
-	return null;
-    }
-    
-    
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
     // Stolen from TMSLayer...
     void myDrawString(Graphics g, String text, int x, int y) {
@@ -206,5 +165,5 @@
         g.drawString(text,x,y);
     }
-    
+
     private class TileSet {
         int x0, x1, y0, y1;
@@ -246,5 +205,5 @@
             }
         }
-        
+
         int size() {
             int x_span = x1 - x0 + 1;
@@ -253,26 +212,26 @@
         }
 
-	@Override
-	public String toString() {
-	    return "TileSet [x0=" + x0 + ", x1=" + x1 + ", y0=" + y0 + ", y1="
-		    + y1 + ", size()=" + size() + ", tilesSpanned()="
-		    + tilesSpanned() + "]";
-	}
-
-	double tilesSpanned() {
-	    return Math.sqrt(1.0 * this.size());
-	}
-
-	boolean tooSmall() {
-	    return this.tilesSpanned() < 1;
-	}
-
-	boolean tooLarge() {
-	    return this.tilesSpanned() > 50;
-	}
-
-	boolean insane() {
-	    return this.tilesSpanned() > 200;
-	}
+        @Override
+        public String toString() {
+            return "TileSet [x0=" + x0 + ", x1=" + x1 + ", y0=" + y0 + ", y1="
+                    + y1 + ", size()=" + size() + ", tilesSpanned()="
+                    + tilesSpanned() + "]";
+        }
+
+        double tilesSpanned() {
+            return Math.sqrt(1.0 * this.size());
+        }
+
+        boolean tooSmall() {
+            return this.tilesSpanned() < 1;
+        }
+
+        boolean tooLarge() {
+            return this.tilesSpanned() > 50;
+        }
+
+        boolean insane() {
+            return this.tilesSpanned() > 200;
+        }
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTile.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTile.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTile.java	(revision 30344)
@@ -1,2 +1,3 @@
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -30,13 +31,13 @@
 
     public ElevationGridTile(TileSource source, int xtile, int ytile, int zoom) {
-	super(source, xtile, ytile, zoom);
+        super(source, xtile, ytile, zoom);
 
-	box = tile2Bounds(xtile, ytile, zoom);
-	initQueue();
+        box = tile2Bounds(xtile, ytile, zoom);
+        initQueue();
     }
 
     public ElevationGridTile(TileSource source, int xtile, int ytile, int zoom,
-	    BufferedImage image) {
-	super(source, xtile, ytile, zoom, image);
+            BufferedImage image) {
+        super(source, xtile, ytile, zoom, image);
 
 
@@ -45,14 +46,14 @@
     @Override
     public void loadPlaceholderFromCache(TileCache cache) {
-	// TODO Auto-generated method stub
-	super.loadPlaceholderFromCache(cache);
+        // TODO Auto-generated method stub
+        super.loadPlaceholderFromCache(cache);
 
-	//System.out.println("loadPlaceholderFromCache");
+        //System.out.println("loadPlaceholderFromCache");
     }
 
     @Override
     public String getUrl() throws IOException {
-	// TODO Auto-generated method stub
-	return super.getUrl();
+        // TODO Auto-generated method stub
+        return super.getUrl();
     }
 
@@ -62,8 +63,8 @@
     @Override
     public void paint(Graphics g, int x, int y) {
-	super.paint(g, x, y);
+        super.paint(g, x, y);
 
-	//g.drawString(String.format("EGT %d/%d ", getXtile(), getYtile()), x, y);
-	g.drawString(getStatus(), x, y);
+        //g.drawString(String.format("EGT %d/%d ", getXtile(), getYtile()), x, y);
+        g.drawString(getStatus(), x, y);
     }
 
@@ -76,43 +77,43 @@
      */
     public void paintTile(Graphics2D g, MapView mv, IVertexRenderer vertexRenderer) {
-	BlockingDeque<EleVertex> list = getVertices();
-	for (EleVertex eleVertex : list) {
-	    Point p0 = mv.getPoint(eleVertex.get(0));
-	    Point p1 = mv.getPoint(eleVertex.get(1));
-	    Point p2 = mv.getPoint(eleVertex.get(2));
-	    Triangle shape = new Triangle(p0, p1, p2);
+        BlockingDeque<EleVertex> list = getVertices();
+        for (EleVertex eleVertex : list) {
+            Point p0 = mv.getPoint(eleVertex.get(0));
+            Point p1 = mv.getPoint(eleVertex.get(1));
+            Point p2 = mv.getPoint(eleVertex.get(2));
+            Triangle shape = new Triangle(p0, p1, p2);
 
-	    // obtain vertex color
-	    g.setColor(vertexRenderer.getElevationColor(eleVertex));
-	    // TODO: Move to renderer
-	    g.fill(shape);
-	}
+            // obtain vertex color
+            g.setColor(vertexRenderer.getElevationColor(eleVertex));
+            // TODO: Move to renderer
+            g.fill(shape);
+        }
     }
 
     @Override
     public void loadImage(InputStream input) throws IOException {
-	if (isLoaded()) return;
+        if (isLoaded()) return;
 
-	// TODO: Save
+        // TODO: Save
 
-	// We abuse the loadImage method to render the vertices...
-	//
-	while (toDo.size() > 0) {
-	    EleVertex vertex = toDo.poll();
+        // We abuse the loadImage method to render the vertices...
+        //
+        while (toDo.size() > 0) {
+            EleVertex vertex = toDo.poll();
 
-	    if (vertex.isFinished()) {
-		vertices.add(vertex);
-	    } else {
-		List<EleVertex> newV = vertex.divide();
-		for (EleVertex eleVertex : newV) {
-		    toDo.add(eleVertex);
-		}
-	    }
-	}
-	setLoaded(true);
+            if (vertex.isFinished()) {
+                vertices.add(vertex);
+            } else {
+                List<EleVertex> newV = vertex.divide();
+                for (EleVertex eleVertex : newV) {
+                    toDo.add(eleVertex);
+                }
+            }
+        }
+        setLoaded(true);
     }
 
     public BlockingDeque<EleVertex> getVertices() {
-	return vertices;
+        return vertices;
     }
 
@@ -125,9 +126,9 @@
      */
     private Bounds tile2Bounds(final int x, final int y, final int zoom) {
-	Bounds bb = new Bounds(
-		new LatLon(source.tileYToLat(y, zoom), source.tileXToLon(x, zoom)),
-		new LatLon(source.tileYToLat(y + 1, zoom), source.tileXToLon(x + 1, zoom)));
+        Bounds bb = new Bounds(
+                new LatLon(source.tileYToLat(y, zoom), source.tileXToLon(x, zoom)),
+                new LatLon(source.tileYToLat(y + 1, zoom), source.tileXToLon(x + 1, zoom)));
 
-	return bb;
+        return bb;
     }
 
@@ -136,38 +137,38 @@
      */
     private void initQueue() {
-	LatLon min = box.getMin();
-	LatLon max = box.getMax();
+        LatLon min = box.getMin();
+        LatLon max = box.getMax();
 
-	// compute missing coordinates
-	LatLon h1 = new LatLon(min.lat(), max.lon());
-	LatLon h2 = new LatLon(max.lat(), min.lon());
+        // compute missing coordinates
+        LatLon h1 = new LatLon(min.lat(), max.lon());
+        LatLon h2 = new LatLon(max.lat(), min.lon());
 
-	double eleMin = ElevationHelper.getSrtmElevation(min);
-	double eleMax = ElevationHelper.getSrtmElevation(max);
+        double eleMin = ElevationHelper.getSrtmElevation(min);
+        double eleMax = ElevationHelper.getSrtmElevation(max);
 
-	// SRTM files present?
-	if (!ElevationHelper.isValidElevation(eleMax) || !ElevationHelper.isValidElevation(eleMin)) {
-	    setError(tr("No SRTM data"));
-	    return;
-	}
+        // SRTM files present?
+        if (!ElevationHelper.isValidElevation(eleMax) || !ElevationHelper.isValidElevation(eleMin)) {
+            setError(tr("No SRTM data"));
+            return;
+        }
 
-	// compute elevation coords
-	EleCoordinate p0 = new EleCoordinate(min, eleMin);
-	EleCoordinate p1 = new EleCoordinate(h1, ElevationHelper.getSrtmElevation(h1));
-	EleCoordinate p2 = new EleCoordinate(max, eleMax);
-	EleCoordinate p3 = new EleCoordinate(h2, ElevationHelper.getSrtmElevation(h2));
+        // compute elevation coords
+        EleCoordinate p0 = new EleCoordinate(min, eleMin);
+        EleCoordinate p1 = new EleCoordinate(h1, ElevationHelper.getSrtmElevation(h1));
+        EleCoordinate p2 = new EleCoordinate(max, eleMax);
+        EleCoordinate p3 = new EleCoordinate(h2, ElevationHelper.getSrtmElevation(h2));
 
-	// compute initial vertices
-	EleVertex v1 = new EleVertex(p0, p1, p2);
-	EleVertex v2 = new EleVertex(p2, p3, p0);
-	// enqueue vertices
-	toDo.add(v1);
-	toDo.add(v2);
+        // compute initial vertices
+        EleVertex v1 = new EleVertex(p0, p1, p2);
+        EleVertex v2 = new EleVertex(p2, p3, p0);
+        // enqueue vertices
+        toDo.add(v1);
+        toDo.add(v2);
     }
 
     @Override
     public String toString() {
-	return "ElevationGridTile [box=" + box + ", xtile=" + xtile
-		+ ", ytile=" + ytile + "]";
+        return "ElevationGridTile [box=" + box + ", xtile=" + xtile
+                + ", ytile=" + ytile + "]";
     }
 
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileController.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileController.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileController.java	(revision 30344)
@@ -1,16 +1,3 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -29,6 +16,6 @@
  */
 public class ElevationGridTileController extends TileController {
-    private JobDispatcher jobDispatcher; // is private and no getter
-    
+    private final JobDispatcher jobDispatcher; // is private and no getter
+
     /**
      * @param source
@@ -37,15 +24,13 @@
      */
     public ElevationGridTileController(TileSource source, TileCache tileCache,
-	    TileLoaderListener listener, TileLoader loader) {
-	super(source, tileCache, listener);
-	
-	tileSource = source; // FIXME: hard-coded in base class (although parameter is given)!!   
-	tileLoader = loader; // FIXME: hard-coded in base class!
-	jobDispatcher = JobDispatcher.getInstance();
+            TileLoaderListener listener, TileLoader loader) {
+        super(source, tileCache, listener);
+
+        tileSource = source; // FIXME: hard-coded in base class (although parameter is given)!!
+        tileLoader = loader; // FIXME: hard-coded in base class!
+        jobDispatcher = JobDispatcher.getInstance();
     }
-    
-    /* (non-Javadoc)
-     * @see org.openstreetmap.gui.jmapviewer.TileController#getTile(int, int, int)
-     */
+
+    @Override
     public Tile getTile(int tilex, int tiley, int zoom) {
         int max = (1 << zoom);
@@ -54,5 +39,5 @@
         Tile tile = tileCache.getTile(tileSource, tilex, tiley, zoom);
         if (tile == null) {
-            // FIXME: Provide/use a factory method here 
+            // FIXME: Provide/use a factory method here
             tile = new ElevationGridTile(tileSource, tilex, tiley, zoom);
             tileCache.addTile(tile);
@@ -67,11 +52,12 @@
         return tile;
     }
-    
+
     /**
-    *
-    */
-   public void cancelOutstandingJobs() {       
-       super.cancelOutstandingJobs(); // should not make a difference but you never know...
-       jobDispatcher.cancelOutstandingJobs();
-   }
+     *
+     */
+    @Override
+    public void cancelOutstandingJobs() {
+        super.cancelOutstandingJobs(); // should not make a difference but you never know...
+        jobDispatcher.cancelOutstandingJobs();
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileLoader.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileLoader.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileLoader.java	(revision 30344)
@@ -1,16 +1,3 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -29,17 +16,15 @@
 
     public ElevationGridTileLoader(TileLoaderListener listener) {
-	CheckParameterUtil.ensureParameterNotNull(listener);
+        CheckParameterUtil.ensureParameterNotNull(listener);
         this.listener = listener;
     }
 
-    /* (non-Javadoc)
-     * @see org.openstreetmap.gui.jmapviewer.interfaces.TileLoader#createTileLoaderJob(org.openstreetmap.gui.jmapviewer.Tile)
-     */
     @Override
     public TileJob createTileLoaderJob(final Tile tile) {
-	CheckParameterUtil.ensureParameterNotNull(tile);
-	
-	return new TileJob() {
+        CheckParameterUtil.ensureParameterNotNull(tile);
 
+        return new TileJob() {
+
+            @Override
             public void run() {
                 synchronized (tile) {
@@ -54,5 +39,5 @@
                 } catch (Exception e) {
                     tile.setError(e.getMessage());
-                    listener.tileLoadingFinished(tile, false);                                        
+                    listener.tileLoadingFinished(tile, false);
                 } finally {
                     tile.finishLoading();
@@ -60,4 +45,5 @@
             }
 
+            @Override
             public Tile getTile() {
                 return tile;
@@ -65,4 +51,4 @@
         };
     }
-   
+
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileSource.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileSource.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileSource.java	(revision 30344)
@@ -1,16 +1,3 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -25,18 +12,19 @@
 public class ElevationGridTileSource extends AbstractTMSTileSource {
     public ElevationGridTileSource(String name) {
-	super(name, "");
-	// TODO Auto-generated constructor stub
+        super(name, "");
+        // TODO Auto-generated constructor stub
     }
 
     @Override
     public TileUpdate getTileUpdate() {
-	return TileUpdate.None;
+        return TileUpdate.None;
     }
 
     @Override
     public String getName() {
-	return "eg";
+        return "eg";
     }
 
+    @Override
     public String getExtension() {
         return "";
@@ -46,8 +34,10 @@
      * @throws IOException when subclass cannot return the tile URL
      */
+    @Override
     public String getTilePath(int zoom, int tilex, int tiley) throws IOException {
         return "/" + zoom + "/" + tilex + "/" + tiley + "." + getExtension();
     }
 
+    @Override
     public String getBaseUrl() {
         return "";
@@ -71,5 +61,5 @@
     @Override
     public int getTileSize() {
-	// TODO
+        // TODO
         return 256;
     }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/SimpleVertexRenderer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/SimpleVertexRenderer.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/SimpleVertexRenderer.java	(revision 30344)
@@ -1,16 +1,3 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.grid;
 
@@ -26,15 +13,15 @@
 public class SimpleVertexRenderer implements IVertexRenderer {
     private ColorMap cMap = null;
-    
+
     /**
      * 
      */
     public SimpleVertexRenderer() {
-	cMap = ColorMap.getMap(ColorMap.getNames()[0]);
+        cMap = ColorMap.getMap(ColorMap.getNames()[0]);
     }
 
     @Override
     public Color getElevationColor(EleVertex vertex) {
-	return cMap.getColor((int) vertex.getEle());
+        return cMap.getColor((int) vertex.getEle());
     }
 
@@ -42,7 +29,7 @@
     @Override
     public void selectColorMap(String name) {
-	// TODO Auto-generated method stub
-	
+        // TODO Auto-generated method stub
+
     }
-    
+
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -40,538 +27,517 @@
 
 /**
- * Provides default rendering for elevation profile layer. 
+ * Provides default rendering for elevation profile layer.
  * @author Oliver Wieland <oliver.wieland@online.de>
  */
 public class DefaultElevationProfileRenderer implements
-		IElevationProfileRenderer {
-
-	private static final int ROUND_RECT_RADIUS = 6;
-	/**
-	 * 
-	 */
-	private static final int TRIANGLE_BASESIZE = 24;
-	/**
-	 * 
-	 */
-	private static final int BASIC_WPT_RADIUS = 1;
-	private static final int BIG_WPT_RADIUS = BASIC_WPT_RADIUS * 16;
-
-	// predefined colors
-	private static final Color HIGH_COLOR = ElevationColors.EPMidBlue;
-	private static final Color LOW_COLOR = ElevationColors.EPMidBlue;
-	private static final Color START_COLOR = Color.GREEN;
-	private static final Color END_POINT = Color.RED;
-	private static final Color LEVEL_GAIN_COLOR = Color.GREEN;
-	private static final Color LEVEL_LOSS_COLOR = Color.RED;
-	private static final Color MARKER_POINT = Color.YELLOW;
-	// Predefined radians
-	private static final double RAD_180 = Math.PI;
-	// private static final double RAD_270 = Math.PI * 1.5;
-	private static final double RAD_90 = Math.PI * 0.5;
-
-	private List<Rectangle> forbiddenRects = new ArrayList<Rectangle>();
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.gui.IElevationProfileRenderer
-	 * #getColorForWaypoint
-	 * (org.openstreetmap.josm.plugins.elevation.IElevationProfile,
-	 * org.openstreetmap.josm.data.gpx.WayPoint,
-	 * org.openstreetmap.josm.plugins.elevation.ElevationWayPointKind)
-	 */
-	public Color getColorForWaypoint(IElevationProfile profile, WayPoint wpt,
-			ElevationWayPointKind kind) {
-
-		if (wpt == null || profile == null) {
-			System.err.println(String.format(
-					"Cannot determine color: prof=%s, wpt=%s", profile, wpt));
-			return null;
-		}
-
-		switch (kind) {
-		case Plain:
-		    	return Color.LIGHT_GRAY;
-		case ElevationLevelLoss:
-		    	return LEVEL_LOSS_COLOR;
-		case ElevationLevelGain:
-			return LEVEL_GAIN_COLOR;
-		case Highlighted:
-			return Color.ORANGE;
-		case ElevationGainHigh:
-		    	return Color.getHSBColor(0.3f, 1.0f, 1.0f); // green
-		case ElevationLossHigh:
-			return Color.getHSBColor(0, 1.0f, 1.0f); // red
-		case ElevationGainLow:
-		    	return Color.getHSBColor(0.3f, 0.5f, 1.0f); // green with low sat
-		case ElevationLossLow:
-			return Color.getHSBColor(0, 0.5f, 1.0f); // red with low sat
-		case FullHour:
-			return MARKER_POINT;
-		case MaxElevation:
-			return HIGH_COLOR;
-		case MinElevation:
-			return LOW_COLOR;
-		case StartPoint:
-			return START_COLOR;
-		case EndPoint:
-			return END_POINT;
-		default:		    
-		    break;
-		}
-
-		throw new RuntimeException("Unknown way point kind: " + kind);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.gui.IElevationProfileRenderer
-	 * #renderWayPoint(java.awt.Graphics,
-	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile,
-	 * org.openstreetmap.josm.data.gpx.WayPoint,
-	 * org.openstreetmap.josm.plugins.elevation.ElevationWayPointKind)
-	 */
-	public void renderWayPoint(Graphics g, IElevationProfile profile,
-			MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
-
-		CheckParameterUtil.ensureParameterNotNull(g, "graphics");
-		CheckParameterUtil.ensureParameterNotNull(profile, "profile");
-		CheckParameterUtil.ensureParameterNotNull(mv, "map view");
-				
-		if (wpt == null) {
-			System.err.println(String.format(
-					"Cannot paint: mv=%s, prof=%s, wpt=%s", mv, profile, wpt));			
-			return;
-		}
-
-		switch (kind) {
-		case MinElevation:
-		case MaxElevation:
-			renderMinMaxPoint(g, profile, mv, wpt, kind);
-			break;
-		case EndPoint:
-		case StartPoint:
-			renderStartEndPoint(g, profile, mv, wpt, kind);
-			break;
-		default:
-			renderRegularWayPoint(g, profile, mv, wpt, kind);
-			break;
-		}
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.gui.IElevationProfileRenderer#renderWayPoints(java.awt.Graphics, org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile, org.openstreetmap.josm.gui.MapView, org.openstreetmap.josm.data.gpx.WayPoint, org.openstreetmap.josm.data.gpx.WayPoint)
-	 */
-	@Override
-	public void renderLine(Graphics g, IElevationProfile profile,
-		MapView mv, WayPoint wpt1, WayPoint wpt2, ElevationWayPointKind kind) {
-	    
-	    	CheckParameterUtil.ensureParameterNotNull(g, "graphics");
-		CheckParameterUtil.ensureParameterNotNull(profile, "profile");
-		CheckParameterUtil.ensureParameterNotNull(mv, "map view");
-		
-		if (wpt1 == null || wpt2 == null) {
-			System.err.println(String.format(
-					"Cannot paint line: mv=%s, prof=%s, kind = %s", mv, profile, kind));			
-			return;
-		}
-		
-		// obtain and set color
-		g.setColor(getColorForWaypoint(profile, wpt2, kind));
-		
-		// transform to view
-		Point pnt1 = mv.getPoint(wpt1.getEastNorth());
-		Point pnt2 = mv.getPoint(wpt2.getEastNorth());
-		
-		// use thick line, if possible
-		if (g instanceof Graphics2D) {
-		    Graphics2D g2 = (Graphics2D) g;
-		    Stroke oldS = g2.getStroke();
-		    try {
-			g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
-			g2.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y);
-		    } finally {
-			// must be restored; otherwise other layers may using this style, too 
-			g2.setStroke(oldS);
-		    }
-		} else {
-		    // only poor man's graphics
-		    g.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y);
-		}
-	}
-
-	/**
-	 * Renders a regular way point.
-	 * 
-	 * @param g
-	 *            The graphics context.
-	 * @param profile
-	 *            The elevation profile.
-	 * @param mv
-	 *            The map view instance.
-	 * @param wpt
-	 *            The way point to render.
-	 * @param kind
-	 *            The way point kind (start, end, max,...).
-	 */
-	private void renderRegularWayPoint(Graphics g, IElevationProfile profile,
-			MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
-
-		Color c = getColorForWaypoint(profile, wpt, kind);
-		Point pnt = mv.getPoint(wpt.getEastNorth());
-		
-		/* Paint full hour label */
-		if (kind == ElevationWayPointKind.FullHour) {
-			int hour = ElevationHelper.getHourOfWayPoint(wpt);
-			drawLabel(String.format("%02d:00", hour), pnt.x, pnt.y
-					+ g.getFontMetrics().getHeight(), g);
-		}
-
-		/* Paint label for elevation levels */
-		if (kind == ElevationWayPointKind.ElevationLevelGain || kind == ElevationWayPointKind.ElevationLevelLoss) {
-		    	int ele = ((int) Math.rint(ElevationHelper.getElevation(wpt) / 100.0)) * 100;
-			drawLabelWithTriangle(ElevationHelper.getElevationText(ele), pnt.x, pnt.y
-					+ g.getFontMetrics().getHeight(), g, Color.darkGray, 8, 
-					getColorForWaypoint(profile, wpt, kind),
-					kind == ElevationWayPointKind.ElevationLevelGain ? TriangleDir.Up : TriangleDir.Down);
-		}
-
-		/* Paint cursor labels */
-		if (kind == ElevationWayPointKind.Highlighted) {
-			drawSphere(g, Color.WHITE, c, pnt.x, pnt.y, BIG_WPT_RADIUS);
-			drawLabel(ElevationHelper.getTimeText(wpt), pnt.x, pnt.y
-					- g.getFontMetrics().getHeight() - 5, g);
-			drawLabel(ElevationHelper.getElevationText(wpt), pnt.x, pnt.y
-					+ g.getFontMetrics().getHeight() + 5, g);
-		}
-	}
-
-	/**
-	 * Renders a min/max point
-	 * 
-	 * @param g
-	 *            The graphics context.
-	 * @param profile
-	 *            The elevation profile.
-	 * @param mv
-	 *            The map view instance.
-	 * @param wpt
-	 *            The way point to render.
-	 * @param kind
-	 *            The way point kind (start, end, max,...).
-	 */
-	private void renderMinMaxPoint(Graphics g, IElevationProfile profile,
-			MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
-
-		Color c = getColorForWaypoint(profile, wpt, kind);
-		int eleH = (int) ElevationHelper.getElevation(wpt);
-		Point pnt = mv.getPoint(wpt.getEastNorth());
-
-		TriangleDir td = TriangleDir.Up;
-
-		switch (kind) {
-		case MaxElevation:
-			td = TriangleDir.Up;
-			break;
-		case MinElevation:
-			td = TriangleDir.Down;
-			break;
-		case EndPoint:
-			td = TriangleDir.Left;
-			break;
-		case StartPoint:
-			td = TriangleDir.Right;
-			break;
-		default:
-			return; // nothing to do
-		}
-
-		drawRegularTriangle(g, c, td, pnt.x, pnt.y,
-				DefaultElevationProfileRenderer.TRIANGLE_BASESIZE);
-
-		drawLabel(ElevationHelper.getElevationText(eleH), pnt.x, pnt.y
-				+ g.getFontMetrics().getHeight(), g, c);
-	}
-
-	/**
-	 * Draws a regular triangle.
-	 * 
-	 * @param g
-	 *            The graphics context.
-	 * @param c
-	 *            The fill color of the triangle.
-	 * @param dir
-	 *            The direction of the triangle
-	 * @param x
-	 *            The x coordinate in the graphics context.
-	 * @param y
-	 *            The y coordinate in the graphics context.
-	 * @param baseLength
-	 *            The side length in pixel of the triangle.
-	 */
-	private void drawRegularTriangle(Graphics g, Color c, TriangleDir dir,
-			int x, int y, int baseLength) {
-		if (baseLength < 2)
-			return; // cannot render triangle
-
-		int b2 = baseLength >> 1;
-
-		// coordinates for upwards directed triangle
-		Point p[] = new Point[3];
-
-		for (int i = 0; i < p.length; i++) {
-			p[i] = new Point();
-		}
-
-		p[0].x = -b2;
-		p[0].y = b2;
-
-		p[1].x = b2;
-		p[1].y = b2;
-
-		p[2].x = 0;
-		p[2].y = -b2;
-
-		Triangle t = new Triangle(p[0], p[1], p[2]);
-
-		// rotation angle in rad
-		double theta = 0.0;
-
-		switch (dir) {
-		case Up:
-			theta = 0.0;
-			break;
-		case Down:
-			theta = RAD_180;
-			break;
-		case Left:
-			theta = -RAD_90;
-			break;
-		case Right:
-			theta = RAD_90;
-			break;
-		}
-
-		// rotate shape
-		AffineTransform at = AffineTransform.getRotateInstance(theta);
-		Shape tRot = at.createTransformedShape(t);
-		// translate shape
-		AffineTransform at2 = AffineTransform.getTranslateInstance(x, y);
-		Shape ts = at2.createTransformedShape(tRot);
-
-		// draw the shape
-		Graphics2D g2 = (Graphics2D) g;
-		if (g2 != null) {
-			Color oldC = g2.getColor();
-			g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-					RenderingHints.VALUE_ANTIALIAS_ON);
-			g2.setColor(c);
-			g2.fill(ts);
-			g2.setColor(oldC);
-		}
-	}
-
-	/**
-	 * Renders a start/end point.
-	 * 
-	 * @param g
-	 *            The graphics context.
-	 * @param profile
-	 *            The elevation profile.
-	 * @param mv
-	 *            The map view instance.
-	 * @param wpt
-	 *            The way point to render.
-	 * @param kind
-	 *            The way point kind (start, end, max,...).
-	 */
-	private void renderStartEndPoint(Graphics g, IElevationProfile profile,
-			MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
-
-		Color c = getColorForWaypoint(profile, wpt, kind);
-		Point pnt = mv.getPoint(wpt.getEastNorth());
-		drawSphere(g, Color.WHITE, c, pnt.x, pnt.y, BIG_WPT_RADIUS);
-	}
-
-	/**
-	 * Draws a shaded sphere.
-	 * 
-	 * @param g
-	 *            The graphics context.
-	 * @param firstCol
-	 *            The focus color (usually white).
-	 * @param secondCol
-	 *            The sphere color.
-	 * @param x
-	 *            The x coordinate of the sphere center.
-	 * @param y
-	 *            The y coordinate of the sphere center.
-	 * @param radius
-	 *            The radius of the sphere.
-	 */
-	private void drawSphere(Graphics g, Color firstCol, Color secondCol, int x,
-			int y, int radius) {
-		Point2D center = new Point2D.Float(x, y);
-		Point2D focus = new Point2D.Float(x - (radius * 0.6f), y
-				- (radius * 0.6f));
-		float[] dist = { 0.1f, 0.2f, 1.0f };
-		Color[] colors = { firstCol, secondCol, Color.DARK_GRAY };
-		RadialGradientPaint p = new RadialGradientPaint(center, radius, focus,
-				dist, colors, CycleMethod.NO_CYCLE);
-
-		Graphics2D g2 = (Graphics2D) g;
-		if (g2 != null) {
-			g2.setPaint(p);
-			int r2 = radius / 2;
-			g2.fillOval(x - r2, y - r2, radius, radius);
-		}
-	}
-
-	/**
-	 * Draws a label within a filled rounded rectangle with standard gradient colors.
-	 * 
-	 * @param s
-	 *            The text to draw.
-	 * @param x
-	 *            The x coordinate of the label.
-	 * @param y
-	 *            The y coordinate of the label.
-	 * @param g
-	 *            The graphics context.
-	 */
-	private void drawLabel(String s, int x, int y, Graphics g) {
-		drawLabel(s, x, y, g, Color.GRAY);
-	}
-
-	/**
-	 * Draws a label within a filled rounded rectangle with the specified second gradient color (first color is <tt>Color.WHITE<tt>).
-	 * 
-	 * @param s
-	 *            The text to draw.
-	 * @param x
-	 *            The x coordinate of the label.
-	 * @param y
-	 *            The y coordinate of the label.
-	 * @param g
-	 *            The graphics context.
-	 * @param secondGradColor
-	 *            The second color of the gradient.
-	 */
-	private void drawLabel(String s, int x, int y, Graphics g,
-			Color secondGradColor) {
-		Graphics2D g2d = (Graphics2D) g;
-
-		int width = g.getFontMetrics(g.getFont()).stringWidth(s) + 10;
-		int height = g.getFont().getSize() + g.getFontMetrics().getLeading()
-				+ 5;
-
-		Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width,
-				height);
-
-		if (isForbiddenArea(r)) {
-			return; // no space left, skip this label
-		}
-
-		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-				RenderingHints.VALUE_ANTIALIAS_ON);
-		GradientPaint gradient = new GradientPaint(x, y, Color.WHITE, x, y
-				+ (height / 2), secondGradColor, false);
-		g2d.setPaint(gradient);
-
-		g2d.fillRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
-				ROUND_RECT_RADIUS);
-
-		g2d.setColor(Color.BLACK);
-
-		g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
-				ROUND_RECT_RADIUS);
-		g2d.drawString(s, x - (width / 2) + 5, y + (height / 2) - 3);
-
-		forbiddenRects.add(r);
-	}
-
-	/**
-	 * Draws a label with an additional triangle on the left side.
-	 * 
-	 * @param s
-	 *            The text to draw.
-	 * @param x
-	 *            The x coordinate of the label.
-	 * @param y
-	 *            The y coordinate of the label.
-	 * @param g
-	 *            The graphics context.
-	 * @param secondGradColor
-	 *            The second color of the gradient.
-	 * @param baseLength
-	 *            The base length of the triangle in pixels.
-	 * @param triangleColor
-	 *            The color of the triangle.
-	 * @param triangleDir
-	 *            The direction of the triangle.
-	 */
-	private void drawLabelWithTriangle(String s, int x, int y, Graphics g,
-			Color secondGradColor, int baseLength, Color triangleColor,
-			TriangleDir triangleDir) {
-		Graphics2D g2d = (Graphics2D) g;
-
-		int width = g.getFontMetrics(g.getFont()).stringWidth(s) + 10 + baseLength + 5;
-		int height = g.getFont().getSize() + g.getFontMetrics().getLeading() + 5;
-
-		Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width, height);
-
-		if (isForbiddenArea(r)) {
-			return; // no space left, skip this label
-		}
-
-		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-				RenderingHints.VALUE_ANTIALIAS_ON);
-		GradientPaint gradient = new GradientPaint(x, y, Color.WHITE, x, y
-				+ (height / 2), secondGradColor, false);
-		g2d.setPaint(gradient);
-
-		g2d.fillRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
-				ROUND_RECT_RADIUS);
-
-		g2d.setColor(Color.BLACK);
-
-		g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
-				ROUND_RECT_RADIUS);
-		g2d.drawString(s, x - (width / 2) + 8 + baseLength, y + (height / 2) - 3);
-		drawRegularTriangle(g2d, triangleColor, triangleDir, r.x + baseLength,
-				r.y + baseLength, baseLength);
-
-		forbiddenRects.add(r);
-	}
-
-	/**
-	 * Checks, if the rectangle has been 'reserved' by an previous draw action.
-	 * 
-	 * @param r
-	 *            The area to check for.
-	 * @return true, if area is already occupied by another rectangle.
-	 */
-	private boolean isForbiddenArea(Rectangle r) {
-
-		for (Rectangle rTest : forbiddenRects) {
-			if (r.intersects(rTest))
-				return true;
-		}
-		return false;
-	}
-
-	@Override
-	public void beginRendering() {
-		forbiddenRects.clear();
-	}
-
-	@Override
-	public void finishRendering() {
-		// nothing to do currently
-	}
-
-	
+IElevationProfileRenderer {
+
+    private static final int ROUND_RECT_RADIUS = 6;
+    /**
+     * 
+     */
+    private static final int TRIANGLE_BASESIZE = 24;
+    /**
+     * 
+     */
+    private static final int BASIC_WPT_RADIUS = 1;
+    private static final int BIG_WPT_RADIUS = BASIC_WPT_RADIUS * 16;
+
+    // predefined colors
+    private static final Color HIGH_COLOR = ElevationColors.EPMidBlue;
+    private static final Color LOW_COLOR = ElevationColors.EPMidBlue;
+    private static final Color START_COLOR = Color.GREEN;
+    private static final Color END_POINT = Color.RED;
+    private static final Color LEVEL_GAIN_COLOR = Color.GREEN;
+    private static final Color LEVEL_LOSS_COLOR = Color.RED;
+    private static final Color MARKER_POINT = Color.YELLOW;
+    // Predefined radians
+    private static final double RAD_180 = Math.PI;
+    // private static final double RAD_270 = Math.PI * 1.5;
+    private static final double RAD_90 = Math.PI * 0.5;
+
+    private final List<Rectangle> forbiddenRects = new ArrayList<Rectangle>();
+
+    @Override
+    public Color getColorForWaypoint(IElevationProfile profile, WayPoint wpt,
+            ElevationWayPointKind kind) {
+
+        if (wpt == null || profile == null) {
+            System.err.println(String.format(
+                    "Cannot determine color: prof=%s, wpt=%s", profile, wpt));
+            return null;
+        }
+
+        switch (kind) {
+        case Plain:
+            return Color.LIGHT_GRAY;
+        case ElevationLevelLoss:
+            return LEVEL_LOSS_COLOR;
+        case ElevationLevelGain:
+            return LEVEL_GAIN_COLOR;
+        case Highlighted:
+            return Color.ORANGE;
+        case ElevationGainHigh:
+            return Color.getHSBColor(0.3f, 1.0f, 1.0f); // green
+        case ElevationLossHigh:
+            return Color.getHSBColor(0, 1.0f, 1.0f); // red
+        case ElevationGainLow:
+            return Color.getHSBColor(0.3f, 0.5f, 1.0f); // green with low sat
+        case ElevationLossLow:
+            return Color.getHSBColor(0, 0.5f, 1.0f); // red with low sat
+        case FullHour:
+            return MARKER_POINT;
+        case MaxElevation:
+            return HIGH_COLOR;
+        case MinElevation:
+            return LOW_COLOR;
+        case StartPoint:
+            return START_COLOR;
+        case EndPoint:
+            return END_POINT;
+        default:
+            break;
+        }
+
+        throw new RuntimeException("Unknown way point kind: " + kind);
+    }
+
+    @Override
+    public void renderWayPoint(Graphics g, IElevationProfile profile,
+            MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
+
+        CheckParameterUtil.ensureParameterNotNull(g, "graphics");
+        CheckParameterUtil.ensureParameterNotNull(profile, "profile");
+        CheckParameterUtil.ensureParameterNotNull(mv, "map view");
+
+        if (wpt == null) {
+            System.err.println(String.format(
+                    "Cannot paint: mv=%s, prof=%s, wpt=%s", mv, profile, wpt));
+            return;
+        }
+
+        switch (kind) {
+        case MinElevation:
+        case MaxElevation:
+            renderMinMaxPoint(g, profile, mv, wpt, kind);
+            break;
+        case EndPoint:
+        case StartPoint:
+            renderStartEndPoint(g, profile, mv, wpt, kind);
+            break;
+        default:
+            renderRegularWayPoint(g, profile, mv, wpt, kind);
+            break;
+        }
+    }
+
+    @Override
+    public void renderLine(Graphics g, IElevationProfile profile,
+            MapView mv, WayPoint wpt1, WayPoint wpt2, ElevationWayPointKind kind) {
+
+        CheckParameterUtil.ensureParameterNotNull(g, "graphics");
+        CheckParameterUtil.ensureParameterNotNull(profile, "profile");
+        CheckParameterUtil.ensureParameterNotNull(mv, "map view");
+
+        if (wpt1 == null || wpt2 == null) {
+            System.err.println(String.format(
+                    "Cannot paint line: mv=%s, prof=%s, kind = %s", mv, profile, kind));
+            return;
+        }
+
+        // obtain and set color
+        g.setColor(getColorForWaypoint(profile, wpt2, kind));
+
+        // transform to view
+        Point pnt1 = mv.getPoint(wpt1.getEastNorth());
+        Point pnt2 = mv.getPoint(wpt2.getEastNorth());
+
+        // use thick line, if possible
+        if (g instanceof Graphics2D) {
+            Graphics2D g2 = (Graphics2D) g;
+            Stroke oldS = g2.getStroke();
+            try {
+                g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+                g2.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y);
+            } finally {
+                // must be restored; otherwise other layers may using this style, too
+                g2.setStroke(oldS);
+            }
+        } else {
+            // only poor man's graphics
+            g.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y);
+        }
+    }
+
+    /**
+     * Renders a regular way point.
+     * 
+     * @param g
+     *            The graphics context.
+     * @param profile
+     *            The elevation profile.
+     * @param mv
+     *            The map view instance.
+     * @param wpt
+     *            The way point to render.
+     * @param kind
+     *            The way point kind (start, end, max,...).
+     */
+    private void renderRegularWayPoint(Graphics g, IElevationProfile profile,
+            MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
+
+        Color c = getColorForWaypoint(profile, wpt, kind);
+        Point pnt = mv.getPoint(wpt.getEastNorth());
+
+        /* Paint full hour label */
+        if (kind == ElevationWayPointKind.FullHour) {
+            int hour = ElevationHelper.getHourOfWayPoint(wpt);
+            drawLabel(String.format("%02d:00", hour), pnt.x, pnt.y
+                    + g.getFontMetrics().getHeight(), g);
+        }
+
+        /* Paint label for elevation levels */
+        if (kind == ElevationWayPointKind.ElevationLevelGain || kind == ElevationWayPointKind.ElevationLevelLoss) {
+            int ele = ((int) Math.rint(ElevationHelper.getElevation(wpt) / 100.0)) * 100;
+            drawLabelWithTriangle(ElevationHelper.getElevationText(ele), pnt.x, pnt.y
+                    + g.getFontMetrics().getHeight(), g, Color.darkGray, 8,
+                    getColorForWaypoint(profile, wpt, kind),
+                    kind == ElevationWayPointKind.ElevationLevelGain ? TriangleDir.Up : TriangleDir.Down);
+        }
+
+        /* Paint cursor labels */
+        if (kind == ElevationWayPointKind.Highlighted) {
+            drawSphere(g, Color.WHITE, c, pnt.x, pnt.y, BIG_WPT_RADIUS);
+            drawLabel(ElevationHelper.getTimeText(wpt), pnt.x, pnt.y
+                    - g.getFontMetrics().getHeight() - 5, g);
+            drawLabel(ElevationHelper.getElevationText(wpt), pnt.x, pnt.y
+                    + g.getFontMetrics().getHeight() + 5, g);
+        }
+    }
+
+    /**
+     * Renders a min/max point
+     * 
+     * @param g
+     *            The graphics context.
+     * @param profile
+     *            The elevation profile.
+     * @param mv
+     *            The map view instance.
+     * @param wpt
+     *            The way point to render.
+     * @param kind
+     *            The way point kind (start, end, max,...).
+     */
+    private void renderMinMaxPoint(Graphics g, IElevationProfile profile,
+            MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
+
+        Color c = getColorForWaypoint(profile, wpt, kind);
+        int eleH = (int) ElevationHelper.getElevation(wpt);
+        Point pnt = mv.getPoint(wpt.getEastNorth());
+
+        TriangleDir td = TriangleDir.Up;
+
+        switch (kind) {
+        case MaxElevation:
+            td = TriangleDir.Up;
+            break;
+        case MinElevation:
+            td = TriangleDir.Down;
+            break;
+        case EndPoint:
+            td = TriangleDir.Left;
+            break;
+        case StartPoint:
+            td = TriangleDir.Right;
+            break;
+        default:
+            return; // nothing to do
+        }
+
+        drawRegularTriangle(g, c, td, pnt.x, pnt.y,
+                DefaultElevationProfileRenderer.TRIANGLE_BASESIZE);
+
+        drawLabel(ElevationHelper.getElevationText(eleH), pnt.x, pnt.y
+                + g.getFontMetrics().getHeight(), g, c);
+    }
+
+    /**
+     * Draws a regular triangle.
+     * 
+     * @param g
+     *            The graphics context.
+     * @param c
+     *            The fill color of the triangle.
+     * @param dir
+     *            The direction of the triangle
+     * @param x
+     *            The x coordinate in the graphics context.
+     * @param y
+     *            The y coordinate in the graphics context.
+     * @param baseLength
+     *            The side length in pixel of the triangle.
+     */
+    private void drawRegularTriangle(Graphics g, Color c, TriangleDir dir,
+            int x, int y, int baseLength) {
+        if (baseLength < 2)
+            return; // cannot render triangle
+
+        int b2 = baseLength >> 1;
+
+        // coordinates for upwards directed triangle
+        Point p[] = new Point[3];
+
+        for (int i = 0; i < p.length; i++) {
+            p[i] = new Point();
+        }
+
+        p[0].x = -b2;
+        p[0].y = b2;
+
+        p[1].x = b2;
+        p[1].y = b2;
+
+        p[2].x = 0;
+        p[2].y = -b2;
+
+        Triangle t = new Triangle(p[0], p[1], p[2]);
+
+        // rotation angle in rad
+        double theta = 0.0;
+
+        switch (dir) {
+        case Up:
+            theta = 0.0;
+            break;
+        case Down:
+            theta = RAD_180;
+            break;
+        case Left:
+            theta = -RAD_90;
+            break;
+        case Right:
+            theta = RAD_90;
+            break;
+        }
+
+        // rotate shape
+        AffineTransform at = AffineTransform.getRotateInstance(theta);
+        Shape tRot = at.createTransformedShape(t);
+        // translate shape
+        AffineTransform at2 = AffineTransform.getTranslateInstance(x, y);
+        Shape ts = at2.createTransformedShape(tRot);
+
+        // draw the shape
+        Graphics2D g2 = (Graphics2D) g;
+        if (g2 != null) {
+            Color oldC = g2.getColor();
+            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                    RenderingHints.VALUE_ANTIALIAS_ON);
+            g2.setColor(c);
+            g2.fill(ts);
+            g2.setColor(oldC);
+        }
+    }
+
+    /**
+     * Renders a start/end point.
+     * 
+     * @param g
+     *            The graphics context.
+     * @param profile
+     *            The elevation profile.
+     * @param mv
+     *            The map view instance.
+     * @param wpt
+     *            The way point to render.
+     * @param kind
+     *            The way point kind (start, end, max,...).
+     */
+    private void renderStartEndPoint(Graphics g, IElevationProfile profile,
+            MapView mv, WayPoint wpt, ElevationWayPointKind kind) {
+
+        Color c = getColorForWaypoint(profile, wpt, kind);
+        Point pnt = mv.getPoint(wpt.getEastNorth());
+        drawSphere(g, Color.WHITE, c, pnt.x, pnt.y, BIG_WPT_RADIUS);
+    }
+
+    /**
+     * Draws a shaded sphere.
+     * 
+     * @param g
+     *            The graphics context.
+     * @param firstCol
+     *            The focus color (usually white).
+     * @param secondCol
+     *            The sphere color.
+     * @param x
+     *            The x coordinate of the sphere center.
+     * @param y
+     *            The y coordinate of the sphere center.
+     * @param radius
+     *            The radius of the sphere.
+     */
+    private void drawSphere(Graphics g, Color firstCol, Color secondCol, int x,
+            int y, int radius) {
+        Point2D center = new Point2D.Float(x, y);
+        Point2D focus = new Point2D.Float(x - (radius * 0.6f), y
+                - (radius * 0.6f));
+        float[] dist = { 0.1f, 0.2f, 1.0f };
+        Color[] colors = { firstCol, secondCol, Color.DARK_GRAY };
+        RadialGradientPaint p = new RadialGradientPaint(center, radius, focus,
+                dist, colors, CycleMethod.NO_CYCLE);
+
+        Graphics2D g2 = (Graphics2D) g;
+        if (g2 != null) {
+            g2.setPaint(p);
+            int r2 = radius / 2;
+            g2.fillOval(x - r2, y - r2, radius, radius);
+        }
+    }
+
+    /**
+     * Draws a label within a filled rounded rectangle with standard gradient colors.
+     * 
+     * @param s
+     *            The text to draw.
+     * @param x
+     *            The x coordinate of the label.
+     * @param y
+     *            The y coordinate of the label.
+     * @param g
+     *            The graphics context.
+     */
+    private void drawLabel(String s, int x, int y, Graphics g) {
+        drawLabel(s, x, y, g, Color.GRAY);
+    }
+
+    /**
+     * Draws a label within a filled rounded rectangle with the specified second gradient color (first color is <tt>Color.WHITE<tt>).
+     * 
+     * @param s
+     *            The text to draw.
+     * @param x
+     *            The x coordinate of the label.
+     * @param y
+     *            The y coordinate of the label.
+     * @param g
+     *            The graphics context.
+     * @param secondGradColor
+     *            The second color of the gradient.
+     */
+    private void drawLabel(String s, int x, int y, Graphics g,
+            Color secondGradColor) {
+        Graphics2D g2d = (Graphics2D) g;
+
+        int width = g.getFontMetrics(g.getFont()).stringWidth(s) + 10;
+        int height = g.getFont().getSize() + g.getFontMetrics().getLeading()
+                + 5;
+
+        Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width,
+                height);
+
+        if (isForbiddenArea(r)) {
+            return; // no space left, skip this label
+        }
+
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                RenderingHints.VALUE_ANTIALIAS_ON);
+        GradientPaint gradient = new GradientPaint(x, y, Color.WHITE, x, y
+                + (height / 2), secondGradColor, false);
+        g2d.setPaint(gradient);
+
+        g2d.fillRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
+                ROUND_RECT_RADIUS);
+
+        g2d.setColor(Color.BLACK);
+
+        g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
+                ROUND_RECT_RADIUS);
+        g2d.drawString(s, x - (width / 2) + 5, y + (height / 2) - 3);
+
+        forbiddenRects.add(r);
+    }
+
+    /**
+     * Draws a label with an additional triangle on the left side.
+     * 
+     * @param s
+     *            The text to draw.
+     * @param x
+     *            The x coordinate of the label.
+     * @param y
+     *            The y coordinate of the label.
+     * @param g
+     *            The graphics context.
+     * @param secondGradColor
+     *            The second color of the gradient.
+     * @param baseLength
+     *            The base length of the triangle in pixels.
+     * @param triangleColor
+     *            The color of the triangle.
+     * @param triangleDir
+     *            The direction of the triangle.
+     */
+    private void drawLabelWithTriangle(String s, int x, int y, Graphics g,
+            Color secondGradColor, int baseLength, Color triangleColor,
+            TriangleDir triangleDir) {
+        Graphics2D g2d = (Graphics2D) g;
+
+        int width = g.getFontMetrics(g.getFont()).stringWidth(s) + 10 + baseLength + 5;
+        int height = g.getFont().getSize() + g.getFontMetrics().getLeading() + 5;
+
+        Rectangle r = new Rectangle(x - (width / 2), y - (height / 2), width, height);
+
+        if (isForbiddenArea(r)) {
+            return; // no space left, skip this label
+        }
+
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                RenderingHints.VALUE_ANTIALIAS_ON);
+        GradientPaint gradient = new GradientPaint(x, y, Color.WHITE, x, y
+                + (height / 2), secondGradColor, false);
+        g2d.setPaint(gradient);
+
+        g2d.fillRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
+                ROUND_RECT_RADIUS);
+
+        g2d.setColor(Color.BLACK);
+
+        g2d.drawRoundRect(r.x, r.y, r.width, r.height, ROUND_RECT_RADIUS,
+                ROUND_RECT_RADIUS);
+        g2d.drawString(s, x - (width / 2) + 8 + baseLength, y + (height / 2) - 3);
+        drawRegularTriangle(g2d, triangleColor, triangleDir, r.x + baseLength,
+                r.y + baseLength, baseLength);
+
+        forbiddenRects.add(r);
+    }
+
+    /**
+     * Checks, if the rectangle has been 'reserved' by an previous draw action.
+     * 
+     * @param r
+     *            The area to check for.
+     * @return true, if area is already occupied by another rectangle.
+     */
+    private boolean isForbiddenArea(Rectangle r) {
+
+        for (Rectangle rTest : forbiddenRects) {
+            if (r.intersects(rTest))
+                return true;
+        }
+        return false;
+    }
+
+    @Override
+    public void beginRendering() {
+        forbiddenRects.clear();
+    }
+
+    @Override
+    public void finishRendering() {
+        // nothing to do currently
+    }
+
+
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationColors.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationColors.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationColors.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -20,90 +7,90 @@
 
 /**
- * Contains some extra predefined colors. 
+ * Contains some extra predefined colors.
  * @author Oliver Wieland <oliver.wieland@online.de>
  */
 public class ElevationColors {
-	public static Color EPDarkBlue = new Color(21, 59, 99);
-	public static Color EPMidBlue = new Color(115, 140, 180);
-	public static Color EPLightBlue = new Color(176, 187, 208);
-	
-	public static Color EPOrange = new Color(180, 140, 115);
-	
-	public static Color EPLightBeige = new Color(235, 235, 215);
-	public static Color EPMidBeige = new Color(227, 222, 215);
-	
-	// TODO: Move to ColorMap.java or delete it	
-	static class ColorMapEntry {
-	    private int ele; // limit
-	    private Color color;
-	    public ColorMapEntry(java.awt.Color color, int ele) {
-		super();
-		this.color = color;
-		this.ele = ele;
-	    }
-	    
-	    public int getEle() {
-	        return ele;
-	    }
-	    
-	    public Color getColor() {
-	        return color;
-	    }
-	}
-	
-	
-	
-	private static ColorMapEntry[] colors = new ColorMapEntry[]{
-		  new ColorMapEntry(new Color(0,128, 0), 0),  
-		  new ColorMapEntry(new Color(156,187, 105), 1),  
-		  new ColorMapEntry(new Color(193,208, 107), 100),
-		  new ColorMapEntry(new Color(244,224, 100), 200),
-		  new ColorMapEntry(new Color(242,216, 149), 500),
-		  new ColorMapEntry(new Color(234,191, 104), 1000),
-		  new ColorMapEntry(new Color(207,169, 96), 2000),
-		};
-	
-		
-	public static Color getElevationColor(double ele) {
-	    if (!ElevationHelper.isValidElevation(ele)) {
-		return Color.white;
-	    }
-	   
-	    // TODO: Better color model...
-	    Color col = Color.green;
-	    
-	    if (ele < 0) {
-		col = Color.blue;
-	    }
-	    
-	    if (ele > 200) {
-		col = colors[1].getColor(); 
-	    }
-	    
-	    if (ele > 300) {
-		col = colors[2].getColor(); 
-	    }
-	    
-	    if (ele > 400) {
-		col = colors[3].getColor(); 
-	    }
-	    
-	    if (ele > 500) {
-		col = Color.yellow; 
-	    }
-	    
-	    if (ele > 750) {
-		col = Color.orange; 
-	    }
-	    
-	    if (ele > 1000) {
-		col = Color.lightGray; 
-	    }
-	    
-	    if (ele > 2000) {
-		col = Color.darkGray; 
-	    }
-	    
-	    return col;
-	}
+    public static Color EPDarkBlue = new Color(21, 59, 99);
+    public static Color EPMidBlue = new Color(115, 140, 180);
+    public static Color EPLightBlue = new Color(176, 187, 208);
+
+    public static Color EPOrange = new Color(180, 140, 115);
+
+    public static Color EPLightBeige = new Color(235, 235, 215);
+    public static Color EPMidBeige = new Color(227, 222, 215);
+
+    // TODO: Move to ColorMap.java or delete it
+    static class ColorMapEntry {
+        private final int ele; // limit
+        private final Color color;
+        public ColorMapEntry(java.awt.Color color, int ele) {
+            super();
+            this.color = color;
+            this.ele = ele;
+        }
+
+        public int getEle() {
+            return ele;
+        }
+
+        public Color getColor() {
+            return color;
+        }
+    }
+
+
+
+    private static ColorMapEntry[] colors = new ColorMapEntry[]{
+        new ColorMapEntry(new Color(0,128, 0), 0),
+        new ColorMapEntry(new Color(156,187, 105), 1),
+        new ColorMapEntry(new Color(193,208, 107), 100),
+        new ColorMapEntry(new Color(244,224, 100), 200),
+        new ColorMapEntry(new Color(242,216, 149), 500),
+        new ColorMapEntry(new Color(234,191, 104), 1000),
+        new ColorMapEntry(new Color(207,169, 96), 2000),
+    };
+
+
+    public static Color getElevationColor(double ele) {
+        if (!ElevationHelper.isValidElevation(ele)) {
+            return Color.white;
+        }
+
+        // TODO: Better color model...
+        Color col = Color.green;
+
+        if (ele < 0) {
+            col = Color.blue;
+        }
+
+        if (ele > 200) {
+            col = colors[1].getColor();
+        }
+
+        if (ele > 300) {
+            col = colors[2].getColor();
+        }
+
+        if (ele > 400) {
+            col = colors[3].getColor();
+        }
+
+        if (ele > 500) {
+            col = Color.yellow;
+        }
+
+        if (ele > 750) {
+            col = Color.orange;
+        }
+
+        if (ele > 1000) {
+            col = Color.lightGray;
+        }
+
+        if (ele > 2000) {
+            col = Color.darkGray;
+        }
+
+        return col;
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -52,4 +39,5 @@
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationModel;
 import org.openstreetmap.josm.tools.Shortcut;
+
 /**
  * @author Oliver Wieland <oliver.wieland@online.de>
@@ -93,6 +81,6 @@
      */
     public ElevationProfileDialog() {
-	this(tr("Elevation Profile"), "elevation",
-		tr("Open the elevation profile window."), null, 200, true);
+        this(tr("Elevation Profile"), "elevation",
+                tr("Open the elevation profile window."), null, 200, true);
     }
 
@@ -101,6 +89,6 @@
      */
     public ElevationProfileDialog(String name, String iconName, String tooltip,
-	    Shortcut shortcut, int preferredHeight) {
-	this(name, iconName, tooltip, shortcut, preferredHeight, false);
+            Shortcut shortcut, int preferredHeight) {
+        this(name, iconName, tooltip, shortcut, preferredHeight, false);
     }
 
@@ -123,101 +111,101 @@
      */
     public ElevationProfileDialog(String name, String iconName, String tooltip,
-	    Shortcut shortcut, int preferredHeight, boolean defShow) {
-	super(name, iconName, tooltip, shortcut, preferredHeight, defShow);
-
-	// create model
-	model = new ElevationModel();
-
-	// top panel
-	JPanel rootPanel = new JPanel();
-	GridLayout gridLayout1 = new GridLayout(2, 1);
-	rootPanel.setLayout(gridLayout1);
-
-	// statistics panel
-	JPanel statPanel = new JPanel();
-	GridLayout gridLayoutStat = new GridLayout(2, 6);
-	statPanel.setLayout(gridLayoutStat);
-
-	// first row: Headlines with bold font
-	String[] labels = new String[]{tr("Min"), tr("Avrg"), tr("Max"), tr("Dist"), tr("Gain"), tr("Time")};
-	for (int i = 0; i < labels.length; i++) {
-	    JLabel lbl = new JLabel(labels[i]);
-	    lbl.setFont(getFont().deriveFont(Font.BOLD));
-	    statPanel.add(lbl);
-	}
-
-	// second row
-	minHeightLabel = new JLabel("0 m");
-	statPanel.add(minHeightLabel);
-	avrgHeightLabel = new JLabel("0 m");
-	statPanel.add(avrgHeightLabel);
-	maxHeightLabel = new JLabel("0 m");
-	statPanel.add(maxHeightLabel);
-	distLabel = new JLabel("0 km");
-	statPanel.add(distLabel);
-	elevationGainLabel = new JLabel("0 m");
-	statPanel.add(elevationGainLabel);
-	totalTimeLabel = new JLabel("0");
-	statPanel.add(totalTimeLabel);
-
-	// track selection panel
-	JPanel trackPanel = new JPanel();
-	FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
-	trackPanel.setLayout(fl);
-
-	JLabel lbTrack = new JLabel(tr("Tracks"));
-	lbTrack.setFont(getFont().deriveFont(Font.BOLD));
-	trackPanel.add(lbTrack);
-
-	zoomButton = new JButton(tr("Zoom"));
-	zoomButton.addActionListener(new ActionListener() {
-	    @Override
-	    public void actionPerformed(ActionEvent arg0) {
-		if (model != null) {
-		    IElevationProfile profile = model.getCurrentProfile();
-		    if (profile != null) {
-			Main.map.mapView.zoomTo(profile.getBounds());
-		    }
-		}
-
-	    }
-	});
-	zoomButton.setEnabled(false);
-
-	trackCombo = new JComboBox(new TrackModel());
-	trackCombo.setPreferredSize(new Dimension(200, 24)); // HACK!
-	trackCombo.setEnabled(false); // we have no model on startup
-
-	trackPanel.add(trackCombo);
-	trackPanel.add(zoomButton);
-
-	// assemble root panel
-	rootPanel.add(statPanel);
-	rootPanel.add(trackPanel);
-
-	add(rootPanel, BorderLayout.PAGE_END);
-
-	// add chart component
-	profPanel = new ElevationProfilePanel(null);
-	add(profPanel, BorderLayout.CENTER);
-	profPanel.addComponentListener(this);
-
-	dock();
+            Shortcut shortcut, int preferredHeight, boolean defShow) {
+        super(name, iconName, tooltip, shortcut, preferredHeight, defShow);
+
+        // create model
+        model = new ElevationModel();
+
+        // top panel
+        JPanel rootPanel = new JPanel();
+        GridLayout gridLayout1 = new GridLayout(2, 1);
+        rootPanel.setLayout(gridLayout1);
+
+        // statistics panel
+        JPanel statPanel = new JPanel();
+        GridLayout gridLayoutStat = new GridLayout(2, 6);
+        statPanel.setLayout(gridLayoutStat);
+
+        // first row: Headlines with bold font
+        String[] labels = new String[]{tr("Min"), tr("Avrg"), tr("Max"), tr("Dist"), tr("Gain"), tr("Time")};
+        for (int i = 0; i < labels.length; i++) {
+            JLabel lbl = new JLabel(labels[i]);
+            lbl.setFont(getFont().deriveFont(Font.BOLD));
+            statPanel.add(lbl);
+        }
+
+        // second row
+        minHeightLabel = new JLabel("0 m");
+        statPanel.add(minHeightLabel);
+        avrgHeightLabel = new JLabel("0 m");
+        statPanel.add(avrgHeightLabel);
+        maxHeightLabel = new JLabel("0 m");
+        statPanel.add(maxHeightLabel);
+        distLabel = new JLabel("0 km");
+        statPanel.add(distLabel);
+        elevationGainLabel = new JLabel("0 m");
+        statPanel.add(elevationGainLabel);
+        totalTimeLabel = new JLabel("0");
+        statPanel.add(totalTimeLabel);
+
+        // track selection panel
+        JPanel trackPanel = new JPanel();
+        FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
+        trackPanel.setLayout(fl);
+
+        JLabel lbTrack = new JLabel(tr("Tracks"));
+        lbTrack.setFont(getFont().deriveFont(Font.BOLD));
+        trackPanel.add(lbTrack);
+
+        zoomButton = new JButton(tr("Zoom"));
+        zoomButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent arg0) {
+                if (model != null) {
+                    IElevationProfile profile = model.getCurrentProfile();
+                    if (profile != null) {
+                        Main.map.mapView.zoomTo(profile.getBounds());
+                    }
+                }
+
+            }
+        });
+        zoomButton.setEnabled(false);
+
+        trackCombo = new JComboBox(new TrackModel());
+        trackCombo.setPreferredSize(new Dimension(200, 24)); // HACK!
+        trackCombo.setEnabled(false); // we have no model on startup
+
+        trackPanel.add(trackCombo);
+        trackPanel.add(zoomButton);
+
+        // assemble root panel
+        rootPanel.add(statPanel);
+        rootPanel.add(trackPanel);
+
+        add(rootPanel, BorderLayout.PAGE_END);
+
+        // add chart component
+        profPanel = new ElevationProfilePanel(null);
+        add(profPanel, BorderLayout.CENTER);
+        profPanel.addComponentListener(this);
+
+        dock();
     }
 
     @Override
     public void showNotify() {
-	MapView.addLayerChangeListener(this);
-	if (Main.isDisplayingMapView()) {
-	    Layer layer = Main.map.mapView.getActiveLayer();
-	    if (layer instanceof GpxLayer) {
-		setActiveLayer((GpxLayer) layer);
-	    }
-	}
+        MapView.addLayerChangeListener(this);
+        if (Main.isDisplayingMapView()) {
+            Layer layer = Main.map.mapView.getActiveLayer();
+            if (layer instanceof GpxLayer) {
+                setActiveLayer((GpxLayer) layer);
+            }
+        }
     }
 
     @Override
     public void hideNotify() {
-	MapView.removeLayerChangeListener(this);
+        MapView.removeLayerChangeListener(this);
     }
 
@@ -227,5 +215,5 @@
      */
     public IElevationModel getModel() {
-	return model;
+        return model;
     }
 
@@ -235,9 +223,9 @@
      */
     public void setModel(IElevationModel model) {
-	if (this.model != model) {
-	    this.model = model;
-	    profPanel.setElevationModel(model);
-	    updateView();
-	}
+        if (this.model != model) {
+            this.model = model;
+            profPanel.setElevationModel(model);
+            updateView();
+        }
     }
 
@@ -247,5 +235,5 @@
      */
     public ElevationProfileLayer getProfileLayer() {
-	return profileLayer;
+        return profileLayer;
     }
 
@@ -255,11 +243,11 @@
      */
     public void setProfileLayer(ElevationProfileLayer profileLayer) {
-	if (this.profileLayer != profileLayer) {
-	    if (this.profileLayer != null) {
-		profPanel.removeSelectionListener(this.profileLayer);
-	    }
-	    this.profileLayer = profileLayer;
-	    profPanel.addSelectionListener(this.profileLayer);
-	}
+        if (this.profileLayer != profileLayer) {
+            if (this.profileLayer != null) {
+                profPanel.removeSelectionListener(this.profileLayer);
+            }
+            this.profileLayer = profileLayer;
+            profPanel.addSelectionListener(this.profileLayer);
+        }
     }
 
@@ -270,58 +258,58 @@
     @SuppressWarnings("unchecked") // TODO: Can be removed in Java 1.7
     private void updateView() {
-	if (model == null) {
-	    disableView();
-	    return;
-	}
-
-	IElevationProfile profile = model.getCurrentProfile();
-	if (profile != null) {
-	    // Show name of profile in title
-	    setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
-
-	    if (profile.hasElevationData()) {
-		// Show elevation data
-		minHeightLabel.setText(
-			ElevationHelper.getElevationText(profile.getMinHeight()));
-		maxHeightLabel.setText(
-			ElevationHelper.getElevationText(profile.getMaxHeight()));
-		avrgHeightLabel.setText(
-			ElevationHelper.getElevationText(profile.getAverageHeight()));
-		elevationGainLabel.setText(
-			ElevationHelper.getElevationText(profile.getGain()));
-	    }
-
-	    // compute values for time and distance
-	    long diff = profile.getTimeDifference();
-	    long minutes = diff / (1000 * 60);
-	    long hours = minutes / 60;
-	    minutes = minutes % 60;
-
-	    double dist = profile.getDistance();
-
-	    totalTimeLabel.setText(String.format("%d:%02d h", hours, minutes));
-	    distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist));
-	    trackCombo.setEnabled(model.profileCount() > 1);
-	    trackCombo.setModel(new TrackModel());
-	    zoomButton.setEnabled(true);
-	} else { // no elevation data, -> switch back to empty view
-	    disableView();
-	}
-
-	fireModelChanged();
-	repaint();
+        if (model == null) {
+            disableView();
+            return;
+        }
+
+        IElevationProfile profile = model.getCurrentProfile();
+        if (profile != null) {
+            // Show name of profile in title
+            setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
+
+            if (profile.hasElevationData()) {
+                // Show elevation data
+                minHeightLabel.setText(
+                        ElevationHelper.getElevationText(profile.getMinHeight()));
+                maxHeightLabel.setText(
+                        ElevationHelper.getElevationText(profile.getMaxHeight()));
+                avrgHeightLabel.setText(
+                        ElevationHelper.getElevationText(profile.getAverageHeight()));
+                elevationGainLabel.setText(
+                        ElevationHelper.getElevationText(profile.getGain()));
+            }
+
+            // compute values for time and distance
+            long diff = profile.getTimeDifference();
+            long minutes = diff / (1000 * 60);
+            long hours = minutes / 60;
+            minutes = minutes % 60;
+
+            double dist = profile.getDistance();
+
+            totalTimeLabel.setText(String.format("%d:%02d h", hours, minutes));
+            distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist));
+            trackCombo.setEnabled(model.profileCount() > 1);
+            trackCombo.setModel(new TrackModel());
+            zoomButton.setEnabled(true);
+        } else { // no elevation data, -> switch back to empty view
+            disableView();
+        }
+
+        fireModelChanged();
+        repaint();
     }
 
     private void disableView() {
-	setTitle(String.format("%s: (No data)", tr("Elevation Profile")));
-
-	minHeightLabel.setText(EMPTY_DATA_STRING);
-	maxHeightLabel.setText(EMPTY_DATA_STRING);
-	avrgHeightLabel.setText(EMPTY_DATA_STRING);
-	elevationGainLabel.setText(EMPTY_DATA_STRING);
-	totalTimeLabel.setText(EMPTY_DATA_STRING);
-	distLabel.setText(EMPTY_DATA_STRING);
-	trackCombo.setEnabled(false);
-	zoomButton.setEnabled(false);
+        setTitle(String.format("%s: (No data)", tr("Elevation Profile")));
+
+        minHeightLabel.setText(EMPTY_DATA_STRING);
+        maxHeightLabel.setText(EMPTY_DATA_STRING);
+        avrgHeightLabel.setText(EMPTY_DATA_STRING);
+        elevationGainLabel.setText(EMPTY_DATA_STRING);
+        totalTimeLabel.setText(EMPTY_DATA_STRING);
+        distLabel.setText(EMPTY_DATA_STRING);
+        trackCombo.setEnabled(false);
+        zoomButton.setEnabled(false);
     }
 
@@ -330,7 +318,7 @@
      */
     protected void fireModelChanged() {
-	for (IElevationModelListener listener : listeners) {
-	    listener.elevationProfileChanged(getModel().getCurrentProfile());
-	}
+        for (IElevationModelListener listener : listeners) {
+            listener.elevationProfileChanged(getModel().getCurrentProfile());
+        }
     }
 
@@ -342,5 +330,5 @@
      */
     public void addModelListener(IElevationModelListener listener) {
-	this.listeners.add(listener);
+        this.listeners.add(listener);
     }
 
@@ -352,5 +340,5 @@
      */
     public void removeModelListener(IElevationModelListener listener) {
-	this.listeners.remove(listener);
+        this.listeners.remove(listener);
     }
 
@@ -359,155 +347,119 @@
      */
     public void removeAllListeners() {
-	this.listeners.clear();
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.MapView.LayerChangeListener#activeLayerChange(org.openstreetmap.josm.gui.layer.Layer, org.openstreetmap.josm.gui.layer.Layer)
-     */
+        this.listeners.clear();
+    }
+
     @Override
     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
-	if (newLayer instanceof GpxLayer) {
-	    setActiveLayer((GpxLayer) newLayer);
-	}
+        if (newLayer instanceof GpxLayer) {
+            setActiveLayer((GpxLayer) newLayer);
+        }
     }
 
     private void setActiveLayer(GpxLayer newLayer) {
-	if (activeLayer != newLayer) {
-	    activeLayer = newLayer;
-
-	    // layer does not exist -> create
-	    if (!layerMap.containsKey(newLayer)) {
-		GpxData gpxData = newLayer.data;
-		ElevationModel newEM = new ElevationModel(newLayer.getName(),
-			gpxData);
-		layerMap.put(newLayer, newEM);
-	    }
-
-	    ElevationModel em = layerMap.get(newLayer);
-	    setModel(em);
-	}
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.MapView.LayerChangeListener#layerAdded(org.openstreetmap.josm.gui.layer.Layer)
-     */
+        if (activeLayer != newLayer) {
+            activeLayer = newLayer;
+
+            // layer does not exist -> create
+            if (!layerMap.containsKey(newLayer)) {
+                GpxData gpxData = newLayer.data;
+                ElevationModel newEM = new ElevationModel(newLayer.getName(),
+                        gpxData);
+                layerMap.put(newLayer, newEM);
+            }
+
+            ElevationModel em = layerMap.get(newLayer);
+            setModel(em);
+        }
+    }
+
     @Override
     public void layerAdded(Layer newLayer) {
-	if (newLayer instanceof GpxLayer) {
-	    GpxLayer gpxLayer = (GpxLayer) newLayer;
-	    setActiveLayer(gpxLayer);
-	}
-    }
-
-    /* (non-Javadoc)
-     * @see org.openstreetmap.josm.gui.MapView.LayerChangeListener#layerRemoved(org.openstreetmap.josm.gui.layer.Layer)
-     */
+        if (newLayer instanceof GpxLayer) {
+            GpxLayer gpxLayer = (GpxLayer) newLayer;
+            setActiveLayer(gpxLayer);
+        }
+    }
+
     @Override
     public void layerRemoved(Layer oldLayer) {
-	if (layerMap.containsKey(oldLayer)) {
-	    layerMap.remove(oldLayer);
-	}
-
-	if (layerMap.size() == 0) {
-	    setModel(null);
-	    if (profileLayer != null) {
-		profileLayer.setProfile(null);
-	    }
-	}
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @seejava.awt.event.ComponentListener#componentHidden(java.awt.event.
-     * ComponentEvent)
-     */
+        if (layerMap.containsKey(oldLayer)) {
+            layerMap.remove(oldLayer);
+        }
+
+        if (layerMap.size() == 0) {
+            setModel(null);
+            if (profileLayer != null) {
+                profileLayer.setProfile(null);
+            }
+        }
+    }
+
     @Override
     public void componentHidden(ComponentEvent e) {
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent
-     * )
-     */
     @Override
     public void componentMoved(ComponentEvent e) {
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seejava.awt.event.ComponentListener#componentResized(java.awt.event.
-     * ComponentEvent)
-     */
     @Override
     public void componentResized(ComponentEvent e) {
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent
-     * )
-     */
     @Override
     public void componentShown(ComponentEvent e) {
     }
-
 
     @SuppressWarnings("rawtypes") // TODO: Can be removed in Java 1.7
     class TrackModel implements ComboBoxModel {
-	private Collection<ListDataListener> listeners;
-
-	@Override
-	public void addListDataListener(ListDataListener arg0) {
-	    if (listeners == null) {
-		listeners = new ArrayList<ListDataListener>();
-	    }
-	    listeners.add(arg0);
-	}
-
-	@Override
-	public IElevationProfile getElementAt(int index) {
-	    if (model == null) return null;
-
-	    IElevationProfile ep = model.getProfiles().get(index);
-	    return ep;
-	}
-
-	@Override
-	public int getSize() {
-	    if (model == null) return 0;
-
-	    return model.profileCount();
-	}
-
-	@Override
-	public void removeListDataListener(ListDataListener listener) {
-	    if (listeners == null) return;
-
-	    listeners.remove(listener);
-	}
-
-	@Override
-	public Object getSelectedItem() {
-	    if (model == null) return null;
-
-	    return model.getCurrentProfile();
-	}
-
-	@Override
-	public void setSelectedItem(Object selectedObject) {
-	    if (model != null && selectedObject instanceof IElevationProfile) {
-		model.setCurrentProfile((IElevationProfile) selectedObject);
-		profileLayer.setProfile(model.getCurrentProfile());
-
-		repaint();
-	    }
-	}
+        private Collection<ListDataListener> listeners;
+
+        @Override
+        public void addListDataListener(ListDataListener arg0) {
+            if (listeners == null) {
+                listeners = new ArrayList<ListDataListener>();
+            }
+            listeners.add(arg0);
+        }
+
+        @Override
+        public IElevationProfile getElementAt(int index) {
+            if (model == null) return null;
+
+            IElevationProfile ep = model.getProfiles().get(index);
+            return ep;
+        }
+
+        @Override
+        public int getSize() {
+            if (model == null) return 0;
+
+            return model.profileCount();
+        }
+
+        @Override
+        public void removeListDataListener(ListDataListener listener) {
+            if (listeners == null) return;
+
+            listeners.remove(listener);
+        }
+
+        @Override
+        public Object getSelectedItem() {
+            if (model == null) return null;
+
+            return model.getCurrentProfile();
+        }
+
+        @Override
+        public void setSelectedItem(Object selectedObject) {
+            if (model != null && selectedObject instanceof IElevationProfile) {
+                model.setCurrentProfile((IElevationProfile) selectedObject);
+                profileLayer.setProfile(model.getCurrentProfile());
+
+                repaint();
+            }
+        }
 
     }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -43,9 +30,9 @@
  */
 public class ElevationProfileLayer extends Layer implements IElevationProfileSelectionListener {
-    
+
     private static final double Level_Factor = 100.0;
     private IElevationProfile profile;
-    private IElevationProfileRenderer renderer = new DefaultElevationProfileRenderer();
-    private WayPoint selWayPoint = null;	
+    private final IElevationProfileRenderer renderer = new DefaultElevationProfileRenderer();
+    private WayPoint selWayPoint = null;
 
     /**
@@ -56,5 +43,5 @@
      */
     public ElevationProfileLayer(String name) {
-	super(name);
+        super(name);
     }
 
@@ -65,5 +52,5 @@
      */
     public IElevationProfile getProfile() {
-	return profile;
+        return profile;
     }
 
@@ -75,137 +62,97 @@
      */
     public void setProfile(IElevationProfile profile) {
-	if (this.profile != profile) {
-        	this.profile = profile;
-        	Main.map.repaint();
-	}
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.openstreetmap.josm.gui.layer.Layer#getIcon()
-     */
+        if (this.profile != profile) {
+            this.profile = profile;
+            Main.map.repaint();
+        }
+    }
+
     @Override
     public Icon getIcon() {
-	return ImageProvider.get("layer", "elevation");
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent()
-     */
+        return ImageProvider.get("layer", "elevation");
+    }
+
     @Override
     public Object getInfoComponent() {
-	return getToolTipText();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries()
-     */
+        return getToolTipText();
+    }
+
     @Override
     public Action[] getMenuEntries() {
-	// TODO: More entries???
-	return new Action[] { new LayerListPopup.InfoAction(this) };
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText()
-     */
+        // TODO: More entries???
+        return new Action[] { new LayerListPopup.InfoAction(this) };
+    }
+
     @Override
     public String getToolTipText() {
-	if (profile != null) {
-	    return tr("Elevation profile for track ''{0}''.", profile.getName());
-	} else {
-	    return tr("Elevation profile");
-	}
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm
-     * .gui.layer.Layer)
-     */
+        if (profile != null) {
+            return tr("Elevation profile for track ''{0}''.", profile.getName());
+        } else {
+            return tr("Elevation profile");
+        }
+    }
+
     @Override
     public boolean isMergable(Layer other) {
-	return false;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm
-     * .gui.layer.Layer)
-     */
+        return false;
+    }
+
     @Override
     public void mergeFrom(Layer from) {
-	// nothing to do
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics2D,
-     * org.openstreetmap.josm.gui.MapView, org.openstreetmap.josm.data.Bounds)
-     */
+        // nothing to do
+    }
+
     @Override
     public void paint(Graphics2D g, MapView mv, Bounds box) {
-	WayPoint lastWpt = null;
-
-	renderer.beginRendering();
-	
-	if (profile != null) {
-	    // choose smaller font
-	    Font oldFont = g.getFont();
-	    Font lFont = g.getFont().deriveFont(9.0f);
-	    g.setFont(lFont);
-
-	    try {
-		// paint way points one by one
-		for (WayPoint wpt : profile.getWayPoints()) {
-		    if (lastWpt != null) {
-			// determine way point
-			ElevationWayPointKind kind = classifyWayPoint(lastWpt, wpt);
-			// render way point as line
-			renderer.renderLine(g, profile, mv, lastWpt, wpt, kind);
-			// render single way point
-			renderer.renderWayPoint(g, profile, mv, wpt, kind);
-		    } // else first way point -> is paint later
-
-		    // remember last wpt for next iteration
-		    lastWpt = wpt;
-		}
-
-		// now we paint special way points in emphasized style 
-
-		// paint start/end
-		renderer.renderWayPoint(g, profile, mv, profile.getStartWayPoint(),
-			ElevationWayPointKind.StartPoint);
-		renderer.renderWayPoint(g, profile, mv, profile.getEndWayPoint(),
-			ElevationWayPointKind.EndPoint);
-		// paint min/max
-		renderer.renderWayPoint(g, profile, mv, profile.getMaxWayPoint(),
-			ElevationWayPointKind.MaxElevation);
-		renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(),
-			ElevationWayPointKind.MinElevation);
-
-
-		// paint selected way point, if available
-		if (selWayPoint != null) {
-		    renderer.renderWayPoint(g, profile, mv, selWayPoint,
-			    ElevationWayPointKind.Highlighted);
-		}
-	    } finally {
-		g.setFont(oldFont);
-	    } 
-	}
-	renderer.finishRendering();
+        WayPoint lastWpt = null;
+
+        renderer.beginRendering();
+
+        if (profile != null) {
+            // choose smaller font
+            Font oldFont = g.getFont();
+            Font lFont = g.getFont().deriveFont(9.0f);
+            g.setFont(lFont);
+
+            try {
+                // paint way points one by one
+                for (WayPoint wpt : profile.getWayPoints()) {
+                    if (lastWpt != null) {
+                        // determine way point
+                        ElevationWayPointKind kind = classifyWayPoint(lastWpt, wpt);
+                        // render way point as line
+                        renderer.renderLine(g, profile, mv, lastWpt, wpt, kind);
+                        // render single way point
+                        renderer.renderWayPoint(g, profile, mv, wpt, kind);
+                    } // else first way point -> is paint later
+
+                    // remember last wpt for next iteration
+                    lastWpt = wpt;
+                }
+
+                // now we paint special way points in emphasized style
+
+                // paint start/end
+                renderer.renderWayPoint(g, profile, mv, profile.getStartWayPoint(),
+                        ElevationWayPointKind.StartPoint);
+                renderer.renderWayPoint(g, profile, mv, profile.getEndWayPoint(),
+                        ElevationWayPointKind.EndPoint);
+                // paint min/max
+                renderer.renderWayPoint(g, profile, mv, profile.getMaxWayPoint(),
+                        ElevationWayPointKind.MaxElevation);
+                renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(),
+                        ElevationWayPointKind.MinElevation);
+
+
+                // paint selected way point, if available
+                if (selWayPoint != null) {
+                    renderer.renderWayPoint(g, profile, mv, selWayPoint,
+                            ElevationWayPointKind.Highlighted);
+                }
+            } finally {
+                g.setFont(oldFont);
+            }
+        }
+        renderer.finishRendering();
     }
 
@@ -217,59 +164,52 @@
      *
      * @param lastWpt the last way point
-     * @param actWpt the actual way point 
+     * @param actWpt the actual way point
      * @return the elevation way point kind
      */
     private ElevationWayPointKind classifyWayPoint(WayPoint lastWpt, WayPoint actWpt) {
-	// get elevation values
-	int actEle = (int) ElevationHelper.getElevation(actWpt);
-	int lastEle = (int) ElevationHelper.getElevation(lastWpt);
-	
-	// normalize elevation to levels
-	int actLevel = (int)(actEle / Level_Factor);
-	int lastLevel = (int)(lastEle / Level_Factor);
-	double slope = Math.abs(ElevationHelper.computeSlope(lastWpt.getCoor(), actWpt.getCoor()));
-
-	// plain way point by default
-	ElevationWayPointKind kind = ElevationWayPointKind.Plain;
-	
-	// check, if we passed an elevation level
-	// We assume, that we cannot pass more than one levels between two way points ;-)
-	if (actLevel != lastLevel && Math.abs(actLevel - lastLevel) == 1) { 
-	    if (actLevel > lastLevel) { // we went down?		
-		kind =ElevationWayPointKind.ElevationLevelGain; 
-	    } else {
-		kind =ElevationWayPointKind.ElevationLevelLoss;
-	    }
-	} else { // check for elevation gain or loss
-	    if (actEle > lastEle) { // we went uphill?
-		// TODO: Provide parameters for high/low thresholds
-		if (slope > 2) kind =ElevationWayPointKind.ElevationGainLow;
-		if (slope > 15) kind =ElevationWayPointKind.ElevationGainHigh;
-	    } else {
-		if (slope > 2) kind =ElevationWayPointKind.ElevationLossLow;
-		if (slope > 15) kind =ElevationWayPointKind.ElevationLossHigh;
-	    }
-	}
-	return kind;
-    }
-    
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap
-     * .josm.data.osm.visitor.BoundingXYVisitor)
-     */
+        // get elevation values
+        int actEle = (int) ElevationHelper.getElevation(actWpt);
+        int lastEle = (int) ElevationHelper.getElevation(lastWpt);
+
+        // normalize elevation to levels
+        int actLevel = (int)(actEle / Level_Factor);
+        int lastLevel = (int)(lastEle / Level_Factor);
+        double slope = Math.abs(ElevationHelper.computeSlope(lastWpt.getCoor(), actWpt.getCoor()));
+
+        // plain way point by default
+        ElevationWayPointKind kind = ElevationWayPointKind.Plain;
+
+        // check, if we passed an elevation level
+        // We assume, that we cannot pass more than one levels between two way points ;-)
+        if (actLevel != lastLevel && Math.abs(actLevel - lastLevel) == 1) {
+            if (actLevel > lastLevel) { // we went down?
+                kind =ElevationWayPointKind.ElevationLevelGain;
+            } else {
+                kind =ElevationWayPointKind.ElevationLevelLoss;
+            }
+        } else { // check for elevation gain or loss
+            if (actEle > lastEle) { // we went uphill?
+                // TODO: Provide parameters for high/low thresholds
+                if (slope > 2) kind =ElevationWayPointKind.ElevationGainLow;
+                if (slope > 15) kind =ElevationWayPointKind.ElevationGainHigh;
+            } else {
+                if (slope > 2) kind =ElevationWayPointKind.ElevationLossLow;
+                if (slope > 15) kind =ElevationWayPointKind.ElevationLossHigh;
+            }
+        }
+        return kind;
+    }
+
     @Override
     public void visitBoundingBox(BoundingXYVisitor v) {
-	// What to do here?	
+        // What to do here?
     }
 
     @Override
     public void selectedWayPointChanged(WayPoint newWayPoint) {
-	if (selWayPoint != newWayPoint) {
-	    selWayPoint = newWayPoint;
-	    Main.map.repaint();
-	}
+        if (selWayPoint != newWayPoint) {
+            selWayPoint = newWayPoint;
+            Main.map.repaint();
+        }
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License along with this program.
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -67,14 +55,14 @@
      */
     public ElevationProfilePanel(IElevationModel profile) {
-	super();
-	this.model = profile;
-	setDoubleBuffered(true);
-	setBackground(Color.WHITE);
-	createOrUpdatePlotArea();
-	addComponentListener(this);
-	addMouseMotionListener(this);
-
-	Font lFont = getFont().deriveFont(9.0f);
-	setFont(lFont);
+        super();
+        this.model = profile;
+        setDoubleBuffered(true);
+        setBackground(Color.WHITE);
+        createOrUpdatePlotArea();
+        addComponentListener(this);
+        addMouseMotionListener(this);
+
+        Font lFont = getFont().deriveFont(9.0f);
+        setFont(lFont);
     }
 
@@ -84,5 +72,5 @@
      */
     public IElevationModel getProfile() {
-	return model;
+        return model;
     }
 
@@ -92,8 +80,8 @@
      */
     public void setElevationModel(IElevationModel model) {
-	if (this.model != model) {
-	    this.model = model;
-	    invalidate();
-	}
+        if (this.model != model) {
+            this.model = model;
+            invalidate();
+        }
     }
 
@@ -103,5 +91,5 @@
      */
     public Rectangle getPlotArea() {
-	return plotArea;
+        return plotArea;
     }
 
@@ -111,5 +99,5 @@
      */
     public void setPlotArea(Rectangle plotArea) {
-	this.plotArea = plotArea;
+        this.plotArea = plotArea;
     }
 
@@ -119,5 +107,5 @@
      */
     public int getSelectedIndex() {
-	return selectedIndex;
+        return selectedIndex;
     }
 
@@ -127,9 +115,9 @@
      */
     public void setSelectedIndex(int selectedIndex) {
-	this.selectedIndex = selectedIndex;
-
-	if (model != null) {
-	    model.setCurrentProfile(selectedIndex);
-	}
+        this.selectedIndex = selectedIndex;
+
+        if (model != null) {
+            model.setCurrentProfile(selectedIndex);
+        }
     }
 
@@ -139,14 +127,14 @@
      */
     public WayPoint getSelectedWayPoint() {
-	if (model == null) return null;
-
-	IElevationProfile profile = model.getCurrentProfile();
-
-	int selWp = this.selectedIndex * step;
-	if (profile != null && profile.getWayPoints() != null && selWp > 0 && profile.getWayPoints().size() > selWp) {
-	    return profile.getWayPoints().get(selWp);
-	} else {
-	    return null;
-	}
+        if (model == null) return null;
+
+        IElevationProfile profile = model.getCurrentProfile();
+
+        int selWp = this.selectedIndex * step;
+        if (profile != null && profile.getWayPoints() != null && selWp > 0 && profile.getWayPoints().size() > selWp) {
+            return profile.getWayPoints().get(selWp);
+        } else {
+            return null;
+        }
     }
 
@@ -156,7 +144,7 @@
      */
     public void addSelectionListener(IElevationProfileSelectionListener listener) {
-	if (listener == null) return;
-
-	selectionChangedListeners.add(listener);
+        if (listener == null) return;
+
+        selectionChangedListeners.add(listener);
     }
 
@@ -166,7 +154,7 @@
      */
     public void removeSelectionListener(IElevationProfileSelectionListener listener) {
-	if (listener == null) return;
-
-	selectionChangedListeners.remove(listener);
+        if (listener == null) return;
+
+        selectionChangedListeners.remove(listener);
     }
 
@@ -175,57 +163,54 @@
      */
     public void removeAllSelectionListeners() {
-	selectionChangedListeners.clear();
+        selectionChangedListeners.clear();
     }
 
     protected void fireSelectionChanged(WayPoint selWayPoint) {
-	for (IElevationProfileSelectionListener listener : selectionChangedListeners) {
-	    listener.selectedWayPointChanged(selWayPoint);
-	}
-    }
-
-    /* (non-Javadoc)
-     * @see javax.swing.JComponent#paint(java.awt.Graphics)
-     */
+        for (IElevationProfileSelectionListener listener : selectionChangedListeners) {
+            listener.selectedWayPointChanged(selWayPoint);
+        }
+    }
+
     @Override
     public void paint(Graphics g) {
-	isPainting = true;
-
-	try {
-	    super.paint(g);
-	    createOrUpdatePlotArea();
-	    int y1 = getPlotBottom();
-
-	    g.setColor(Color.DARK_GRAY);
-	    g.drawLine(plotArea.x, plotArea.y, plotArea.x, plotArea.y
-		    + plotArea.height);
-	    g.drawLine(plotArea.x, plotArea.y + plotArea.height, plotArea.x
-		    + plotArea.width, plotArea.y + plotArea.height);
-
-
-	    if (model != null) {
-		IElevationProfile profile = model.getCurrentProfile();
-		if (profile != null && profile.hasElevationData()) {
-		    // Draw start and end date
-		    drawAlignedString(formatDate(profile.getStart()), 5, y1 + BOTTOM_TEXT_Y_OFFSET,
-			    TextAlignment.Left, g);
-		    drawAlignedString(formatDate(profile.getEnd()),
-			    getPlotRight(), y1 + BOTTOM_TEXT_Y_OFFSET, TextAlignment.Right, g);
-
-		    // Show SRTM indicator
-		    if (ElevationHelper.hasSrtmData(profile.getBounds())) {
-			String txt = "SRTM";
-			drawAlignedString(txt, getPlotHCenter(), y1 + BOTTOM_TEXT_Y_OFFSET, TextAlignment.Centered, g);
-		    }
-		    drawProfile(g);
-		    drawElevationLines(g);
-		} else {
-		    // No profile or profile supports no elevation data
-		    drawAlignedString(tr("(No elevation data)"), getPlotHCenter(),
-			    getPlotVCenter(), TextAlignment.Centered, g);
-		}
-	    }
-	} finally {
-	    isPainting = false;
-	}
+        isPainting = true;
+
+        try {
+            super.paint(g);
+            createOrUpdatePlotArea();
+            int y1 = getPlotBottom();
+
+            g.setColor(Color.DARK_GRAY);
+            g.drawLine(plotArea.x, plotArea.y, plotArea.x, plotArea.y
+                    + plotArea.height);
+            g.drawLine(plotArea.x, plotArea.y + plotArea.height, plotArea.x
+                    + plotArea.width, plotArea.y + plotArea.height);
+
+
+            if (model != null) {
+                IElevationProfile profile = model.getCurrentProfile();
+                if (profile != null && profile.hasElevationData()) {
+                    // Draw start and end date
+                    drawAlignedString(formatDate(profile.getStart()), 5, y1 + BOTTOM_TEXT_Y_OFFSET,
+                            TextAlignment.Left, g);
+                    drawAlignedString(formatDate(profile.getEnd()),
+                            getPlotRight(), y1 + BOTTOM_TEXT_Y_OFFSET, TextAlignment.Right, g);
+
+                    // Show SRTM indicator
+                    if (ElevationHelper.hasSrtmData(profile.getBounds())) {
+                        String txt = "SRTM";
+                        drawAlignedString(txt, getPlotHCenter(), y1 + BOTTOM_TEXT_Y_OFFSET, TextAlignment.Centered, g);
+                    }
+                    drawProfile(g);
+                    drawElevationLines(g);
+                } else {
+                    // No profile or profile supports no elevation data
+                    drawAlignedString(tr("(No elevation data)"), getPlotHCenter(),
+                            getPlotVCenter(), TextAlignment.Centered, g);
+                }
+            }
+        } finally {
+            isPainting = false;
+        }
     }
 
@@ -240,22 +225,22 @@
      */
     private Rectangle drawAlignedString(String s, int x, int y,
-	    TextAlignment align, Graphics g) {
-	FontMetrics fm = g.getFontMetrics();
-	int w = fm.stringWidth(s);
-	int h = fm.getHeight();
-
-	int xoff = w / 2;
-	int yoff = h / 2;
-
-	if (align == TextAlignment.Left) {
-	    xoff = 0;
-	}
-	if (align == TextAlignment.Right) {
-	    xoff = w;
-	}
-
-	g.drawString(s, x - xoff, y + yoff);
-
-	return new Rectangle(x - xoff, y - yoff, w, h);
+            TextAlignment align, Graphics g) {
+        FontMetrics fm = g.getFontMetrics();
+        int w = fm.stringWidth(s);
+        int h = fm.getHeight();
+
+        int xoff = w / 2;
+        int yoff = h / 2;
+
+        if (align == TextAlignment.Left) {
+            xoff = 0;
+        }
+        if (align == TextAlignment.Right) {
+            xoff = w;
+        }
+
+        g.drawString(s, x - xoff, y + yoff);
+
+        return new Rectangle(x - xoff, y - yoff, w, h);
     }
 
@@ -268,7 +253,7 @@
      * @return The resulting rectangle of the drawn string.
 
-	private void drawHCenteredString(String s, int x, int y, Graphics g) {
-		drawAlignedString(s, x, y, TextAlignment.Centered, g);
-	}*/
+    private void drawHCenteredString(String s, int x, int y, Graphics g) {
+        drawAlignedString(s, x, y, TextAlignment.Centered, g);
+    }*/
 
     /**
@@ -278,7 +263,7 @@
      */
     private String formatDate(Date date) {
-	Format formatter = new SimpleDateFormat("d MMM yy, HH:mm");
-
-	return formatter.format(date);
+        Format formatter = new SimpleDateFormat("d MMM yy, HH:mm");
+
+        return formatter.format(date);
     }
 
@@ -288,47 +273,47 @@
      */
     private void drawElevationLines(Graphics g) {
-	IElevationProfile profile = model.getCurrentProfile();
-
-	double diff = profile.getHeightDifference();
-
-	if (diff == 0.0) {
-	    return;
-	}
-
-	double z10 = Math.floor(Math.log10(diff));
-	double scaleUnit = Math.pow(10, z10); // scale unit, e. g. 100 for
-	// values below 1000
-
-	int upperLimit = (int) (Math.round(Math.ceil(profile.getMaxHeight()
-		/ scaleUnit)) * scaleUnit);
-	int lowerLimit = (int) (Math.round(Math.floor(profile.getMinHeight()
-		/ scaleUnit)) * scaleUnit);
-	int su = (int) scaleUnit;
-
-	for (int i = lowerLimit; i <= upperLimit; i += su) {
-	    int yLine = getYForEelevation(i);
-
-	    // check bounds
-	    if (yLine <= getPlotBottom() && yLine >= getPlotTop()) {
-		String txt = ElevationHelper.getElevationText(i);
-
-		Rectangle r = drawAlignedString(txt, getPlotHCenter(), yLine - 2,
-			TextAlignment.Right, g);
-		r.grow(2, 2);
-
-		// Draw left and right line segment
-		g.drawLine(getPlotLeftAxis(), yLine, r.x,
-			yLine);
-		g.drawLine(r.x + r.width, yLine, getPlotRight(),
-			yLine);
-		// Draw label with shadow
-		g.setColor(Color.WHITE);
-		drawAlignedString(txt, getPlotHCenter() + 1, yLine - 1,
-			TextAlignment.Right, g);
-		g.setColor(Color.BLACK);
-		drawAlignedString(txt, getPlotHCenter(), yLine - 2,
-			TextAlignment.Right, g);
-	    }
-	}
+        IElevationProfile profile = model.getCurrentProfile();
+
+        double diff = profile.getHeightDifference();
+
+        if (diff == 0.0) {
+            return;
+        }
+
+        double z10 = Math.floor(Math.log10(diff));
+        double scaleUnit = Math.pow(10, z10); // scale unit, e. g. 100 for
+        // values below 1000
+
+        int upperLimit = (int) (Math.round(Math.ceil(profile.getMaxHeight()
+                / scaleUnit)) * scaleUnit);
+        int lowerLimit = (int) (Math.round(Math.floor(profile.getMinHeight()
+                / scaleUnit)) * scaleUnit);
+        int su = (int) scaleUnit;
+
+        for (int i = lowerLimit; i <= upperLimit; i += su) {
+            int yLine = getYForEelevation(i);
+
+            // check bounds
+            if (yLine <= getPlotBottom() && yLine >= getPlotTop()) {
+                String txt = ElevationHelper.getElevationText(i);
+
+                Rectangle r = drawAlignedString(txt, getPlotHCenter(), yLine - 2,
+                        TextAlignment.Right, g);
+                r.grow(2, 2);
+
+                // Draw left and right line segment
+                g.drawLine(getPlotLeftAxis(), yLine, r.x,
+                        yLine);
+                g.drawLine(r.x + r.width, yLine, getPlotRight(),
+                        yLine);
+                // Draw label with shadow
+                g.setColor(Color.WHITE);
+                drawAlignedString(txt, getPlotHCenter() + 1, yLine - 1,
+                        TextAlignment.Right, g);
+                g.setColor(Color.BLACK);
+                drawAlignedString(txt, getPlotHCenter(), yLine - 2,
+                        TextAlignment.Right, g);
+            }
+        }
     }
 
@@ -340,5 +325,5 @@
      */
     private int getPlotLeftAxis() {
-	return plotArea.x - 3;
+        return plotArea.x - 3;
     }
 
@@ -349,5 +334,5 @@
      */
     private int getPlotLeft() {
-	return plotArea.x + 1;
+        return plotArea.x + 1;
     }
 
@@ -358,5 +343,5 @@
      */
     private int getPlotHCenter() {
-	return (getPlotLeft() + getPlotRight()) / 2;
+        return (getPlotLeft() + getPlotRight()) / 2;
     }
 
@@ -367,5 +352,5 @@
      */
     private int getPlotVCenter() {
-	return (getPlotTop() + getPlotBottom()) / 2;
+        return (getPlotTop() + getPlotBottom()) / 2;
     }
 
@@ -376,13 +361,13 @@
      */
     private int getPlotRight() {
-	return plotArea.x + plotArea.width - 1;
+        return plotArea.x + plotArea.width - 1;
     }
 
     private int getPlotBottom() {
-	return plotArea.y + plotArea.height - 1;
+        return plotArea.y + plotArea.height - 1;
     }
 
     private int getPlotTop() {
-	return plotArea.y + 1;
+        return plotArea.y + 1;
     }
 
@@ -394,15 +379,15 @@
      */
     private int getYForEelevation(int elevation) {
-	int y1 = getPlotBottom();
-
-	IElevationProfile profile = model.getCurrentProfile();
-
-	if (!profile.hasElevationData()) {
-	    return y1;
-	}
-
-	double diff = profile.getHeightDifference();
-
-	return y1 - (int) Math.round(((elevation - profile.getMinHeight()) / diff * plotArea.height));
+        int y1 = getPlotBottom();
+
+        IElevationProfile profile = model.getCurrentProfile();
+
+        if (!profile.hasElevationData()) {
+            return y1;
+        }
+
+        double diff = profile.getHeightDifference();
+
+        return y1 - (int) Math.round(((elevation - profile.getMinHeight()) / diff * plotArea.height));
     }
 
@@ -413,58 +398,53 @@
      */
     private void drawProfile(Graphics g) {
-	IElevationProfile profile = model.getCurrentProfile();
-
-	int nwp = profile.getNumberOfWayPoints();
-	int n = Math.min(plotArea.width, nwp);
-
-	if (n == 0) return; // nothing to draw
-	// compute step size in panel (add 1 to make sure that
-	// the complete range fits into panel
-	step = (nwp / n) + 1;
-
-	int yBottom = getPlotBottom();
-	Color oldC = g.getColor();
-
-	for (int i = 0, ip = 0; i < n && ip < nwp; i++, ip += step) {
-	    WayPoint wpt = profile.getWayPoints().get(ip);
-	    int eleVal = (int) ElevationHelper.getElevation(wpt);
-	    Color c = renderer.getColorForWaypoint(profile, wpt,
-		    ElevationWayPointKind.Plain);
-
-	    // draw cursor
-	    if (i == this.selectedIndex) {
-		g.setColor(Color.BLACK);
-		drawAlignedString(ElevationHelper.getElevationText(eleVal),
-			(getPlotRight() + getPlotLeft()) / 2,
-			getPlotBottom() + 6,
-			TextAlignment.Centered,
-			g);
-
-		c = renderer.getColorForWaypoint(profile, wpt, ElevationWayPointKind.Highlighted);
-	    }
-
-	    int yEle = getYForEelevation(eleVal);
-	    int x = getPlotLeft() + i;
-
-	    g.setColor(c);
-	    g.drawLine(x, yBottom, x, yEle);
-	    g.setColor(ElevationColors.EPLightBlue);
-	}
-
-	g.setColor(oldC);
-    }
-
-
-    /* (non-Javadoc)
-     * @see javax.swing.JComponent#paintBorder(java.awt.Graphics)
-     */
+        IElevationProfile profile = model.getCurrentProfile();
+
+        int nwp = profile.getNumberOfWayPoints();
+        int n = Math.min(plotArea.width, nwp);
+
+        if (n == 0) return; // nothing to draw
+        // compute step size in panel (add 1 to make sure that
+        // the complete range fits into panel
+        step = (nwp / n) + 1;
+
+        int yBottom = getPlotBottom();
+        Color oldC = g.getColor();
+
+        for (int i = 0, ip = 0; i < n && ip < nwp; i++, ip += step) {
+            WayPoint wpt = profile.getWayPoints().get(ip);
+            int eleVal = (int) ElevationHelper.getElevation(wpt);
+            Color c = renderer.getColorForWaypoint(profile, wpt,
+                    ElevationWayPointKind.Plain);
+
+            // draw cursor
+            if (i == this.selectedIndex) {
+                g.setColor(Color.BLACK);
+                drawAlignedString(ElevationHelper.getElevationText(eleVal),
+                        (getPlotRight() + getPlotLeft()) / 2,
+                        getPlotBottom() + 6,
+                        TextAlignment.Centered,
+                        g);
+
+                c = renderer.getColorForWaypoint(profile, wpt, ElevationWayPointKind.Highlighted);
+            }
+
+            int yEle = getYForEelevation(eleVal);
+            int x = getPlotLeft() + i;
+
+            g.setColor(c);
+            g.drawLine(x, yBottom, x, yEle);
+            g.setColor(ElevationColors.EPLightBlue);
+        }
+
+        g.setColor(oldC);
+    }
+
     @Override
     protected void paintBorder(Graphics g) {
-	super.paintBorder(g);
-
-	Border loweredbevel = BorderFactory.createLoweredBevelBorder();
-	this.setBorder(loweredbevel);
-    }
-
+        super.paintBorder(g);
+
+        Border loweredbevel = BorderFactory.createLoweredBevelBorder();
+        this.setBorder(loweredbevel);
+    }
 
     /**
@@ -472,67 +452,40 @@
      */
     private void createOrUpdatePlotArea() {
-	Dimension caSize = getSize();
-
-	if (plotArea == null) {
-	    plotArea = new Rectangle(0, 0, caSize.width, caSize.height);
-	} else {
-	    plotArea.width = caSize.width;
-	    plotArea.height = caSize.height;
-	}
-
-	plotArea.setLocation(0, 0);
-	plotArea.grow(-10, -15);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @seejava.awt.event.ComponentListener#componentHidden(java.awt.event.
-     * ComponentEvent)
-     */
+        Dimension caSize = getSize();
+
+        if (plotArea == null) {
+            plotArea = new Rectangle(0, 0, caSize.width, caSize.height);
+        } else {
+            plotArea.width = caSize.width;
+            plotArea.height = caSize.height;
+        }
+
+        plotArea.setLocation(0, 0);
+        plotArea.grow(-10, -15);
+    }
+
     @Override
     public void componentHidden(ComponentEvent arg0) {
-	// TODO Auto-generated method stub
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent
-     * )
-     */
+        // TODO Auto-generated method stub
+    }
+
     @Override
     public void componentMoved(ComponentEvent arg0) {
-	// TODO Auto-generated method stub
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @seejava.awt.event.ComponentListener#componentResized(java.awt.event.
-     * ComponentEvent)
-     */
+        // TODO Auto-generated method stub
+    }
+
     @Override
     public void componentResized(ComponentEvent arg0) {
-	createOrUpdatePlotArea();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent
-     * )
-     */
+        createOrUpdatePlotArea();
+    }
+
     @Override
     public void componentShown(ComponentEvent arg0) {
-	// TODO Auto-generated method stub
-
+        // TODO Auto-generated method stub
     }
 
     @Override
     public void mouseDragged(MouseEvent arg0) {
-	// TODO Auto-generated method stub
+        // TODO Auto-generated method stub
 
     }
@@ -540,26 +493,26 @@
     @Override
     public void mouseMoved(MouseEvent arg0) {
-	if (isPainting || arg0.isControlDown() || arg0.isAltDown() || arg0.isShiftDown()) arg0.consume();
-
-	int x = arg0.getX();
-	int l = this.getX();
-	int pl = this.getPlotLeft();
-	int newIdx = x - l - pl;
-
-	if (newIdx != this.selectedIndex && newIdx >= 0) {
-	    this.selectedIndex = newIdx;
-	    this.repaint();
-	    fireSelectionChanged(getSelectedWayPoint());
-	}
+        if (isPainting || arg0.isControlDown() || arg0.isAltDown() || arg0.isShiftDown()) arg0.consume();
+
+        int x = arg0.getX();
+        int l = this.getX();
+        int pl = this.getPlotLeft();
+        int newIdx = x - l - pl;
+
+        if (newIdx != this.selectedIndex && newIdx >= 0) {
+            this.selectedIndex = newIdx;
+            this.repaint();
+            fireSelectionChanged(getSelectedWayPoint());
+        }
     }
 
     @Override
     public String getToolTipText() {
-	WayPoint wpt = getSelectedWayPoint();
-	if (wpt != null) {
-	    return  String.format("%s: %s", ElevationHelper.getTimeText(wpt), ElevationHelper.getElevationText(wpt));
-	}
-
-	return super.getToolTipText();
+        WayPoint wpt = getSelectedWayPoint();
+        if (wpt != null) {
+            return  String.format("%s: %s", ElevationHelper.getTimeText(wpt), ElevationHelper.getElevationText(wpt));
+        }
+
+        return super.getToolTipText();
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -27,5 +14,5 @@
  * for a given way point, so that as well the dialog as the layer can share the color scheme.
  * Second, the layer can simply pass the painting stuff to a renderer without taking care of
- * details. 
+ * details.
  * 
  * @author Oliver Wieland <oliver.wieland@online.de>
@@ -33,43 +20,43 @@
  */
 public interface IElevationProfileRenderer {
-	/**
-	 * Gets the color for a given way point.
-	 * @param profile The elevation profile that contains the way point.
-	 * @param wpt The way point to get the color for.
-	 * @param kind The way point kind (see {@link ElevationWayPointKind}).
-	 * @return The color for the way point or null, if invalid arguments have been specified.
-	 */
-	Color getColorForWaypoint(IElevationProfile profile, WayPoint wpt, ElevationWayPointKind kind);
-	
-	/**
-	 * Renders the way point with the lowest elevation.
-	 *
-	 * @param g The graphics context.
-	 * @param profile The elevation profile that contains the way point.
-	 * @param mv the associated view
-	 * @param wpt The way point to render.
-	 * @param kind The way point kind (see {@link ElevationWayPointKind}).
-	 */
-	void renderWayPoint(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt, ElevationWayPointKind kind);
-	
-	/**
-	 * Render line between two way points. This is intended to render speed or slope.
-	 *
-	 * @param g The graphics context.
-	 * @param profile The elevation profile that contains the way point.
-	 * @param mv the associated view
-	 * @param wpt1 the first way point
-	 * @param wpt2 the second way point
-	 */
-	void renderLine(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt1, WayPoint wpt2, ElevationWayPointKind kind);
-	
-	/**
-	 * Notifies the renderer that rendering starts.
-	 */
-	void beginRendering();
-	
-	/**
-	 * Notifies the renderer that rendering has been finished.
-	 */
-	void finishRendering();
+    /**
+     * Gets the color for a given way point.
+     * @param profile The elevation profile that contains the way point.
+     * @param wpt The way point to get the color for.
+     * @param kind The way point kind (see {@link ElevationWayPointKind}).
+     * @return The color for the way point or null, if invalid arguments have been specified.
+     */
+    Color getColorForWaypoint(IElevationProfile profile, WayPoint wpt, ElevationWayPointKind kind);
+
+    /**
+     * Renders the way point with the lowest elevation.
+     *
+     * @param g The graphics context.
+     * @param profile The elevation profile that contains the way point.
+     * @param mv the associated view
+     * @param wpt The way point to render.
+     * @param kind The way point kind (see {@link ElevationWayPointKind}).
+     */
+    void renderWayPoint(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt, ElevationWayPointKind kind);
+
+    /**
+     * Render line between two way points. This is intended to render speed or slope.
+     *
+     * @param g The graphics context.
+     * @param profile The elevation profile that contains the way point.
+     * @param mv the associated view
+     * @param wpt1 the first way point
+     * @param wpt2 the second way point
+     */
+    void renderLine(Graphics g, IElevationProfile profile, MapView mv, WayPoint wpt1, WayPoint wpt2, ElevationWayPointKind kind);
+
+    /**
+     * Notifies the renderer that rendering starts.
+     */
+    void beginRendering();
+
+    /**
+     * Notifies the renderer that rendering has been finished.
+     */
+    void finishRendering();
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileSelectionListener.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileSelectionListener.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileSelectionListener.java	(revision 30344)
@@ -1,15 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -17,8 +5,8 @@
 
 public interface IElevationProfileSelectionListener {
-	/**
-	 * Notifies clients about selected index changed. 
-	 * @param newIndex
-	 */
-	public void selectedWayPointChanged(WayPoint wpt);
+    /**
+     * Notifies clients about selected index changed.
+     * @param newIndex
+     */
+    public void selectedWayPointChanged(WayPoint wpt);
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TextAlignment.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TextAlignment.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TextAlignment.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -20,6 +7,6 @@
  */
 public enum TextAlignment {
-	Left,
-	Right,
-	Centered
+    Left,
+    Right,
+    Centered
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/Triangle.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/Triangle.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/Triangle.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -30,114 +17,93 @@
  */
 public class Triangle implements Shape {
-	private Polygon poly;
+    private final Polygon poly;
 
-	/**
-	 * Copy constructor.
-	 * @param p
-	 */
-	public Triangle(Polygon p) {
-		if (p == null || p.npoints != 3) throw new RuntimeException("Given polygon was null or had invalid number of points");
-		poly = p;
-	}
+    /**
+     * Copy constructor.
+     * @param p
+     */
+    public Triangle(Polygon p) {
+        if (p == null || p.npoints != 3) throw new RuntimeException("Given polygon was null or had invalid number of points");
+        poly = p;
+    }
 
-	/**
-	 * Creates a triangle from 3 given points. The points are used without any sanity check, so it is up to
-	 * the user that the points form a triangle.
-	 * @param p1
-	 * @param p2
-	 * @param p3
-	 */
-	public Triangle(Point p1, Point p2, Point p3) {
-		poly = new Polygon();
-		poly.addPoint(p1.x, p1.y);
-		poly.addPoint(p2.x, p2.y);
-		poly.addPoint(p3.x, p3.y);		
-	}
+    /**
+     * Creates a triangle from 3 given points. The points are used without any sanity check, so it is up to
+     * the user that the points form a triangle.
+     * @param p1
+     * @param p2
+     * @param p3
+     */
+    public Triangle(Point p1, Point p2, Point p3) {
+        poly = new Polygon();
+        poly.addPoint(p1.x, p1.y);
+        poly.addPoint(p2.x, p2.y);
+        poly.addPoint(p3.x, p3.y);
+    }
 
-	/**
-	 * Draws an outlined triangle.
-	 * @param g
-	 */
-	public void draw(Graphics g) {
-		g.drawPolygon(poly);
-	}
+    /**
+     * Draws an outlined triangle.
+     * @param g
+     */
+    public void draw(Graphics g) {
+        g.drawPolygon(poly);
+    }
 
-	/**
-	 * Draws a filled triangle.
-	 * @param g
-	 */
-	public void fill(Graphics g) {
-		g.fillPolygon(poly);
-	}
+    /**
+     * Draws a filled triangle.
+     * @param g
+     */
+    public void fill(Graphics g) {
+        g.fillPolygon(poly);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#getBounds()
-	 */
-	public Rectangle getBounds() {
-		return poly.getBounds();
-	}
+    @Override
+    public Rectangle getBounds() {
+        return poly.getBounds();
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#getBounds2D()
-	 */
-	public Rectangle2D getBounds2D() {
-		return poly.getBounds2D();
-	}
+    @Override
+    public Rectangle2D getBounds2D() {
+        return poly.getBounds2D();
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#contains(double, double)
-	 */
-	public boolean contains(double x, double y) {
-		return poly.contains(x, y);
-	}
+    @Override
+    public boolean contains(double x, double y) {
+        return poly.contains(x, y);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#contains(java.awt.geom.Point2D)
-	 */
-	public boolean contains(Point2D p) {
-		return poly.contains(p);
-	}
+    @Override
+    public boolean contains(Point2D p) {
+        return poly.contains(p);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#intersects(double, double, double, double)
-	 */
-	public boolean intersects(double x, double y, double w, double h) {
-		return poly.intersects(x, y, w, h);
-	}
+    @Override
+    public boolean intersects(double x, double y, double w, double h) {
+        return poly.intersects(x, y, w, h);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D)
-	 */
-	public boolean intersects(Rectangle2D r) {
-		return poly.intersects(r);
-	}
+    @Override
+    public boolean intersects(Rectangle2D r) {
+        return poly.intersects(r);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#contains(double, double, double, double)
-	 */
-	public boolean contains(double x, double y, double w, double h) {
-		return poly.contains(x, y, w, h);
-	}
+    @Override
+    public boolean contains(double x, double y, double w, double h) {
+        return poly.contains(x, y, w, h);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#contains(java.awt.geom.Rectangle2D)
-	 */
-	public boolean contains(Rectangle2D r) {
-		return poly.intersects(r);
-	}
+    @Override
+    public boolean contains(Rectangle2D r) {
+        return poly.intersects(r);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform)
-	 */
-	public PathIterator getPathIterator(AffineTransform at) {
-		return poly.getPathIterator(at);
-	}
+    @Override
+    public PathIterator getPathIterator(AffineTransform at) {
+        return poly.getPathIterator(at);
+    }
 
-	/* (non-Javadoc)
-	 * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform, double)
-	 */
-	public PathIterator getPathIterator(AffineTransform at, double flatness) {
-		return poly.getPathIterator(at, flatness);
-	}
-
+    @Override
+    public PathIterator getPathIterator(AffineTransform at, double flatness) {
+        return poly.getPathIterator(at, flatness);
+    }
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TriangleDir.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TriangleDir.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TriangleDir.java	(revision 30344)
@@ -1,16 +1,3 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.gui;
 
@@ -20,7 +7,7 @@
  */
 public enum TriangleDir {
-	Up,
-	Down,
-	Left,
-	Right
+    Up,
+    Down,
+    Left,
+    Right
 }
Index: applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/EleVertexTest.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/EleVertexTest.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/EleVertexTest.java	(revision 30344)
@@ -1,2 +1,3 @@
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.tests;
 
@@ -18,97 +19,98 @@
      * Setup test.
      */
+    @Override
     public void setUp() {
         Main.pref = new Preferences();
     }
-    
+
     public void testDivide() {
-	EleCoordinate p1 = new EleCoordinate(30.0, 30.0, 100.0);
-	EleCoordinate p2 = new EleCoordinate(35.0, 30.0, 120.0);
-	EleCoordinate p3 = new EleCoordinate(35.0, 40.0, 110.0);
-	EleVertex ev = new EleVertex(p1, p2, p3);
-	
-	List<EleVertex> list = ev.divide();
-	
-	assertEquals(2, list.size());
-	
-	// 1st vertex (p1, p2, pN  105m) 
-	EleVertex v1 = list.get(0);
-	assertEquals(325 / 3D, v1.getEle());
-	assertCoorEq(v1, 30D, 30D, 0);
-	assertCoorEq(v1, 30D, 35D, 1);
-	assertCoorEq(v1, 35D, 32.5D, 2);
-	
-	// 2nd vertex (p3, p2, pN = 105m) 
-	EleVertex v2 = list.get(1);
-	
-	assertEquals(335/3D, v2.getEle());
-	assertCoorEq(v2, 40D, 35D, 0);
-	assertCoorEq(v2, 30D, 35D, 1);
-	assertCoorEq(v2, 35D, 32.5D, 2);
+        EleCoordinate p1 = new EleCoordinate(30.0, 30.0, 100.0);
+        EleCoordinate p2 = new EleCoordinate(35.0, 30.0, 120.0);
+        EleCoordinate p3 = new EleCoordinate(35.0, 40.0, 110.0);
+        EleVertex ev = new EleVertex(p1, p2, p3);
+
+        List<EleVertex> list = ev.divide();
+
+        assertEquals(2, list.size());
+
+        // 1st vertex (p1, p2, pN  105m)
+        EleVertex v1 = list.get(0);
+        assertEquals(325 / 3D, v1.getEle());
+        assertCoorEq(v1, 30D, 30D, 0);
+        assertCoorEq(v1, 30D, 35D, 1);
+        assertCoorEq(v1, 35D, 32.5D, 2);
+
+        // 2nd vertex (p3, p2, pN = 105m)
+        EleVertex v2 = list.get(1);
+
+        assertEquals(335/3D, v2.getEle());
+        assertCoorEq(v2, 40D, 35D, 0);
+        assertCoorEq(v2, 30D, 35D, 1);
+        assertCoorEq(v2, 35D, 32.5D, 2);
     }
-    
+
     public void testSimpleRecurse() {
-	EleCoordinate c1 = new EleCoordinate(new LatLon(50.8328, 8.1337), 300);
-	EleCoordinate c2 = new EleCoordinate(new LatLon(50.8328, 7.9217), 200);
-	EleCoordinate c3 = new EleCoordinate(new LatLon(50.9558, 7.9217), 400);
-	EleCoordinate c4 = new EleCoordinate(new LatLon(50.5767627, 9.1938483), 100);
-	
-	EleVertex v1 = new EleVertex(c1, c2, c3);
-	System.out.println("Start recurse");
-	recurse(v1, 0);
+        EleCoordinate c1 = new EleCoordinate(new LatLon(50.8328, 8.1337), 300);
+        EleCoordinate c2 = new EleCoordinate(new LatLon(50.8328, 7.9217), 200);
+        EleCoordinate c3 = new EleCoordinate(new LatLon(50.9558, 7.9217), 400);
+        EleCoordinate c4 = new EleCoordinate(new LatLon(50.5767627, 9.1938483), 100);
+
+        EleVertex v1 = new EleVertex(c1, c2, c3);
+        System.out.println("Start recurse");
+        recurse(v1, 0);
     }
-    
+
     private void recurse(EleVertex v, int depth) {
-	if (!v.isFinished() && depth <100) {
-	    System.out.println("\tDivide: " + v);
-	    List<EleVertex> list = v.divide();
-	    assertNotNull(list);
-	    assertEquals(2, list.size());
-	    assertTrue(depth < 50); //, "Too many recursions?");	    
-	    for (EleVertex eleVertex : list) {
-		//System.out.println("\t\tRecurse: " + eleVertex);
-		assertTrue("Area is larger " + v.getArea() + " > " + eleVertex.getArea(), eleVertex.getArea() < v.getArea());
-		recurse(eleVertex, depth + 1);
-	    }
-	} else {
-	    System.out.println("Finished: " + depth);
-	}
+        if (!v.isFinished() && depth <100) {
+            System.out.println("\tDivide: " + v);
+            List<EleVertex> list = v.divide();
+            assertNotNull(list);
+            assertEquals(2, list.size());
+            assertTrue(depth < 50); //, "Too many recursions?");
+            for (EleVertex eleVertex : list) {
+                //System.out.println("\t\tRecurse: " + eleVertex);
+                assertTrue("Area is larger " + v.getArea() + " > " + eleVertex.getArea(), eleVertex.getArea() < v.getArea());
+                recurse(eleVertex, depth + 1);
+            }
+        } else {
+            System.out.println("Finished: " + depth);
+        }
     }
     /*
     public void testRenderer() {
-	
-	// Staufenberg, Hessen
-	// Ulrichstein, Hessen
-	GridRenderer er = new GridRenderer("Ele", new Bounds(
-		new LatLon(50.6607106, 8.7337029), 
-		new LatLon(50.5767627, 9.1938483)), null);
-	
-	er.run();
+
+    // Staufenberg, Hessen
+    // Ulrichstein, Hessen
+    GridRenderer er = new GridRenderer("Ele", new Bounds(
+        new LatLon(50.6607106, 8.7337029),
+        new LatLon(50.5767627, 9.1938483)), null);
+
+    er.run();
     }*/
-    
+
     public void testColorMap() {
-	ColorMap testMap  = ColorMap.create("Test", new Color[]{Color.white, Color.black}, new int[]{0, 1000});
-	
-	// range test
-	Color c1 = testMap.getColor(-100);
-	assertEquals(Color.white, c1);
-	// range test
-	Color c2 = testMap.getColor(1100);
-	assertEquals(Color.black, c2);
-	// test mid (RGB 128, 128, 128)
-	Color c3 = testMap.getColor(500);
-	assertEquals(Color.gray, c3);
-	
-	// test 0.75 (RGB 192 x 3)
-	Color c4 = testMap.getColor(751);
-	assertEquals(Color.lightGray, c4);
-	// test 0.25 (RGB 64 x 3)
-	Color c5 = testMap.getColor(251);
-	assertEquals(Color.darkGray, c5);	
+        ColorMap testMap  = ColorMap.create("Test", new Color[]{Color.white, Color.black}, new int[]{0, 1000});
+
+        // range test
+        Color c1 = testMap.getColor(-100);
+        assertEquals(Color.white, c1);
+        // range test
+        Color c2 = testMap.getColor(1100);
+        assertEquals(Color.black, c2);
+        // test mid (RGB 128, 128, 128)
+        Color c3 = testMap.getColor(500);
+        assertEquals(Color.gray, c3);
+
+        // test 0.75 (RGB 192 x 3)
+        Color c4 = testMap.getColor(751);
+        assertEquals(Color.lightGray, c4);
+        // test 0.25 (RGB 64 x 3)
+        Color c5 = testMap.getColor(251);
+        assertEquals(Color.darkGray, c5);
     }
 
     private void assertCoorEq(EleVertex v1, double x, double y, int n) {
-	assertEquals(x, v1.get(n).getX());
-	assertEquals(y, v1.get(n).getY());
+        assertEquals(x, v1.get(n).getX());
+        assertEquals(y, v1.get(n).getY());
     }
 }
Index: applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java	(revision 30343)
+++ applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java	(revision 30344)
@@ -1,5 +1,4 @@
+// License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.elevation.tests;
-
-
 
 import junit.framework.TestCase;
@@ -15,4 +14,5 @@
      * Setup test.
      */
+    @Override
     public void setUp() {
         Main.pref = new Preferences();
@@ -20,25 +20,25 @@
 
     public void testGetElevationFromHgt() {
-	// Staufenberg, Hessen
-	testHgtData(50.6607106, 8.7337029, "N50E008.hgt", 199);
-	// Ulrichstein, Hessen
-	testHgtData(50.5767627, 9.1938483, "N50E009.hgt", 560);
-	// Fujijama
-	//testHgtData(35.360555, 138.727777, "N35E138.hgt", 3741);
+        // Staufenberg, Hessen
+        testHgtData(50.6607106, 8.7337029, "N50E008.hgt", 199);
+        // Ulrichstein, Hessen
+        testHgtData(50.5767627, 9.1938483, "N50E009.hgt", 560);
+        // Fujijama
+        //testHgtData(35.360555, 138.727777, "N35E138.hgt", 3741);
     }
 
     private void testHgtData(final double lat, final double lon,
-	    final String expTag, final int expHeight) {
-	LatLon l = new LatLon(lat, lon);
-	HgtReader hr = new HgtReader();
-	String text = hr.getHgtFileName(l);
-	
-	assertEquals(expTag, text);
-	
-	double d = hr.getElevationFromHgt(l);
-	System.out.println(d);
-	assertFalse("Data missing or void for coor " + l, Double.isNaN(d));
-	
-	assertEquals((int)d, expHeight);
+            final String expTag, final int expHeight) {
+        LatLon l = new LatLon(lat, lon);
+        HgtReader hr = new HgtReader();
+        String text = hr.getHgtFileName(l);
+
+        assertEquals(expTag, text);
+
+        double d = hr.getElevationFromHgt(l);
+        System.out.println(d);
+        assertFalse("Data missing or void for coor " + l, Double.isNaN(d));
+
+        assertEquals((int)d, expHeight);
     }
 }
