j3d.org Code

org.j3d.ui.image
Class JPEGImageObserver

java.lang.Object
  extended by org.j3d.ui.image.JPEGImageObserver
All Implemented Interfaces:
CapturedImageObserver

public class JPEGImageObserver
extends java.lang.Object
implements CapturedImageObserver

A one-shot image observer that turns the image into a JPEG image.

This oneshot will only write a single image the first time it is called. After that it will ignore any incoming requests.

If the filename already exists, it will automatically overwrite the existing image. If the filename contains non-existant intermediate directories, these will be automatically created.

This uses the Sun codec classes to save the image to disk. Don't know how this will react on non-sun JVMs.

Version:
$Revision $
Author:
Justin Couch

Constructor Summary
JPEGImageObserver()
          Construct a default observer with no filename set and it has not yet captured an image.
 
Method Summary
 void canvasImageCaptured(java.awt.image.BufferedImage img)
          Notification that an image has been captured from the canvas and is ready for processing.
 void setCaptureNextFrame()
          Tell the observer to capture the next frame it is told about.
 void setFilename(java.lang.String name)
          Set the filename that this will write to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPEGImageObserver

public JPEGImageObserver()
Construct a default observer with no filename set and it has not yet captured an image.

Method Detail

setCaptureNextFrame

public void setCaptureNextFrame()
Tell the observer to capture the next frame it is told about. If the observer has already fired, it will throw an IllegalStateException.

Throws:
java.lang.IllegalStateException - The image capture has already fired

setFilename

public void setFilename(java.lang.String name)
                 throws java.lang.IllegalStateException
Set the filename that this will write to. If the filename is null, this will remove the previously set name. It can only be set if the image has not yet been captured.

Parameters:
name - The name of the file to write to.
Throws:
java.lang.IllegalStateException - Calling to set the name after the image capture has fired

canvasImageCaptured

public void canvasImageCaptured(java.awt.image.BufferedImage img)
Notification that an image has been captured from the canvas and is ready for processing. If the filename has not been set then this will throw an exception.

Specified by:
canvasImageCaptured in interface CapturedImageObserver
Parameters:
img - The image that was captured
Throws:
java.lang.IllegalStateException - The filename has not been set

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org