Class Plugin
- java.lang.Object
-
- org.openstreetmap.josm.plugins.Plugin
-
- All Implemented Interfaces:
MapFrameListener
- Direct Known Subclasses:
PluginProxy
public abstract class Plugin extends java.lang.Object implements MapFrameListener
For all purposes of loading dynamic resources, the Plugin's class loader should be used (or else, the plugin jar will not be within the class path).A plugin may subclass this abstract base class (but it is optional).
The actual implementation of this class is optional, as all functions will be called via reflection. This is to be able to change this interface without the need of recompiling or even breaking the plugins. If your class does not provide a function here (or does provide a function with a mismatching signature), it will not be called. That simple.
Or in other words: See this base class as an documentation of what automatic callbacks are provided (you can register yourself to more callbacks in your plugin class constructor).
Subclassing Plugin and overriding some functions makes it easy for you to keep sync with the correct actual plugin architecture of JOSM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
Plugin.PluginBaseDirectories
-
Field Summary
Fields Modifier and Type Field Description private PluginInformation
info
This is the info available for this plugin.private IBaseDirectories
pluginBaseDirectories
-
Constructor Summary
Constructors Modifier Constructor Description protected
Plugin(PluginInformation info)
Creates the plugin
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDownloadSelection(java.util.List<DownloadSelection> list)
Called in the download dialog to give the plugin a chance to modify the list of bounding box selectors.IBaseDirectories
getPluginDirs()
Get the directories where this plugin can store various files.PluginInformation
getPluginInformation()
Replies the plugin information object for this pluginjava.lang.ClassLoader
getPluginResourceClassLoader()
Get a class loader for loading resources from the plugin jar.PreferenceSetting
getPreferenceSetting()
Called in the preferences dialog to create a preferences page for the plugin, if any available.void
mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame)
Called after Main.mapFrame is initialized.void
setPluginInformation(PluginInformation info)
Sets the plugin information object for this plugin
-
-
-
Field Detail
-
info
private PluginInformation info
This is the info available for this plugin. You can access this from your constructor.(The actual implementation to request the info from a static variable is a bit hacky, but it works).
-
pluginBaseDirectories
private final IBaseDirectories pluginBaseDirectories
-
-
Constructor Detail
-
Plugin
protected Plugin(PluginInformation info)
Creates the plugin- Parameters:
info
- the plugin information describing the plugin.
-
-
Method Detail
-
getPluginInformation
public PluginInformation getPluginInformation()
Replies the plugin information object for this plugin- Returns:
- the plugin information object
-
setPluginInformation
public void setPluginInformation(PluginInformation info)
Sets the plugin information object for this plugin- Parameters:
info
- the plugin information object
-
getPluginDirs
public IBaseDirectories getPluginDirs()
Get the directories where this plugin can store various files.- Returns:
- the directories where this plugin can store files
- Since:
- 13007
-
mapFrameInitialized
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame)
Description copied from interface:MapFrameListener
Called after Main.mapFrame is initialized. (After the first data is loaded). You can use this callback to tweak the newFrame to your needs, as example install an alternative Painter.- Specified by:
mapFrameInitialized
in interfaceMapFrameListener
- Parameters:
oldFrame
- The old MapFramenewFrame
- The new MapFrame
-
getPreferenceSetting
public PreferenceSetting getPreferenceSetting()
Called in the preferences dialog to create a preferences page for the plugin, if any available.- Returns:
- the preferences dialog, or
null
-
addDownloadSelection
public void addDownloadSelection(java.util.List<DownloadSelection> list)
Called in the download dialog to give the plugin a chance to modify the list of bounding box selectors.- Parameters:
list
- list of bounding box selectors
-
getPluginResourceClassLoader
public java.lang.ClassLoader getPluginResourceClassLoader()
Get a class loader for loading resources from the plugin jar. This can be used to avoid getting a file from another plugin that happens to have a file with the same file name and path. Usage: Instead of getClass().getResource("/resources/pluginProperties.properties"); write getPluginResourceClassLoader().getResource("resources/pluginProperties.properties"); (Note the missing leading "/".)- Returns:
- a class loader for loading resources from the plugin jar
-
-