Changes between Version 79 and Version 80 of DevelopersGuide/DevelopingPlugins
- Timestamp:
- 2016-08-21T15:51:45+02:00 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevelopersGuide/DevelopingPlugins
v79 v80 155 155 ||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. || 156 156 ||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}}}.|| 157 ||Main.map.mapView||This is the main UI component in JOSM. It provides the view with the rendered layers. You usually access this to call methods like {{{getCenter()}}}, {{{getScale()}}} or {{{zoomTo()}}}. '''Beware''': {{{Main.map}}} can be null when no layers are created yet.|| 157 ||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.|| 158 ||Main.getLayerManager()||This provides you with the list of layers that are currently displayed.|| 158 159 159 160 JOSM plugins can '''register''' for a couple of '''events''' emitted by JOSM. … … 161 162 * '''layer change events''' 162 163 163 Implement a [source:/trunk/src/org/openstreetmap/josm/gui/ MapView.java org.openstreetmap.josm.gui.MapView.LayerChangeListener] and register it using [source:/trunk/src/org/openstreetmap/josm/gui/MapView.javaaddLayerChangeListener(LayerChangeListener listener)]. JOSM will then notify you about added, removed, and renamed layers. You may only or also register an [source:/trunk/src/org/openstreetmap/josm/gui/MapView.java org.openstreetmap.josm.gui.MapView.EditLayerChangeListener] in which case JOSM will notify the plugin about changes in the current edit layer, in particular whether there is or there isn't a current edit layer.164 Implement a [source:/trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java LayerChangeListener] and register it using [source:/trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java#L33 Main.getLayerManager().addLayerChangeListener(LayerChangeListener listener)]. JOSM will then notify you about added, removed, and renamed layers. You may only or also register an [source:/trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java org.openstreetmap.josm.gui.MapView.ActiveLayerChangeListener] in which case JOSM will notify the plugin about changes in the current edit layer, in particular whether there is or there isn't a current edit layer. 164 165 165 166 * '''selection change listener''' … … 174 175 175 176 * ''' preference change listener''' 176 If your plugin needs to respond to changes in the JOSM preferences it can implement a [source:/trunk/src/org/openstreetmap/josm/data/Preferences.java org.openstreetmap.josm.data.Preferences.PreferenceChangedListener]. Invoke {{{addPreferenceChangedListener(PreferenceChangedListener listener)}}} on {{{Main.pref}}}. 177 If your plugin needs to respond to general changes in the JOSM preferences it can implement a [source:/trunk/src/org/openstreetmap/josm/data/Preferences.java org.openstreetmap.josm.data.Preferences.PreferenceChangedListener]. Invoke {{{addPreferenceChangedListener(PreferenceChangedListener listener)}}} on {{{Main.pref}}}. You are encouraged to use a property object like [source:/trunk/src/org/openstreetmap/josm/data/preferences/IntegerProperty.java IntegerProperty] to access preferences. You can register a listener to that single preference there. 177 178 178 179 === Accessing the local file system ===