简体   繁体   中英

ImageJ java API: how to test if command exists?

In a custom ImageJ plugin, before IJ.run(imp, myCommand, myArguments) I would like to check if myCommand exists and if not - try another command.

There doesn't seem to be a method for this purpose in the IJ class . What are the alternatives to try {} catch ?

Some alternatives:

  1. Write an ImageJ2 plugin so your command will be automatically exposed in the framework, eg in the CommandService . This would also allow you to use prioritization of plugins, which it sounds is potentially what you're looking for.

  2. You could use Menus.getCommands() : if (Menus.getCommands().get(command) != null) IJ.run(command);

  3. Try...catch a Class.forName call

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM