Posted by
Sami Badawi-2 on
Apr 11, 2008; 6:05am
URL: http://imagej.273.s1.nabble.com/Details-on-calling-a-plugin-from-another-one-tp3696579p3696580.html
Hi Pablo,
Is there a way to put each plugin in a different folder? Yes
Is it necessary to import Object_Counter3D in my plugin? No
I created a little test class PlugInFilter to show how to do it, and
tested it by calling both an ImageJ PlugInFilter and one of my own
PlugInFilter.
import ij.IJ;
import ij.ImagePlus;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
/** Shows how how to call one pluginFilter from another. */
public class PlugInFilterCaller_ implements PlugInFilter {
String _pluginName;
String _arg;
int _returnValueForSetup;
/** Default is to call dilate from ImageJ Binary. */
public PlugInFilterCaller_() {
this("ij.plugin.filter.Binary", "dilate", DOES_8G);
}
// /** Default is to call ShapeLogic segmenter. */
// public PlugInFilterCaller_() {
// this("SBSegment_", "", DOES_8G+DOES_RGB+DOES_STACKS+SUPPORTS_MASKING);
// }
/** Use this to setup your own plugin runner. */
public PlugInFilterCaller_(String pluginName, String arg, int
returnValueForSetup) {
_pluginName = pluginName;
_arg = arg;
_returnValueForSetup = returnValueForSetup;
}
/** Empty everything is done in setup. */
public void run(ImageProcessor ip) {
}
public int setup(String arg, ImagePlus imp) {
IJ.runPlugIn(_pluginName, _arg);
return _returnValueForSetup;
}
}
-Sami Badawi
http://www.shapelogic.orgOn Thu, Apr 10, 2008 at 4:12 PM, Pablo Manuel Jais <
[hidden email]> wrote:
> Hi, I have a question on the details of calling a plugin's method from
> another plugin. I've read this post (
>
https://list.nih.gov/cgi-bin/wa?A2=ind0306&L=IMAGEJ&D=0&I=-3&P=31044 )
> dated 27 Jun 2003 in which Adrian explained how to use a plugin from
> another by means of its public methods (see code below).
>
> I tried someting similar with the Object_Counter3D plugin (
>
http://rsb.info.nih.gov/ij/plugins/track/objects.html ), since it is
> prepared to be used that way. However, I am forced to place the file
> MyPlugin.java and Object_Counter3D.java in the same folder. Otherwise, the
> compiler gives an error ("Class ReUsable not found") Is there a way to put
> each plugin in a different folder? Is it necessary to import
> Object_Counter3D in my plugin?
>
> Thank you in advance for your answer,
> Pablo
>
>
> Adrian proposed the following plugin structure:
> public class ReUsable implements PlugIn {
> run() {
> GenericDialog gd = new GenericDialog("...");
> ...
> initThings();
> setParams(p1,p2,...);
> process();
> }
>
> public initThings() {...}
> public setParams() {...}
> public process() {...}
> }
>
> And the code to use it:
> public class MyPlugin implements PlugIn {
> ReUsable pi = new ReUsable();
> pi.initThings();
> pi.setParams(...);
> pi.process(...);
> }
>