Package org.scijava.widget
Interface WidgetModel
-
- All Superinterfaces:
Contextual
- All Known Implementing Classes:
DefaultWidgetModel
public interface WidgetModel extends Contextual
The backing data model for a particularInputWidget.- Author:
- Curtis Rueden
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcallback()Executes the callback associated with this widget's associated input.String[]getChoices()Gets the multiple choice list for the module input.ModuleItem<?>getItem()Gets the module input's associated item descriptor.NumbergetMax()Gets the maximum value for the module input.NumbergetMin()Gets the minimum value for the module input.ModulegetModule()Gets the module's associated module instance.List<?>getObjectPool()Gets the available objects for use with the widget.InputPanel<?,?>getPanel()Gets the input panel intended to house the widget.NumbergetSoftMax()Gets the "soft" maximum value for the module input.NumbergetSoftMin()Gets the "soft" minimum value for the module input.NumbergetStepSize()Gets the step size between values for the module input.StringgetText()Gets the input's value rendered as a string.StringgetValidationMessage()Gets the current validation error message for this widget.ObjectgetValue()Gets the current value of the module input.StringgetWidgetLabel()Gets the text to use when labeling this widget.booleanisBoolean()Gets whether the input is a boolean type (i.e.,Booleanorboolean).booleanisCharacter()Gets whether the input is a character type (i.e.,Characterorchar).booleanisInitialized()Gets the widget's initialization state.booleanisMessage()Gets whether the input is a message.booleanisMultipleChoice()Gets whether the input provides a restricted set of choices.booleanisNumber()booleanisStyle(String style)Gets whether the widget is the given style.booleanisText()booleanisType(Class<?> type)Gets whether the input is compatible with the given type.voidsetInitialized(boolean initialized)Toggles the widget's initialization state.voidsetValue(Object value)Sets the current value of the module input.voidupdateValidation()Re-runs this item's validation and updates the stored validation message.-
Methods inherited from interface org.scijava.Contextual
context, getContext, setContext
-
-
-
-
Method Detail
-
getPanel
InputPanel<?,?> getPanel()
Gets the input panel intended to house the widget.
-
getModule
Module getModule()
Gets the module's associated module instance.
-
getItem
ModuleItem<?> getItem()
Gets the module input's associated item descriptor.
-
getObjectPool
List<?> getObjectPool()
Gets the available objects for use with the widget. For example,ObjectWidgets typically display a dropdown combo box providing multiple choice selection between these objects.Note that this list does not represent a constraint in allowed widget values, but rather provides a list of possibilities in cases where the realm of values is not defined by the type in some other way.
- See Also:
ObjectWidget
-
getWidgetLabel
String getWidgetLabel()
Gets the text to use when labeling this widget. The linked item's label will be given if available (i.e.,BasicDetails.getLabel()). Otherwise, a capitalized version of the item's name is given (i.e.,Named.getName()).
-
isStyle
boolean isStyle(String style)
Gets whether the widget is the given style. A widget may have multiple styles separated by commas, so this method is more correct than usingstyle.equals(getItem().getWidgetStyle()).
-
getValue
Object getValue()
Gets the current value of the module input.In the case of inputs with a limited set of choices (i.e.,
ChoiceWidgets andObjectWidgets), this method ensures the value is in the set; if not, it returns the first item of the set.
-
setValue
void setValue(Object value)
Sets the current value of the module input.
-
callback
void callback()
Executes the callback associated with this widget's associated input.
-
getMin
Number getMin()
Gets the minimum value for the module input.- Returns:
- The minimum value, or null if the type is unbounded.
-
getMax
Number getMax()
Gets the maximum value for the module input.- Returns:
- The maximum value, or null if the type is unbounded.
-
getSoftMin
Number getSoftMin()
Gets the "soft" minimum value for the module input.- Returns:
- The "soft" minimum value, or
getMin()if none. - See Also:
ModuleItem.getSoftMinimum()
-
getSoftMax
Number getSoftMax()
Gets the "soft" maximum value for the module input.- Returns:
- The "soft" maximum value, or
getMax()if none. - See Also:
ModuleItem.getSoftMaximum()
-
getStepSize
Number getStepSize()
Gets the step size between values for the module input.- Returns:
- The step size, or 1 by default.
-
getChoices
String[] getChoices()
Gets the multiple choice list for the module input.- Returns:
- The available choices, or an empty list if not multiple choice.
- See Also:
ChoiceWidget
-
getText
String getText()
Gets the input's value rendered as a string.- Returns:
- String representation of the input value, or the empty string if the value is null or the null character ('\0').
-
isMessage
boolean isMessage()
Gets whether the input is a message.- See Also:
ItemVisibility.MESSAGE
-
isText
boolean isText()
-
isCharacter
boolean isCharacter()
Gets whether the input is a character type (i.e.,Characterorchar).
-
isNumber
boolean isNumber()
-
isBoolean
boolean isBoolean()
Gets whether the input is a boolean type (i.e.,Booleanorboolean).
-
isMultipleChoice
boolean isMultipleChoice()
Gets whether the input provides a restricted set of choices.
-
isType
boolean isType(Class<?> type)
Gets whether the input is compatible with the given type.
-
getValidationMessage
String getValidationMessage()
Gets the current validation error message for this widget.- Returns:
- the error message from the most recent validation run, or
nullif the last validation passed or no validation has been run yet. - See Also:
ModuleItem.validateMessage(org.scijava.module.Module)
-
updateValidation
void updateValidation()
Re-runs this item's validation and updates the stored validation message.This should be called on all widgets whenever any parameter value changes, since a change to one parameter may affect the validity of others.
- See Also:
getValidationMessage()
-
setInitialized
void setInitialized(boolean initialized)
Toggles the widget's initialization state. An initialized widget can be assumed to be an active part of a containerInputPanel.
-
isInitialized
boolean isInitialized()
Gets the widget's initialization state. An initialized widget can be assumed to be an active part of a containerInputPanel.
-
-