You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TypeChanger class is currently a DynamicCommand but does not need to be. It has a private String typeName parameter with an initializer that asks the DataTypeService for its list of instances. But the module framework takes care of this automatically now: just change the parameter to private DataType type and the available singletons will be automatically used in a multiple choice (via the ObjectWidget). See ImageCalculator and Threshold for working examples.
There is also a large amount of code embedded in the command, which should be factored out to one or more methods of DataTypeService instead. Then the TypeChanger command itself becomes very simple, merely delegating to DataTypeService to perform the actual type change. This is the preferred ImageJ2 design pattern so that the type change operation is available to other code directly from a @Parameter DataTypeService dataTypeService field, instead of needing to explicitly construct and invoke a TypeChanger command instance.
The
TypeChanger
class is currently aDynamicCommand
but does not need to be. It has aprivate String typeName
parameter with an initializer that asks theDataTypeService
for its list of instances. But the module framework takes care of this automatically now: just change the parameter toprivate DataType type
and the available singletons will be automatically used in a multiple choice (via theObjectWidget
). SeeImageCalculator
andThreshold
for working examples.There is also a large amount of code embedded in the command, which should be factored out to one or more methods of
DataTypeService
instead. Then theTypeChanger
command itself becomes very simple, merely delegating toDataTypeService
to perform the actual type change. This is the preferred ImageJ2 design pattern so that the type change operation is available to other code directly from a@Parameter DataTypeService dataTypeService
field, instead of needing to explicitly construct and invoke aTypeChanger
command instance.Migrated-From: http://trac.imagej.net/ticket/2007
The text was updated successfully, but these errors were encountered: