Class ImageVideo

All Implemented Interfaces:
PropertyChangeListener, EventListener, Drawable, Interactive, Measurable, DrawableImage, InteractiveImage, Trackable, Video

public class ImageVideo extends VideoAdapter
This is a Video assembled from one or more still images.
Version:
1.0
Author:
Douglas Brown
  • Field Details

    • observer

      protected Component observer
    • images

      protected Image[] images
    • rgbImage

      protected BufferedImage rgbImage
    • paths

      protected String[] paths
    • readOnly

      protected boolean readOnly
    • deltaT

      protected double deltaT
    • rgbSize

      protected Dimension rgbSize
  • Constructor Details

    • ImageVideo

      public ImageVideo(String imageName, String basePath, boolean sequence) throws IOException
      Creates a read-only ImageVideo and loads a named image or image sequence. The standard constructor.
      Parameters:
      imageName - the name of the image file
      sequence - true to automatically load image sequence, if any
      Throws:
      IOException
    • ImageVideo

      public ImageVideo(String imageName) throws IOException
      Creates a read-only ImageVideo and loads a named image or image sequence, asking the user if they want just the first image or all, if numbers are found. No reference to this constructor in osp, ejs, or tracker
      Parameters:
      imageName - the name of the image file
      Throws:
      IOException
    • ImageVideo

      public ImageVideo(Image clipBoardImage)
      Creates an editable ImageVideo from an image pasted from the clipboard. No questions are asked.
      Parameters:
      clipBoardImage - the image
    • ImageVideo

      public ImageVideo(ImageVideo video)
      Creates an editable ImageVideo from another ImageVideo Replaces ImageVideo(BufferedImage[]) BH: Code moved here from VideoIO Called by VideoIO.clone (which is not referenced?), untested.
      Parameters:
      images - the image array
  • Method Details

    • play

      public void play()
      Plays the video at the current rate.
    • stop

      public void stop()
      Stops the video.
    • setFrameNumber

      public void setFrameNumber(int n)
      Description copied from class: VideoAdapter
      Sets the video frame number.
      Specified by:
      setFrameNumber in interface Video
      Overrides:
      setFrameNumber in class VideoAdapter
      Parameters:
      n - the desired frame number
      See Also:
    • setFrameDuration

      public void setFrameDuration(double millis)
      Sets the frame duration in milliseconds.
      Parameters:
      millis - the desired frame duration in milliseconds
    • getEndTime

      public double getEndTime()
      Gets the end time in milliseconds.
      Specified by:
      getEndTime in interface Video
      Overrides:
      getEndTime in class VideoAdapter
      Returns:
      the end time in milliseconds, or -1 if not known
    • setEndTime

      public void setEndTime(double millis)
      Sets the end time in milliseconds. NOTE: the actual end time is set to the end of a frame.
      Specified by:
      setEndTime in interface Video
      Overrides:
      setEndTime in class VideoAdapter
      Parameters:
      millis - the desired end time in milliseconds
    • getFrameCountDurationMS

      public double getFrameCountDurationMS()
      Gets the duration of the video.
      Returns:
      the duration of the video in milliseconds, or -1 if not known
    • getFrameTime

      public double getFrameTime(int n)
      Gets the start time of the specified frame in milliseconds.
      Specified by:
      getFrameTime in interface Video
      Overrides:
      getFrameTime in class VideoAdapter
      Parameters:
      n - the frame number
      Returns:
      the start time of the frame in milliseconds, or -1 if not known
    • getImages

      public Image[] getImages()
      Gets the image array.
      Returns:
      the image array
    • append

      public void append(String imageName) throws IOException
      Appends the named image or image sequence to the end of this video. This method will ask user whether to load sequences, if any.
      Parameters:
      imageName - the image name
      Throws:
      IOException
    • append

      public void append(String imageName, boolean sequence) throws IOException
      Appends the named image or image sequence to the end of this video.
      Parameters:
      imageName - the image name
      sequence - true to automatically load image sequence, if any
      Throws:
      IOException
    • insert

      public void insert(String imageName, int index) throws IOException
      Inserts the named image or image sequence at the specified index. This method will ask user whether to load sequences, if any.
      Parameters:
      imageName - the image name
      index - the index
      Throws:
      IOException
    • insert

      public void insert(String imageName, int index, boolean sequence) throws IOException
      Inserts the named image or image sequence at the specified index.
      Parameters:
      imageName - the image name
      index - the index
      sequence - true to automatically load image sequence, if any
      Throws:
      IOException
    • insert

      public void insert(Image image, int index)
      Inserts an image at the specified index.
      Parameters:
      image - the image
      index - the index
    • remove

      public String remove(int index)
      Removes the image at the specified index.
      Parameters:
      index - the index
      Returns:
      the path of the image, or null if none removed
    • getRGBSize

      public Dimension getRGBSize()
      Gets the RGB size of this image video.
      Returns:
      the RGB size of the current image
    • isFileBased

      public boolean isFileBased()
      Returns true if all of the images are associated with files.
      Returns:
      true if all images are file-based
    • isEditable

      public boolean isEditable()
      Returns true if all images are loaded into memory.
      Returns:
      true if editable
    • setEditable

      public void setEditable(boolean edit) throws IOException
      Sets the editable property.
      Parameters:
      edit - true to edit
      Throws:
      IOException
    • saveInvalidImages

      public boolean saveInvalidImages()
      Allows user to save invalid images, if any.
      Returns:
      true if saved
    • getValidPaths

      public String[] getValidPaths()
      Returns the valid paths (i.e., those that are not ""). Invalid paths are associated with pasted images rather than files.
      Returns:
      the valid paths
    • getValidPathsRelativeTo

      protected String[] getValidPathsRelativeTo(String base)
      Returns the valid paths (i.e., those that are not "") relative to a base path. Invalid paths are associated with pasted images rather than files.
      Parameters:
      base - a base path
      Returns:
      the valid relative paths
    • insert

      protected void insert(Image[] newImages, int index, String[] imagePaths)
      Inserts images starting at the specified index.
      Parameters:
      newImages - an array of images. May be null if readOnly
      index - the insertion index
      imagePaths - array of image file paths.
    • updateBufferedImage

      protected void updateBufferedImage()
      Overrides:
      updateBufferedImage in class VideoAdapter
    • getImage

      public BufferedImage getImage()
      Gets the current video image after applying enabled filters.
      Specified by:
      getImage in interface DrawableImage
      Overrides:
      getImage in class VideoAdapter
      Returns:
      the current video image with filters applied
    • getNextImagePathInSequence

      public static String getNextImagePathInSequence(String imagePath)
    • getStackPaths

      public static ArrayList<String> getStackPaths(String imagePath)
      Returns a list of all numbered images that follow the original name pattern. Note this does NOT check to see if the path resources exist.
      Returns:
      the list
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns an XML.ObjectLoader to save and load ImageVideo data.
      Returns:
      the object loader
    • getTypeName

      public String getTypeName()
      Description copied from interface: Video
      Returns the VideoType name of this video.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setStartTimes

      protected void setStartTimes()
      Specified by:
      setStartTimes in class VideoAdapter