Difference between revisions of "Developing plug-in programs"
(→Installing a build environment) |
(→On Windows workstations) |
||
Line 170: | Line 170: | ||
===== On Windows workstations ===== | ===== On Windows workstations ===== | ||
− | + | <div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 1 Click Start > Control Panel. The Control Panel window opens.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 2 Double-click the System icon. The System Properties dialog box opens. <br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 3 Click Advanced. The Advanced page of the System Properties dialog box appears.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 4 Click Environment Variables. The Environment Variables dialog box opens.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 5 Decide whether to add and edit variables in the User variables box or the System variables box based on which users should have access to the Java SDK and Ant.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 6 Add the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">JAVA_HOME</font></span> variable to your environment:<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> a Click New. The New User Variable dialog box or the New System Variable dialog box opens.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> b Type <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">JAVA_HOME</font></span> in Variable name.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> c Type the path for the Java SDK on your computer (e.g., <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">C:\Program Files\Java\jdk1.6.0_02</font></span>) in Variable value.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> d Click OK. The<span style="font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline">''<font color="#000000"> </font>''</span><span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">JAVA_HOME</font></span> variable appears in either the User variables box or System variables box as appropriate.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 7 Add the <span style="font-style: normal; text-decoration: none; text-transform: none; vertical-align: baseline">'''<font color="#000000">ANT_HOME</font>'''</span> variable to your environment by doing the following:<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> a Click New under either the User variables box or the System variables box. The New User Variable dialog box or the New System Variables dialog box opens as appropriate.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> b Type <span style="font-style: normal; text-decoration: none; text-transform: none; vertical-align: baseline">'''<font color="#000000">ANT_HOME</font>'''</span> in Variable name.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> c Type the path for the Ant on your computer (e.g., <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">C:\Program Files\Ant\apache-ant-1.7.0</font></span>) in Variable value.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> d Click OK. The <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">ANT_HOME</font></span> variable appears in either the User variables box or System variables box as appropriate.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 8 Update either the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">PATH</font></span> variable in the User variables box or the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">Path</font></span> variable in the System variables box by doing the following:<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> a Select the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">PATH</font></span> variable in the User variables box, or select the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">Path</font></span> variable in the System variables box.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> b Click Edit under the User variables box, or click Edit under the System variables box. Either the Edit User Variable dialog box or the Edit System Variable dialog box opens.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> c Type <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000"><nowiki>;%JAVA_HOME%\bin;%ANT_HOME%\bin</nowiki></font></span><span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000"> </font></span>to the end of the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">PATH </font></span>variable or to the end of the Path variable.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> d Click OK. The edited variable appears either in the User variables box or the System variables box. See also Figure 14.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 9 Open a new terminal for the change to take effect by doing the following:<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> a Click Start > Run. The Run dialog box opens.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 36pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> b Type <span style="font-style: normal; text-decoration: none; text-transform: none; vertical-align: baseline">'''<font color="#000000">cmd</font>'''</span> in Open, and click OK. A terminal window opens. <br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 10 Retrieve the<span style="font-style: normal; font-weight: normal; text-transform: none; vertical-align: baseline"><u><font color="#000000"> sample Ant build file (build.xml)</font></u></span> from the MIPAV web site and place it in the same directory as the plug-in<span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">.java</font></span> files you want to compile.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 18pt; margin-right: 0pt; margin-top: 6pt; text-align: left; text-decoration: none; text-indent: -18pt; text-transform: none; vertical-align: baseline"><font color="#000000"> 11 Alter the <span style="font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline">''<font color="#000000">dir.mipav</font>''</span> and <span style="font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline">''<font color="#000000">dir.jdk</font>''</span> properties within the <span style="font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; vertical-align: baseline"><font color="#000000">build.xml</font></span> to point to the directory where MIPAV and the SDK are installed, respectively.<br /></font></div><div style="font-style: normal; font-weight: normal; margin-bottom: 0pt; margin-left: 0pt; margin-right: 0pt; margin-top: 0pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline"><font color="#000000"> | |
{| border="1" cellpadding="5" | {| border="1" cellpadding="5" | ||
− | |+ <div style="font-style: normal; margin-bottom: 3pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">'''<font color="#000000"> Figure | + | |+ <div style="font-style: normal; margin-bottom: 3pt; margin-left: 0pt; margin-right: 0pt; margin-top: 9pt; text-align: left; text-decoration: none; text-indent: 0pt; text-transform: none; vertical-align: baseline">'''<font color="#000000"> Figure 14. Configuring system variables for MS Windows<br /></font>'''</div> |
|- | |- | ||
− | |||
− | |||
| | | | ||
[[Image:EnvironmentVariables.jpg]] | [[Image:EnvironmentVariables.jpg]] | ||
− | |||
|} | |} | ||
Revision as of 21:54, 15 February 2012
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