Difference between revisions of "Writing MIPAV plugins without access to MIPAV source code"

From MIPAV
Redirect page
Jump to: navigation, search
(Requirements: corrected link)
(linked to current version)
 
Line 1: Line 1:
There exists a way within eclipse to develop plugins for MIPAV without access to the MIPAV source code.
+
#Redirect [[Writing_MIPAV_plugins_without_MIPAV_source_code]]
 
+
== Requirements ==
+
 
+
First, you'll need to download the following software.  Note that Java may already be installed on your system.  Find out what version of Java you have [http://www.java.com/en/download/installed.jsp?detect=jdk&try=1 here].
+
 
+
* Java SE Development Kit. Version 1.5 or higher is needed. [http://java.sun.com/javase/downloads/?intcmp=1281 Download here] 
+
* Eclipse IDE for Java Developers.  The current version is required. [http://www.eclipse.org/downloads/ Download here]
+
* A release of MIPAV. [http://mipav.cit.nih.gov/download.php Available here]
+
* The following files:
+
** [[File:PlugInDialogNewGeneric2.java]]
+
** [[File:PlugInAlgorithmNewGeneric2.java]]
+
** [[File:PlugInNewGeneric2.java]]
+
 
+
== Installation ==
+
 
+
Installation should be completed in the following order.
+
 
+
=== Installing Java ===
+
 
+
Java installation simply requires following the prompts.
+
 
+
=== Installing Eclipse ===
+
 
+
Open the downloaded zip file.  Unzip the entire contents to a convenient folder, such as C:\Program Files\
+
 
+
=== Installing MIPAV ===
+
 
+
Mipav installation is also quickly completed by following the prompts.  Note where you installed MIPAV, by default this is in the folder C:\Program Files\mipav
+
 
+
== Building the Eclipse project ==
+
<table>
+
<tr>
+
  <td>
+
Start Eclipse.  A dialog will ask you where the default workspace is located.  Note the location it specifies and then click OK.  With Eclipse started, click File -> New -> Java Project. 
+
  </td>
+
  <td>
+
[[Image:New Project.jpg|thumb|500px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
Name your project mipav-plugin.  Ensure that the button next to "Create seperate folders for source and class files" is checked.  Click the Next button.
+
 
+
On the Source tab, change the Default output folder tab to "mipav-plugin/classes" 
+
  </td>
+
  <td> 
+
[[Image: Java Settings.jpg|thumb|499px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
On the libraries tab, click "Add External Class Folder" where you'll want to navigate to where you installed MIPAV.  Select the corresponding folder.
+
  </td>
+
  <td>
+
[[Image:External class folder.jpg|thumb|555px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
Also on the libraries tab, click "Add External JARs" and then add all the files from the following locations:
+
*mipav/lib/*
+
*mipav/lib/jaxp/*
+
*mipav/help/mipav_help.jar
+
*mipav/InsightToolkit/lib/InsightToolkit/InsightToolkit.jar
+
<br>
+
[[Image:allLibraries.jpg|thumb|500px|left]]
+
 
+
  </td>
+
  <td>
+
[[Image:External JARS.jpg|thumb|650px]]
+
  </td>
+
</tr>
+
</table>
+
Click Finish when complete.  A new project called mipav-plugin should appear.  You're now ready to run MIPAV.
+
 
+
== Running MIPAV with a sample plugin within Eclipse ==
+
 
+
<table>
+
<tr>
+
  <td>
+
To make sure you've set everything up correctly, we'll try to run MIPAV inside of Eclipse.  Navigate to Run->Run Configurations... on the control panel. On the dialog box that opens, highlight Java Application, and then click the New Launch Configuration on the left.  Fill out the Name and Project fields with the phrase "mipav-plugin"  To fill in the Main Class, click the Search... button.  Search for the name "MipavMain" If found, great!  Otherwise go to [[#Troubleshooting|troubleshooting]].
+
  </td>
+
  <td>
+
[[Image:MipavMain.jpg|thumb|650px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
Click on the arguments tab.  In the VM arguments box, put the following phrase "-Xms800M -Xmx800"  This specifies how many megabytes Java has available to run MIPAV.  If your computer has more or less, feel free to adjust the numbers accordingly.
+
  </td>
+
  <td>
+
[[Image:VmArg.jpg|thumb|550px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
When finished, click Run.  If MIPAV starts, you're ready to start developing plugins.  If not, go to [[#Troubleshooting|troubleshooting]].
+
  </td>
+
  <td>
+
[[Image:Splash.png|thumb]]
+
  </td>
+
</tr>
+
</table>
+
=== Importing the plugin ===
+
<table>
+
<tr>
+
  <td>
+
For now download these three files to a convenient location:
+
* [[File:PlugInDialogNewGeneric2.java]]
+
* [[File:PlugInAlgorithmNewGeneric2.java]]
+
* [[File:PlugInNewGeneric2.java]]
+
 
+
Import these files into Eclipse using the dialog from File->Import.
+
<br>
+
[[Image:import.jpg|thumb|400px|left]]
+
</td>
+
<td>
+
[[Image:import2.jpg|thumb|500px]]
+
</td>
+
</tr>
+
</table>
+
 
+
=== Installing the plugin ===
+
<table>
+
<tr>
+
  <td>
+
Start MIPAV using the method shown in Running MIPAV within Eclipse.  If that's already set up, press the green play button as shown.  Once MIPAV starts, navigate to Plugins->Install Plugin.  Once you press the Browse button, find the folder where the mipav-plugin project resides.  This should be inside of the default workspace folder you noted earlier.  Once found, go to click on the mipav-plugin/classes folder.  You should see the following classes:
+
*PlugInDialogNewGeneric2.class
+
*PlugInAlgorithmNewGeneric2.class
+
*PlugInNewGeneric2.class
+
  </td>
+
  <td>
+
[[Image:openPlugin.jpg|thumb|500px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
Select PlugInNewGeneric2.class and then press Open, and then OK.  Now open an image using MIPAV.  You can now click on  Plugs->Algorithms->PlugInNewGeneric2. 
+
  </td>
+
  <td>
+
[[Image:pluginOpen.jpg|thumb|650px]]
+
  </td>
+
</tr>
+
<tr>
+
  <td>
+
This plugin opens a blank dialog box with working OK and Cancel buttons. 
+
  </td>
+
  <td>
+
[[Image:pluginDialog.jpg|thumb|500px]]
+
  </td>
+
</tr>
+
</table>
+
 
+
=== Modifying the plugin ===
+
You'll see the the OK and Cancel buttons print those words to the Console window in Eclipse.  These words can be modified on lines X and Y of PlugInDialogNewGeneric2.  Note that because we loaded the plugin from the classes folder, the plugin is automatically updated when you make changes to the code.  When you want to test a new version of your plugin, simply restart MIPAV and then run your plugin.
+
 
+
== Writing a plugin ==
+
Writing a plugin, including accessing the MIPAV API, the structure of plugins, and accessing MIPAV help is covered extensively in the following [http://mipav.cit.nih.gov/documentation/userguide/volume1/MIPAV_PlugIns.pdf PDF document] or this [http://mipav.cit.nih.gov/documentation/presentations/plugins.pdf powerpoint presentation].
+
 
+
== Attaching the MIPAV Source ==
+
If you have an older copy of the MIPAV source code, this can be integrated into your plugin development.  Right click on the mipav folder in the referenced libraries as shown, and then click on Properties.  Under Java Source Attachment, you can select the external file or folder that contains the MIPAV source.
+
 
+
== Troubleshooting ==
+
 
+
What could have possibly gone wrong?  Please e-mail [mailto:SenseneyJ@mail.nih.gov SenseneyJ@mail.nih.gov] so your problem can be fixed and added to this page.  You could also leave a comment on the [[Talk:Writing_MIPAV_plugins_without_access_to_MIPAV_source_code|talk page]].
+

Latest revision as of 16:16, 28 May 2010