Developing plug-in programs
Contents
Developing plug-in programs
Determining the type of plug-in program
Determining which version of Java to use
The first line in the About System dialog box indicates the version of Java that was used to develop MIPAV. To obtain the correct version of Java, go to the following web site: <http://www.java.sun.com>
Writing the source code
When you develop a plug-in for MIPAV, several lines must be present in the code so that it executes properly. Some mandatory code should be included in all plug-in files. Other code might change depending on the plug-in type.
Including mandatory code
The next three figures (Figure 6-Figure 8) show the mandatory source code needed for creating a file type of plug-in, a view type of plug-in, and an algorithm type of plug-in. The plug-ins directory of MIPAV includes these three files (e.g. C:\[$MIPAV]\mipav\plugins):
import gov.nih.mipav.view.*;
|
Lines 3, 4, and 6 in the PlugInView.java and PlugInAlgorithm.java files import the model structures, view functions, and the basic Java package that has GUI functions (Figure 10).
import gov.nih.mipav.model.structures.*; // MIPAV package where main // MIPAV structures are located (e.g., model image) import gov.nih.mipav.view.*; Â import java.awt.*
|
If you reference a class, you must include it in the plug-in package so that it can be called from the main file. After you write and compile, you must now install files in the user or home directory:
An example of this appears in the first line of Figure 11.
package plugins; // added to plugins pkg. so PlugInSampleStub may // call it.
|
Lines of code that are dependent on plug-in type
Declaration
Type of plug-in
|
Declaration
|
---|---|
File
|
public interface PlugInFile extends PlugIn (
|
View
|
public interface PlugInView extends PlugIn (
|
Algorithm
|
public interface PlugInAlgorithm extends PlugIn (
|
Parameters for the run method
Type of plug-in
|
Parameters for the run method
|
---|---|
File
|
public void run(ViewUserInterface UI);
|
View
|
public void run(ViewUserInterface UI, Frame parentFrame, ModelImage image);
|
Algorithm
|
public void run(ViewUserInterface UI, Frame parentFrame, ModelImage image);
|
1 package gov.nih.mipav.plugins; 2 3 import gov.nih.mipav.model structures.*; 4 import gov.nih.mipav.view.*; 5 6 import java.awt *; 7 8 public interface PlugInAlgorithm extends PlugIn { 9 10 /** 11 * run 12 * @param UI MIPAV main user interface. 13 * @param parentFrame Frame that displays the MIPAV image. 14 * Can be used as a parent frame when building dialogs. 15 * @param image Model of the MIPAV image. 16 * @see ModelImage 17 * @see ViewJFrameImage 18 */ 19 public void run(ViewUserInterface UI, Frame parentFrame, ModelImage image;) 20 21 }
|
Building and compiling plug-in programs
Installing a build environment
Configuring the environment
On Windows workstations
See also:
On Linux or UNIX workstations
Bash users should do the following:
Build.xml
build.xml 1 <!-- build file for MIPAV plugin class --> 2 - 3 <project basedir="." default="compile" name="mipav_plugin"> 4 <property name="dir.mipav" value="c:\\Program Files\\mipav\\"/> 5 <property name="dir.jdk" value="c:\\Program Files\\Java\\jdk1.6.0_02"/> 6 - 7 <target name="init"> 8 <tstamp/> 9 - 10 <path id="build.classpath"> 11 <pathelement path="${dir.mipav}"/> 12 <pathelement location="${dir.mipav}/InsightToolkit/lib/InsightToolkit/InsightToolkit.jar"/> 13 - 14 <fileset dir="${dir.mipav}"> 15 <filename name="*.jar"/> 16 </fileset> 17 </path> 18 <property name="build.cp" refid="build.classpath"/> 19 </target> 20 - 21 <target name="compile" depends="init"> 22 <echo>classpath: ${build.cp}</echo> 23 - 24 <javac debug="true" deprecation="true" description="Builds MIPAV" verbose="no" listfiles="yes" nowarn="no" fork="true" memoryInitialSize="220M" memoryMaximumSize="1000M" id="mipav build" source="1.4" target="1.4" destdir="." srcdir="." compiler="modern"> 25 <classpath refid="build.classpath"/> 26 </javac> 27 </target> 28 - 29 <target name="clean" depends="init"> 30 - 31 <delete> 32 - 33 <fileset dir="."> 34 <include name="**/*.class"/> 35 </fileset> 36 </delete> 37 </target> 38 </project>
|
Compiling the plug-in files