Class TrackerIO
java.lang.Object
org.opensourcephysics.media.core.VideoIO
org.opensourcephysics.cabrillo.tracker.TrackerIO
This provides static methods for managing video and text input/output.
- Author:
- Douglas Brown
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.opensourcephysics.media.core.VideoIO
VideoIO.EditorPaneMessage, VideoIO.FinalizableLoader, VideoIO.SingleExtFileFilter, VideoIO.StreamPiper, VideoIO.ZipImageVideoType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static boolean
protected static double
protected static PropertyChangeListener
protected static boolean
static final Runnable
static final int
static final int
static final int
static final int
static final int
static String
protected static TFrame
Fields inherited from class org.opensourcephysics.media.core.VideoIO
chooser, COMMA, customDelimiters, DEFAULT_PREFERRED_EXPORT_EXTENSION, DEFAULT_VIDEO_EXTENSION, defaultDelimiter, defaultXMLExt, delimitedTextFileFilter, delimiter, delimiters, imageFileFilter, incrementToLoad, jarFileFilter, jpgFileFilter, KNOWN_VIDEO_EXTENSIONS, loader, loadIncrementally, preferredExportExtension, PROGRESS_COMPLETE, PROGRESS_LOAD_INIT, PROGRESS_VIDEO_CANCELED, PROGRESS_VIDEO_LOADING, PROGRESS_VIDEO_PROCESSING, PROGRESS_VIDEO_READY, SEMICOLON, singleVideoTypeFilters, SPACE, TAB, trkFileFilter, trzFileFilter, txtFileFilter, VIDEO_CONVERSION_HELP_PATH, videoAndTrkFileFilter, videoFileFilter, videoTypes, zipFileFilter
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCustomDelimiter
(String custom) Adds a custom delimiter to the collection of delimitersstatic void
choose
(TrackerPanel trackerPanel, XMLControl control, boolean isExport, Runnable ok) Displays a ListChooser with choices from the specified control.static void
Copies the specified image to the system clipboard.static void
Copies data in the specified datatable to the system clipboard.static void
Copies an xml string representation of the specified object to the system clipboard.static void
exportVideoImages
(TrackerPanel panel, String exportVideoName) static void
exportXMLFile
(TrackerPanel trackerPanel) Exports xml data from the specified tracker panel to a file selected with a chooser.static BitSet
findBadVideoFrames
(TrackerPanel trackerPanel, double tolerance, boolean showDialog, boolean onlyIfFound, boolean showSetDefaultButton) Checks for video frames with durations that vary from the mean.protected static File
static File
getChooserFileForName
(String name) Displays a file chooser and returns the chosen file, adding or changing the extension to match the specified extension.static File[]
getChooserFiles
(String type) Deprecated.static File[]
Displays a file chooser and returns the chosen files.static Image
Returns the image on the clipboard, if any.static StringBuffer
Gets the data selected by the user in a datatable.Gets the delimiters for copied or exported data This overrides the VideoIO method since the TrackerRes strings have already been translatedstatic byte[]
getImageBytes
(TrackerPanel panel, int i) static String
getVideoFormat
(String preferredExtension) protected static Object[]
static void
importFile
(TrackerPanel trackerPanel) Imports xml data into a tracker panel from a file selected with a chooser.static void
importVideo
(String path, TrackerPanel trackerPanel, Runnable whenDone) static void
importVideo
(TrackerPanel trackerPanel, Runnable whenDone) Imports chooser-selected video to the specified tracker panel.protected static void
importXMLAction
(TrackerPanel trackerPanel, File file) static File[]
insertImagesIntoVideo
(File[] files, TrackerPanel trackerPanel, int startIndex) Inserts file-based images into an ImageVideo on a TrackerPanel.static void
insertImagesIntoVideo
(TrackerPanel trackerPanel, int startIndex) Inserts chooser-selected images into an ImageVideo on a TrackerPanel.static boolean
isImageFile
(File file) Returns true if the specified file is an image.static boolean
static boolean
loadFiles
(TFrame frame, List<File> fileList, TrackerPanel targetPanel) From FileDropHandlerstatic void
openFileFromDialog
(File file, TFrame frame, Runnable whenDone) Loads data or a video from a specified file into a new TrackerPanel.static org.opensourcephysics.cabrillo.tracker.TrackerIO.AsyncLoader
openFromLibrary
(List<String> uriPaths, TFrame frame, Runnable whenDone) Loads a set of trk, trz, zip, or video files into one or more new TrackerPanels (tabs).static org.opensourcephysics.cabrillo.tracker.TrackerIO.AsyncLoader
static void
Refreshes the format set.static void
removeCustomDelimiter
(String custom) Removes a custom delimiter from the collection of delimitersstatic File
save
(File file, TrackerPanel trackerPanel) Writes TrackerPanel data to the specified file.static File
saveTabset
(File file, TFrame frame) Saves a tabset in the specified file.static File
saveVideo
(File file, TrackerPanel trackerPanel, boolean asZipFile, boolean notify) Saves a video to a file by copying the original.Methods inherited from class org.opensourcephysics.media.core.VideoIO
addVideoType, canWrite, checkMP4, clone, getChooser, getChooserFilesAsync, getDelimiter, getExtension, getImageSequencePaths, getMovieType, getPreferredExportExtension, getRelativePath, getVideo, getVideo, getVideoCodec, getVideoExtensions, getVideoType, getVideoTypes, getVideoTypesForPath, getZippedImagePaths, handleUnsupportedVideo, isCanceled, isKnownVideoExtension, openVideoPanelFileAsync, processChoose, progressForFraction, requiresReload, save, save, setCanceled, setDefaultXMLExtension, setDelimiter, setPreferredExportExtension, testExec, writeImageFile
-
Field Details
-
NULL_RUNNABLE
-
isffmpegError
protected static boolean isffmpegError -
theFrame
-
ffmpegListener
-
defaultBadFrameTolerance
protected static double defaultBadFrameTolerance -
dataCopiedToClipboard
protected static boolean dataCopiedToClipboard -
videoFormatDescriptions
-
videoFormats
-
selectedVideoFormat
-
PROGRESS_PANEL_READY
public static final int PROGRESS_PANEL_READY- See Also:
-
PROGRESS_VIDEO_LOADED
public static final int PROGRESS_VIDEO_LOADED- See Also:
-
PROGRESS_TOOLBAR_AND_COORD_READY
public static final int PROGRESS_TOOLBAR_AND_COORD_READY- See Also:
-
PROGRESS_TRACKS_ADDED
public static final int PROGRESS_TRACKS_ADDED- See Also:
-
PROGRESS_TRACKS_INITIALIZED
public static final int PROGRESS_TRACKS_INITIALIZED- See Also:
-
-
Method Details
-
getDelimiters
Gets the delimiters for copied or exported data This overrides the VideoIO method since the TrackerRes strings have already been translated- Returns:
- the delimiter map
-
save
Writes TrackerPanel data to the specified file. If the file is null it brings up a chooser.- Parameters:
file
- the file to write totrackerPanel
- the TrackerPanel- Returns:
- the file written to, or null if not written
-
saveTabset
Saves a tabset in the specified file. If the file is null this brings up a chooser.- Parameters:
file
- the file to write toframe
- the TFrame- Returns:
- the file written to, or null if not written
-
getChooserFiles
Deprecated.A Stop-gap method to allow Java-only functionality.- Parameters:
type
-- Returns:
-
getChooserFilesAsync
public static File[] getChooserFilesAsync(TFrame frame, String type, Function<File[], Void> processFiles) Displays a file chooser and returns the chosen files.- Parameters:
frame
- TODOtype
- may be open, open video, save, insert image, export file, import file, save tabset, open data, open trk- Returns:
- the files, or null if no files chosen
-
fixXML
-
getChooserFileForName
Displays a file chooser and returns the chosen file, adding or changing the extension to match the specified extension.- Parameters:
extension
- the extension- Returns:
- the file, or null if no file chosen
-
loadFiles
From FileDropHandler- Parameters:
fileList
-targetPanel
-- Returns:
-
openFileFromDialog
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 TrackerPanelwhenDone
- to do when completed, or null
-
openURL
-
openFromLibrary
public static org.opensourcephysics.cabrillo.tracker.TrackerIO.AsyncLoader openFromLibrary(List<String> uriPaths, TFrame frame, Runnable whenDone) Loads a set of trk, trz, zip, or video files into one or more new TrackerPanels (tabs).- Parameters:
uriPaths
- an array of URL paths to be loadedframe
- the frame for the TrackerPanels
-
importFile
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
-
importXMLAction
-
saveVideo
public static File saveVideo(File file, TrackerPanel trackerPanel, boolean asZipFile, boolean notify) Saves a video to a file by copying the original. If the file is null, a fileChooser is used to pick one.- Parameters:
trackerPanel
- the tracker panel with the video- Returns:
- the saved file, or null if not saved
-
importVideo
Imports chooser-selected video to the specified tracker panel.- Parameters:
trackerPanel
- the tracker panel
-
importVideo
-
findBadVideoFrames
public static BitSet 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 checktolerance
- the unacceptable variation limitshowDialog
- true to display the results in a dialogonlyIfFound
- true to display the dialog only if problems are foundshowSetDefaultButton
- true to show the "Don't show again" button- Returns:
- null if dialog or a BitSet indicating frames with odd durations
-
insertImagesIntoVideo
Inserts chooser-selected images into an ImageVideo on a TrackerPanel.- Parameters:
trackerPanel
- the TrackerPanelstartIndex
- the insertion index
-
insertImagesIntoVideo
Inserts file-based images into an ImageVideo on a TrackerPanel.- Parameters:
files
- array of image filestrackerPanel
- the TrackerPanelstartIndex
- the insertion index- Returns:
- an array of inserted files
-
exportXMLFile
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
-
choose
public static void choose(TrackerPanel trackerPanel, XMLControl control, boolean isExport, Runnable ok) Displays a ListChooser with choices from the specified control. Modifies the control and returns true if the OK button is clicked.- Parameters:
trackerPanel
-control
- the XMLControlisExport
-ok
- run only if not canceled
-
copyXML
Copies an xml string representation of the specified object to the system clipboard.- Parameters:
obj
- the object to copy
-
copyTable
Copies data in the specified datatable to the system clipboard.- Parameters:
table
- the datatable to copyasFormatted
- true to retain table formattingheader
- the table header
-
copyImage
Copies the specified image to the system clipboard.- Parameters:
image
- the image to copy
-
getClipboardImage
Returns the image on the clipboard, if any.- Returns:
- the image, or null if none found
-
getData
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 dataasFormatted
- true to retain table formatting- Returns:
- a StringBuffer containing the data.
-
addCustomDelimiter
Adds a custom delimiter to the collection of delimiters- Parameters:
custom
- the delimiter to add
-
removeCustomDelimiter
Removes a custom delimiter from the collection of delimiters- Parameters:
custom
- the delimiter to remove
-
getVideoFormats
-
refreshVideoFormats
public static void refreshVideoFormats()Refreshes the format set. -
getVideoFormat
-
isImageFile
Returns true if the specified file is an image.- Parameters:
file
- the File- Returns:
- true if an image
-
isVideo
-
exportVideoImages
-
getImageBytes
- Throws:
IOException
-