Changeset 23976 in osm for applications/editors/josm
- Timestamp:
- 2010-11-01T00:38:13+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/.classpath
r23783 r23976 5 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 6 6 <classpathentry kind="lib" path="J:/Dokumente und Einstellungen/Oliver/Eigene Dateien/Java/Josm-svn/core/dist/3529/josm-tested.jar"/> 7 <classpathentry kind="output" path="b in"/>7 <classpathentry kind="output" path="build"/> 8 8 </classpath> -
applications/editors/josm/plugins/ElevationProfile/.project
r23777 r23976 7 7 <buildSpec> 8 8 <buildCommand> 9 <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> 10 <triggers>full,incremental,</triggers> 9 <name>org.eclipse.jdt.core.javabuilder</name> 11 10 <arguments> 12 <dictionary>13 <key>LaunchConfigHandle</key>14 <value><project>/.externalToolBuilders/org.eclipse.jdt.core.javabuilder.launch</value>15 </dictionary>16 11 </arguments> 17 12 </buildCommand> -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationModel.java
r23795 r23976 14 14 15 15 package org.openstreetmap.josm.plugins.elevation; 16 17 import static org.openstreetmap.josm.tools.I18n.tr;18 16 19 17 import java.util.ArrayList; … … 80 78 return gpxData; 81 79 } 80 81 /** 82 * @return the tracks 83 */ 84 protected List<IElevationProfile> getTracks() { 85 return tracks; 86 } 82 87 83 88 /** … … 137 142 trackCounter = 0; 138 143 144 super.updateValues(); 139 145 if (tracks == null) { 140 146 tracks = new ArrayList<IElevationProfile>(); … … 148 154 GpxIterator.visit(gpxData, this); 149 155 150 setWayPoints(tmpWaypoints, true);151 156 // reduce data 152 157 setWayPoints(WayPointHelper.downsampleWayPoints(tmpWaypoints, … … 160 165 public void updateElevationData() { 161 166 computeProfile(); 162 }163 164 public String toString() {165 return "ElevationModel [start=" + getStart() + ", end=" + getEnd()166 + ", minHeight=" + getMinHeight() + ", maxHeight="167 + getMaxHeight() + ", wayPoints=" + numberOfWayPoints + "]";168 167 } 169 168 … … 190 189 processWayPoint(wp); 191 190 } 192 193 public void end(GpxRoute route) { 194 String trackName = "Route#" + trackCounter; 195 addTrackOrRoute(trackName); 196 } 197 198 public void end(GpxTrack track) { 191 192 /* (non-Javadoc) 193 * @see org.openstreetmap.josm.plugins.elevation.ElevationProfileBase#visit(org.openstreetmap.josm.data.gpx.WayPoint) 194 */ 195 @Override 196 public void visit(WayPoint wp) { 197 super.visit(wp); 198 processWayPoint(wp); 199 } 200 201 public void start() { 202 buffer.clear(); 203 } 204 205 public void end() { 199 206 String trackName = "Track#" + trackCounter; 200 addTrackOrRoute(trackName); 201 } 202 207 addTrackOrRoute(trackName); 208 } 209 203 210 private void addTrackOrRoute(String trackName) { 204 211 if (getSliceSize() > 0) { 205 212 ElevationProfileNode emt = new ElevationProfileNode(trackName, 206 213 this, buffer, getSliceSize()); 207 // System.out.println("Add track/route: " + trackName);208 214 tracks.add(emt); 209 215 } … … 212 218 } 213 219 214 public void start(GpxRoute route) {215 // buffer should be empty -> isolated way points216 if (buffer.size() > 0) {217 addTrackOrRoute(tr("Unknown"));218 }219 }220 221 public void start(GpxTrack track) {222 // buffer should be empty -> isolated way points223 if (buffer.size() > 0) {224 addTrackOrRoute(tr("Unknown"));225 }226 }227 228 220 private void processWayPoint(WayPoint wp) { 221 if (wp == null) { 222 throw new RuntimeException("WPT must not be null!"); 223 } 224 229 225 buffer.add(wp); 230 226 tmpWaypoints.add(wp); -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfileBase.java
r23795 r23976 494 494 } 495 495 } 496 497 public String toString() { 498 return "ElevationProfileBase [start=" + getStart() + ", end=" + getEnd() 499 + ", minHeight=" + getMinHeight() + ", maxHeight=" 500 + getMaxHeight() + "]"; 501 } 496 502 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/GpxIterator.java
r23795 r23976 46 46 if (visitor == null) return; 47 47 48 visitor.start(); 48 49 visitSingleWaypoints(data, visitor); 50 visitor.end(); 49 51 50 52 // routes … … 92 94 93 95 Collection<GpxTrackSegment> segments = trk.getSegments(); 94 visitor.start( trk);96 visitor.start(); 95 97 96 98 if (segments != null) { … … 102 104 103 105 for (WayPoint wayPoint : waypts) { 104 visitor.visit( trk, segment,wayPoint);106 visitor.visit(wayPoint); 105 107 } 106 108 } 107 109 } 108 visitor.end( trk);110 visitor.end(); 109 111 } 110 112 … … 117 119 if (visitor == null) return; 118 120 119 visitor.start( route);121 visitor.start(); 120 122 for (WayPoint wpt : route.routePoints) { 121 visitor.visit( route,wpt);123 visitor.visit(wpt); 122 124 } 123 visitor.end( route);125 visitor.end(); 124 126 } 125 127 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IGpxVisitor.java
r23795 r23976 15 15 package org.openstreetmap.josm.plugins.elevation; 16 16 17 import org.openstreetmap.josm.data.gpx.GpxRoute;18 import org.openstreetmap.josm.data.gpx.GpxTrack;19 import org.openstreetmap.josm.data.gpx.GpxTrackSegment;20 17 import org.openstreetmap.josm.data.gpx.WayPoint; 21 18 … … 26 23 public interface IGpxVisitor extends IGpxWaypointVisitor { 27 24 /** 28 * Starts a GPX route. 29 * @param route The route to visit. 25 * Starts a GPX route, track or way point collection. 30 26 */ 31 void start( GpxRoute route);27 void start(); 32 28 33 29 /** 34 * Ends a GPX route. 35 * @param route The route to visit. 30 * Ends a GPX route, track or way point collection. 36 31 */ 37 void end( GpxRoute route);32 void end(); 38 33 39 34 /** … … 42 37 * @param wp The way point to visit. 43 38 */ 44 void visit(GpxRoute route, WayPoint wp); 45 46 /** 47 * Called before a GPX track is iterated. 48 * @param track The track to visit. 49 */ 50 void start(GpxTrack track); 51 52 /** 53 * Called after a track iteration. 54 * @param track The track to visit. 55 */ 56 void end(GpxTrack track); 57 58 /** 59 * Visits a way point within a GPX track. 60 * @param track The associated track of the way point. 61 * @param segment The associated segment of the way point. 62 * @param wp The way point to visit. 63 */ 64 void visit(GpxTrack track, GpxTrackSegment segment, WayPoint wp); 39 void visit(WayPoint wp); 65 40 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r23795 r23976 136 136 System.err.println(String.format( 137 137 "Cannot paint: mv=%s, prof=%s, wpt=%s", mv, profile, wpt)); 138 if (wpt == null) { 139 throw new RuntimeException("WPT must not be null, profile " + profile); 140 } 138 141 return; 139 142 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r23795 r23976 48 48 import org.openstreetmap.josm.plugins.elevation.GeoidCorrectionKind; 49 49 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener; 50 import org.openstreetmap.josm.plugins.elevation.IElevationProfile;51 50 import org.openstreetmap.josm.plugins.elevation.WayPointHelper; 52 51 import org.openstreetmap.josm.tools.Shortcut; … … 67 66 private static final long serialVersionUID = -868463893732535577L; 68 67 /* Elevation profile instance */ 69 private IElevationProfileprofile;68 private ElevationModel profile; 70 69 /* GPX data */ 71 70 private GpxLayer activeLayer = null; … … 241 240 * @return 242 241 */ 243 public IElevationProfilegetModel() {242 public ElevationModel getModel() { 244 243 return profile; 245 244 } … … 249 248 * @param model The new model. 250 249 */ 251 public void setModel( IElevationProfilemodel) {250 public void setModel(ElevationModel model) { 252 251 if (this.profile != model) { 253 252 this.profile = model; … … 290 289 291 290 if (profile.hasElevationData()) { 292 // Show elevation data293 minHeightLabel.setText(294 WayPointHelper.getElevationText(profile.getMinHeight()));295 maxHeightLabel.setText(296 WayPointHelper.getElevationText(profile.getMaxHeight()));297 avrgHeightLabel.setText(298 WayPointHelper.getElevationText(profile.getAverageHeight()));299 elevationGainLabel.setText(300 WayPointHelper.getElevationText(profile.getGain()));291 // Show elevation data 292 minHeightLabel.setText( 293 WayPointHelper.getElevationText(profile.getMinHeight())); 294 maxHeightLabel.setText( 295 WayPointHelper.getElevationText(profile.getMaxHeight())); 296 avrgHeightLabel.setText( 297 WayPointHelper.getElevationText(profile.getAverageHeight())); 298 elevationGainLabel.setText( 299 WayPointHelper.getElevationText(profile.getGain())); 301 300 } 302 301 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r23795 r23976 162 162 for (WayPoint wpt : profile.getWayPoints()) { 163 163 int ele = (int) WayPointHelper.getElevation(wpt); 164 165 if (wpt == null) { 166 throw new RuntimeException("WPT must not be null, profile " + profile); 167 } 164 168 165 169 if (lastWpt != null) { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java
r23795 r23976 174 174 public void paint(Graphics g) { 175 175 isPainting = true; 176 super.paint(g); 177 178 int y1 = getPlotBottom(); 179 180 g.setColor(Color.DARK_GRAY); 181 g.drawLine(plotArea.x, plotArea.y, plotArea.x, plotArea.y 182 + plotArea.height); 183 g.drawLine(plotArea.x, plotArea.y + plotArea.height, plotArea.x 184 + plotArea.width, plotArea.y + plotArea.height); 185 176 186 177 Font oldFont = getFont(); 187 178 Font lFont = getFont().deriveFont(9.0f); 188 179 setFont(lFont); 189 180 try { 190 if (profile != null) { 181 super.paint(g); 182 183 int y1 = getPlotBottom(); 184 185 g.setColor(Color.DARK_GRAY); 186 g.drawLine(plotArea.x, plotArea.y, plotArea.x, plotArea.y 187 + plotArea.height); 188 g.drawLine(plotArea.x, plotArea.y + plotArea.height, plotArea.x 189 + plotArea.width, plotArea.y + plotArea.height); 190 191 192 193 if (profile != null && profile.hasElevationData()) { 191 194 drawAlignedString(formatDate(profile.getStart()), 5, y1 + 5, 192 195 TextAlignment.Left, g); … … 267 270 double diff = profile.getHeightDifference(); 268 271 272 if (diff == 0.0) { 273 return; 274 } 275 269 276 double z10 = Math.floor(Math.log10(diff)); 270 277 double scaleUnit = Math.pow(10, z10); // scale unit, e. g. 100 for … … 397 404 398 405 if (i == this.selectedIndex) { 406 g.setColor(Color.BLACK); 407 drawAlignedString(WayPointHelper.getElevationText(eleVal), 408 (getPlotRight() + getPlotLeft()) / 2, 409 getPlotBottom() + 6, 410 TextAlignment.Centered, 411 g); 412 399 413 c = renderer.getColorForWaypoint(profile, wpt, ElevationWayPointKind.Highlighted); 400 414 } … … 407 421 int geoidVal = 0; 408 422 switch(WayPointHelper.getGeoidKind()) { 409 case Auto: geoidVal = WayPointHelper.getGeoidCorrection(wpt); break;410 case Fixed: // not impl423 case Auto: geoidVal = WayPointHelper.getGeoidCorrection(wpt); break; 424 case Fixed: // not impl 411 425 } 426 412 427 g.setColor(ElevationColors.EPLightBlue); 413 428 … … 506 521 int newIdx = x - l - pl; 507 522 508 if (newIdx != this.selectedIndex && newIdx > 0) {523 if (newIdx != this.selectedIndex && newIdx >= 0) { 509 524 this.selectedIndex = newIdx; 510 525 this.repaint();
Note:
See TracChangeset
for help on using the changeset viewer.