Creating a parameter type

JIPipe requires you to register custom parameter types, where they are assigned an unique identifier. This is done to allow future refactoring without breaking a user’s project.

If you just want custom lists of compound parameters, consider the usage of ParameterCollectionList (since JIPipe 1.73.0)

A custom parameter type must be JSON-serializable via the Jackson library. It is associated to an editor UI that is responsible for updating the parameter value from the GUI.

A parameter type cannot be a generic class. This is due to restrictions in the JVM. We recommend to create a sub-class for a list of a parameter if you require a list of it down the line. The list parameter inherits from the ListParameter class.

Creating an editor

To create an editor UI, you have to inherit from JIPipeParameterEditorUI.

The UI class provides access to the JIPipeParameterCollection object and the JIPipeParameterAccess object that encapsulates the getter and setters, as well as additional annotations.

There is also access to the SciJava context object.

Please be careful to avoid infinite loops between reloading and setting parameters from UI elements.

Registering a parameter

Register the parameter type and its UI in JIPipeJavaExtension:

@Plugin(type = JIPipeJavaExtension.class)
public class MyExtension extends JIPipeDefaultJavaExtension {

    // ... See previous tutorial for other methods
    @Override
    public void register() {
        // You have to provide an unique ID, the parameter class, a method to create a new instance, a method to create a deep copy, and an UI class
        registerParameterType("my-parameter",
                              MyParameter.class,
                              MyParameter::new,
                              p -> p.clone(),
                              "My parameter",
                              "A custom parameter type",
                              MyParameterParameterEditorUI.class);

        // If you have a hierarchy of parameters, you can register the editor for the whole hierarchy:
        registerParameterEditor(MyCollectionBase.class, MyCollectionParameterEditorUI.class);

        // There is a predefined method to register enum values:
        registerEnumParameterType("my-enum", MyEnum.class, "My Enum", "Enum of values");
    }

}

Do not forget to register all algorithm parameter types. JIPipe will throw an error if it detects a missing parameter registration.

There is an overload of registerParameterType that takes the matching list directly and automatically generates the ID, name, and description.

You can set the instance creation function to null if the parameter is default-constructable. You can set the clone function to null if the parameter type can be copied via a copy constructor.

You can review your parameter UI via Tools > Development > Show all parameter types.

Making use of the parameter registration

You can use the parameter type registry to get a parameter type info. The info provides access to all metadata from the registry.

JIPipe comes preinstalled with some common Java types (String, numerics, file and folder paths). You can take a look at the Parameters Extension package for all default parameters that are provided by JIPipe.