Ignore:
Timestamp:
2013-08-25T16:26:09+02:00 (11 years ago)
Author:
oliverw
Message:

Distinguish different levels of elevation gain/loss as proposed by Helmut S.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java

    r29611 r29874  
    2929 */
    3030public class ElevationProfilePlugin extends Plugin {
    31        
    32         private ElevationMapMode eleMode;
    33         private IconToggleButton eleModeButton;
    34         private static ElevationProfileLayer currentLayer;
    3531
    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;
    4235
    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();
    5049        }
    51        
    52         /**
     50    }
     51
     52    /**
    5353     * Called after Main.mapFrame is initialized. (After the first data is loaded).
    5454     * You can use this callback to tweak the newFrame to your needs, as example install
    5555     * an alternative Painter.
    5656     */
    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);
    6867        }
    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);                   
    8179        }
     80        return currentLayer;
     81    }
    8282}
Note: See TracChangeset for help on using the changeset viewer.