Changes between Version 92 and Version 93 of DevelopersGuide/DevelopingPlugins


Ignore:
Timestamp:
2019-08-23T17:05:28+02:00 (6 years ago)
Author:
chippy
Comment:

update JOSM plugin API table as the Main object has been long deprecated and removed

Legend:

Unmodified
Added
Removed
Modified
  • DevelopersGuide/DevelopingPlugins

    v92 v93  
    162162Most of the current JOSM authors don't follow this approach and in 2008 and 2009 large parts of the JOSM code base have been refactored in order to improve the maintainability and stability of the code. You're encouraged to follow the well-established principles of encapsulation and information hiding in plugins too.
    163163
    164 There are still a couple of global objects accessible through [source:/trunk/src/org/openstreetmap/josm/Main.java Main], though.
    165 
    166 ||Main.parent||This is the parent of all GUI elements. Use this as first parameter to JOptionPane.show* if you want to popup a message||
    167 ||Main.pref|| This is the global preferences file, loaded from  {{{${josm.home}/preferences}}}. Use {{{Main.pref.get(...)}}} and {{{Main.pref.put(...)}}} to access the preferences. They will be saved immediately after a put, so don't put anything you dont want to have there. Please, prefix custom plugin preferences with your plugin name. ||
    168 ||Main.proj||This is the current [source:/trunk/src/org/openstreetmap/josm/data/projection/Projection.java Projection] used in JOSM. If you want to translate between Lat/Lon and East/North, use {{{Main.proj.latlon2eastnorth}}} and {{{Main.proj.eastnorth2latlon}}}.||
    169 ||Main.map.mapView||This is the main UI component in JOSM to paint the map. You usually access this to call methods like {{{getCenter()}}}, {{{getScale()}}} or {{{zoomTo()}}}. '''Beware''': {{{Main.map}}} can be null when no layers are created yet.||
    170 ||Main.getLayerManager()||This provides you with the list of layers that are currently displayed.||
     164In 2017 The Plugin API was reworked to make the source more modular. [source:/trunk/src/org/openstreetmap/josm/Main.java Main] object was removed and replaced by other more modular API.  These are some of the new objects:
     165
     166||MainApplication.getMainFrame()||This is the parent of all GUI elements. Use this as first parameter to JOptionPane.show* if you want to popup a message||
     167||Config.getPref()|| This is the global preferences file, loaded from  {{{${josm.home}/preferences}}}. Use {{{Config.getPref().get(key)}}} and {{{Config.getPref().put(key,value)}}} to access the preferences. They will be saved immediately after a put, so don't put anything you dont want to have there. Please, prefix custom plugin preferences with your plugin name. ||
     168||Projection||This is the current [source:/trunk/src/org/openstreetmap/josm/data/projection/Projection.java Projection] used in JOSM. If you want to translate between Lat/Lon and East/North, use {{{Projection.latlon2eastnorth}}} and {{{Projection.latlon2eastnorth}}}.||
     169||MainApplication.getMap().mapView||This is the main UI component in JOSM to paint the map. You usually access this to call methods like {{{getCenter()}}}, {{{getScale()}}} or {{{zoomTo()}}}. '''Beware''': {{{MainApplication.getMap()}}} can be null when no layers are created yet.||
     170||MainApplication.getLayerManager()||This provides you with the list of layers that are currently displayed.||
    171171
    172172JOSM plugins can '''register''' for a couple of '''events''' emitted by JOSM.