Class VideoGrabber

java.lang.Object
org.opensourcephysics.tools.VideoCaptureTool
org.opensourcephysics.media.core.VideoGrabber
All Implemented Interfaces:
Tool, VideoTool

public class VideoGrabber extends VideoCaptureTool
A video capture utility using media classes.
Version:
1.0
Author:
Douglas Brown
  • Field Details

    • VIDEO_CAPTURE_TOOL

      public static VideoGrabber VIDEO_CAPTURE_TOOL
      A shared video capture tool.
  • Constructor Details

    • VideoGrabber

      public VideoGrabber()
      Constructor that uses default video dimensions.
    • VideoGrabber

      public VideoGrabber(Dimension dim)
      Constructor that sets the video dimensions.
      Parameters:
      dim - the dimension
  • Method Details

    • getTool

      public static VideoGrabber getTool()
      Gets the shared VideoGrabber.
      Returns:
      the shared VideoGrabber
    • getTool

      public static VideoGrabber getTool(Dimension dim)
      Gets the shared VideoGrabber and sets the video dimensions.
      Parameters:
      dim - the dimension
      Returns:
      the shared VideoGrabber
    • clear

      public void clear()
      Clear the video from the tool in preparation for a new video.
      Specified by:
      clear in interface VideoTool
      Overrides:
      clear in class VideoCaptureTool
    • addFrame

      public boolean addFrame(BufferedImage image)
      Adds a frame to the video if it is recording.
      Specified by:
      addFrame in interface VideoTool
      Overrides:
      addFrame in class VideoCaptureTool
      Parameters:
      image - the frame to be added
      Returns:
      true if frame was added
    • setVisible

      public void setVisible(boolean visible)
      Sets the visibility.
      Specified by:
      setVisible in interface VideoTool
      Overrides:
      setVisible in class VideoCaptureTool
      Parameters:
      visible - true to set this visible
    • isVisible

      public boolean isVisible()
      Gets the visibility.
      Overrides:
      isVisible in class VideoCaptureTool
      Returns:
      true if visible
    • setRecording

      public void setRecording(boolean record)
      Sets the recording flag.
      Overrides:
      setRecording in class VideoCaptureTool
      Parameters:
      record - true to record rendered images
    • isRecording

      public boolean isRecording()
      Gets the recording flag.
      Specified by:
      isRecording in interface VideoTool
      Overrides:
      isRecording in class VideoCaptureTool
      Returns:
      true if recording rendered images
    • setVideoType

      public void setVideoType(VideoType type)
      Sets the video type.
      Overrides:
      setVideoType in class VideoCaptureTool
      Parameters:
      type - the video type
    • setFrameRate

      public void setFrameRate(double fps)
      Sets the frame rate.
      Overrides:
      setFrameRate in class VideoCaptureTool
      Parameters:
      fps - the frame rate in frames per second
    • saveVideoAs

      public String saveVideoAs()
      Saves the video to a file and returns the file name.
      Returns:
      the name of the file, or null if not saved
    • getRecorder

      public VideoRecorder getRecorder()
      Gets the video recorder.
      Returns:
      the VideoRecorder
    • createGUI

      protected void createGUI()
      Creates the GUI.
    • createActions

      protected void createActions()
      Creates the actions.
    • refreshGUI

      protected void refreshGUI()
      Refreshes the GUI.