|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--quicktime.app.spaces.SimpleSpace | +--quicktime.app.anim.SWCompositor
SWCompositor provides the capability to composit a complex image together of disparate image sources and then treat the result as a single image which is presented to the user.
It uses the QuickTime SpriteWorld internally to perform the compositing tasks. Thus all of the actual drawing of the members of a SWCompositor is handled through the interaction between the SpriteWorld and Sprite classes of quicktime.
The SpriteWorld itself is wrapped by the SWCompositor class, and to represent the Sprite class it uses the TwoDSprite. The TwoDSprite is a presenter - it presents image information and the presenation of the image information within the context of the SWCompositor's SpriteWorld is determined by the matrix, graphics mode, layer and visibility of the TwoDSprite's Sprite object.
To create a Sprite you need a valid SpriteWorld. To create a SpriteWorld you need a valid QDGraphics destination. Depending on whether a SWCompositor is visible or not you may or may not have a valid destination QDGraphics. The interaction between the SWCompositor and its TwoDSprite presenters handles the saving and creating of SpriteWorlds and their Sprites - the application does not need to deal specifically with this issue.
The SWCompositor has been designed without the requirement that its members be TwoDSprites. It maybe more convenient for an application to add members of a Compositor that are a source of image data and have the addMember method deal with the mechanics of creating the TwoDSprite presenter. Thus there are also methods that must be defined by the subclass for getting a member's TwoDSprite, and getting a TwoDSprite's member. This is important to understand for the following reason. Once a member has been added to a SWCompositor, it is the presenter within the SWCompositor itself (the TwoDSprite) that must be interacted with to effect the display characteristics of the member in the SWCompositor. Whilst a subclass may provide the capability to create the TwoDSprite presenter with display characteristics like Matrix and GraphicsMode, once the member is added altering the member's display characteristics directly may or may not effect the display characteristics of the member in the SWCompositor. Thus an application is better to always interact with the member's TwoDSprite presenter.
After a member is added to the SWCompositor the subclass should call the postProcessAdd (and remove in the case of a removeMember call). This call will look at the member that is being added and will perform two services. If the new member is an instance of the Notifier class then the SWCompositor registers the Notifer with the TwoDSprite presenter as the NotifyListener. That way a Sprite who presents image data that is not available at the time the member is added can still prepare itself for displaying an image when its Notifier notifies the TwoDSprite that its image data is valid. If the new member is an instance of DynamicImage, then this method will also call that member's addedToCompositor method to allow this new member to establish the invalidation mechanism it uses. Explicit invalidation is required for the SpriteWorld to redraw a Sprite that presents image data that is changing (such as a Movie) when nothing about the Sprite's presentation has changed.
The subclass defines completely the storage mechanism and protocols of its members.
SpriteWorld
,
Sprite
,
TwoDSprite
,
quicktime.app.display.Compositor
Field Summary | |
int |
hitTestFlag
default hit test is only to test on the visible pixels of a sprite |
int |
taskFlag
This flag is used when the task method is called. |
Fields inherited from class quicktime.app.spaces.SimpleSpace |
containedSpaces, controllersVec, ticklers, timer |
Fields inherited from interface quicktime.app.time.Ticklish |
kScale |
Constructor Summary | |
protected |
SWCompositor(QDGraphics spriteGWorld,
QDColor backgroundColor,
QDGraphics background,
int scale,
int period,
Protocol defaultProtocol)
Used by subclasses to construct a SWCompositor. |
Method Summary | |
void |
addDrawingListener(DrawingListener listener)
Registers an object as a listener of the Compositor. |
Invalidator |
addedToCompositor(SWCompositor c,
TwoDSprite s)
Returns an object that invalidates a sprite. |
protected void |
createMembers()
This method is called after the Compositor has been added to a valid QDGraphics and the sprites can be added to the spriteworld. |
Region |
getClip()
Returns the current clipping region used by the sprite world |
Compositable |
getCompositable(java.lang.Object member)
This will return the TwoDSprite for the member as a Compositable object to enable an application to get and set the graphics mode presentation of the member object. |
ImageDescription |
getDescription()
This method should return an ImageDescription that describes the image data that the class contains. |
QDRect |
getDisplayBounds()
QTCanvas calls this method when it needs to get the client's location, width and/or height. |
GraphicsMode |
getGraphicsMode()
Sets the graphics mode of the SpriteDisplay object - this will be restored on each subsequent creation of the internal SpriteWorld. |
QDGraphics |
getGWorld()
QTCanvas calls this method to get the destination QDGraphics of its client. |
EncodedImage |
getImage()
This method returns the actual image data. |
java.awt.Dimension |
getInitialSize()
Deprecated. since QTJava 4.0 |
java.util.Enumeration |
getInvalidatorList()
Returns the list of invalidator objects for the Compositor's sprites that have a dynamic image source. |
Layerable |
getLayerable(java.lang.Object member)
This will return the TwoDSprite for the member as a Layerable object to enable an application to get and set the layer presentation of the member object. |
Matrix |
getMatrix()
This will return the client's current display transformations |
Invalidator |
getMemberInvalidator(java.lang.Object member)
Returns the invalidator that is associated with the supplied member if the member has an Invalidator. |
abstract TwoDSprite |
getMemberSprite(java.lang.Object member)
This method returns the TwoDSprite presenter that is presenting the image data of the given member. |
QDDimension |
getOriginalSize()
This method returns the original size before the transformations specified in the returned matrix are applied. |
SWCompositor |
getParent()
Returns the SWCompositor that this is the parent container of this SWCompositor. |
abstract java.lang.Object |
getSpriteMember(TwoDSprite sprite)
This method returns the member that is being presented by the supplied TwoDSprite presenter. |
float |
getStatistics()
The compositor's frame rate is calculated by the number of times it is tickled from the time an application calls resetStatistics and is only valid if the rate of the Compositor's Timer is not zero. |
Transformable |
getTransformable(java.lang.Object member)
This will return the TwoDSprite for the member as a Transformable object to enable an application to get and set the display presentation (its location, scale, etc) of the member object. |
boolean |
hasRecordMovie()
Returns true if the SWCompositor has a RecordMovie object. |
java.lang.Object |
hitTest(int x,
int y)
Return the frontmost object that is located at the specified coordinates. |
protected void |
idle()
This method can be called to explicitly force the SWCompositor to redraw itself. |
boolean |
isAutoRedrawing()
Returns the current state of the auto redrawing flag. |
protected void |
postProcessAdd(java.lang.Object member,
TwoDSprite s)
This method should be called by the subclass after the member has been added to the SWCompositor. |
protected void |
postProcessRemove(java.lang.Object member,
TwoDSprite s)
This method should be called by the subclass before the member has been removed from the SWCompositor. |
void |
redraw(Region invalidRgn)
QTCanvas calls this method when the client should redraw itself. |
void |
removedFromCompositor(SWCompositor c)
When a dynamic image class is removed from a SWCompositor this method is called to allow the class to cleanup any of the invalidation processes it had established in the addedToCompositor call. |
void |
removeDrawingListener(DrawingListener listener)
Removes an object that is a listener of the Compositor. |
void |
resetStatistics()
Resets the internal counters that are used to calculate the frame rate of the Compositor. |
protected void |
saveMembers()
This method is called if a SpriteWorld has previously been created and the destination QDGraphics or QDGraphics is about to go away (such as removing a SpriteWorld from a QTCanvas). |
void |
setAutoRedrawing(boolean flag)
If a SWCompositor's time rate is equal to zero, changing a property of a member's sprite requires the SWCompositor to be redrawn to see this change. |
void |
setClip(Region clipRgn)
This method sets the sprite world's clip. |
void |
setDisplayBounds(QDRect bounds)
QTCanvas calls this method when it needs to tell the client to adjust its location, width and/or height. |
void |
setGraphicsMode(GraphicsMode mode)
Sets the current graphics mode. |
void |
setGWorld(QDGraphics cgp)
QTCanvas calls this method to give the client the QDGraphics object it should use to do its drawing. |
void |
setLocation(int x,
int y)
A convenience method to set the position of a QTDrawable object. |
void |
setMatrix(Matrix matrix)
This method sets the current matrix of the Transformable object to the new matrix. |
void |
setRecordMovie(RecordMovie rm)
This method allows the application to register the intent to record a movie out of the compositing output of the SWCompositor. |
abstract java.util.Enumeration |
sprites()
This returns an Enumeration that allows your application to iterate over the TwoDSprite presenters that are responsible for presenting the image data within the Compositor. |
boolean |
tickle(float er,
int time)
The Timer invokes the tickle method when the invocation constraints of the Timer are reached. |
java.lang.String |
toString()
Return a string representation of this object. |
Methods inherited from class quicktime.app.spaces.SimpleSpace |
addController, addedTo, addMember, controllers, finalize, getProtocol, getSource, getTimer, hasMember, isAppropriate, memberAdded, memberRemoved, removeAllControllers, removeAllMembers, removeController, removedFrom, removeMember, tickleList, timeChanged |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface quicktime.app.display.QTDisplaySpace |
addMember, getBackLayer, getFrontLayer |
Methods inherited from interface quicktime.app.spaces.Listener |
addedTo, removedFrom |
Methods inherited from interface quicktime.app.spaces.Space |
addController, controllers, getSource, getTimer, removeController, tickleList |
Methods inherited from interface quicktime.app.spaces.DynamicCollection |
getProtocol |
Methods inherited from interface quicktime.app.spaces.Collection |
addMember, hasMember, isAppropriate, isEmpty, members, removeMember, size |
Methods inherited from interface quicktime.app.time.Ticklish |
timeChanged |
Field Detail |
public int hitTestFlag
public int taskFlag
Constructor Detail |
protected SWCompositor(QDGraphics spriteGWorld, QDColor backgroundColor, QDGraphics background, int scale, int period, Protocol defaultProtocol) throws QTException
spriteGWorld
- this the buffer which the internal SpriteWorld uses to composit its image into.background
- this is background that can be supplied to the SpriteWorldbackgroundColor
- this is background color that can be supplied to the SpriteWorldscale
- the initial scale of the Space's timerperiod
- the initial period of the Space's timerdefaultProtocol
- the minimal Protocol that members of the SWCompositor must meetMethod Detail |
public void resetStatistics()
public float getStatistics()
myCompositor.resetStatistics(); Thread.sleep (2000); //sleep the stat's thread for 2 seconds to allow gathering of profile info float fps = myCompositor.getStatistics();This call does not reset the internal counters, so consequent calls of getStatistics will return frames rendered over a longer period of time.
public java.util.Enumeration getInvalidatorList()
public Invalidator getMemberInvalidator(java.lang.Object member)
member
- a member of the Compositorpublic void setRecordMovie(RecordMovie rm) throws QTException
rm
- the RecordMovie objectpublic boolean hasRecordMovie()
public ImageDescription getDescription() throws QTException
getDescription
in interface ImageSpec
public EncodedImage getImage() throws QTException, java.lang.IndexOutOfBoundsException
getImage
in interface ImageSpec
public SWCompositor getParent()
public Matrix getMatrix() throws StdQTException
getMatrix
in interface Transformable
public void setMatrix(Matrix matrix) throws QTException
setMatrix
in interface Transformable
public java.awt.Dimension getInitialSize() throws QTException
()
public QDDimension getOriginalSize() throws QTException
getOriginalSize
in interface Transformable
public QDGraphics getGWorld()
getGWorld
in interface QTDrawable
public void setGWorld(QDGraphics cgp) throws QTException
setGWorld
in interface QTDrawable
cgp
- a QDGraphics objectpublic void setDisplayBounds(QDRect bounds) throws StdQTException
setDisplayBounds
in interface Drawable
bounds
- the new size and location.public void setLocation(int x, int y) throws QTException
setLocation
in interface QTDrawable
x
- the new x locationy
- the new y locationpublic QDRect getDisplayBounds() throws QTException
getDisplayBounds
in interface Drawable
public final void redraw(Region invalidRgn) throws QTException
redraw
in interface Drawable
invalidRgn
- the invalidRgn that the client should redrawpublic boolean isAutoRedrawing()
(boolean)
public void setAutoRedrawing(boolean flag)
Typically an application will set this flag to false, make the changes to its sprites, then reset the flag to true. The application will still have to redraw the SWCompositor after making the changes to its member sprites.
If the rate of the SWCompositor's TimeBase is not equal to zero, then this flag has no effect as the composite cycle is being controlled by the time-based rendering cycle.
Regardless of the value of this flag, the SWCompositor will still redraw itself when the redraw method is called. This flag only controls whether the SWCompositor's member sprites will automatically redraw their parents.
flag
- controls the auto redrawing capability of a SWCompositor. By default the auto-redrawing is set to true.protected void idle() throws QTException
In the normal course of operations an application does not need to call this method but it is particularly useful for profiling. It should only be called if the SpriteWorld that is presenting the SWCompositor is NOT null - otherwise a NullPointerException will be thrown.
public java.lang.Object hitTest(int x, int y) throws QTException
hitTest
in interface QTDisplaySpace
x
- the x coordinatey
- the y coordinatepublic void setClip(Region clipRgn) throws QTException
setClip
in interface QTDrawable
clipRgn
- Specifies the clipping region.public Region getClip()
getClip
in interface QTDrawable
public boolean tickle(float er, int time) throws QTException
Ticklish
tickle
in interface Ticklish
tickle
in class SimpleSpace
quicktime.app.time.Ticklish
er
- the effective rate of the Timer when the time condition matchestime
- the time that the Timer invoked the tickle method.public void removedFromCompositor(SWCompositor c) throws QTException
removedFromCompositor
in interface DynamicImage
c
- the SWCompositor it is being removed frompublic Invalidator addedToCompositor(SWCompositor c, TwoDSprite s) throws QTException
The Invalidators provided with objects that implement the DynamicImage interface will execute at the scale and period of the Compositor when they are created.
addedToCompositor
in interface DynamicImage
c
- the Compositor in which the DynamicImage is a members
- the TwoDSprite that is presenting the DynamicImage's image in
the Compositor. This is the sprite that must be invalidated.quicktime.app.display.SWCompositor
public GraphicsMode getGraphicsMode()
getGraphicsMode
in interface Compositable
public void setGraphicsMode(GraphicsMode mode) throws QTException
setGraphicsMode
in interface Compositable
mode
- the new graphics modepublic abstract TwoDSprite getMemberSprite(java.lang.Object member)
member
- the member objectpublic abstract java.util.Enumeration sprites()
public abstract java.lang.Object getSpriteMember(TwoDSprite sprite)
sprite
- the TwoDSprite presenterpublic Compositable getCompositable(java.lang.Object member)
member
- the member objectpublic Layerable getLayerable(java.lang.Object member)
getLayerable
in interface QTDisplaySpace
member
- the member objectpublic Transformable getTransformable(java.lang.Object member)
getTransformable
in interface QTDisplaySpace
member
- the member objectprotected void postProcessAdd(java.lang.Object member, TwoDSprite s) throws QTException
member
- the new member that has been added.s
- the TwoDSprite that will present this memberprotected void postProcessRemove(java.lang.Object member, TwoDSprite s) throws QTException
member
- the new member that has been removed.s
- the TwoDSprite that presented this memberprotected void saveMembers() throws QTException
protected void createMembers() throws QTException
public java.lang.String toString()
toString
in class java.lang.Object
public void addDrawingListener(DrawingListener listener)
addDrawingListener
in interface DrawingNotifier
quicktime.app.display.DrawingNotifier
source
- the object that is to be the source of interest for the
the Listener object.public void removeDrawingListener(DrawingListener listener)
removeDrawingListener
in interface DrawingNotifier
quicktime.app.display.DrawingNotifier
source
- the object that is to be the source of interest for the
the Listener object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |