Changeset 29961 in osm for applications/editors/josm/plugins/ElevationProfile
- Timestamp:
- 2013-09-25T18:34:06+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ColoredElevationLayer.java
r29960 r29961 54 54 @Override 55 55 public Icon getIcon() { 56 return ImageProvider.get("layer", "elevation _small");56 return ImageProvider.get("layer", "elevation"); 57 57 } 58 58 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r29950 r29961 57 57 58 58 // TODO: Disable this view as long as it is not stable 59 //MainMenu.add(Main.main.menu.viewMenu, action, false, 0);59 MainMenu.add(Main.main.menu.viewMenu, action, false, 0); 60 60 } catch (Exception e1) { 61 61 System.err.println("Init of ElevationProfilePlugin failed: " + e1); -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java
r29955 r29961 18 18 import java.util.List; 19 19 20 import org.openstreetmap.josm.data.Bounds; 20 21 import org.openstreetmap.josm.data.gpx.WayPoint; 21 22 … … 135 136 136 137 /** 138 * Gets the coordinate bounds of the elevation profile. 139 * 140 * @return the bounds 141 */ 142 public Bounds getBounds(); 143 144 /** 137 145 * Gets the children of the segment (maybe null). 138 146 */ -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileBase.java
r29958 r29961 19 19 import java.util.List; 20 20 21 import org.openstreetmap.josm.data.Bounds; 21 22 import org.openstreetmap.josm.data.gpx.WayPoint; 22 23 import org.openstreetmap.josm.plugins.elevation.ElevationHelper; … … 64 65 private int gain; 65 66 private int lastEle; 67 private Bounds bounds; 68 66 69 private static boolean ignoreZeroHeight = true; 67 70 … … 92 95 this.name = name; 93 96 this.parent = parent; 97 94 98 setWayPoints(wayPoints); 95 99 } 96 100 101 /** 102 * Checks if zero elevation should be ignored or not. 103 * 104 * @return true, if is ignore zero height 105 */ 97 106 public static boolean isIgnoreZeroHeight() { 98 107 return ignoreZeroHeight; 99 108 } 100 109 110 /** 111 * Sets the ignore zero height. 112 * 113 * @param ignoreZeroHeight the new ignore zero height 114 */ 101 115 public static void setIgnoreZeroHeight(boolean ignoreZeroHeight) { 102 116 ElevationProfileBase.ignoreZeroHeight = ignoreZeroHeight; … … 448 462 return numWayPoints;// wayPoints != null ? wayPoints.size() : 0; 449 463 } 464 465 /** 466 * Gets the coordinate bounds of this profile. See {@link Bounds} for details. 467 * 468 * @return the bounds of this elevation profile 469 */ 470 public Bounds getBounds() { 471 return bounds; 472 } 450 473 451 474 /** … … 473 496 } 474 497 498 // update boundaries 499 if (bounds == null) { 500 bounds = new Bounds(wp.getCoor()); 501 } else { 502 bounds.extend(wp.getCoor()); 503 } 504 475 505 int ele = (int) ElevationHelper.getElevation(wp); 476 506 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r29960 r29961 18 18 19 19 import java.awt.BorderLayout; 20 import java.awt.Dimension; 20 21 import java.awt.FlowLayout; 21 22 import java.awt.Font; 22 23 import java.awt.GridLayout; 24 import java.awt.event.ActionEvent; 25 import java.awt.event.ActionListener; 23 26 import java.awt.event.ComponentEvent; 24 27 import java.awt.event.ComponentListener; … … 29 32 30 33 import javax.swing.ComboBoxModel; 34 import javax.swing.JButton; 31 35 import javax.swing.JComboBox; 32 36 import javax.swing.JLabel; … … 75 79 private JLabel distLabel; 76 80 private JComboBox<IElevationProfile> trackCombo; 81 private JButton zoomButton; 77 82 78 83 /* Listener to the elevation model */ … … 83 88 */ 84 89 private ElevationProfileLayer profileLayer; 85 86 90 87 91 /** … … 166 170 trackPanel.add(lbTrack); 167 171 168 trackCombo = new JComboBox<IElevationProfile>(new TrackModel()); 172 zoomButton = new JButton(tr("Zoom")); 173 zoomButton.addActionListener(new ActionListener() { 174 @Override 175 public void actionPerformed(ActionEvent arg0) { 176 if (model != null) { 177 IElevationProfile profile = model.getCurrentProfile(); 178 if (profile != null) { 179 Main.map.mapView.zoomTo(profile.getBounds()); 180 } 181 } 182 183 } 184 }); 185 zoomButton.setEnabled(false); 186 187 trackCombo = new JComboBox<IElevationProfile>(new TrackModel()); 188 trackCombo.setPreferredSize(new Dimension(200, 24)); // HACK! 189 trackCombo.setEnabled(false); // we have no model on startup 190 169 191 trackPanel.add(trackCombo); 192 trackPanel.add(zoomButton); 170 193 171 194 // assemble root panel … … 246 269 */ 247 270 private void updateView() { 248 if (model == null) return; 271 if (model == null) { 272 disableView(); 273 return; 274 } 249 275 250 276 IElevationProfile profile = model.getCurrentProfile(); 251 252 277 if (profile != null) { 253 278 // Show name of profile in title … … 276 301 totalTimeLabel.setText(String.format("%d:%d h", hours, minutes)); 277 302 distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist)); 278 trackCombo.setEnabled(model.profileCount() > 1); 303 trackCombo.setEnabled(model.profileCount() > 1); 304 trackCombo.setModel(new TrackModel()); 305 zoomButton.setEnabled(true); 279 306 } else { // no elevation data, -> switch back to empty view 280 setTitle(String.format("%s: (No data)", tr("Elevation Profile"))); 281 282 minHeightLabel.setText(EMPTY_DATA_STRING); 283 maxHeightLabel.setText(EMPTY_DATA_STRING); 284 avrgHeightLabel.setText(EMPTY_DATA_STRING); 285 elevationGainLabel.setText(EMPTY_DATA_STRING); 286 totalTimeLabel.setText(EMPTY_DATA_STRING); 287 distLabel.setText(EMPTY_DATA_STRING); 288 trackCombo.setEnabled(false); 307 disableView(); 289 308 } 290 309 291 310 fireModelChanged(); 292 311 repaint(); 312 } 313 314 private void disableView() { 315 setTitle(String.format("%s: (No data)", tr("Elevation Profile"))); 316 317 minHeightLabel.setText(EMPTY_DATA_STRING); 318 maxHeightLabel.setText(EMPTY_DATA_STRING); 319 avrgHeightLabel.setText(EMPTY_DATA_STRING); 320 elevationGainLabel.setText(EMPTY_DATA_STRING); 321 totalTimeLabel.setText(EMPTY_DATA_STRING); 322 distLabel.setText(EMPTY_DATA_STRING); 323 trackCombo.setEnabled(false); 324 zoomButton.setEnabled(false); 293 325 } 294 326
Note:
See TracChangeset
for help on using the changeset viewer.