top bar

Writing plugins for Micro-Manager

Revision as of 17:43, 2 March 2010 by Arthuredelstein (Talk | contribs)

Micro-Manager has a plugin system similar to ImageJ's. To write a Micro-Manager plugin, simply implement the MMPlugin interface. Note the static String menuName lets you control the name of the plugin that appears in the Micro-Manager Plugins menu.

Micro-Manager's classpath is set up so that Micro-Manager plugins can import classes from:

  1. the Java 2 SE 5.0 Libraries
  2. Micro-Manager
  3. ImageJ
  4. Apache Commons Math

Once you have compiled your code into a .class file or a .jar file, drop that file into Micro-Manager's mmplugins directory, and it will be loaded at startup. You can also dynamically load your plugin by including a line in the MMStartup.bsh file (in the root directory of your Micro-Manager installation). For example:

gui.installPlugin("org.micromanager.surveyor.SurveyorPlugin");

Using Eclipse or Netbeans

The dynamic loading feature (described above) is useful if you are developing your plugin using an IDE such as Eclipse or Netbeans. Here are the steps:

  1. Set up your project so that Micro-Manager's jars are on the classpath.
  2. Create a MMStartup.bsh file as described above.
  3. Set your IDE's run command to start up ImageJ, by calling the main function in ij.ImageJ in your Micro-Manager root directory.
  4. Build and run

As long as your plugin is placed on the classpath by the IDE (as is done by both Eclipse and Netbeans), the MMStartup.bsh script will properly load your nascent plugin in the plugins menu.

In addition, you have access to the GUI and core instances (objects) already created by Micro-Manager startup. Micro-Manager will call public void setApp(ScriptInterface app); you can get the GUI object and core objects thus:

MMStudioMainFrame gui_ = (MMStudioMainFrame) app;
CMMCore core_ = gui_.getMMCore();

Micro-Manager distribution includes swing-layout-*.*.jar so that you can use the free Netbeans GUI Builder for your plugin. Make sure you set the "Layout Generation Style" property as explained on the Netbeans website.

© Micro-Manager : Vale Lab, UCSF 2006-2011 | All Rights Reserved | Contact