org.opensourcephysics.media.gif
Class GifVideo

java.lang.Object
  extended by org.opensourcephysics.media.core.VideoAdapter
      extended by org.opensourcephysics.media.gif.GifVideo
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Drawable, Interactive, Measurable, DrawableImage, InteractiveImage, Playable, Trackable, Video

public class GifVideo
extends VideoAdapter

This is a video that wraps an animated gif image.

Version:
1.0
Author:
Douglas Brown

Field Summary
protected  GifDecoder decoder
           
protected  int[] startTimes
           
 
Fields inherited from class org.opensourcephysics.media.core.VideoAdapter
aspects, bufferedImage, clearRaster, coords, endFrameNumber, filteredImage, filterStack, frameCount, frameNumber, isMeasured, isValidFilteredImage, isValidImage, isValidMeasure, looping, maxX, maxY, minX, minY, mouseEnabled, playing, properties, rate, rawImage, size, startFrameNumber, support, visible, widthDominates
 
Constructor Summary
GifVideo(java.lang.String gifName)
          Creates a GifVideo and loads a gif image specified by name
 
Method Summary
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the video image on the panel.
protected  void finalize()
          Called by the garbage collector when this video is no longer in use.
 double getDuration()
          Gets the duration of the video.
 double getEndTime()
          Gets the end time in milliseconds.
 double getFrameTime(int n)
          Gets the start time of the specified frame in milliseconds.
static XML.ObjectLoader getLoader()
          Returns an XML.ObjectLoader to save and load GifVideo data.
 double getStartTime()
          Gets the start time in milliseconds.
 double getTime()
          Gets the current video time in milliseconds.
protected  void load(java.lang.String gifName)
          Loads a gif image specified by name.
 void play()
          Plays the video at the current rate.
 void setEndTime(double millis)
          Sets the end time in milliseconds.
 void setFrameNumber(int n)
          Overrides ImageVideo setFrameNumber method.
 void setStartTime(double millis)
          Sets the start time in milliseconds.
 void setTime(double millis)
          Sets the video time in milliseconds.
 void stop()
          Stops the video.
 
Methods inherited from class org.opensourcephysics.media.core.VideoAdapter
addPropertyChangeListener, addPropertyChangeListener, back, dispose, findInteractive, findMinMaxValues, firePropertyChange, getAngle, getCoords, getEndFrameNumber, getFilterStack, getFrameCount, getFrameDuration, getFrameNumber, getHeight, getImage, getProperty, getPropertyNames, getRate, getRelativeAspect, getStartFrameNumber, getWidth, getX, getXMax, getXMin, getY, getYMax, getYMin, goToEnd, goToStart, initialize, isEnabled, isLooping, isMeasured, isPlaying, isVisible, propertyChange, refreshBufferedImage, removePropertyChangeListener, removePropertyChangeListener, reset, setAngle, setCoords, setEnabled, setEndFrameNumber, setFilterStack, setFrameAngle, setFrameHeight, setFrameRelativeAspect, setFrameWidth, setFrameX, setFrameXY, setFrameY, setHeight, setLooping, setPlaying, setProperty, setRate, setRelativeAspect, setStartFrameNumber, setVisible, setWidth, setX, setXY, setY, step
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decoder

protected GifDecoder decoder

startTimes

protected int[] startTimes
Constructor Detail

GifVideo

public GifVideo(java.lang.String gifName)
         throws java.io.IOException
Creates a GifVideo and loads a gif image specified by name

Parameters:
gifName - the name of the image file
Throws:
java.io.IOException
Method Detail

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Draws the video image on the panel.

Specified by:
draw in interface Drawable
Overrides:
draw in class VideoAdapter
Parameters:
panel - the drawing panel requesting the drawing
g - the graphics context on which to draw

finalize

protected void finalize()
Called by the garbage collector when this video is no longer in use.

Overrides:
finalize in class VideoAdapter

play

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

Specified by:
play in interface Playable
Overrides:
play in class VideoAdapter

stop

public void stop()
Stops the video.

Specified by:
stop in interface Playable
Overrides:
stop in class VideoAdapter

setFrameNumber

public void setFrameNumber(int n)
Overrides ImageVideo setFrameNumber method.

Specified by:
setFrameNumber in interface Video
Overrides:
setFrameNumber in class VideoAdapter
Parameters:
n - the desired frame number
See Also:
Video.getStartFrameNumber(), Video.getEndFrameNumber()

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

getTime

public double getTime()
Gets the current video time in milliseconds.

Specified by:
getTime in interface Playable
Overrides:
getTime in class VideoAdapter
Returns:
the current time in milliseconds, or -1 if not known

setTime

public void setTime(double millis)
Sets the video time in milliseconds.

Specified by:
setTime in interface Playable
Overrides:
setTime in class VideoAdapter
Parameters:
millis - the desired time in milliseconds

getStartTime

public double getStartTime()
Gets the start time in milliseconds.

Specified by:
getStartTime in interface Playable
Overrides:
getStartTime in class VideoAdapter
Returns:
the start time in milliseconds, or -1 if not known

setStartTime

public void setStartTime(double millis)
Sets the start time in milliseconds. NOTE: the actual start time is normally set to the beginning of a frame.

Specified by:
setStartTime in interface Playable
Overrides:
setStartTime in class VideoAdapter
Parameters:
millis - the desired start time in milliseconds

getEndTime

public double getEndTime()
Gets the end time in milliseconds.

Specified by:
getEndTime in interface Playable
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 Playable
Overrides:
setEndTime in class VideoAdapter
Parameters:
millis - the desired end time in milliseconds

getDuration

public double getDuration()
Gets the duration of the video.

Specified by:
getDuration in interface Playable
Overrides:
getDuration in class VideoAdapter
Returns:
the duration of the video in milliseconds, or -1 if not known

load

protected void load(java.lang.String gifName)
             throws java.io.IOException
Loads a gif image specified by name.

Parameters:
gifName - the gif image name
Throws:
java.io.IOException

getLoader

public static XML.ObjectLoader getLoader()
Returns an XML.ObjectLoader to save and load GifVideo data.

Returns:
the object loader