Class 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 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);
     
     
    Author:
    Curtis Rueden