Reusing Scijava Parameter annotations system

I have a Settings class that hold a bunch of public fields I use for settings in my project. I added to each fields the @Parameter annotation in order to set a label, description, min value, etc.

I am pretty sure it’s possible to automatically generate GUI components from this class without much work (according to this for example :

My question is how ?

And more precisely I would like to a have a fine control on which settings I display or not in my GUI and where (for this I am not sure whether it is possible or not…).


1 Like

Definitely possible to autogenerate the GUI, yeah.

If you make it an OptionsPlugin and give it a menuPath in the @Plugin annotation then it will automatically do so.

Here is an example from imagej-common.

Where is your code?


I think I didn’t explain well what I want to do. I don’t want to add something in the menu and I don’t want neither to add @Plugin which is done in another class.

I have a class called Setting that is basically a set of public field that I use as parameters ( with some methods for input and output of settings). I am using @Parameter as a way to specify label and description.

The code is not available (yet) but that is what my class looks like :

public class Settings {

    private transient LogService log;

    public Settings(final Context context) {

    // Image related settings
    @Parameter(label = "Dataset")
    public transient Dataset dataset;

    @Parameter(label = "Time Interval")
    public double dt = 1;
    @Parameter(label = "X spatial resolution")
    public double dx = 1;
    @Parameter(label = "Y spatial resolution")
    public double dy = 1;
    @Parameter(label = "Z spatial resolution")
    public double dz = 1;

    @Parameter(label = "Width")
    public int width;
    @Parameter(label = "Height")
    public int height;
    @Parameter(label = "Time axis size")
    public int zSize;
    @Parameter(label = "Z axis size")
    public int timeSize;
    @Parameter(label = "Channel axis size")
    public int channelSize;

    @Parameter(label = "Folder contaning dataset")
    public String imageFolder = "";
    @Parameter(label = "Filename of the dataset")
    public String imageFileName = "";

    // Active contour method related settings
    @Parameter(label = "Sigma",
            description = "Size of the gaussian filter (in pixel). "
            + "A value of 0 will disable gaussian filter.",
            min = "0")
    public double sigma = 2;

    @Parameter(label = "Alpha Parameter",
            description = "Weight controlling the amount of stretch in the snake.",
            min = "0", stepSize = "0.001")
    public double alpha = 0.01;

    @Parameter(label = "Beta Parameter",
            description = "Weight controlling the amount of curvature in the snake.",
            min = "0", stepSize = "0.001")
    public double beta = 0.1;

// and so forth....

    public void fromDataset(Dataset dataset) {
         // Guess some parameters from the dataset

    // Input and ouput as JSON file
    public String toJSON() {
        Gson gson = new Gson();
        return gson.toJson(this);

    public static Settings fromJSON(String json) {
        Gson gson = new Gson();
        Settings settings = gson.fromJson(json, Settings.class);

        return settings;

I would like to construct the GUI to fill these parameters but I want a very fine control of the GUI by specifying which parameters I want to display and where.

So I guess it’s about reusing the code you are using for displaying parameters in a @Plugin class with @Parameter annotations. Could you point me out to the right direction ?

PS: I don’t want to use the classic IJ2 way for constructing plugin with parameters here because I gonna have a pretty complex GUI (in the same spirit as TrackMate for example).

Thank you