org.opensourcephysics.cabrillo.tracker
Class TrackerIO

java.lang.Object
  extended by org.opensourcephysics.media.core.VideoIO
      extended by org.opensourcephysics.cabrillo.tracker.TrackerIO

public class TrackerIO
extends VideoIO

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

Author:
Douglas Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.media.core.VideoIO
VideoIO.StreamPiper, VideoIO.VideoEnginePanel
 
Field Summary
protected static java.lang.String COMMA
           
protected static java.util.Map<java.lang.String,java.lang.String> customDelimiters
           
protected static double defaultBadFrameTolerance
           
protected static java.lang.String defaultDelimiter
           
protected static java.lang.String delimiter
           
protected static java.util.Map<java.lang.String,java.lang.String> delimiters
           
protected static java.beans.PropertyChangeListener ffmpegListener
           
protected static boolean isffmpegError
           
protected static boolean loadInSeparateThread
           
protected static java.util.Set<org.opensourcephysics.cabrillo.tracker.MonitorDialog> monitors
           
protected static java.lang.String SEMICOLON
           
protected static java.lang.String SPACE
           
protected static java.lang.String TAB
           
protected static TFrame theFrame
           
protected static javax.swing.filechooser.FileFilter trkFileFilter
           
protected static javax.swing.filechooser.FileFilter trzFileFilter
           
protected static javax.swing.filechooser.FileFilter videoAndTrkFileFilter
           
protected static javax.swing.filechooser.FileFilter zipFileFilter
           
 
Fields inherited from class org.opensourcephysics.media.core.VideoIO
canceled, chooser, DEFAULT_PREFERRED_EXPORT_EXTENSION, defaultXMLExt, ENGINE_NONE, ENGINE_QUICKTIME, ENGINE_XUGGLE, imageFileFilter, preferredExportExtension, singleVideoTypeFilters, VIDEO_EXTENSIONS, videoEngine, videoEnginePanel, videoEngines, videoFileFilter, videoTypes, XUGGLE_54_FILE_LENGTH
 
Method Summary
static void addCustomDelimiter(java.lang.String custom)
          Adds a custom delimiter to the collection of delimiters
static boolean canWrite(java.io.File file)
          Determines if a file can be written.
static boolean choose(XMLControl control, ListChooser dialog)
          Displays a ListChooser with choices from the specified control.
static void copyImage(java.awt.Image image)
          Copies the specified image to the system clipboard.
static void copyTable(DataTable table, boolean asFormatted, java.lang.String header)
          Copies data in the specified datatable to the system clipboard.
static void copyXML(java.lang.Object obj)
          Copies an xml string representation of the specified object to the system clipboard.
static java.io.File exportFile(TrackerPanel trackerPanel)
          Exports xml data from the specified tracker panel to a file selected with a chooser.
static java.util.ArrayList<java.lang.Integer> findBadVideoFrames(TrackerPanel trackerPanel, double tolerance, boolean showDialog, boolean onlyIfFound, boolean showSetDefaultButton)
          Checks for video frames with durations that vary from the mean.
static java.io.File[] getChooserFiles(java.lang.String type)
          Displays a file chooser and returns the chosen files.
static java.awt.Image getClipboardImage()
          Returns the image on the clipboard, if any.
static java.lang.StringBuffer getData(DataTable table, boolean asFormatted)
          Gets the data selected by the user in a datatable.
static java.lang.String getDelimiter()
          Gets the delimiter for copied or exported data
static Video getVideo(java.lang.String path, VideoType vidType)
          Returns a video from a specified path.
static java.io.File importFile(TrackerPanel trackerPanel)
          Imports xml data into a tracker panel from a file selected with a chooser.
static void importVideo(java.io.File file, TrackerPanel trackerPanel, VideoType vidType)
          Imports a video file to the specified tracker panel.
static void importVideo(TrackerPanel trackerPanel)
          Imports chooser-selected video to the specified tracker panel.
static java.io.File[] insertImagesIntoVideo(java.io.File[] files, TrackerPanel trackerPanel, int startIndex)
          Inserts file-based images into an ImageVideo on a TrackerPanel.
static java.io.File[] insertImagesIntoVideo(TrackerPanel trackerPanel, int startIndex)
          Inserts chooser-selected images into an ImageVideo on a TrackerPanel.
static void open(java.util.Collection<java.lang.String> urlPaths, TFrame frame, java.util.ArrayList<java.lang.String> desktopFiles)
          Loads a set of trk or video files into new TrackerPanels.
static void open(java.io.File file, TFrame frame)
          Loads data or a video from a specified file into a new TrackerPanel.
