Sunday, 8 July 2007

Java 2D API --- the renderables

Renderable layer is for simplified image manipulation and it won't directly process image pixels. However, in many cases it is either necessary or desirable to work with pixels and the Rendered layer is used for this purpose.

The renderable layer is primarily defined by the RenderableImage interface. A chain in this layer is a chain of RenderableImages. Specifically, it is a chain of RenderableImageOps (a class that implements RenderableImage), ultimately sourced by a RenderableImage.

There is only one RenderableImageOp class. It is a lightweight, general purpose class that takes on the functionality of a specific operation through a parameter provided at instantiation time. That parameter is the name of a class that implements a ContextualRenderedImageFactory (known as a CRIF, for short). Each instantiation of RenderableImageOp derives its specific functionality from the named class. In this way, the Renderable layer is heavily dependent on the Rendered layer.

Interface: RenderableImage
OR ContextualRenderedImage-Factory
Extends: RenderedImageFactory

Class: ParameterBlock
Extends: Object
Implements: Cloneable, Serializable

Class: RenderableImageOp
Extends: Object
Implements: RenderableImage

Class: RenderableImageProducer
Extends: Object
Implements: ImageProducer, Runnable

Class: RenderContext
Extends: Object
Implements: Cloneable

A Renderable chain is constructed by instantiating each successive RenderableImageOp, passing in the last RenderableImage as the source in the ParameterBlock. This chain can then be requested to provide a number of renderings to specific device spaces through the getImage method. This chain, once constructed, remains editable.

No comments: