imagej / imagej/imagej-plugins-commands

Make TypeChanger non-dynamic, and use DataTypeService

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5
Forks
7
PR merge metrics
No merged PRs in 30d

Description

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.

Migrated-From: http://trac.imagej.net/ticket/2007

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the TypeChanger command and compare its parameter handling with the ImageCalculator and Threshold examples, including the ObjectWidget behavior. Then inspect DataTypeService for the code embedded in TypeChanger and move the type-change operation there so TypeChanger delegates to the service and other code can invoke it directly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.