How to use jar file in ImageJ plugin?

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

How to use jar file in ImageJ plugin?

panovr
Hi,
  I want to pack some class files in a jar file, and use this jar file in ImageJ plugin.
  Suppose that my source package java files are:
  ===============================================
  1. MyClassA.java
  package mypackage
  [import statements]
  public MyClassA extends Object {
      ...
  }
  2. MyClassB.java
  package mypackage
  [import statements]
  public MyClassB extends Object {
      ...
  }
  ================================================
  Step 1: put MyClassA.java and MyClassB.java in D:\mypackage directory
  Step 2: go into D:\ directory, and type "javac MyClassA.java" and "javac MyClassB.java" in Dos command
  Step 3: how to use jar command to pack MyClassA.class and MyClassB.class into a jar file? Do I need to supply a manifest file?
  Step 4: where should I put this jar file in order to ImageJ can find  and I can use this jar file when develop ImageJ plugin?

  Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: How to use jar file in ImageJ plugin?

panovr
Hi,
  I also have another two questions:
  1. Does ImageJ support that loading plugins from jar file?
  2. It can not use "package" keyword in ImageJ plugin, is it?
  Thanks!
 
Reply | Threaded
Open this post in threaded view
|

Re: How to use jar file in ImageJ plugin?

ctrueden
In reply to this post by panovr
Hi,

>  I want to pack some class files in a jar file, and use this jar file in ImageJ plugin.
>  
>

Take a look at the JAR Plugin programming example available on the
ImageJ site:
http://rsb.info.nih.gov/ij/plugins/jar-demo.html

-Curtis
Reply | Threaded
Open this post in threaded view
|

Re: How to use jar file in ImageJ plugin?

Wayne Rasband
In reply to this post by panovr
>   I want to pack some class files in a jar file, and use this jar  
> file in ImageJ plugin.

There is an example at "http://rsb.info.nih.gov/ij/plugins/jar- 
demo.html".

>   Step 1: put MyClassA.java and MyClassB.java in D:\mypackage  
> directory
>   Step 2: go into D:\ directory, and type "javac MyClassA.java" and  
> "javac MyClassB.java" in Dos command

You do not need to use javac. You can compile and test plugins within  
ImageJ using the Plugins>Compile and Run command.

>   Step 3: how to use jar command to pack MyClassA.class and  
> MyClassB.class into a jar file?

Instructions for using the jar command are included with the example.

> Do I need to supply a manifest file?

A manifest file is not required. A plugins.config file is required if  
the jar file contains more than one plugin or you want to install a  
plugin somewhere other than the Plugins menu (e.g., in the  
File>Import menu).

>   Step 4: where should I put this jar file in order to ImageJ can  
> find  and I can use this jar file when develop ImageJ plugin?

Jar files go in the plugins folder, or immediate sub-folder.

>   I also have another two questions:
>   1. Does ImageJ support that loading plugins from jar file?

Yes.

>   2. It can not use "package" keyword in ImageJ plugin, is it?

The main class cannot use a package statement but classes called by  
the main class can.

-wayne
Reply | Threaded
Open this post in threaded view
|

How to instantiate ImagePlus in an existing window ?

Andy Gotz
Hi,

I would like to use ImageJ in my own application. In order to make the
windowing consistent I would like to have ImagePlus create its windows in
a panel I have created. Currently when I create an ImagePlus object and
call show() on a top level window is created as with ImageJ. But I would
like it to appear in a window I have created. I have not seen a
constructor which takes a JPanel or JFrame as parent. Does such a
constructor exist? Has anyone done anything similar? I know it is not
common but I would like to use ImageJ in my application because of all its
great features.

Thanks for any help or pointers on this one.

Andy Gotz

--
European Synchrotron Radiation Facility
6, rue Jules Horowitz,
Grenoble, 38043
FRANCE
Reply | Threaded
Open this post in threaded view
|

Re: How to instantiate ImagePlus in an existing window ?

Albert Cardona
Andy,

Simply create the Image plus and DO NOT call show() on it.

If you plan to use it inside an AWT Component, then instantiate a new
ij.gui.ImageCanvas that contains the ImagePlus, and add that canvas to the
awt.Window or whatever awt component.

If you plan to use it inside a SWING JComponent, then extend a JPanel,
override the update(Graphics g) to call paint(g), and override paint(Graphics
g) to paint the awt.Image that you can get from the ImagePlus (or its
ImageProcessor) by calling my_image_plus.getImage() . Be sure to
setMinimumSize of the extended JPanel to the size of the ImagePlus.

The approach for SWING fixes lots of repainting problems when it has to
coexist with other SWING JComponent objects inside the same layout (awt
components are painted last, and over any other swing JComponent objects).


Hope it helps.

Albert

--
Albert Cardona
Molecular Cell Developmental Biology
University of California Los Angeles
Tel +1 310 2067376
Programming: http://www.pensament.net/java/
Research: http://www.mcdb.ucla.edu/Research/Hartenstein/
Web design: http://www.pixelets.com