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  java.util.ArrayList<java.awt.image.BufferedImage> images
           
 
Fields inherited from class org.opensourcephysics.media.core.ScratchVideoRecorder
canRecord, chooser, chooserField, dim, ext, frameCount, frameDuration, frameImage, hasContent, ignoreChooser, isSaved, saveChanges, saveFile, scratchFile, scratchName, scratchNumber, videoType
 
Constructor Summary
ImageVideoRecorder()
          Constructs a ImageVideoRecorder object.
 
Method Summary
protected  boolean append(java.awt.Image image)
          Appends a frame to the current video.
protected  int getAppendedNumber(java.lang.String path)
           
protected  java.lang.String getBase(java.lang.String path)
           
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.
protected  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.
protected  boolean startRecording()
          Starts the video recording process.
 
Methods inherited from class org.opensourcephysics.media.core.ScratchVideoRecorder
addFrame, createScratch, createVideo, createVideo, getFileName, reset, saveVideo, saveVideoAs, selectFile, setFileName, setFrameDuration, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

images

protected java.util.ArrayList<java.awt.image.BufferedImage> images
Constructor Detail

ImageVideoRecorder

public ImageVideoRecorder()
Constructs a ImageVideoRecorder object.

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

saveScratch

protected void saveScratch()
Required by ScratchVideoRecorder, but unused.

Specified by:
saveScratch in class ScratchVideoRecorder

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. Note: this creates a new BufferedImage each time a frame is appended and can use lots of memory in a hurry.

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

saveImages

protected 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

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

getBase

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

getAppendedNumber

protected int getAppendedNumber(java.lang.String path)