Index: /applications/editors/josm/plugins/ElevationProfile/.classpath
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/.classpath	(revision 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/.classpath	(revision 23976)
@@ -5,4 +5,4 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="J:/Dokumente und Einstellungen/Oliver/Eigene Dateien/Java/Josm-svn/core/dist/3529/josm-tested.jar"/>
-	<classpathentry kind="output" path="bin"/>
+	<classpathentry kind="output" path="build"/>
 </classpath>
Index: /applications/editors/josm/plugins/ElevationProfile/.project
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/.project	(revision 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/.project	(revision 23976)
@@ -7,11 +7,6 @@
 	<buildSpec>
 		<buildCommand>
-			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
-			<triggers>full,incremental,</triggers>
+			<name>org.eclipse.jdt.core.javabuilder</name>
 			<arguments>
-				<dictionary>
-					<key>LaunchConfigHandle</key>
-					<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.jdt.core.javabuilder.launch</value>
-				</dictionary>
 			</arguments>
 		</buildCommand>
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationModel.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationModel.java	(revision 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationModel.java	(revision 23976)
@@ -14,6 +14,4 @@
 
 package org.openstreetmap.josm.plugins.elevation;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.util.ArrayList;
@@ -80,4 +78,11 @@
 		return gpxData;
 	}
+	
+	/**
+	 * @return the tracks
+	 */
+	protected List<IElevationProfile> getTracks() {
+		return tracks;
+	}
 
 	/**
@@ -137,4 +142,5 @@
 		trackCounter = 0;
 
+		super.updateValues();
 		if (tracks == null) {
 			tracks = new ArrayList<IElevationProfile>();
@@ -148,5 +154,4 @@
 		GpxIterator.visit(gpxData, this);
 
-		setWayPoints(tmpWaypoints, true);
 		// reduce data
 		setWayPoints(WayPointHelper.downsampleWayPoints(tmpWaypoints,
@@ -160,10 +165,4 @@
 	public void updateElevationData() {
 		computeProfile();
-	}
-
-	public String toString() {
-		return "ElevationModel [start=" + getStart() + ", end=" + getEnd()
-				+ ", minHeight=" + getMinHeight() + ", maxHeight="
-				+ getMaxHeight() + ", wayPoints=" + numberOfWayPoints + "]";
 	}
 
@@ -190,20 +189,27 @@
 		processWayPoint(wp);
 	}
-
-	public void end(GpxRoute route) {
-		String trackName = "Route#" + trackCounter;
-		addTrackOrRoute(trackName);
-	}
-
-	public void end(GpxTrack track) {
+	
+	/* (non-Javadoc)
+	 * @see org.openstreetmap.josm.plugins.elevation.ElevationProfileBase#visit(org.openstreetmap.josm.data.gpx.WayPoint)
+	 */
+	@Override
+	public void visit(WayPoint wp) {
+		super.visit(wp);
+		processWayPoint(wp);
+	}
+
+	public void start() {
+		buffer.clear();
+	}
+
+	public void end() {
 		String trackName = "Track#" + trackCounter;
-		addTrackOrRoute(trackName);
-	}
-
+		addTrackOrRoute(trackName);		
+	}
+	
 	private void addTrackOrRoute(String trackName) {
 		if (getSliceSize() > 0) {
 			ElevationProfileNode emt = new ElevationProfileNode(trackName,
 					this, buffer, getSliceSize());
-			// System.out.println("Add track/route: " + trackName);
 			tracks.add(emt);
 		}
@@ -212,19 +218,9 @@
 	}
 
-	public void start(GpxRoute route) {
-		// buffer should be empty -> isolated way points
-		if (buffer.size() > 0) {
-			addTrackOrRoute(tr("Unknown"));
-		}
-	}
-
-	public void start(GpxTrack track) {
-		// buffer should be empty -> isolated way points
-		if (buffer.size() > 0) {
-			addTrackOrRoute(tr("Unknown"));
-		}
-	}
-
 	private void processWayPoint(WayPoint wp) {
+		if (wp == null) {
+			throw new RuntimeException("WPT must not be null!");
+		}
+		
 		buffer.add(wp);
 		tmpWaypoints.add(wp);
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfileBase.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfileBase.java	(revision 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfileBase.java	(revision 23976)
@@ -494,3 +494,9 @@
 		}
 	}
+	
+	public String toString() {
+		return "ElevationProfileBase [start=" + getStart() + ", end=" + getEnd()
+				+ ", minHeight=" + getMinHeight() + ", maxHeight="
+				+ getMaxHeight() + "]";
+	}
 }
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/GpxIterator.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/GpxIterator.java	(revision 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/GpxIterator.java	(revision 23976)
@@ -46,5 +46,7 @@
 		if (visitor == null) return;
 		
+		visitor.start();
 		visitSingleWaypoints(data, visitor);
+		visitor.end();
 
 		// routes
@@ -92,5 +94,5 @@
 		
 		Collection<GpxTrackSegment> segments = trk.getSegments();
-		visitor.start(trk);
+		visitor.start();
 
 		if (segments != null) {
@@ -102,9 +104,9 @@
 
 				for (WayPoint wayPoint : waypts) {
-					visitor.visit(trk, segment, wayPoint);
+					visitor.visit(wayPoint);
 				}
 			}
 		}
