j3d.org Code

org.j3d.ui.image
Class JPEGSequenceObserver

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

public class JPEGSequenceObserver
extends java.lang.Object
implements CapturedImageObserver

An image observer that turns each call into an separate JPEG image as a sequentially numbered set.

The purpose of this observer is to create a sequence of images to be captured to disk so that we could make a video type presentation out of them at a later date. The generated filenames start from the base name given and just add a sequence number and the .jpg extension.

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
JPEGSequenceObserver()
          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 setEnabled(boolean enable)
          Tell the observer to start or stop capturing the next frame it is told about.
 void setFileDetails(java.lang.String dir, java.lang.String fileBase)
          Set the recording details about the directory that should be written to and the base filename to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPEGSequenceObserver

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

Method Detail

setFileDetails

public void setFileDetails(java.lang.String dir,
                           java.lang.String fileBase)
Set the recording details about the directory that should be written to and the base filename to use. If the directory does not exist, the code will create the requested directory silently. The filename base should not include the extension because we automatically add it. Setting this will also reset the sequence number to zero.

Parameters:
dir - The directory to use
fileBase - The base filename to use
Throws:
java.lang.IllegalArgumentException - One or other of the params are null
java.lang.IllegalStateException - The capturing is current enabled

setEnabled

public void setEnabled(boolean enable)
Tell the observer to start or stop capturing the next frame it is told about.

Parameters:
enable - true to start capturing images

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