Grid overlay plugin in GUI application for FIJI

fiji
imagej

#1

Hi everyone,

I am very new to Java GUI programming and also new to creating plugins for FIJI.
My goal is to create a plugin for FIJI as a Java GUI that loads an image and add a grid on top of it.

I realized that there is already a command in FIJI in ( Analyse > Tool) that adds a grid to your image but how to combine this grid functionality in the new plugin that I am creating?

I am using eclipse IDE for this project:

I have been watching the available tutorials online and so far my code just looks like this :


#2

Hello Wrise -

A couple of comments:

First, it looks like you are mixing “IJ1” and “IJ2” style development.
For example, import net.imagej.ImageJ; lives in the IJ2 world,
as does @Plugin, while ImagePlus img = IJ.getImage();
is IJ1-style.

You should probably pick one or the other, and stick to it.

I’m not sure exactly how you’re using eclipse, and where it’s putting
the plugin after you compile it, but my preference when developing
plugins is to produce a .jar file that contains the plugin (or a .class
file, if it is sufficiently simple), and copy it to my Fiji (*) install’s plugins
directory, and then run the plugin after launching Fiji / ImageJ.

(*) I work with the Fiji distribution of ImageJ.

Could you tell us what specific problem you are encountering so we can
zero in on concrete roadblocks to what you are trying to accomplish?

Last, could you post your actual code, rather than a screenshot? We
can’t cut-and-paste code snippets from a screenshot (and it can’t be
searched, etc.)

Thanks, mm


#3

Hi mountain_man,

I am using eclipse the way you described it : producing the jar files from the java class by building the project in maven, then copy it to FIJI plugin folder and restart it. ( I was just following one of the tutorials out there online).

I don’t have much java programming experience and also very new to plugin development.

Objective:
I am trying to create a plugin that loads an image and adds a grid on top of it in order to do some counting based on the grid. all of it implemented as GUI in Java using eclipse IDE

Problems encounter:
I don’t know how to combine the grid functionality that already exist in FIJI in ( Analyse > Tool) to my plugin and build my GUI on top of that.

also is there any recommendation of tutorials for starters on how to develop plugins using IJ2?

Thank you,

Wrise.

actual code :

import net.imagej.ImageJ;
import org.scijava.command.Command;
import org.scijava.plugin.Plugin;

import ij.IJ;
import ij.ImagePlus;
import ij.gui.Roi;
import ij.io.OpenDialog;

@Plugin(name = “GUI_example_plugin”, type = Command.class, menuPath = “Plugins > GUI_example_plugin”, headless = true)
public class GUI_example_plugin implements Command {

static ImagePlus img;

 

public void run() {
    //Code here
	
	
	 img = null;
     img = IJ.getImage();
     img.getWindow().setVisible(false);
     OpenDialog.setDefaultDirectory(img.getOriginalFileInfo().directory);
 
}

public static void main(String[] args){
    ImageJ ij = new ImageJ();
    ij.launch();
}

}


#4

Hello Wrise -

I would suggest that you first pick either IJ1 or IJ2. Then write a simple
plugin that: first, writes out a message to the console; and second,
creates a trivial image and displays it.

If your compilation fails, show us the error message. If the plugin
fails, show us the stack trace / error message. If it runs, but doesn’t
do what you expect, tell us the problem – i.e., what happened vs.
what you expected.

After we get that baseline, we can help you work toward the grid-overlay
functionality you are trying to implement.

I don’t have a specific suggestion for IJ2 tutorials, but there is a current
thread about plugin-development documentation that might be useful
to you:

Thanks, mm