Changeset 23759 in osm for applications/editors/josm
- Timestamp:
- 2010-10-23T00:37:00+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r23754 r23759 63 63 ComponentListener { 64 64 65 private static final String EMPTY_DATA_STRING = "-"; 65 66 /** 66 67 * … … 246 247 public void setModel(IElevationProfile model) { 247 248 if (this.profile != model) { 248 if (model != null) { 249 // System.out.println("Set model " + model); 250 this.profile = model; 251 profPanel.setElevationModel(model); 252 updateView(); 253 } 249 this.profile = model; 250 profPanel.setElevationModel(model); 251 252 updateView(); 254 253 } 255 254 } … … 282 281 */ 283 282 private void updateView() { 284 if (profile == null) { // emergency exit 285 setTitle(String.format("%s: (No data)", tr("Elevation Profile"))); 286 return; 287 } 288 289 // Show name of profile in title 290 setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName())); 291 292 if (profile.hasElevationData()) { 283 if (profile != null) { 284 // Show name of profile in title 285 setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName())); 286 287 if (profile.hasElevationData()) { 293 288 // Show elevation data 294 289 minHeightLabel.setText( … … 300 295 elevationGainLabel.setText( 301 296 NavigatableComponent.getSystemOfMeasurement().getDistText(profile.getGain())); 302 } else { // no elevation data 303 minHeightLabel.setText("-"); 304 maxHeightLabel.setText("-"); 305 avrgHeightLabel.setText("-"); 306 elevationGainLabel.setText("-"); 307 } 308 309 // compute values for time and distance 310 long diff = profile.getTimeDifference(); 311 long minutes = diff / (1000 * 60); 312 long hours = minutes / 60; 313 minutes = minutes % 60; 314 315 double dist = profile.getDistance(); 316 317 totalTimeLabel.setText(String.format("%d:%d h", hours, minutes)); 318 distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist)); 297 } 298 299 // compute values for time and distance 300 long diff = profile.getTimeDifference(); 301 long minutes = diff / (1000 * 60); 302 long hours = minutes / 60; 303 minutes = minutes % 60; 304 305 double dist = profile.getDistance(); 306 307 totalTimeLabel.setText(String.format("%d:%d h", hours, minutes)); 308 distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist)); 309 } else { // no elevation data, -> switch back to empty view 310 setTitle(String.format("%s: (No data)", tr("Elevation Profile"))); 311 312 minHeightLabel.setText(EMPTY_DATA_STRING); 313 maxHeightLabel.setText(EMPTY_DATA_STRING); 314 avrgHeightLabel.setText(EMPTY_DATA_STRING); 315 elevationGainLabel.setText(EMPTY_DATA_STRING); 316 totalTimeLabel.setText(EMPTY_DATA_STRING); 317 distLabel.setText(EMPTY_DATA_STRING); 318 } 319 319 320 320 fireModelChanged(); … … 414 414 } 415 415 416 System.out.println("Active layer: " + newLayer.getName());417 416 ElevationModel em = layerMap.get(newLayer); 418 417 em.setSliceSize(slices); … … 424 423 public void layerAdded(Layer newLayer) { 425 424 createLayer(newLayer); 426 System.out.println("layerAdded: " + newLayer.getName());427 425 } 428 426 … … 432 430 layerMap.remove(oldLayer); 433 431 } 434 432 if (layerMap.size() == 0) { 433 setModel(null); 434 profileLayer.setProfile(null); 435 } 435 436 } 436 437 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r23757 r23759 158 158 int index = 0; 159 159 160 if (profile != null) {161 renderer.beginRendering();160 renderer.beginRendering(); 161 if (profile != null) { 162 162 for (WayPoint wpt : profile.getWayPoints()) { 163 163 int ele = (int) WayPointHelper.getElevation(wpt); … … 206 206 renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(), 207 207 ElevationWayPointKind.MinElevation); 208 } else { 209 System.err.println("Layer#paint: No profile"); 210 } 208 } 211 209 212 210 renderer.finishRendering();
Note:
See TracChangeset
for help on using the changeset viewer.