static void open(java.lang.String path, TFrame frame)
          Loads data or a video from a specified path into a new TrackerPanel.
static void open(java.net.URL url, TFrame frame)
          Loads data or a video from a specified url into a new TrackerPanel.
static void pasteXML(TrackerPanel trackerPanel)
          Pastes a new object into the specified tracker panel from an xml string on the system clipboard.
static void removeCustomDelimiter(java.lang.String custom)
          Removes a custom delimiter from the collection of delimiters
static java.io.File save(java.io.File file, TrackerPanel trackerPanel)
          Writes TrackerPanel data to the specified file.
static java.io.File saveTabset(java.io.File file, TFrame frame)
          Saves a tabset in the specified file.
static void setDelimiter(java.lang.String delimiter)
          Sets the delimiter for copied or exported data
 
Methods inherited from class org.opensourcephysics.media.core.VideoIO
addVideoEngine, addVideoType, clone, copyFile, getChooser, getDefaultEngine, getEngine, getExtension, getPreferredExportExtension, getRelativePath, getVideoExtensions, getVideoType, getVideoTypes, getVideoTypesForEngine, getVideoTypesForExtension, guessXuggleVersion, isCanceled, isEngineInstalled, open, open, save, save, setCanceled, setDefaultXMLExtension, setEngine, setPreferredExportExtension, testExec, updateEngine, writeImageFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAB

protected static final java.lang.String TAB
See Also:
Constant Field Values

SPACE

protected static final java.lang.String SPACE
See Also:
Constant Field Values

COMMA

protected static final java.lang.String COMMA
See Also:
Constant Field Values

SEMICOLON

protected static final java.lang.String SEMICOLON
See Also:
Constant Field Values

zipFileFilter

protected static javax.swing.filechooser.FileFilter zipFileFilter

trkFileFilter

protected static javax.swing.filechooser.FileFilter trkFileFilter

trzFileFilter

protected static javax.swing.filechooser.FileFilter trzFileFilter

videoAndTrkFileFilter

protected static javax.swing.filechooser.FileFilter videoAndTrkFileFilter

defaultDelimiter

protected static java.lang.String defaultDelimiter

delimiter

protected static java.lang.String delimiter

delimiters

protected static java.util.Map<java.lang.String,java.lang.String> delimiters

customDelimiters

protected static java.util.Map<java.lang.String,java.lang.String> customDelimiters

isffmpegError

protected static boolean isffmpegError

theFrame

protected static TFrame theFrame

ffmpegListener

protected static java.beans.PropertyChangeListener ffmpegListener

loadInSeparateThread

protected static boolean loadInSeparateThread

monitors

protected static java.util.Set<org.opensourcephysics.cabrillo.tracker.MonitorDialog> monitors

defaultBadFrameTolerance

protected static double defaultBadFrameTolerance
Method Detail

save

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

Parameters:
file - the file to write to
trackerPanel - the TrackerPanel
Returns:
the file written to, or null if not written

saveTabset

public static java.io.File saveTabset(java.io.File file,
                                      TFrame frame)
Saves a tabset in the specified file. If the file is null this brings up a chooser.

Parameters:
file - the file to write to
frame - the TFrame
Returns:
the file written to, or null if not written

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, insert image, export file, import file, save tabset
Returns:
the files, or null if no files chosen

canWrite

public static boolean canWrite(java.io.File file)
Determines if a file can be written. If the file exists, the user is prompted for approval to overwrite.

Parameters:
file - the file to check
Returns:
true if the file can be written

getVideo

public static Video getVideo(java.lang.String path,
                             VideoType vidType)
Returns a video from a specified path. May return null. Overrides VideoIO method.

Parameters:
path - the path
vidType - a requested video type (may be null)
Returns:
the video

open

public static void open(java.io.File file,
                        TFrame frame)
Loads data or a video from a specified file into a new TrackerPanel. If file is null, a file chooser is displayed.

Parameters:
file - the file to be loaded (may be null)
frame - the frame for the TrackerPanel

open

public static void open(java.net.URL url,
                        TFrame frame)
Loads data or a video from a specified url into a new TrackerPanel.

Parameters:
url - the url to be loaded
frame - the frame for the TrackerPanel

open

public static void open(java.util.Collection<java.lang.String> urlPaths,
                        TFrame frame,
                        java.util.ArrayList<java.lang.String> desktopFiles)
Loads a set of trk or video files into new TrackerPanels.

Parameters:
urlPaths - an array of URL paths to be loaded
frame - the frame for the TrackerPanels
desktopFiles - supplemental HTML and PDF files to load on the desktop

open

