public final class Inputs extends DynamicCommand
The Runnable.run()
method of this command does nothing. If you want something
custom to happen during execution, use a normal Command
instead:
either implement directly
, or extend ContextCommand
or DynamicCommand
.
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);
moduleService, pluginService
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
harvest() |
cancel, context, getCancelReason, getContext, getInfo, getInput, getOutput, isCanceled, saveInputs, setContext, setInput, setOutput, uncancel
cancel, getDelegateObject, getInputs, getOutputs, initialize, isInputResolved, isOutputResolved, preview, resolveInput, resolveOutput, setInputs, setOutputs, unresolveInput, unresolveOutput
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addInput, addInput, addOutput, addOutput, removeInput, removeOutput, run
cancel, getDelegateObject, getInputs, getOutputs, initialize, isInputResolved, isOutputResolved, isResolved, preview, resolveInput, resolveOutput, setInputs, setOutputs, setResolved, unresolveInput, unresolveOutput
Copyright © 2015–2022 SciJava. All rights reserved.