How to uninstall macros?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to uninstall macros?

vischer
Hi List,

I would like to know the file name from which the current macro set is  
loaded. Further, I look for a way to uninstall all macros that appear  
under menu Plugins>Macros>, as well as the macro tools in the ImageJ  
main window.

Currently, I need to load a new macro set to clear the old one, and  
need to define new tool macros to clear the old tools. I would  
appreciate if there was a public method such as uninstallAllMacros(),  
so my plugin can guarantee a clean situation.
Further, I was not able to obtain the name of the macro file that is  
currently active. Looking at the MacroInstaller, it would be nice if  
"MacroInstaller.fileName" would be public (Wayne, does this make sense?)

Norbert Vischer
Reply | Threaded
Open this post in threaded view
|

Re: How to uninstall macros?

Michael Schmid
Hi Norbert,

if you install a new macro (Plugins>Macros>Install or menu item  
'install' in a text window with a macro), the old tools will be  
removed and replaced by the tools in the new macro. No need for  
uninstall.
On startup, ImageJ reads the macros from StartupMacros.txt in the  
ImageJ/macros folder.

The rightmost tool icon with the double arrow '>>' gives you quick  
access to several macro sets, e.g. the StartupMacros.

Michael
________________________________________________________________

On 12 Jul 2009, at 16:34, Norbert Vischer wrote:

> Hi List,
>
> I would like to know the file name from which the current macro set  
> is loaded. Further, I look for a way to uninstall all macros that  
> appear under menu Plugins>Macros>, as well as the macro tools in  
> the ImageJ main window.
>
> Currently, I need to load a new macro set to clear the old one, and  
> need to define new tool macros to clear the old tools. I would  
> appreciate if there was a public method such as uninstallAllMacros
> (), so my plugin can guarantee a clean situation.
> Further, I was not able to obtain the name of the macro file that  
> is currently active. Looking at the MacroInstaller, it would be  
> nice if "MacroInstaller.fileName" would be public (Wayne, does this  
> make sense?)
>
> Norbert Vischer
Reply | Threaded
Open this post in threaded view
|

How to test plugin?

Vivian Yong
Hi there,
I tried to write a testing plugin based on the ImageJ tutorial. I can
test it after I put the plugin file in the ImageJ plugin folder. I just
wonder how can I test run it in Eclipse? Also, I would like to see the
output on the system for debugging purpose by using
System.out.print("..."); before the plugin be deployed to ImageJ, is
that possible and how?

Thanks in advance for answering my questions.

Regards,
Vivian
Reply | Threaded
Open this post in threaded view
|

Re: How to test plugin?

dscho
Hi Vivian,

On Tue, 14 Jul 2009, Vivian Yong wrote:

> I tried to write a testing plugin based on the ImageJ tutorial. I can
> test it after I put the plugin file in the ImageJ plugin folder. I just
> wonder how can I test run it in Eclipse? Also, I would like to see the
> output on the system for debugging purpose by using
> System.out.print("..."); before the plugin be deployed to ImageJ, is
> that possible and how?

In a plugin I recently reviewed, I saw this gem:

        public static void main(String[] args) {
                try {
                        System.getProperties().list(System.err);
               System.setProperty("plugins.dir", args[0]);
                        new ImageJ();
                        IJ.run("This Plugin", "argument=value argument=value");
                } catch (Exception ex) {
                        e.printStackTrace();
        }
        }

You specify the plugin class as main class, and pass the main() method the
path to the directory containing the corresponding .class file.  Before
constructing ImageJ(), you can output anything to System.out (or
System.err).  Of course, you need to adjust the parameters of IJ.run()
appropriately.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: How to test plugin?

Senseney, Justin (NIH/CIT) [E]
Vivian,

Dscho's solution is a good general solution, but there's another way that I've found works a lot better when developing ImageJ plugins in Eclipse.  This only works reliably with the newer versions of Eclipse (Europa, Ganymede, etc). Try these steps:

1) Create a new Java project in Eclipse called "ImageJ" and put the ij.jar and IJ_Prefs.txt from your ImageJ install into this new project's working directory.  

2) Change the default output folder of your ImageJ project to "plugins", create a "src" folder to hold all your plugins in that same dialog box.

3) Refresh the project (so you can see the jars), then add ij.jar to the project's classpath.

4) Make a dummy plugin (implements PlugIn, has run(String) method)

5) Finally, in the Run configurations... tab set your main class to ij.ImageJ

When you run this configuration, your dummy_plugin appears in ImageJ's list of plugins.  When you make changes to this plugin, your changes are reflected as soon as you restart ImageJ.  It's a little work to set up, but this is the most efficient way I've found to work on ImageJ plugins.  You can even attach the ImageJ src to the jar and use those files to debug w/ line references.

-Justin

-----Original Message-----
From: Johannes Schindelin [mailto:[hidden email]]
Sent: Tuesday, July 14, 2009 6:42 AM
To: List IMAGEJ
Subject: Re: How to test plugin?

