This class provides a mechanism by which enumerated parameters may be added to subclasses of
OperationDescriptorImpl
while retaining the ability to perform introspection on the allowable range of values of the enumeration. An example of an enumerated parameter is the
type parameter of the "Transpose" operation which is defined in
TransposeDescriptor
to accept only the values defined by the
FLIP_*
and
ROTATE_*
fields of the descriptor.
This class may be used to create enumerated parameters in an OperationDescriptor
as follows:
- For each constrained-value parameter create a final class extending
EnumeratedParameter
. This class should consist of only a package private constructor with a single String
parameter called name and a single statement invoking the superclass constructor with name as the parameter. - Define the class of the parameter in question to be the subclass of
EnumeratedParameter
which was created for it in in the previous step. - For each possible value of the parameter, define in the
OperationDescriptor
of the operator a public static final field of type equal to the class defined in the first step. Each field should be assigned an instance of the subclass defined in the first step. The name and value
used for each of these EnumeratedParameter
subclass instances should be distinct for each distinct field or an error will occur.
With respect to
TransposeDescriptor
, the three steps above would be to 1) create a final class
TransposeType
in the
com.lightcrafts.mediax.jai.operator
package; 2) define the type of the "type" parameter as
TransposeType.class
; and 3) define a static final field of class
TransposeType
for each of the enumerated values with each field being initialized to an instance of
TransposeType
with
name equal to the name of the field and
value to its integral (enumerated) value.
@see OperationDescriptorImpl
@see com.lightcrafts.mediax.jai.operator.TransposeDescriptor
@since JAI 1.1