This pages gives you a walk-through on how to build a custom plugin implemenation:
SelectionPlugin is a simple CalculatorPlugin descendant class written as an example for custom plugin implementation. SelectionPluginDisplay is the corresponding CalculatorPluginDisplay descendant class. This latter is not mandatory for a custom plugin; for most plugins the default implementation is enough, provided that the plugin implements [getResultMolecule()](https://apidocs.chemaxon.com/marvin/help/developer/beans/api/chemaxon/marvin/plugin/CalculatorPlugin.html#getResultMolecule()) in a way that it returns a molecule object with atomic results set in atom extra labels and molecular results in molecule properties. SelectionPluginDisplay gives an example to modify the default molecule view display: it adds a text area with some data.
SelectionPluginTest is the test sketcher application that shows how to insert the plugin administration into your code in case when you want to use a customized GUI for plugin invocation instead of or in addition to the built-in Tools menu.
To integrate the SelectionPlugin into MarvinSketch/MarvinView, you need to do the following steps (you should also perform similar tasks if you have your own plugin):
Create the plugin JAR with manifest SelectionPlugin.txt:
jar cmf SelectionPlugin.txt SelectionPlugin.jar SelectionPlugin.class SelectionPluginDisplay.class xjars/SelectionPluginParameters.xml
Copy the plugin JAR into the
plugins directory (if the
plugins directory does not exist, create it in the home directory of Marvin Beans):
cp SelectionPlugin.jar MarvinBeans/plugins (Linux / UNIX) copy SelectionPlugin.jar MarvinBeans\plugins (Windows)
MarvinBeans/plugins/plugins.properties file. Add this line to the file:
Use JAR files from Marvin Applets package for compilation of the new plugin. Since Marvin applets classes are compiled with 1.5 compatible compiler, additional code has to be compatible with 1.5 compatible JDK. To provide compatibility, set the source and the target attributes to 1.5.
javac -source 1.5 -target 1.5 -classpath "marvin/jmarvin.jar:marvin/sjars/Plugin.jar:marvin/sjars/PluginGUI.jar" SelectionPlugin.java SelectionPluginDisplay.java
Marvin applets accept custom plugins from certain location:
marvin/plugin/extensions.jar. Therefore, wrap resources for your plugin intoextensions.jar. In this example, SelectionPlugin.txt is the manifest file for the JAR file.
jar cmf SelectionPlugin.txt extensions.jar *.class xjars/SelectionPluginParameters.xml
The JAR files that Marvin applets load have to be signed.
jarsigner -keystore "<keystorepath>" -storepass <password> extensions.jar <alias>
Copy the JAR file into the marvin/plugins directory.
cp extensions.jar marvin/plugins/.
Create your own instance of plugins.properties in the marvin/plugins directory. This properties file describes the structure of the Tools menu in MarvinSketch / MarvinView. If this file exists, it overwrites the default "Tools" menu. There is a template for plugins.properties (plugins.properties.sample.txt) in this directory. Just make a copy of it, then edit it.
cp marvin/plugins/plugins.properties.sample.txt marvin/plugins/plugins.properties
To assign your plugin to ChemAxon plugins add the following line to this file. The header of the properties file describes the syntax:
Now you are ready. In MarvinSketch/MarvinView applet the new plugin will be displayed in the Tools/Other menu.