Class TrackerIO

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

public class TrackerIO extends VideoIO
This provides static methods for managing video and text input/output.
Author:
Douglas Brown
  • Field Details

    • NULL_RUNNABLE

      public static final Runnable NULL_RUNNABLE
    • isffmpegError

      protected static boolean isffmpegError
    • theFrame

      protected static TFrame theFrame
    • ffmpegListener

      protected static PropertyChangeListener ffmpegListener
    • defaultBadFrameTolerance

      protected static double defaultBadFrameTolerance
    • dataCopiedToClipboard

      protected static boolean dataCopiedToClipboard
    • videoFormatDescriptions

      protected static TreeSet<String> videoFormatDescriptions
    • videoFormats

      protected static HashMap<String,VideoType> videoFormats
    • selectedVideoFormat

      public static String 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

      public static Map<String,String> 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

      public static File save(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 File saveTabset(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

      @Deprecated public static File[] getChooserFiles(String type)
      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 - TODO
      type - 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

      protected static File fixXML(File file)
    • getChooserFileForName

      public static File getChooserFileForName(String name)
      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

      public static boolean loadFiles(TFrame frame, List<File> fileList, TrackerPanel targetPanel)
      From FileDropHandler
      Parameters:
      fileList -
      targetPanel -
      Returns:
    • openFileFromDialog

      public static void openFileFromDialog(File file, TFrame frame, Runnable whenDone)
      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
      whenDone - to do when completed, or null
    • openURL

      public static org.opensourcephysics.cabrillo.tracker.TrackerIO.AsyncLoader openURL(String path, TFrame frame, Runnable whenDone)
    • 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 loaded
      frame - the frame for the TrackerPanels
    • importFile

      public static void 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
    • importXMLAction

      protected static void importXMLAction(TrackerPanel trackerPanel, File file)
    • 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

      public static void importVideo(TrackerPanel trackerPanel, Runnable whenDone)
      Imports chooser-selected video to the specified tracker panel.
      Parameters:
      trackerPanel - the tracker panel
    • importVideo

      public static void importVideo(String path, TrackerPanel trackerPanel, Runnable whenDone)
    • 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 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:
      null if dialog or a BitSet indicating frames with odd durations
    • insertImagesIntoVideo

      public static void insertImagesIntoVideo(TrackerPanel trackerPanel, int startIndex)
      Inserts chooser-selected images into an ImageVideo on a TrackerPanel.
      Parameters:
      trackerPanel - the TrackerPanel
      startIndex - the insertion index
    • insertImagesIntoVideo

      public static File[] insertImagesIntoVideo(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
    • exportXMLFile

      public static void exportXMLFile(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
    • 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 XMLControl
      isExport -
      ok - run only if not canceled
    • copyXML

      public static void copyXML(Object obj)
      Copies an xml string representation of the specified object to the system clipboard.
      Parameters:
      obj - the object to copy
    • copyTable

      public static void copyTable(DataTable table, boolean asFormatted, 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(Image image)
      Copies the specified image to the system clipboard.
      Parameters:
      image - the image to copy
    • getClipboardImage

      public static Image getClipboardImage()
      Returns the image on the clipboard, if any.
      Returns:
      the image, or null if none found
    • getData

      public static 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.
    • addCustomDelimiter

      public static void addCustomDelimiter(String custom)
      Adds a custom delimiter to the collection of delimiters
      Parameters:
      custom - the delimiter to add
    • removeCustomDelimiter

      public static void removeCustomDelimiter(String custom)
      Removes a custom delimiter from the collection of delimiters
      Parameters:
      custom - the delimiter to remove
    • getVideoFormats

      protected static Object[] getVideoFormats()
    • refreshVideoFormats

      public static void refreshVideoFormats()
      Refreshes the format set.
    • getVideoFormat

      public static String getVideoFormat(String preferredExtension)
    • isImageFile

      public static boolean isImageFile(File file)
      Returns true if the specified file is an image.
      Parameters:
      file - the File
      Returns:
      true if an image
    • isVideo

      public static boolean isVideo(File f)
    • exportVideoImages

      public static void exportVideoImages(TrackerPanel panel, String exportVideoName)
    • getImageBytes

      public static byte[] getImageBytes(TrackerPanel panel, int i) throws IOException
      Throws:
      IOException