com.threerings.media.image
Class VolatileMirage

java.lang.Object
  extended by com.threerings.media.image.VolatileMirage
All Implemented Interfaces:
Mirage
Direct Known Subclasses:
BackedVolatileMirage, CachedVolatileMirage, CompositedMultiFrameImage.CompositedVolatileMirage

public abstract class VolatileMirage
extends Object
implements Mirage

A mirage implementation which allows the image to be maintained in video memory and rebuilt from some source image or images in the event that our target screen resolution changes or we are flushed from video memory for some other reason.


Field Summary
protected  Rectangle _bounds
          The bounds of the region of our source image which we desire for this mirage (possibly the whole thing).
protected  BufferedImage _image
          Our volatile image which lives in video memory and can go away at any time.
protected  ImageManager _imgr
          The image manager with whom we interoperate.
protected static boolean IMAGE_DEBUG
          Turns off image rendering for testing.
 
Constructor Summary
protected VolatileMirage(ImageManager imgr, Rectangle bounds)
          Informs the base class of its image manager and image bounds.
 
Method Summary
protected  void createVolatileImage()
          Creates our volatile image from the information in our source image.
 long getEstimatedMemoryUsage()
          Returns an estimate of the memory consumed by this mirage's image raster data.
 int getHeight()
          Returns the height of this mirage.
 BufferedImage getSnapshot()
          Returns a snapshot of this mirage as a buffered image.
protected abstract  int getTransparency()
          Returns the transparency that should be used when creating our volatile image.
 int getWidth()
          Returns the width of this mirage.
 int getX()
          Returns the x offset into our source image, which is generally zero but may be non-zero for a mirage that obtains its data from a region of its source image.
 int getY()
          Returns the y offset into our source image, which is generally zero but may be non-zero for a mirage that obtains its data from a region of its source image.
 boolean hitTest(int x, int y)
          Returns true if this mirage contains a non-transparent pixel at the specified coordinate.
 void paint(Graphics2D gfx, int x, int y)
          Renders this mirage at the specified position in the supplied graphics context.
protected abstract  void refreshVolatileImage()
          Rerenders our volatile image from the its source image data.
 String toString()
           
protected  void toString(StringBuilder buf)
          Generates a string representation of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_imgr

protected ImageManager _imgr
The image manager with whom we interoperate.


_bounds

protected Rectangle _bounds
The bounds of the region of our source image which we desire for this mirage (possibly the whole thing).


_image

protected BufferedImage _image
Our volatile image which lives in video memory and can go away at any time.


IMAGE_DEBUG

protected static final boolean IMAGE_DEBUG
Turns off image rendering for testing.

See Also:
Constant Field Values
Constructor Detail

VolatileMirage

protected VolatileMirage(ImageManager imgr,
                         Rectangle bounds)
Informs the base class of its image manager and image bounds.

Method Detail

paint

public void paint(Graphics2D gfx,
                  int x,
                  int y)
Description copied from interface: Mirage
Renders this mirage at the specified position in the supplied graphics context.

Specified by:
paint in interface Mirage

getX

public int getX()
Returns the x offset into our source image, which is generally zero but may be non-zero for a mirage that obtains its data from a region of its source image.


getY

public int getY()
Returns the y offset into our source image, which is generally zero but may be non-zero for a mirage that obtains its data from a region of its source image.


getWidth

public int getWidth()
Description copied from interface: Mirage
Returns the width of this mirage.

Specified by:
getWidth in interface Mirage

getHeight

public int getHeight()
Description copied from interface: Mirage
Returns the height of this mirage.

Specified by:
getHeight in interface Mirage

hitTest

public boolean hitTest(int x,
                       int y)
Description copied from interface: Mirage
Returns true if this mirage contains a non-transparent pixel at the specified coordinate.

Specified by:
hitTest in interface Mirage

getEstimatedMemoryUsage

public long getEstimatedMemoryUsage()
Description copied from interface: Mirage
Returns an estimate of the memory consumed by this mirage's image raster data.

Specified by:
getEstimatedMemoryUsage in interface Mirage

getSnapshot

public BufferedImage getSnapshot()
Description copied from interface: Mirage
Returns a snapshot of this mirage as a buffered image. The snapshot should not be modified by the caller.

Specified by:
getSnapshot in interface Mirage

createVolatileImage

protected void createVolatileImage()
Creates our volatile image from the information in our source image.


getTransparency

protected abstract int getTransparency()
Returns the transparency that should be used when creating our volatile image.


refreshVolatileImage

protected abstract void refreshVolatileImage()
Rerenders our volatile image from the its source image data.


toString

public String toString()
Overrides:
toString in class Object

toString

protected void toString(StringBuilder buf)
Generates a string representation of this instance.