Skip to content

Consider using parameterized SciJava Command plugins #5

@ctrueden

Description

@ctrueden

Right now, all the examples implement ij.plugin.PlugIn, which is the ImageJ 1.x interface for plugins. If the examples instead used org.scijava.command.Command, you could gain the advantages of SciJava parameterized modules, including auto-conversion of parameter types. Here is a simple example ImageJ Command plugin.

With this approach, it would no longer be necessary to explicitly convert types. Instead, you annotate parameter fields (using @Parameter) of the type needed by the algorithm itself, and the framework takes care of converting/auto-filling parameters whenever objects exist whose types are convertible to those field types.

Even in cases where you need to explicitly invoke a conversion for some reason, you also gain the power to write @Parameter ConvertService convertService and then in your run method you can say things like Mat mat = convertService.convert(IJ.getImage(), Mat.class); without needing to explicitly instantiate converter plugins. This provides extensibility, so that other converter plugins can be created to perform the same conversions in special cases more efficiently, for example. Whereas if you use new ...(), then there cannot be extensibility—you are locking in the implementation to that specific concrete class forever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions