Changeset 26034 in osm for applications/editors/josm/plugins/ElevationProfile/src
- Timestamp:
- 2011-05-22T20:33:33+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r23795 r26034 70 70 if(Main.map != null){ 71 71 Main.map.toolGroup.add(eleModeButton); 72 73 Main.map.mapView.addPropertyChangeListener(eleProfileDlg);74 MapView.addLayerChangeListener(eleProfileDlg);75 72 eleProfileDlg.setProfileLayer(getCurrentLayer()); 76 73 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r23976 r26034 24 24 import java.awt.event.ComponentEvent; 25 25 import java.awt.event.ComponentListener; 26 import java.beans.PropertyChangeEvent;27 import java.beans.PropertyChangeListener;28 26 import java.util.ArrayList; 29 27 import java.util.HashMap; … … 36 34 import javax.swing.JTextField; 37 35 36 import org.openstreetmap.josm.Main; 38 37 import org.openstreetmap.josm.data.gpx.GpxData; 38 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 39 39 import org.openstreetmap.josm.gui.MapView; 40 40 import org.openstreetmap.josm.gui.NavigatableComponent; 41 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;42 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;43 41 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 44 42 import org.openstreetmap.josm.gui.layer.GpxLayer; 45 43 import org.openstreetmap.josm.gui.layer.Layer; 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer;47 44 import org.openstreetmap.josm.plugins.elevation.ElevationModel; 48 45 import org.openstreetmap.josm.plugins.elevation.GeoidCorrectionKind; … … 56 53 * connection between layer and elevation profile. 57 54 */ 58 public class ElevationProfileDialog extends ToggleDialog implements 59 PropertyChangeListener, LayerChangeListener, EditLayerChangeListener, 60 ComponentListener { 55 public class ElevationProfileDialog extends ToggleDialog implements LayerChangeListener, ComponentListener { 61 56 62 57 private static final String EMPTY_DATA_STRING = "-"; … … 235 230 dock(); 236 231 } 232 233 @Override 234 public void showNotify() { 235 MapView.addLayerChangeListener(this); 236 if (Main.isDisplayingMapView()) { 237 Layer layer = Main.map.mapView.getActiveLayer(); 238 if (layer instanceof GpxLayer) { 239 setActiveLayer((GpxLayer) layer); 240 } 241 } 242 } 243 244 @Override 245 public void hideNotify() { 246 MapView.removeLayerChangeListener(this); 247 } 237 248 238 249 /** … … 361 372 } 362 373 363 /*364 * (non-Javadoc)365 *366 * @seejava.beans.PropertyChangeListener#propertyChange(java.beans.367 * PropertyChangeEvent)368 */369 370 /*371 * WORKAROUND: The layer list dialog does not notify any listener when the372 * selection of the list changes. So the user has to toggle the visibility373 * of the layer to update the elevation profile.374 */375 public void propertyChange(PropertyChangeEvent event) {376 Object src = event.getSource();377 if (src instanceof MapView) {378 MapView mapView = (MapView) src;379 Layer l = mapView.getActiveLayer();380 if (l instanceof GpxLayer) {381 setActiveLayer((GpxLayer) l);382 }383 } else if (src instanceof GpxLayer) {384 GpxLayer gpxLayer = (GpxLayer) src;385 setActiveLayer(gpxLayer);386 }387 }388 389 374 /* (non-Javadoc) 390 375 * @see org.openstreetmap.josm.gui.MapView.LayerChangeListener#activeLayerChange(org.openstreetmap.josm.gui.layer.Layer, org.openstreetmap.josm.gui.layer.Layer) … … 396 381 } 397 382 398 /**399 * Internal helper to create elevation data for a new layer.400 * @param newLayer The layer added by the user.401 */402 private void createLayer(Layer newLayer) {403 if (newLayer != null) {404 if (newLayer instanceof GpxLayer) {405 newLayer.addPropertyChangeListener(this);406 GpxLayer gpxLayer = (GpxLayer) newLayer;407 setActiveLayer(gpxLayer);408 }409 }410 }411 412 /**413 * Internal helper to update internal cache and synchronize elevation model.414 * @param newLayer The layer added by the user.415 */416 383 private void setActiveLayer(GpxLayer newLayer) { 417 384 if (activeLayer != newLayer) { 385 activeLayer = newLayer; 418 386 int slices = 250; 419 387 if (profPanel != null && profPanel.getPlotArea().width > 0) { … … 438 406 */ 439 407 public void layerAdded(Layer newLayer) { 440 createLayer(newLayer); 408 if (newLayer instanceof GpxLayer) { 409 GpxLayer gpxLayer = (GpxLayer) newLayer; 410 setActiveLayer(gpxLayer); 411 } 441 412 } 442 413 … … 452 423 profileLayer.setProfile(null); 453 424 } 454 }455 456 /* (non-Javadoc)457 * @see org.openstreetmap.josm.gui.MapView.EditLayerChangeListener#editLayerChanged(org.openstreetmap.josm.gui.layer.OsmDataLayer, org.openstreetmap.josm.gui.layer.OsmDataLayer)458 */459 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {460 // Nothing to do...461 425 } 462 426
Note:
See TracChangeset
for help on using the changeset viewer.