-		visitor.end(trk);
+		visitor.end();
 	}
 
@@ -117,9 +119,9 @@
 		if (visitor == null) return;
 		
-		visitor.start(route);
+		visitor.start();
 		for (WayPoint wpt : route.routePoints) {
-			visitor.visit(route, wpt);
+			visitor.visit(wpt);
 		}
-		visitor.end(route);
+		visitor.end();
 	}
 
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IGpxVisitor.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IGpxVisitor.java	(revision 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IGpxVisitor.java	(revision 23976)
@@ -15,7 +15,4 @@
 package org.openstreetmap.josm.plugins.elevation;
 
-import org.openstreetmap.josm.data.gpx.GpxRoute;
-import org.openstreetmap.josm.data.gpx.GpxTrack;
-import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
 import org.openstreetmap.josm.data.gpx.WayPoint;
 
@@ -26,14 +23,12 @@
 public interface IGpxVisitor extends IGpxWaypointVisitor {
 	/**
-	 * Starts a GPX route.
-	 * @param route The route to visit.
+	 * Starts a GPX route, track or way point collection.
 	 */
-	void start(GpxRoute route);
+	void start();
 	
 	/**
-	 * Ends a GPX route.
-	 * @param route The route to visit.
+	 * Ends a GPX route, track or way point collection.
 	 */
-	void end(GpxRoute route);
+	void end();
 	
 	/**
@@ -42,24 +37,4 @@
 	 * @param wp The way point to visit.
 	 */
-	void visit(GpxRoute route, WayPoint wp);
-	
-	/**
-	 * Called before a GPX track is iterated.
-	 * @param track The track to visit.
-	 */
-	void start(GpxTrack track);
-	
-	/**
-	 * Called after a track iteration.
-	 * @param track The track to visit.
-	 */
-	void end(GpxTrack track);
-	
-	/**
-	 * Visits a way point within a GPX track.
-	 * @param track The associated track of the way point.
-	 * @param segment The associated segment of the way point.
-	 * @param wp The way point to visit.
-	 */
-	void visit(GpxTrack track, GpxTrackSegment segment, WayPoint wp);
+	void visit(WayPoint wp);
 }
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 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java	(revision 23976)
@@ -136,4 +136,7 @@
 			System.err.println(String.format(
 					"Cannot paint: mv=%s, prof=%s, wpt=%s", mv, profile, wpt));
+			if (wpt == null) {
+				throw new RuntimeException("WPT must not be null, profile " + profile);
+			}
 			return;
 		}
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 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java	(revision 23976)
@@ -48,5 +48,4 @@
 import org.openstreetmap.josm.plugins.elevation.GeoidCorrectionKind;
 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
 import org.openstreetmap.josm.plugins.elevation.WayPointHelper;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -67,5 +66,5 @@
 	private static final long serialVersionUID = -868463893732535577L;
 	/* Elevation profile instance */