public static void open(java.lang.String path,
                        TFrame frame)
Loads data or a video from a specified path into a new TrackerPanel.

Parameters:
path - the path
frame - the frame for the TrackerPanel

importFile

public static java.io.File importFile(TrackerPanel trackerPanel)
Imports xml data into a tracker panel from a file selected with a chooser. The user selects the elements to import with a ListChooser.

Parameters:
trackerPanel - the tracker panel
Returns:
the file

importVideo

public static void importVideo(TrackerPanel trackerPanel)
Imports chooser-selected video to the specified tracker panel.

Parameters:
trackerPanel - the tracker panel

importVideo

public static void importVideo(java.io.File file,
                               TrackerPanel trackerPanel,
                               VideoType vidType)
Imports a video file to the specified tracker panel.

Parameters:
file - the video file
trackerPanel - the tracker panel
vidType - the preferred video type

findBadVideoFrames

public static java.util.ArrayList<java.lang.Integer> findBadVideoFrames(TrackerPanel trackerPanel,
                                                                        double tolerance,
                                                                        boolean showDialog,
                                                                        boolean onlyIfFound,
                                                                        boolean showSetDefaultButton)
Checks for video frames with durations that vary from the mean.

Parameters:
trackerPanel - the TrackerPanel to check
tolerance - the unacceptable variation limit
showDialog - true to display the results in a dialog
onlyIfFound - true to display the dialog only if problems are found
showSetDefaultButton - true to show the "Don't show again" button
Returns:
an array of frames with odd durations

insertImagesIntoVideo

public static java.io.File[] insertImagesIntoVideo(TrackerPanel trackerPanel,
                                                   int startIndex)
Inserts chooser-selected images into an ImageVideo on a TrackerPanel.

Parameters:
trackerPanel - the TrackerPanel
startIndex - the insertion index
Returns:
an array of inserted files

insertImagesIntoVideo

public static java.io.File[] insertImagesIntoVideo(java.io.File[] files,
                                                   TrackerPanel trackerPanel,
                                                   int startIndex)
Inserts file-based images into an ImageVideo on a TrackerPanel.

Parameters:
files - array of image files
trackerPanel - the TrackerPanel
startIndex - the insertion index
Returns:
an array of inserted files

exportFile

public static java.io.File exportFile(TrackerPanel trackerPanel)
Exports xml data from the specified tracker panel to a file selected with a chooser. Displays a dialog with choices of items to export.

Parameters:
trackerPanel - the tracker panel
Returns:
the file

choose

public static boolean choose(XMLControl control,
                             ListChooser dialog)
Displays a ListChooser with choices from the specified control. Modifies the control and returns true if the OK button is clicked.

Parameters:
control - the XMLControl
dialog - the dialog
Returns:
true if OK button is clicked

copyXML

public static void copyXML(java.lang.Object obj)
Copies an xml string representation of the specified object to the system clipboard.

Parameters:
obj - the object to copy

pasteXML

public static void pasteXML(TrackerPanel trackerPanel)
Pastes a new object into the specified tracker panel from an xml string on the system clipboard.

Parameters:
trackerPanel - the tracker panel

copyTable

public static void copyTable(DataTable table,
                             boolean asFormatted,
                             java.lang.String header)
Copies data in the specified datatable to the system clipboard.

Parameters:
table - the datatable to copy
asFormatted - true to retain table formatting
header - the table header

copyImage

public static void copyImage(java.awt.Image image)
Copies the specified image to the system clipboard.

Parameters:
image - the image to copy

getClipboardImage

public static java.awt.Image getClipboardImage()
Returns the image on the clipboard, if any.

Returns:
the image, or null if none found

getData

public static java.lang.StringBuffer getData(DataTable table,
                                             boolean asFormatted)
Gets the data selected by the user in a datatable. This method is modified from the org.opensourcephysics.display.DataTableFrame getSelectedData method.

Parameters:
table - the datatable containing the data
asFormatted - true to retain table formatting
Returns:
a StringBuffer containing the data.

setDelimiter

public static void setDelimiter(java.lang.String delimiter)
Sets the delimiter for copied or exported data

Parameters:
delimiter - the delimiter

getDelimiter

public static java.lang.String getDelimiter()
Gets the delimiter for copied or exported data

Returns:
the delimiter

addCustomDelimiter

public static void addCustomDelimiter(java.lang.String custom)
Adds a custom delimiter to the collection of delimiters

Parameters:
custom - the delimiter to add

removeCustomDelimiter

public static void removeCustomDelimiter(java.lang.String custom)
Removes a custom delimiter from the collection of delimiters

Parameters:
custom - the delimiter to remove