Develop a plugin depending on an other one.

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

Develop a plugin depending on an other one.

Ben
Dear All,

I am trying to develop a new ImageJ/Fiji plugin . I have read those guides:
http://fiji.sc/Developing_Fiji_in_Eclipse
http://fiji.sc/Introduction_into_Developing_Plugins
http://developer.imagej.net/writing-imagej-plugins (which is actually not
using Maven)

Using Maven, I understood I could reference other(s) Maven plugin(s), like
it is done for Trainable_Segmentation, see
https://github.com/fiji/Trainable_Segmentation/blob/master/pom.xml .

However, I want to use inside my new plugin an existing plugin that is *not* in
Maven yet (in my case, Sigma_Filter_Plus
<http://rsb.info.nih.gov/ij/plugins/sigma-filter.html>), so what would be
the best way to do it ? Is there a tutorial explaining that?

Benjamin

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Develop a plugin depending on an other one.

Peterbauer Thomas
Dear Benjamin,

I assume you are working with Eclipse; within this IDE, you can embed
external jars in the build path. Download the jar file of the plugin,
right click on the project in the package explorer, Properties > Java
Build Path > Libraries > Add External Jars.
You can even define a "User Library", where you can group external jars
together and supplement them with API docs and/or source code.


On 2014-08-13 16:45, Benjamin Pavie wrote:

>   Dear All,
>
> I am trying to develop a new ImageJ/Fiji plugin . I have read those guides:
> http://fiji.sc/Developing_Fiji_in_Eclipse
> http://fiji.sc/Introduction_into_Developing_Plugins
> http://developer.imagej.net/writing-imagej-plugins (which is actually not
> using Maven)
>
> Using Maven, I understood I could reference other(s) Maven plugin(s), like
> it is done for Trainable_Segmentation, see
> https://github.com/fiji/Trainable_Segmentation/blob/master/pom.xml .
>
> However, I want to use inside my new plugin an existing plugin that is *not* in
> Maven yet (in my case, Sigma_Filter_Plus
> <http://rsb.info.nih.gov/ij/plugins/sigma-filter.html>), so what would be
> the best way to do it ? Is there a tutorial explaining that?
>
> Benjamin
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Ben
Reply | Threaded
Open this post in threaded view
|

Re: Develop a plugin depending on an other one.

Ben
Thanks Thomas for your answer, my question was more how to organize that using the Maven way (like Fiji is proposing to do).

But to summarize, you suggest to create a .jar file form the plugin .class

jar cvf Sigma_Filter_Plus.jar Sigma_Filter_Plus.class

Then add it to the project via
Properties > Java Build Path > Libraries > Add External Jars
.

But now, if I want to call this plugin inside my code, if I do:
IJ.run("Sigma Filter Plus", "radius=1 use=2 minimum=0.2 outlier");
, it will not work because the plugin is not in the plugin.dir directory.
I know that I can call the plugin via the run method directly after passing some arguments, but in the case of this plugin, it is a bit more complicated. From my understanding, this is how I have to do it:
      int kNPoints=9;
      int kRadius=1;
      int[] lineRadius={1, 1, 1};
      int nPasses=1;
      Sigma_Filter_Plus filter = new Sigma_Filter_Plus();
      filter.setkNPoints(kNPoints);
      filter.setkRadius(kRadius);
      filter.setLineRadius(lineRadius);
      filter.setNPasses(nPasses);
      ImageProcessor ip = imp.getProcessor();
      FloatProcessor fp = null;
      for (int i=0; i<ip.getNChannels(); i++) {
        fp = ip.toFloat(i, fp);
        fp.setSliceNumber(ip.getSliceNumber());
        filter.run(fp);
        ip.setPixels(i, fp);
      }

It works, but it looks complicated, is there not a easier way to reference and call a plugin inside a plugin in Imagej/fiji ?

Reply | Threaded
Open this post in threaded view
|

Re: Develop a plugin depending on an other one.

Peterbauer Thomas
Ah, now I see the problem. Unfortunately, it's hard to give a clear answer
without knowing your particular setup of Eclipse. There are too many ways
how one can configure it and options to launch a plugin (the reason, I
guess, why there is no simple tutorial). If you let Maven create a jar file
somewhere, an easy way might be to place a copy of the sigma filter jar file
in the same folder, so your running ImageJ/Fiji instance will have access to
both, and you should be able to use IJ.run("Sigma Filter Plus",...).

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Ben
Sent: 14 August 2014 08:26
To: [hidden email]
Subject: Re: Develop a plugin depending on an other one.

Thanks Thomas for your answer, my question was more how to organize that
using the Maven way (like Fiji is proposing to do).

But to summarize, you suggest to create a .jar file form the plugin .class



Then add it to the project via .

But now, if I want to call this plugin inside my code, if I do:
, it will not work because the plugin is not in the plugin.dir directory.
I know that I can call the plugin via the run method directly after passing
some arguments, but in the case of this plugin, it is a bit more
complicated. From my understanding, this is how I have to do it:


It works, but it looks complicated, is there not a easier way to reference
and call a plugin inside a plugin in Imagej/fiji ?





--
View this message in context:
http://imagej.1557.x6.nabble.com/Develop-a-plugin-depending-on-an-other-one-
tp5009177p5009194.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Develop a plugin depending on an other one.

ctrueden
In reply to this post by Ben
Hi Ben,

> I want to use inside my new plugin an existing plugin that is *not* in
> Maven yet

The short answer is: get the dependency into a Maven repository -- ideally
Central, or failing that, the ImageJ Maven repository.

In the Maven community, the canonical article discussing solutions to this
problem is:


http://developer-blog.cloudbees.com/2013/03/playing-trade-offs-with-maven.html

As a stopgap, you could use the non-maven-jar plugin solution discussed in
that article.

Or if all you need is to invoke that plugin at runtime with specific
parameter values, you can avoid the compile-time dependency altogether by
writing e.g.:

   IJ.runPlugIn("Sigma_Filter_Plus", "<arguments to pass>");

This topic is also briefly discussed on the ImageJ wiki's Maven page:


http://imagej.net/Maven#How_to_find_a_dependency.27s_groupId.2FartifactId.2Fversion_.28GAV.29.3F

Relevant quote:

--snip--
If you need to depend on a library that is not present in either Maven
Central or the ImageJ Maven repository, you will need to install it into
your local Maven repository cache yourself. The command is mvn
install:install-file. For example, if you have a library foo.jar to
install, you could run:

 mvn install:install-file -Dfile=/path/to/foo.jar -DgroupId=org.foo \
   -DartifactId=foo -Dversion=1.0.0 -Dpackaging=jar

For the groupId, it is typically best to use the reversed domain name of
the library's web site. For libraries that are not explicitly versioned,
you may want to use a datestamp such as "20120920" for the version, rather
than inventing your own versioning scheme.

WARNING: If you use install:install-file, others will not be able to build
your code unless they also use install:install-file to install the library
on their systems. Before resorting to this technique, double check the
project's web site for any documentation on using their library with Maven.
They might provide their own public Maven repository which you could use
instead (by adding a <repository> to the <repositories> section of your
POM). Alternately, you could contact the ImageJ & Fiji maintainers to get
your needed dependency added to the ImageJ Maven repository, so that
everyone can build your code more easily.
--snap--

Regards,
Curtis


On Wed, Aug 13, 2014 at 9:45 AM, Benjamin Pavie <[hidden email]>
wrote:

> Dear All,
>
> I am trying to develop a new ImageJ/Fiji plugin . I have read those guides:
> http://fiji.sc/Developing_Fiji_in_Eclipse
> http://fiji.sc/Introduction_into_Developing_Plugins
> http://developer.imagej.net/writing-imagej-plugins (which is actually not
> using Maven)
>
> Using Maven, I understood I could reference other(s) Maven plugin(s), like
> it is done for Trainable_Segmentation, see
> https://github.com/fiji/Trainable_Segmentation/blob/master/pom.xml .
>
> However, I want to use inside my new plugin an existing plugin that is
> *not* in
> Maven yet (in my case, Sigma_Filter_Plus
> <http://rsb.info.nih.gov/ij/plugins/sigma-filter.html>), so what would be
> the best way to do it ? Is there a tutorial explaining that?
>
> Benjamin
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Develop a plugin depending on an other one.

Mark Hiner-2
In reply to this post by Ben
Hi Benjamin,

>However, I want to use inside my new plugin an existing plugin that is
*not* in Maven yet
>Is there a tutorial explaining that?

There are a few ways to get a non-Mavenized file into a Maven repository.

The easiest way is to upload the dependency manually to a maven repository,
as described here:

http://blog.sonatype.com/2008/11/adding-a-jar-to-a-maven-repository-with-sonatype-nexus/#.U-0ZYEhRFi4

These instructions should apply whether using a local or hosted Nexus.

You can also manually install files to your local Maven repository:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Both of these methods can make your jar available to other Mavenized
projects in Eclipse, as well as command line builds via "mvn".

Hope that helps,
Mark


On Thu, Aug 14, 2014 at 5:45 AM, Thomas Peterbauer <
[hidden email]> wrote:

> Ah, now I see the problem. Unfortunately, it's hard to give a clear answer
> without knowing your particular setup of Eclipse. There are too many ways
> how one can configure it and options to launch a plugin (the reason, I
> guess, why there is no simple tutorial). If you let Maven create a jar file
> somewhere, an easy way might be to place a copy of the sigma filter jar
> file
> in the same folder, so your running ImageJ/Fiji instance will have access
> to
> both, and you should be able to use IJ.run("Sigma Filter Plus",...).
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Ben
> Sent: 14 August 2014 08:26
> To: [hidden email]
> Subject: Re: Develop a plugin depending on an other one.
>
> Thanks Thomas for your answer, my question was more how to organize that
> using the Maven way (like Fiji is proposing to do).
>
> But to summarize, you suggest to create a .jar file form the plugin .class
>
>
>
> Then add it to the project via .
>
> But now, if I want to call this plugin inside my code, if I do:
> , it will not work because the plugin is not in the plugin.dir directory.
> I know that I can call the plugin via the run method directly after passing
> some arguments, but in the case of this plugin, it is a bit more
> complicated. From my understanding, this is how I have to do it:
>
>
> It works, but it looks complicated, is there not a easier way to reference
> and call a plugin inside a plugin in Imagej/fiji ?
>
>
>
>
>
> --
> View this message in context:
>
> http://imagej.1557.x6.nabble.com/Develop-a-plugin-depending-on-an-other-one-
> tp5009177p5009194.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html