-	private IElevationProfile profile;
+	private ElevationModel profile;
 	/* GPX data */
 	private GpxLayer activeLayer = null;
@@ -241,5 +240,5 @@
 	 * @return
 	 */
-	public IElevationProfile getModel() {
+	public ElevationModel getModel() {
 		return profile;
 	}
@@ -249,5 +248,5 @@
 	 * @param model The new model.
 	 */
-	public void setModel(IElevationProfile model) {
+	public void setModel(ElevationModel model) {
 		if (this.profile != model) {
 			this.profile = model;
@@ -290,13 +289,13 @@
 
 			if (profile.hasElevationData()) {
-			// Show elevation data
-			minHeightLabel.setText(
-					WayPointHelper.getElevationText(profile.getMinHeight()));
-			maxHeightLabel.setText(
-					WayPointHelper.getElevationText(profile.getMaxHeight()));
-			avrgHeightLabel.setText(
-					WayPointHelper.getElevationText(profile.getAverageHeight()));
-			elevationGainLabel.setText(
-					WayPointHelper.getElevationText(profile.getGain()));
+				// Show elevation data
+				minHeightLabel.setText(
+						WayPointHelper.getElevationText(profile.getMinHeight()));
+				maxHeightLabel.setText(
+						WayPointHelper.getElevationText(profile.getMaxHeight()));
+				avrgHeightLabel.setText(
+						WayPointHelper.getElevationText(profile.getAverageHeight()));
+				elevationGainLabel.setText(
+						WayPointHelper.getElevationText(profile.getGain()));
 			}
 			
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 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 23976)
@@ -162,4 +162,8 @@
 			for (WayPoint wpt : profile.getWayPoints()) {
 				int ele = (int) WayPointHelper.getElevation(wpt);
+				
+				if (wpt == null) {
+					throw new RuntimeException("WPT must not be null, profile " + profile);
+				}
 
 				if (lastWpt != null) {
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 23975)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java	(revision 23976)
@@ -174,19 +174,22 @@
 	public void paint(Graphics g) {
 		isPainting = true;
-		super.paint(g);
-
-		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);
-
+		
 		Font oldFont = getFont();
 		Font lFont = getFont().deriveFont(9.0f);
 		setFont(lFont);
 		try {
-			if (profile != null) {
+			super.paint(g);
+	
+			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 (profile != null && profile.hasElevationData()) {
 				drawAlignedString(formatDate(profile.getStart()), 5, y1 + 5,
 						TextAlignment.Left, g);
@@ -267,4 +270,8 @@
 		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
@@ -397,4 +404,11 @@
 			
 			if (i == this.selectedIndex) {
+				g.setColor(Color.BLACK);
+				drawAlignedString(WayPointHelper.getElevationText(eleVal), 
+						(getPlotRight() + getPlotLeft()) / 2, 
+						getPlotBottom() + 6, 
+						TextAlignment.Centered, 
+						g);
+				
 				c = renderer.getColorForWaypoint(profile, wpt, ElevationWayPointKind.Highlighted);
 			}
@@ -407,7 +421,8 @@
 			int geoidVal = 0;
 			switch(WayPointHelper.getGeoidKind()) {
-			case Auto: geoidVal = WayPointHelper.getGeoidCorrection(wpt); break;
-			case Fixed: // not impl
+				case Auto: geoidVal = WayPointHelper.getGeoidCorrection(wpt); break;
+				case Fixed: // not impl
 			}
+			
 			g.setColor(ElevationColors.EPLightBlue);
 			
@@ -506,5 +521,5 @@
 		int newIdx = x - l - pl;
 		
-		if (newIdx != this.selectedIndex && newIdx > 0) {
+		if (newIdx != this.selectedIndex && newIdx >= 0) {
 			this.selectedIndex = newIdx;
 			this.repaint();		
