Examples of MIPAV plug-ins
From MIPAV
Revision as of 22:12, 15 February 2012 by Angelfish100 (Talk)
Examples of MIPAV plug-ins
To build plug-in programs, three files are typically required:
PluginFoo.java-Provides an interface to MIPAV and the plugin.
PluginDialogFoo.java-Invokes the dialog to get user-supplied parameters; it can be hidden when no parameters are required.
PluginAlgorithmFoo.java-Provides the actual algorithm to be implemented. It can be a mixture of calls to MIPAV's API, C programs, Perl, ITK, etc.
Where Foo is the name that you supply for the program. The following sample plug-in program(s) are included in MIPAV documentation:
PlugInSample-a sample plug-in, see [MIPAV_Plugins.html#1300237 "Sample plug-in program" ] below.
PlugInCT_MD-a typical plug-in. (Refer to the MIPAV Users Guide, PDF version.)
PlugInAlgorithm.Median-a very complicated plug-in. Refer to MIPAV Volume 1 Users Guide, Appendix D.
PlugInDialogImageVOIDisplay.java - a self contained plug-in.
Sample plug-in program
The source code for the plug-in program, PlugInSample.java is an example of a simple algorithm type of plug-in. See Figure 20.
PlugInSample.java 1 import gov.nih.mipav.plugins.*; // needed to load PluginAlgorithm / PluginView / 2 // PlugInFile interface 3 import gov.nih.mipav.view.*; 4 import gov.nih.mipav.model.structures.*; 5 import java.awt.*; 6 7 /*** This is a simple plugin to display a image in a new frame @see PlugInAlgorithm */ 8 9 /** This is an Algorithm type of PlugIn and therefore must implement PlugInAlgorithm 10 ** Implementing the PlugInAlgorithm requires this class to implement the run method 11 ** with the correct parameters */ 12 13 public class PlugInSample implements PlugInAlgorithm { 14 /** 15 * Defines body of run method, which was declared in the interface. 16 * @param UI User Interface 17 * @param parentFrame ParentFrame 18 * @param image Current ModelImage--this is an image already loaded into 19 * MIPAV. Can be null. 20 */ 21 22 public void run (ViewUserInterface UI, Frame parentFrame, ModelImage image){ 23 if (parentFrame instanceof ViewJFrameImage) { 24 new PlugInDialogSample(parentFrame,image); 25 } else { 26 MipavUtil.displayError("PlugInSample only runs on an image frame."); 27 } 28 } 29 }
|