public interface Op extends Command, Environmental
Ops discoverable at runtime must implement this interface and be annotated
with @Plugin
with attribute Plugin.type()
= Op
.class
or a subtype thereof (see the interfaces of Ops
). While it is
possible to create an op merely by implementing this interface, it is
encouraged to instead extend AbstractOp
, for convenience.
Each op has a name (provided in the Plugin.name()
attribute, which is
not necessarily unique. This allows multiple "overloaded" ops with different
combinations of parameter types, similar to the method overloading feature of
Java and other programming languages. The
OpEnvironment.op(String, Object...)
and
OpEnvironment.run(String, Object...)
methods can be used to obtain and
execute (respectively) the best matching op instances for a given name and
set of input arguments.
An op may optionally have a namespace. This is analogous to packages in Java
and similar features in other languages. The namespace is expressed as a
prefix; such ops are referenced by their namespace, followed by a dot,
followed by the op name. Ops without a namespace belong to the "global"
namespace, with no prefix or dot. Two ops with the same name but different
namespaces only partially "overload" or "override" one other; see
OpEnvironment.run(String, Object...)
for details.
The naming convention for both namespaces and op names is to use an alphameric string, in lower camel case.
Command
Every op is a Command
. And like Command
s, ops may have
multiple inputs and multiple outputs. However, ops impose some additional
requirements beyond those of regular Command
s:
Plugin
,
PluginService
ops, setEnvironment
Copyright © 2014–2022 ImageJ. All rights reserved.