com.threerings.media
Class MediaOverlay

java.lang.Object
  extended by com.threerings.media.MediaOverlay
All Implemented Interfaces:
MediaHost

public class MediaOverlay
extends Object
implements MediaHost

Provides an overlaid media "canvas" that allows for the rendering of sprites and animations on top of everything else that takes place the view managed by a FrameManager. The media overlay coordinates through the ActiveRepaintManager to repaint areas of the screen that it has left dirty.


Field Summary
protected  Rectangle[] _dirty
          A temporary list of dirty rectangles maintained during the painting process.
protected  FrameManager _framemgr
          The frame manager with whom we cooperate.
protected  MetaMediaManager _metamgr
          Handles the heavy lifting involving media.
 
Constructor Summary
protected MediaOverlay(FrameManager fmgr)
          Creates a media overlay.
 
Method Summary
 void abortAnimation(Animation anim)
          Aborts a currently running animation and removes it from this overlay.
 void addAnimation(Animation anim)
          Adds an animation to this overlay.
 void addDirtyRegion(Rectangle rect)
          Adds a dirty region to this overlay.
 void addSprite(Sprite sprite)
          Adds a sprite to this overlay.
 void clearAnimations()
          Removes all animations from this overlay.
 void clearSprites()
          Removes all sprites from this overlay.
 Graphics2D createGraphics()
          Creates a graphics context for the component underlying this media host.
 AnimationManager getAnimationManager()
          Returns a reference to the animation manager used by this media panel.
 SpriteManager getSpriteManager()
          Returns a reference to the sprite manager used by this media overlay.
 boolean isManaged(Animation anim)
           
 boolean isManaged(Sprite sprite)
           
 boolean paint(Graphics2D gfx)
          Called by the FrameManager after everything is done painting, allowing us to paint gloriously overtop of everything in the frame.
 void propagateDirtyRegions(ActiveRepaintManager repmgr, JRootPane root)
          Called by the FrameManager to propagate our dirty regions to the active repaint manager so that it can repaint the underlying components just prior to our painting our media.
 void removeSprite(Sprite sprite)
          Removes a sprite from this overlay.
 void tick(long tickStamp)
          Called by the frame manager on every tick.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_framemgr

protected FrameManager _framemgr
The frame manager with whom we cooperate.


_metamgr

protected MetaMediaManager _metamgr
Handles the heavy lifting involving media.


_dirty

protected Rectangle[] _dirty
A temporary list of dirty rectangles maintained during the painting process.

Constructor Detail

MediaOverlay

protected MediaOverlay(FrameManager fmgr)
Creates a media overlay. Only the FrameManager will construct an instance.

Method Detail

getAnimationManager

public AnimationManager getAnimationManager()
Returns a reference to the animation manager used by this media panel.


getSpriteManager

public SpriteManager getSpriteManager()
Returns a reference to the sprite manager used by this media overlay.


addSprite

public void addSprite(Sprite sprite)
Adds a sprite to this overlay.


isManaged

public boolean isManaged(Sprite sprite)
Returns:
true if the sprite is already added to this overlay.

removeSprite

public void removeSprite(Sprite sprite)
Removes a sprite from this overlay.


clearSprites

public void clearSprites()
Removes all sprites from this overlay.


addAnimation

public void addAnimation(Animation anim)
Adds an animation to this overlay. Animations are automatically removed when they finish.


isManaged

public boolean isManaged(Animation anim)
Returns:
true if the animation is already added to this overlay.

abortAnimation

public void abortAnimation(Animation anim)
Aborts a currently running animation and removes it from this overlay. Animations are normally automatically removed when they finish.


clearAnimations

public void clearAnimations()
Removes all animations from this overlay.


addDirtyRegion

public void addDirtyRegion(Rectangle rect)
Adds a dirty region to this overlay.


propagateDirtyRegions

public void propagateDirtyRegions(ActiveRepaintManager repmgr,
                                  JRootPane root)
Called by the FrameManager to propagate our dirty regions to the active repaint manager so that it can repaint the underlying components just prior to our painting our media. This will be followed by a call to paint(java.awt.Graphics2D) after the components have been repainted.


paint

public boolean paint(Graphics2D gfx)
Called by the FrameManager after everything is done painting, allowing us to paint gloriously overtop of everything in the frame.

Returns:
true if we painted something, false otherwise.

createGraphics

public Graphics2D createGraphics()
Description copied from interface: MediaHost
Creates a graphics context for the component underlying this media host. This method can return null if the component is not currently displayable. The graphics created must be disposed by the caller.

Specified by:
createGraphics in interface MediaHost

tick

public void tick(long tickStamp)
Called by the frame manager on every tick.