Hi Vivian,

On Tue, 14 Jul 2009, Vivian Yong wrote:

> I tried to write a testing plugin based on the ImageJ tutorial. I can
> test it after I put the plugin file in the ImageJ plugin folder. I just
> wonder how can I test run it in Eclipse? Also, I would like to see the
> output on the system for debugging purpose by using
> System.out.print("..."); before the plugin be deployed to ImageJ, is
> that possible and how?

In a plugin I recently reviewed, I saw this gem:

        public static void main(String[] args) {
                try {
                        System.getProperties().list(System.err);
               System.setProperty("plugins.dir", args[0]);
                        new ImageJ();
                        IJ.run("This Plugin", "argument=value argument=value");
                } catch (Exception ex) {
                        e.printStackTrace();
        }
        }

You specify the plugin class as main class, and pass the main() method the
path to the directory containing the corresponding .class file.  Before
constructing ImageJ(), you can output anything to System.out (or
System.err).  Of course, you need to adjust the parameters of IJ.run()
appropriately.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: How to test plugin?

Thomas Peterbauer
Vivian,
I also frequently use what one could call a "launcher" class (Dscho's
variant) as the main class to start ImageJ in Eclipse (Galileo), and in
my opinion this route is more convenient than Justin's variant: your
plugin is started automatically, and you can set the launcher to do all
the things a user would normally do before running the plugin. For example:

      new ImageJ(null);
      IJ.open(path_to_file);
      IJ.run("Measure");
      IJ.runPlugIn("My_Plugin", "");

The macro recorder in combination with the Convert to Plugin command is
a nice tools to get corresponding java code without having to dig too
much in APIs.//
If you do not want to care about arguments to be passed from the IDE to
the main() method, let the launcher do the job:

import ij.IJ;
import ij.ImageJ;
import java.net.URL;

public class IJLauncher implements Runnable {
  public void run() {
      String name = getClass().getName();              
      URL url =getClass().getResource(name+".class");
      String path = url.toString().replaceAll("%20", " ");
      path = path.substring(6, path.indexOf("/plugins"));
      //System.out.println(path);
      System.getProperties().setProperty("plugins.dir", path);
      new ImageJ(null);
      IJ.runPlugIn("My_Plugin", "");
  }

  public static void main(String args[]) {
      Thread runnable = new Thread(new IJLauncher());
      runnable.start();
  }
}

Yours,
Thomas

Senseney, Justin (NIH/CIT) [E] schrieb:

> Vivian,
>
> Dscho's solution is a good general solution, but there's another way that I've found works a lot better when developing ImageJ plugins in Eclipse.  This only works reliably with the newer versions of Eclipse (Europa, Ganymede, etc). Try these steps:
>
> 1) Create a new Java project in Eclipse called "ImageJ" and put the ij.jar and IJ_Prefs.txt from your ImageJ install into this new project's working directory.  
>
> 2) Change the default output folder of your ImageJ project to "plugins", create a "src" folder to hold all your plugins in that same dialog box.
>
> 3) Refresh the project (so you can see the jars), then add ij.jar to the project's classpath.
>
> 4) Make a dummy plugin (implements PlugIn, has run(String) method)
>
> 5) Finally, in the Run configurations... tab set your main class to ij.ImageJ
>
> When you run this configuration, your dummy_plugin appears in ImageJ's list of plugins.  When you make changes to this plugin, your changes are reflected as soon as you restart ImageJ.  It's a little work to set up, but this is the most efficient way I've found to work on ImageJ plugins.  You can even attach the ImageJ src to the jar and use those files to debug w/ line references.
>
> -Justin
>
> -----Original Message-----
> From: Johannes Schindelin [mailto:[hidden email]]
> Sent: Tuesday, July 14, 2009 6:42 AM
> To: List IMAGEJ
> Subject: Re: How to test plugin?
>
> Hi Vivian,
>
> On Tue, 14 Jul 2009, Vivian Yong wrote:
>
>  
>> I tried to write a testing plugin based on the ImageJ tutorial. I can
>> test it after I put the plugin file in the ImageJ plugin folder. I just
>> wonder how can I test run it in Eclipse? Also, I would like to see the
>> output on the system for debugging purpose by using
>> System.out.print("..."); before the plugin be deployed to ImageJ, is
>> that possible and how?
>>    
>
> In a plugin I recently reviewed, I saw this gem:
>
>         public static void main(String[] args) {
>        try {
>                System.getProperties().list(System.err);
>                System.setProperty("plugins.dir", args[0]);
>                new ImageJ();
> IJ.run("This Plugin", "argument=value argument=value");
>        } catch (Exception ex) {
> e.printStackTrace();
>         }
>         }
>
> You specify the plugin class as main class, and pass the main() method the
> path to the directory containing the corresponding .class file.  Before
> constructing ImageJ(), you can output anything to System.out (or
> System.err).  Of course, you need to adjust the parameters of IJ.run()
> appropriately.
>
> Hth,
> Dscho
>