Changeset 29874 in osm for applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
- Timestamp:
- 2013-08-25T16:26:09+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r29611 r29874 29 29 */ 30 30 public class ElevationProfilePlugin extends Plugin { 31 32 private ElevationMapMode eleMode;33 private IconToggleButton eleModeButton;34 private static ElevationProfileLayer currentLayer;35 31 36 /** 37 * Initializes the plugin. 38 * @param info Context information about the plugin. 39 */ 40 public ElevationProfilePlugin(PluginInformation info) { 41 super(info); 32 private ElevationMapMode eleMode; 33 private IconToggleButton eleModeButton; 34 private static ElevationProfileLayer currentLayer; 42 35 43 try { 44 eleMode = new ElevationMapMode("Elevation profile", Main.map); 45 eleModeButton = new IconToggleButton(eleMode); 46 } catch (Exception e1) { 47 System.err.println("Init of ElevationProfilePlugin failed: " + e1); 48 e1.printStackTrace(); 49 } 36 /** 37 * Initializes the plugin. 38 * @param info Context information about the plugin. 39 */ 40 public ElevationProfilePlugin(PluginInformation info) { 41 super(info); 42 43 try { 44 eleMode = new ElevationMapMode("Elevation profile", Main.map); 45 eleModeButton = new IconToggleButton(eleMode); 46 } catch (Exception e1) { 47 System.err.println("Init of ElevationProfilePlugin failed: " + e1); 48 e1.printStackTrace(); 50 49 } 51 52 /** 50 } 51 52 /** 53 53 * Called after Main.mapFrame is initialized. (After the first data is loaded). 54 54 * You can use this callback to tweak the newFrame to your needs, as example install 55 55 * an alternative Painter. 56 56 */ 57 @Override 58 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 59 super.mapFrameInitialized(oldFrame, newFrame); 60 61 if (newFrame != null) { 62 newFrame.addMapMode(eleModeButton); 63 ElevationProfileDialog eleProfileDlg = new ElevationProfileDialog(); 64 eleProfileDlg.addModelListener(eleMode); 65 eleProfileDlg.setProfileLayer(getCurrentLayer()); 66 newFrame.addToggleDialog(eleProfileDlg); 67 } 57 @Override 58 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 59 super.mapFrameInitialized(oldFrame, newFrame); 60 61 if (newFrame != null) { 62 newFrame.addMapMode(eleModeButton); 63 ElevationProfileDialog eleProfileDlg = new ElevationProfileDialog(); 64 eleProfileDlg.addModelListener(eleMode); 65 eleProfileDlg.setProfileLayer(getCurrentLayer()); 66 newFrame.addToggleDialog(eleProfileDlg); 68 67 } 69 70 /** 71 * Gets the elevation profile layer which decorates the current layer 72 * with some markers. 73 * @return 74 */ 75 public static ElevationProfileLayer getCurrentLayer(){ 76 if(currentLayer == null){ 77 currentLayer = new ElevationProfileLayer("Elevation profile"); 78 Main.main.addLayer(currentLayer); 79 } 80 return currentLayer; 68 } 69 70 /** 71 * Gets the elevation profile layer which decorates the current layer 72 * with some markers. 73 * @return 74 */ 75 public static ElevationProfileLayer getCurrentLayer(){ 76 if(currentLayer == null){ 77 currentLayer = new ElevationProfileLayer("Elevation profile"); 78 Main.main.addLayer(currentLayer); 81 79 } 80 return currentLayer; 81 } 82 82 }
Note:
See TracChangeset
for help on using the changeset viewer.