org.opensourcephysics.media.core
Class VideoIO

java.lang.Object
  extended by org.opensourcephysics.media.core.VideoIO

public class VideoIO
extends java.lang.Object

This provides static methods for managing video and text input/output.

Version:
1.0
Author:
Douglas Brown

Field Summary
protected static javax.swing.JFileChooser chooser
           
protected static java.lang.String defaultXMLExt
           
protected static javax.swing.filechooser.FileFilter imageFileFilter
           
protected static javax.swing.filechooser.FileFilter qtFileFilter
           
protected static javax.swing.filechooser.FileFilter videoFileFilter
           
protected static java.util.Collection<VideoType> videoTypes
           
 
Constructor Summary
protected VideoIO()
          protected constructor to discourage instantiation
 
Method Summary
static void addVideoType(VideoType type)
          Adds a video type to the list of available types
static Video clone(Video video)
          Returns a clone of the specified video.
static javax.swing.JFileChooser getChooser()
          Gets the video file chooser.
static java.io.File[] getChooserFiles(java.lang.String type)
          Displays a file chooser and returns the chosen files.
static java.lang.String getExtension(java.io.File file)
          Gets the extension of a file.
static java.lang.String getRelativePath(java.lang.String absolutePath)
          Gets the path relative to the user directory.
static Video getVideo(java.io.File file)
          Returns a video from a specified file.
static VideoType[] getVideoTypes()
          Gets an array of available video types
static java.io.File open(java.io.File file, VideoPanel vidPanel)
          Loads data or a video from a specified file into a VideoPanel.
static java.io.File open(VideoPanel vidPanel)
          Loads the specified video panel from a file selected with a chooser and sets the data file of the panel.
static java.io.File save(java.io.File file, VideoPanel vidPanel)
          Writes VideoPanel data to the specified file.
static void setDefaultXMLExtension(java.lang.String ext)
          Sets the default xml extension used when saving data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chooser

protected static javax.swing.JFileChooser chooser

videoFileFilter

protected static javax.swing.filechooser.FileFilter videoFileFilter

qtFileFilter

protected static javax.swing.filechooser.FileFilter qtFileFilter

imageFileFilter

protected static javax.swing.filechooser.FileFilter imageFileFilter

videoTypes

protected static java.util.Collection<VideoType> videoTypes

defaultXMLExt

protected static java.lang.String defaultXMLExt
Constructor Detail

VideoIO

protected VideoIO()
protected constructor to discourage instantiation

Method Detail

getExtension

public static java.lang.String getExtension(java.io.File file)
Gets the extension of a file.

Parameters:
file - the file
Returns:
the extension of the file

getChooser

public static javax.swing.JFileChooser getChooser()
Gets the video file chooser.

Returns:
the file chooser

setDefaultXMLExtension

public static void setDefaultXMLExtension(java.lang.String ext)
Sets the default xml extension used when saving data.

Parameters:
ext - the default extension

getRelativePath

public static java.lang.String getRelativePath(java.lang.String absolutePath)
Gets the path relative to the user directory.

Parameters:
absolutePath - the absolute path
Returns:
the relative path

addVideoType

public static void addVideoType(VideoType type)
Adds a video type to the list of available types

Parameters:
type - the video type

getVideoTypes

public static VideoType[] getVideoTypes()
Gets an array of available video types

Returns:
the video types

getVideo

public static Video getVideo(java.io.File file)
Returns a video from a specified file. May return null.

Parameters:
file - the file
Returns:
the video

clone

public static Video clone(Video video)
Returns a clone of the specified video.

Parameters:
video - the video to clone
Returns:
the clone

open

public static java.io.File open(VideoPanel vidPanel)
Loads the specified video panel from a file selected with a chooser and sets the data file of the panel.

Parameters:
vidPanel - the video panel
Returns:
an array containing the loaded object and file

getChooserFiles

public static java.io.File[] getChooserFiles(java.lang.String type)
Displays a file chooser and returns the chosen files.

Parameters:
type - may be "open", "open video", "save", "qt", "insert image"
Returns:
the files, or null if no files chosen

open

public static java.io.File open(java.io.File file,
                                VideoPanel vidPanel)
Loads data or a video from a specified file into a VideoPanel. If file is null, a file chooser is displayed.

Parameters:
file - the file to be loaded
vidPanel - the video panel
Returns:
the file opened

save

public static java.io.File save(java.io.File file,
                                VideoPanel vidPanel)
Writes VideoPanel data to the specified file. If the file is null it brings up a chooser.

Parameters:
file - the file to write to
vidPanel - the video panel
Returns:
the file written to, or null if not written