Package org.opensourcephysics.media.core
Class ScratchVideoRecorder
java.lang.Object
org.opensourcephysics.media.core.ScratchVideoRecorder
- All Implemented Interfaces:
VideoRecorder
- Direct Known Subclasses:
GifVideoRecorder,ImageVideoRecorder,XuggleVideoRecorder
This VideoRecorder records to a scratch file which is then copied as needed.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected booleanprotected static JFileChooserprotected static JTextComponentprotected Stringprotected Dimensionprotected static Stringprotected intprotected doubleprotected Imageprotected booleanprotected static booleanprotected booleanprotected booleanprotected Fileprotected Fileprotected Stringprotected intprotected Stringprotected static Stringprotected Stringprotected static Stringprotected Stringprotected VideoType -
Constructor Summary
ConstructorsConstructorDescriptionScratchVideoRecorder(VideoType vidType) Constructs a ScratchVideoRecorder for the specified video type. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a video frame with the specified image.protected abstract booleanAppends a frame to the current video.protected voidCreates the scratch file.voidCreates a new video (scratch file) and sets fileName to null.voidcreateVideo(String fileName) Creates a new video and sets the destination file name.voidcreateVideo(String fileName, String trkPath) Creates a new video with the specified file name.protected voiddeleteFiles(ArrayList<File> files) Deletes files.protected voidDeletes the temporary files.protected voidfinalize()Called by the garbage collector when this recorder is no longer in use.Gets the file name of the destination video.protected FilegetFileToBeSaved(File file) Return the file that will be saved if the specified file is selected.protected StringReturns the extension to use for the scratch file.getVideo()Gets the current scratch video.Gets the VideoType.voidreset()Discards the current video and resets the recorder to a ready state.protected abstract voidSaves the current video to the scratch file.Saves the scratch video to the current file or chooser file.Saves the current scratch video to the specified file name.Saves the scratch video to a file picked from a chooser.protected FileShows a save dialog used to set the output movie file.static voidsetChooserExtension(String extension) Sets the extension used in the chooser.voidsetFileName(String path) Sets the file name.voidsetFrameDuration(double millis) Sets the time duration per frame.voidSets the size of the video.protected abstract booleanStarts the video recording process using current dimension dim.voidsuggestFileName(String name) Suggests a file name.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensourcephysics.media.core.VideoRecorder
getCodec
-
Field Details
-
chooser
-
chooserField
-
ext
-
ignoreChooser
protected static boolean ignoreChooser -
tempDirectory
-
tempFilePrefix
-
videoType
-
dim
-
frameImage
-
frameDuration
protected double frameDuration -
frameCount
protected int frameCount -
scratchName
-
scratchNumber
protected int scratchNumber -
scratchFile
-
canRecord
protected boolean canRecord -
hasContent
protected boolean hasContent -
isSaved
protected boolean isSaved -
saveFile
-
saveChanges
protected boolean saveChanges -
tempFileBasePath
-
tempFileType
-
tempFiles
-
suggestedFileName
-
chosenExtension
-
baseDir
-
-
Constructor Details
-
ScratchVideoRecorder
Constructs a ScratchVideoRecorder for the specified video type.- Parameters:
vidType- the video type
-
-
Method Details
-
createVideo
Creates a new video (scratch file) and sets fileName to null.- Specified by:
createVideoin interfaceVideoRecorder- Throws:
IOException
-
createVideo
Creates a new video and sets the destination file name. If fileName is null, the user can select a file with a chooser.- Specified by:
createVideoin interfaceVideoRecorder- Parameters:
fileName- name of the file to which the video will be written- Throws:
IOException
-
createVideo
Description copied from interface:VideoRecorderCreates a new video with the specified file name.- Specified by:
createVideoin interfaceVideoRecorder- Parameters:
fileName- name of the file to which the video will be written- Throws:
IOException
-
setSize
Sets the size of the video.- Specified by:
setSizein interfaceVideoRecorder- Parameters:
dimension- the dimensions of the new video
-
setFrameDuration
public void setFrameDuration(double millis) Sets the time duration per frame.- Specified by:
setFrameDurationin interfaceVideoRecorder- Parameters:
millis- the duration per frame in milliseconds
-
addFrame
Adds a video frame with the specified image.- Specified by:
addFramein interfaceVideoRecorder- Parameters:
image- the image to be drawn on the video frame.- Throws:
IOException
-
getVideoType
Gets the VideoType.- Returns:
- the video type
-
getVideo
Gets the current scratch video.- Specified by:
getVideoin interfaceVideoRecorder- Returns:
- the video
- Throws:
IOException
-
saveVideo
Saves the scratch video to the current file or chooser file.- Specified by:
saveVideoin interfaceVideoRecorder- Returns:
- the full path to the saved file
- Throws:
IOException
-
saveVideo
Saves the current scratch video to the specified file name.- Specified by:
saveVideoin interfaceVideoRecorder- Parameters:
fileName- the file name- Returns:
- the full path of the saved file
- Throws:
IOException
-
saveVideoAs
Saves the scratch video to a file picked from a chooser.- Specified by:
saveVideoAsin interfaceVideoRecorder- Returns:
- the full path of the saved file
- Throws:
IOException
-
getFileName
Gets the file name of the destination video.- Specified by:
getFileNamein interfaceVideoRecorder- Returns:
- the file name
-
setFileName
Sets the file name. May be null.- Specified by:
setFileNamein interfaceVideoRecorder- Parameters:
path- the file name
-
suggestFileName
Suggests a file name. May be null.- Parameters:
name- the file name
-
reset
public void reset()Discards the current video and resets the recorder to a ready state.- Specified by:
resetin interfaceVideoRecorder
-
setChooserExtension
Sets the extension used in the chooser. -
createScratch
Creates the scratch file.- Throws:
IOException
-
getScratchExtension
Returns the extension to use for the scratch file.- Returns:
- the extension
-
selectFile
Shows a save dialog used to set the output movie file.- Returns:
- the movie file, or none if canceled by user
-
getFileToBeSaved
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. This default implementation returns the file itself.- Parameters:
file- the file selected with the chooser- Returns:
- the file (or first file) to be saved
-
finalize
protected void finalize()Called by the garbage collector when this recorder is no longer in use. -
deleteTempFiles
protected void deleteTempFiles()Deletes the temporary files. -
deleteFiles
Deletes files. -
saveScratch
Saves the current video to the scratch file.- Throws:
IOException
-
startRecording
protected abstract boolean startRecording()Starts the video recording process using current dimension dim.- Returns:
- true if video recording successfully started
-
append
Appends a frame to the current video.- Parameters:
image- the image to append- Returns:
- true if image successfully appended
-