Package org.scijava.command
Class Inputs
- java.lang.Object
-
- org.scijava.module.AbstractModule
-
- org.scijava.module.DefaultMutableModule
-
- org.scijava.command.DynamicCommand
-
- org.scijava.command.Inputs
-
- All Implemented Interfaces:
Runnable,Cancelable,Command,Contextual,Module,MutableModule,SciJavaPlugin
public final class Inputs extends DynamicCommand
A way to build a dynamic set of inputs, whose values are then harvested by the preprocessing framework.The
Runnable.run()method of this command does nothing. If you want something custom to happen during execution, use a normalCommandinstead: either implementdirectly, or extendContextCommandorDynamicCommand.Here is are some examples of usage:
// Single input, no configuration. Inputs inputs = new Inputs(context); inputs.addInput("sigma", Double.class); Double sigma = (Double) inputs.harvest().get("sigma"); // Two inputs, no configuration. Inputs inputs = new Inputs(context); inputs.addInput("name", String.class); inputs.addInput("age", Integer.class); Map<String, Object> values = inputs.harvest(); String name = (String) values.get("name"); Integer age = (Integer) values.get("age"); // Inputs with configuration. Inputs inputs = new Inputs(context); MutableModuleItem<String> wordInput = inputs.addInput("word", String.class); wordInput.setLabel("Favorite word"); wordInput.setChoices(Arrays.asList("quick", "brown", "fox")); wordInput.setDefaultValue("fox"); MutableModuleItem<Double> opacityInput = inputs.addInput("opacity", Double.class); opacityInput.setMinimumValue(0.0); opacityInput.setMaximumValue(1.0); opacityInput.setDefaultValue(0.5); opacityInput.setWidgetStyle(NumberWidget.SCROLL_BAR_STYLE); inputs.harvest(); String word = wordInput.getValue(inputs); Double opacity = opacityInput.getValue(inputs);- Author:
- Curtis Rueden
-
-
Field Summary
-
Fields inherited from class org.scijava.command.DynamicCommand
moduleService, pluginService
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>harvest()-
Methods inherited from class org.scijava.command.DynamicCommand
cancel, context, getCancelReason, getContext, getInfo, getInput, getOutput, isCanceled, saveInputs, setContext, setInput, setOutput, uncancel
-
Methods inherited from class org.scijava.module.AbstractModule
cancel, getDelegateObject, getInputs, getOutputs, initialize, isInputResolved, isOutputResolved, preview, resolveInput, resolveOutput, setInputs, setOutputs, unresolveInput, unresolveOutput
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.scijava.module.Module
cancel, getDelegateObject, getInputs, getOutputs, initialize, isInputResolved, isOutputResolved, isResolved, preview, resolveInput, resolveOutput, setInputs, setOutputs, setResolved, unresolveInput, unresolveOutput
-
Methods inherited from interface org.scijava.module.MutableModule
addInput, addInput, addOutput, addOutput, removeInput, removeOutput, run
-
-