Class VideoPanel

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, InteractiveMouseHandler, OSPRuntime.Disposable, Renderable
Direct Known Subclasses:
TrackerPanel

public class VideoPanel extends InteractivePanel implements PropertyChangeListener
This is an interactive drawing panel with a video player. It can draw videos and other Trackable objects in either imagespace or worldspace. When drawing in imagespace, the image reference frame (ie the image itself) is fixed. When drawing in worldspace, the world reference frame is fixed. The image reference frame defines positions in pixel units relative to the upper left corner of a video image--ie, the UL corner of a 320 x 240 video is at (0.0, 0.0) and the LR corner is at (320.0, 240.0). When drawing in imagespace, non-Trackable objects are not drawn.
Version:
1.0
Author:
Douglas Brown
See Also:
  • Field Details

    • defaultWidth

      protected static final int defaultWidth
      See Also:
    • defaultHeight

      protected static final int defaultHeight
      See Also:
    • PROPERTY_VIDEOPANEL_DATAFILE

      public static final String PROPERTY_VIDEOPANEL_DATAFILE
      See Also:
    • PROPERTY_VIDEOPANEL_IMAGESPACE

      public static final String PROPERTY_VIDEOPANEL_IMAGESPACE
      See Also:
    • changed

      public boolean changed
      set to true when this panel has been changed, false when saved
    • defaultFileName

      public String defaultFileName
      default file name used for initial saveAs
    • progress

      protected int progress
      progress and framesLoaded used to keep track of loading process
    • framesLoaded

      public int framesLoaded
    • player

      protected VideoPlayer player
    • video

      protected Video video
    • playerVisible

      protected boolean playerVisible
    • drawingInImageSpace

      protected boolean drawingInImageSpace
    • imageWidth

      protected double imageWidth
    • imageHeight

      protected double imageHeight
    • xOffset

      protected double xOffset
    • yOffset

      protected double yOffset
    • imageBorder

      protected double imageBorder
    • coords

      protected ImageCoordSystem coords
    • pt

      protected Point2D pt
    • dataFile

      protected File dataFile
    • timeUnit

      protected String timeUnit
    • filterClasses

      protected Map<String,Class<? extends Filter>> filterClasses
      map filter names to classes
    • loader

      protected VideoIO.FinalizableLoader loader
  • Constructor Details

    • VideoPanel

      public VideoPanel()
      Constructs a blank VideoPanel with a player.
    • VideoPanel

      public VideoPanel(Video video)
      Constructs a VideoPanel with a video and player.
      Parameters:
      video - the video to be drawn
  • Method Details

    • addVideoPlayer

      protected void addVideoPlayer()
    • setVideo

      public void setVideo(Video newVideo, boolean playAllSteps)
      Sets the video.
      Parameters:
      newVideo - the video
      playAllSteps - true to play all steps
    • setVideo

      public void setVideo(Video newVideo)
      Sets the video.
      Parameters:
      newVideo - the video
    • getVideo

      public Video getVideo()
      Gets the video.
      Returns:
      the video
    • getImageWidth

      public double getImageWidth()
      Gets the image width in image units.
      Returns:
      the width
    • setImageWidth

      public void setImageWidth(double w)
      Sets the image width in image units.
      Parameters:
      w - the width
    • getImageHeight

      public double getImageHeight()
      Gets the image height in image units (1.0 unit/pixel).
      Returns:
      the height
    • setImageHeight

      public void setImageHeight(double h)
      Sets the image height in image units (1.0 unit/pixel).
      Parameters:
      h - the height
    • getImageBorder

      public double getImageBorder()
      Gets the image border.
      Returns:
      the border fraction
    • setImageBorder

      public void setImageBorder(double borderFraction)
      Sets the image border.
      Parameters:
      borderFraction - the border fraction
    • getTimeUnit

      public String getTimeUnit()
      Gets the time unit
      Returns:
      unit the desired unit
    • setTimeUnit

      public boolean setTimeUnit(String unit)
      Sets the time unit.
      Parameters:
      unit - the time unit
      Returns:
      true if unit was changed
    • setCoords

      public void setCoords(ImageCoordSystem newCoords)
      Sets the image coordinate system used to convert between image and world spaces.
      Parameters:
      newCoords - the image coordinate system
    • getCoords

      public ImageCoordSystem getCoords()
      Gets the current image coordinate system used for drawing.
      Returns:
      the current image coordinate system
    • setDataFile

      public void setDataFile(File file)
      Sets the file in which data is saved.
      Parameters:
      file - the data file
    • getDataFile

      public File getDataFile()
      Gets the file where data is saved.
      Returns:
      the data file
    • getFilePath

      public String getFilePath()
      Gets the default path for the saveAs method.
      Returns:
      the relative path to the file
    • setDrawingInImageSpace

      public void setDrawingInImageSpace(boolean imagespace)
      Sets the drawing space to imagespace or worldspace.
      Parameters:
      imagespace - true to draw in imagespace
    • isDrawingInImageSpace

      public boolean isDrawingInImageSpace()
      Returns true if this is drawing in image space rather than world space.
      Returns:
      true if drawing in image space
    • getPlayer

      public VideoPlayer getPlayer()
      Gets the video player.
      Returns:
      the video player
    • setPlayerVisible

      public void setPlayerVisible(boolean visible)
      Shows or hides the video player.
      Parameters:
      visible - true to show the player
    • isPlayerVisible

      public boolean isPlayerVisible()
      Gets the video player visibility.
      Returns:
      true if the player is visible
    • getStepNumber

      public int getStepNumber()
      Gets the current step number.
      Returns:
      the current step number
    • getFrameNumber

      public int getFrameNumber()
      Gets the current frame number.
      Returns:
      the frame number
    • getDrawables

      public ArrayList<Drawable> getDrawables()
      Description copied from class: DrawingPanel
      Gets the cloned list of Drawable objects. This is a shallow clone. The same objects will be in both the drawable list and the cloned list.
      Overrides:
      getDrawables in class DrawingPanel
      Returns:
      cloned list
    • getDrawablesNoClone

      public ArrayList<Drawable> getDrawablesNoClone()
      Must clone if removing Trackable
      Overrides:
      getDrawablesNoClone in class DrawingPanel
    • addDrawable

      public void addDrawable(Drawable drawable)
      Adds a drawable object to the drawable list.
      Overrides:
      addDrawable in class InteractivePanel
      Parameters:
      drawable - the drawable object
    • removeDrawable

      public void removeDrawable(Drawable drawable)
      Removes a drawable object from the drawable list.
      Overrides:
      removeDrawable in class DrawingPanel
      Parameters:
      drawable - the drawable object
    • removeObjectsOfClass

      public <T extends Drawable> void removeObjectsOfClass(Class<T> c)
      Removes all objects of the specified class.
      Overrides:
      removeObjectsOfClass in class DrawingPanel
      Parameters:
      c - the class to remove
      See Also:
    • clear

      public void clear()
      Removes all drawable objects except the video. To remove the video, use setVideo(null);
      Overrides:
      clear in class InteractivePanel
    • addFilter

      public void addFilter(Class<? extends Filter> filterClass)
      Adds a video filter class to the map of available filters.
      Parameters:
      filterClass - the filter class to add
    • removeFilter

      public void removeFilter(Class<?> filterClass)
      Removes a video filter class from the map of available filters.
      Parameters:
      filterClass - the filter class to remove
    • clearFilters

      public void clearFilters()
      Clears all video filter classes from the map of available filters.
    • getFilters

      public Map<String,Class<? extends Filter>> getFilters()
      Gets the map of available video filters.
      Returns:
      the map of available video filters
    • hideMouseBox

      public void hideMouseBox()
      Hides the mouse box
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events. VideoPanel listens for the following events: "videoclip" and "stepnumber" from VideoPlayer, "coords" and "image" from Video.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - the property change event
    • importData

      public DataTrack importData(Data data, Object source)
      Imports Data from a source into a DataTrack. This method returns null, but superclass TrackerPanel overrides it and returns a DataTrack track. Source object may be String path, JPanel controlPanel, Tool tool, etc
      Parameters:
      data - the Data to import
      source - the data source (may be null)
      Returns:
      the DataTrack with the Data (may return null)
    • paintEverything

      protected void paintEverything(Graphics g)
      Overrides DrawingPanel paintEverything method.
      Overrides:
      paintEverything in class DrawingPanel
      Parameters:
      g - the graphics context to draw on
    • scale

      protected void scale(ArrayList<Drawable> drawables)
      Overrides DrawingPanel scale method to handle drawing in imagespace
      Overrides:
      scale in class DrawingPanel
      Parameters:
      drawables - the list of drawable objects
    • checkImage

      protected boolean checkImage()
      Overrides DrawingPanel checkImage method so offscreenImage will not include the videoPlayer.
      Returns:
      true if the image is correctly sized
    • getWorldMousePoint

      public Point2D getWorldMousePoint()
      Gets the world coordinates of the last mouse event
      Returns:
      world coordinates of last mouse event
    • getXYCoordinateStringBuilder

      public XYCoordinateStringBuilder getXYCoordinateStringBuilder(TPoint point)
      Gets a XYCoordinateStringBuilder for a TPoint to display its coordinates. This default implementation returns the static TPoint string builder.
      Parameters:
      point - the TPoint
      Returns:
      the XYCoordinateStringBuilder
    • getLoader

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

      public void setLoader(VideoIO.FinalizableLoader loader)
    • setResourceLoading

      public void setResourceLoading(Video video)
    • setProgress

      public void setProgress(int p)
    • getProgress

      public int getProgress()
    • releaseResources

      public void releaseResources()
      Video loading has failed.
    • offerReloadVM

      protected void offerReloadVM(String ext, String message)
    • dispose

      public void dispose()
      Specified by:
      dispose in interface OSPRuntime.Disposable
      Overrides:
      dispose in class InteractivePanel