Difference between revisions of "User input"

m (emphasiye ImageJ1/2 difference)
(Add more explanations of the pros/cons of script parameters vs. GenericDialog)
Line 1: Line 1:
Even though one could use any Java library to make a Graphical User Interface (GUI) for a script or plugin, there are mostly 2 recommended ways to collect input from the user in Fiji.<br>All those methods can be used with the scripting languages (including the IJ macro language for the script parameters).  
+
Even though one could use any Java library to present a graphical user interface (GUI) for a script or plugin, there are mostly 2 recommended ways to collect input from the user in ImageJ. Both methods can be used with all [[Scripting#Supported_languages|available scripting languages]], including the [[Macros|ImageJ macro language]].
  
== [[Script parameters|Script Parameters]] ==
+
== Script Parameters ==
This is an ImageJ2/SciJava feature and the simplest option to make a GUI in Fiji.<br>
 
GUI items (integer, string input...) are created by using a generic notation in the form <code>#@ ParameterType VariableName</code> that is put at the top of the script.<br>
 
There are as many notations/lines as there are items to put in the GUI, and the items are rendered on top of each other in the resulting interface in the order of appearance in the code.<br>
 
  
In practice, the script parameters are the quickest option to make a GUI in Fiji but they do not offer as many options as the GenericDialog class (no custom layout, no Help button, no custom button).
+
[[Script parameters]] are a fast, succinct option to make a GUI in ImageJ and beyond. Scripts written using the <code>#@</code> parameter syntax can also be consumed by other tools in the [[SciJava]] ecosystem, including [[KNIME]], [[OMERO]] and others. They are independent of user interface, meaning alternative GUIs coded in other frameworks—such as [[ImageJFX]] coded using JavaFX—can also present a GUI for your plugin/script that matches the application.
  
 +
Each parameter (integer, string input, etc.) corresponds to a user interface element, and is created by using a generic notation in the form <code>#@ ParameterType variableName</code> that is put at the top of the script.
  
== [[Generic dialog|GenericDialog]] ==
+
There are as many notations/lines as there are items to put in the GUI, and the items are rendered vertically in the resulting interface, in the order of appearance in the code.
This ImageJ1 class (and its subclasses) offers more possibilities than the script parameters (custom layout and buttons) but requires more coding (e.g. parameters recall between successive calls to the plugin is not automatic).
+
 
 +
See the [[script parameters]] page for further details.
 +
 
 +
In practice, the script parameters are
 +
 
 +
but they do not offer as many options as the <code>GenericDialog</code> class (no custom layout, no Help button, no custom button).
 +
 
 +
 
 +
== GenericDialog ==
 +
 
 +
The [[generic dialog|GenericDialog]] class—part of [[ImageJ1]]—offers more flexibility than the [[script parameters]], including custom layout and buttons, but requires more coding—e.g., successive calls to the plugin do not automatically remember previously entered values. Plugins coded using <code>GenericDialog</code> are also not automatically usable in other [[SciJava]] tools such as [[KNIME]] or [[ImageJFX]].
 +
 
 +
See the [[generic dialog]] page for further details.

Revision as of 12:03, 6 June 2019

Even though one could use any Java library to present a graphical user interface (GUI) for a script or plugin, there are mostly 2 recommended ways to collect input from the user in ImageJ. Both methods can be used with all available scripting languages, including the ImageJ macro language.

Script Parameters

Script parameters are a fast, succinct option to make a GUI in ImageJ and beyond. Scripts written using the #@ parameter syntax can also be consumed by other tools in the SciJava ecosystem, including KNIME, OMERO and others. They are independent of user interface, meaning alternative GUIs coded in other frameworks—such as ImageJFX coded using JavaFX—can also present a GUI for your plugin/script that matches the application.

Each parameter (integer, string input, etc.) corresponds to a user interface element, and is created by using a generic notation in the form #@ ParameterType variableName that is put at the top of the script.

There are as many notations/lines as there are items to put in the GUI, and the items are rendered vertically in the resulting interface, in the order of appearance in the code.

See the script parameters page for further details.

In practice, the script parameters are

but they do not offer as many options as the GenericDialog class (no custom layout, no Help button, no custom button).


GenericDialog

The GenericDialog class—part of ImageJ1—offers more flexibility than the script parameters, including custom layout and buttons, but requires more coding—e.g., successive calls to the plugin do not automatically remember previously entered values. Plugins coded using GenericDialog are also not automatically usable in other SciJava tools such as KNIME or ImageJFX.

See the generic dialog page for further details.