This class allows programmers to use the syntax:
import com.lightcrafts.mediax.jai.JAI; RenderedOp im = JAI.create("convolve", paramBlock, renderHints);to create new images or collections by applying operators. The
create()
method returns a RenderedOp
encapsulating the operation name, parameter block, and rendering hints. Additionally, it performs validity checking on the operation parameters. Programmers may also refer to JAI.createCollection("opname", paramBlock, renderHints)
, JAI.createRenderable("opname", paramBlock, renderHints)
, and JAI.createRenderableCollection("opname", paramBlock, renderHints)
. If the OperationDescriptor
associated with the named operation returns true
from its isImmediate()
method, the JAI.createNS()
method will ask the RenderedOp
it constructs to render itself immediately. If this rendering is null
, createNS()
will itself return null
rather than returning an instance of RenderedOp
as it normally does.
It is possible to create new instances of theJAI
class in order to control each instance's registry, tile cache, and tile scheduler individually. Most users will want to use only the static methods of this class, which perform all operations on a default instance, which in turn makes use of a default registry. To create a new image or collection on a non-default JAI
instance, the createNS()
and createCollectionNS
(NS being short for "non-static") methods are used.
The JAI
class contains convenience methods for a number of common argument list formats. These methods perform the work of constructing a ParameterBlock
automatically. The convenience methods are available only in static
form and make use of the default instance. When operating with a specific instance, the general, non-static functions createNS()
and createCollectionNS()
should be used. All of the convenience methods operate by calling createNS()
on the default JAI
instance, and thus inherit the semantics of that method with regard to immediate rendering.
The registry being used by a particular instance may be retrieved or set using the getOperationRegistry()
and setOperationRegistry()
methods, respectively. Only advanced users should attempt to set the registry. The tile cache and tile scheduler being used by a particular instance may likewise be set or retrieved using the methods setTileCache()
, setTileScheduler()
, getTileCache()
, or getTileScheduler()
.
Each instance of JAI
contains a set of rendering hints which will be used for all image or collection creations. These hints are merged with any hints supplied to the create
method; directly supplied hints take precedence over the common hints. When a new JAI
instance is constructed, its hints are initialized to a copy of the hints associated with the default instance. When the default instance is constructed, hints for the default registry, tile cache, and tile scheduler are added to the set of common rendering hints. Similarly, invoking setOperationRegistry()
, setTileCache()
, or setTileScheduler()
on a JAI
instance will cause the respective entity to be added to the common rendering hints. The hints associated with any instance, including the default instance, may be manipulated using the getRenderingHints()
, setRenderingHints()
, and clearRenderingHints()
methods.
An ImagingListener
will reside in each instance of JAI
. It can be used to listen to (and process) the exceptional situations that occur in the operations and JAI. A default ImagingListener
is initially registered which re-throws RuntimeException
s and prints the error message and the stack trace of other types to System.err
. To override this default behavior an instance of an alternate ImagingListener
implementation should be registered using {@link JAI#setImagingListener}.
An ImagingListener
also can be attached to a node as a rendering hint, which maps the key KEY_IMAGING_LISTENER
. The Throwable
s which arise in the creation and the rendering of this node will be sent to this ImagingListener
(note that those thrown at the top levels such as node creation failure will be handled by the listener registered to the JAI
instead.) The default value for this hint will be the one registered to the instance of JAI
.
|
|