org.scijava.widget
Class WidgetModel

java.lang.Object
  extended by org.scijava.AbstractContextual
      extended by org.scijava.widget.WidgetModel
All Implemented Interfaces:
Contextual

public class WidgetModel
extends AbstractContextual

The backing data model for a particular InputWidget.

Author:
Curtis Rueden

Constructor Summary
WidgetModel(Context context, InputPanel<?,?> inputPanel, Module module, ModuleItem<?> item, List<?> objectPool)
           
 
Method Summary
 void callback()
          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.
 Number getMax()
          Gets the maximum value for the module input.
 Number getMin()
          Gets the minimum value for the module input.
 Module getModule()
          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.
 Number getSoftMax()
          Gets the "soft" maximum value for the module input.
 Number getSoftMin()
          Gets the "soft" minimum value for the module input.
 Number getStepSize()
          Gets the step size between values for the module input.
 String getText()
          Gets the input's value rendered as a string.
 Object getValue()
          Gets the current value of the module input.
 String getWidgetLabel()
          Gets the text to use when labeling this widget.
 boolean isBoolean()
          Gets whether the input is a boolean type (i.e., Boolean or boolean).
 boolean isCharacter()
          Gets whether the input is a character type (i.e., Character or char).
 boolean isInitialized()
          Gets the widget's initialization state.
 boolean isMessage()
          Gets whether the input is a message.
 boolean isMultipleChoice()
          Gets whether the input provides a restricted set of choices.
 boolean isNumber()
          Gets whether the input is a number type (e.g., int, float or any Number implementation.
 boolean isStyle(String style)
          Gets whether the widget is the given style.
 boolean isText()
          Gets whether the input is a text type (i.e., String, Character or char.
 boolean isType(Class<?> type)
          Gets whether the input is compatible with the given type.
 void setInitialized(boolean initialized)
          Toggles the widget's initialization state.
 void setValue(Object value)
          Sets the current value of the module input.
 
Methods inherited from class org.scijava.AbstractContextual
context, getContext, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WidgetModel

public WidgetModel(Context context,
                   InputPanel<?,?> inputPanel,
                   Module module,
                   ModuleItem<?> item,
                   List<?> objectPool)
Method Detail

getPanel

public InputPanel<?,?> getPanel()
Gets the input panel intended to house the widget.


getModule

public Module getModule()
Gets the module's associated module instance.


getItem

public ModuleItem<?> getItem()
Gets the module input's associated item descriptor.


getObjectPool

public 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

public 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., BasicDetails.getName()).


isStyle

public 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 using style.equals(getItem().getWidgetStyle()).


getValue

public Object getValue()
Gets the current value of the module input.

In the case of inputs with a limited set of choices (i.e., ChoiceWidgets and ObjectWidgets), this method ensures the value is in the set; if not, it returns the first item of the set.


setValue

public void setValue(Object value)
Sets the current value of the module input.


callback

public void callback()
Executes the callback associated with this widget's associated input.


getMin

public Number getMin()
Gets the minimum value for the module input.

Returns:
The minimum value, or null if the type is unbounded.

getMax

public Number getMax()
Gets the maximum value for the module input.

Returns:
The maximum value, or null if the type is unbounded.

getSoftMin

public 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

public 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

public Number getStepSize()
Gets the step size between values for the module input.

Returns:
The step size, or 1 by default.

getChoices

public 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

public 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

public boolean isMessage()
Gets whether the input is a message.

See Also:
ItemVisibility.MESSAGE

isText

public boolean isText()
Gets whether the input is a text type (i.e., String, Character or char.


isCharacter

public boolean isCharacter()
Gets whether the input is a character type (i.e., Character or char).


isNumber

public boolean isNumber()
Gets whether the input is a number type (e.g., int, float or any Number implementation.


isBoolean

public boolean isBoolean()
Gets whether the input is a boolean type (i.e., Boolean or boolean).


isMultipleChoice

public boolean isMultipleChoice()
Gets whether the input provides a restricted set of choices.


isType

public boolean isType(Class<?> type)
Gets whether the input is compatible with the given type.


setInitialized

public void setInitialized(boolean initialized)
Toggles the widget's initialization state. An initialized widget can be assumed to be an active part of a container InputPanel.


isInitialized

public boolean isInitialized()
Gets the widget's initialization state. An initialized widget can be assumed to be an active part of a container InputPanel.



Copyright © 2009–2014 SciJava. All rights reserved.