org.opensourcephysics.media.core
Class ImageVideoRecorder

java.lang.Object
  extended by org.opensourcephysics.media.core.ScratchVideoRecorder
      extended by org.opensourcephysics.media.core.ImageVideoRecorder
All Implemented Interfaces:
VideoRecorder

public class ImageVideoRecorder
extends ScratchVideoRecorder

This is an image video recorder that uses scratch files.

Version:
1.0
Author:
Douglas Brown

Field Summary
protected  int frameCount
           
 
Fields inherited from class org.opensourcephysics.media.core.ScratchVideoRecorder
canRecord, chooser, chooserField, chosenExtension, dim, ext, frameDuration, frameImage, hasContent, ignoreChooser, isSaved, saveChanges, saveFile, scratchFile, scratchName, scratchNumber, suggestedFileName, tempDirectory, tempFilePrefix, tempFiles, videoType
 
Constructor Summary
ImageVideoRecorder()
          Constructs a default ImageVideoRecorder object.
ImageVideoRecorder(ImageVideoType type)
          Constructs a ImageVideoRecorder object for a specific image type.
 
Method Summary
protected  boolean append(java.awt.Image image)
          Appends a frame to the current video by saving the image in a tempFile.
protected  void finalize()
          Called by the garbage collector when this recorder is no longer in use.
protected static int getAppendedNumber(java.lang.String path)
           
protected static java.lang.String getBase(java.lang.String path)
           
protected static java.lang.String[] getFileNames(java.lang.String fileName, int length)
           
protected  java.io.File getFileToBeSaved(java.io.File file)
          Return the file that will be saved if the specified file is selected.
 Video getVideo()
          Gets the video.
 void reset()
          Discards the current video and resets the recorder to a ready state.
protected static java.lang.String[] saveImages(java.lang.String fileName, java.awt.image.BufferedImage[] images)
          Saves images to a numbered sequence of jpg files.
protected  void saveScratch()
          Required by ScratchVideoRecorder, but unused.
 java.lang.String saveVideo(java.lang.String fileName)
          Saves all video images to a numbered sequence of files.
 void setExpectedFrameCount(int n)
          Sets the expected frame count.
protected  boolean startRecording()
          Starts the video recording process.
 
Methods inherited from class org.opensourcephysics.media.core.ScratchVideoRecorder
addFrame, createScratch, createVideo, createVideo, deleteTempFiles, getFileName, getScratchExtension, saveVideo, saveVideoAs, selectFile, setFileName, setFrameDuration, setSize, suggestFileName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frameCount

protected int frameCount
Constructor Detail

ImageVideoRecorder

public ImageVideoRecorder()
Constructs a default ImageVideoRecorder object.


ImageVideoRecorder

public ImageVideoRecorder(ImageVideoType type)
Constructs a ImageVideoRecorder object for a specific image type.

Parameters:
type - the image type
Method Detail

getVideo

public Video getVideo()
               throws java.io.IOException
Gets the video.

Specified by:
getVideo in interface VideoRecorder
Overrides:
getVideo in class ScratchVideoRecorder
Returns:
the video
Throws:
java.io.IOException

saveVideo

public java.lang.String saveVideo(java.lang.String fileName)
                           throws java.io.IOException
Saves all video images to a numbered sequence of files.

Specified by:
saveVideo in interface VideoRecorder
Overrides:
saveVideo in class ScratchVideoRecorder
Parameters:
fileName - the file name basis for images
Returns:
the full path of the first image in the sequence
Throws:
java.io.IOException

setExpectedFrameCount

public void setExpectedFrameCount(int n)
Sets the expected frame count.

Parameters:
n - the expected frame count

reset

public void reset()
Discards the current video and resets the recorder to a ready state.

Specified by:
reset in interface VideoRecorder
Overrides:
reset in class ScratchVideoRecorder

finalize

protected void finalize()
Called by the garbage collector when this recorder is no longer in use.

Overrides:
finalize in class ScratchVideoRecorder

saveScratch

protected void saveScratch()
                    throws java.io.IOException
Required by ScratchVideoRecorder, but unused.

Specified by:
saveScratch in class ScratchVideoRecorder
Throws:
java.io.IOException

startRecording

protected boolean startRecording()
Starts the video recording process.

Specified by:
startRecording in class ScratchVideoRecorder
Returns:
true if video recording successfully started

append

protected boolean append(java.awt.Image image)
Appends a frame to the current video by saving the image in a tempFile.

Specified by:
append in class ScratchVideoRecorder
Parameters:
image - the image to append
Returns:
true if image successfully appended

getFileToBeSaved

protected java.io.File getFileToBeSaved(java.io.File file)
Return the file that will be saved if the specified file is selected. This is needed by ImageVideoRecorder since it strips and/or appends digits to the selected file name.

Overrides:
getFileToBeSaved in class ScratchVideoRecorder
Parameters:
file - the file selected with the chooser
Returns:
the file (or first file) to be saved

saveImages

protected static java.lang.String[] saveImages(java.lang.String fileName,
                                               java.awt.image.BufferedImage[] images)
                                        throws java.io.IOException
Saves images to a numbered sequence of jpg files.

Parameters:
fileName - the file name basis for images
images - the images to save
Returns:
the paths of the saved images
Throws:
java.io.IOException

getFileNames

protected static java.lang.String[] getFileNames(java.lang.String fileName,
                                                 int length)

getBase

protected static java.lang.String getBase(java.lang.String path)

getAppendedNumber

protected static int getAppendedNumber(java.lang.String path)