As we've seen, the QTDrawable interface is used to handle the negotiation between the QTCanvas and one of several QuickTime objects. The QuickTime objects that implement the QTDrawable interface are extensive and include the following:
The QTDrawable interface is designed to work hand-in-hand with a QTCanvas object. The class that implements this interface draws into the supplied QDGraphics object. The QTCanvas will call the methods of its client (setting its destination QDGraphics, setting display bounds, and redrawing it) as required.
These methods are used by the QTCanvas to notify the client object that it has been added to or removed from the QTCanvas. Various clients require this notification:
These methods are used to get the current size of a QTCanvas client and set its size. The QTCanvas determines the size of itself and its client based on a complex interaction between the size the QTCanvas parent container allocates to the QTCanvas, the initial (or best) size of its client, and the setting of the resize and alignment flags of the QTCanvas itself.
Once the QTCanvas has determined the correct size of itself and its client, it uses the setDisplayBounds() method to resize and locate its client. The size and location of a QTCanvas and its client is always the same.
then a special QDGraphics, QDGraphics.scratch(), is used to indicate to the QTDrawable that it is invisible and basically disabled. While the following methods are not used specifically in the relationship between QTCanvas and its client, they are presented here for the sake of completeness and also express capabilities that all QTDrawable objects possess:
The DirectGroup display space enables one or more QTDrawable objects to draw into the same QTCanvas destination QDGraphics. It provides the capability to layer the objects in such a group, so that the objects do not draw over each other. This layering is achieved through the use of clipping regions. The DirectGroup clips its members so that members that are behind others cannot draw into the area where those in front are positioned. As this group by definition draws directly to the screen, this is the only means that can be used to avoid the flickering that would occur if the QTDrawable objects could not be clipped.
The QTDrawable interface also extends the Transformable interface.
The Transformable interface expresses the ability of QuickTime drawers to have a matrix applied that will map the source pixels of a drawing object to some transformed destination appearance. A matrix allows the following transformations to be applied in the rendering process:
Your application can freely mix and match these different transformations at its own discretion.
All QTDrawable objects can have a matrix applied to them that will transform their visual appearance. A Sprite in a SpriteWorld can also have matrix transformations applied to it, as can a 3D model. The TwoDSprite also implements the Transformable interface.
The Transformable interface allows for applications to define behaviors
that can be applied to any of these objects. For example, the
quicktime.app.actions.Dragger, which will position objects in response to a mouseDragged event, is defined totally in terms of the Transformable interface. Thus, the Dragger can reposition any TwoDSprite in a SWCompositor or any QTDrawable in a GroupDrawable. Using interfaces to express common functionality is a powerful concept and is relied upon extensively in the QuickTime for Java Application Framework.