scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

Add utility method to get parameter map of modules

Open imagejan opened this issue 7 years ago • 0 comments

To get a map of all parameters for a command (in order to call it via commandService.run()), you can query its CommandInfo object, like in this Groovy script:

#@ CommandService commands

import net.imagej.plugins.commands.imglib.RotateImageXY

commandInfo = commands.getCommand(RotateImageXY.class)

commandInfo.inputs().each {
	println "*** ${it.getName()} --- type ${it.getType()} --- default ${it.getDefaultValue()}"
}

null

It would be useful to have a utility method in CommandService or ModuleService that returns a map that could be reused as inputMap to run the command (ideally either leaving away the auto-fillable parameters, or containing prefilled values for them already).

This would allow for something like:

moduleInfo = commandService.getCommand(MyCommand.class)
inputMap = moduleService.getPrefilledMap(moduleInfo)
// change only some inputs here, leave all others untouched
moduleService.run(moduleInfo, false, inputMap)

(Suggested by @tischi)

imagejan avatar Jun 07 '18 07:06 imagejan