org.opensourcephysics.media.core
Class ClipControl

java.lang.Object
  extended by org.opensourcephysics.media.core.ClipControl
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
StepperClipControl, VideoClipControl

public abstract class ClipControl
extends java.lang.Object
implements java.beans.PropertyChangeListener

A ClipControl controls a VideoClip. This is an abstract class that cannot be instantiated directly.

Version:
1.0
Author:
Douglas Brown

Field Summary
protected  VideoClip clip
           
protected  boolean looping
           
protected  double rate
           
protected  int stepNumber
           
protected  java.beans.PropertyChangeSupport support
           
protected  double timeStretch
           
protected  Video video
           
protected  int videoFrameNumber
           
 
Constructor Summary
protected ClipControl(VideoClip videoClip)
          Constructs a ClipControl object.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 void back()
          Steps back one step.
 void dispose()
          Empty dispose method.
static ClipControl getControl(VideoClip clip)
          Returns an instance of ClipControl.
 int getFrameNumber()
          Gets the current frame number.
abstract  double getMeanFrameDuration()
          Gets the average frame duration in milliseconds.
 double getRate()
          Gets the play rate.
 int getStepNumber()
          Gets the step number.
abstract  double getStepTime(int stepNumber)
          Gets the start time of the specified step measured from step 0.
abstract  double getTime()
          Gets the current time in milliseconds measured from step 0.
 VideoClip getVideoClip()
          Gets the clip that is controlled by this clip control.
 boolean isLooping()
          Gets the looping status.
abstract  boolean isPlaying()
          Gets the playing status.
 void play()
          Plays the clip.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener.
 void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener for a specified property.
abstract  void setFrameDuration(double duration)
          Sets the frame duration.
 void setFrameNumber(int n)
          Sets the frame number.
 void setLooping(boolean loops)
          Turns on/off looping.
 void setRate(double newRate)
          Sets the play rate.
 void setStepNumber(int n)
          Sets the step number.
 void step()
          Steps forward one step.
 void stop()
          Stops at the next step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stepNumber

protected int stepNumber

videoFrameNumber

protected int videoFrameNumber

clip

protected final VideoClip clip

video

protected Video video

rate

protected double rate

looping

protected boolean looping

support

protected java.beans.PropertyChangeSupport support

timeStretch

protected double timeStretch
Constructor Detail

ClipControl

protected ClipControl(VideoClip videoClip)
Constructs a ClipControl object. This is an abstract class that cannot be instantiated directly.

Parameters:
videoClip - the video clip
Method Detail

getControl

public static ClipControl getControl(VideoClip clip)
Returns an instance of ClipControl.

Parameters:
clip - the video clip
Returns:
an appropriate clip control

getVideoClip

public VideoClip getVideoClip()
Gets the clip that is controlled by this clip control.

Returns:
the clip

play

public void play()
Plays the clip.


stop

public void stop()
Stops at the next step.


step

public void step()
Steps forward one step.


back

public void back()
Steps back one step.


setFrameNumber

public void setFrameNumber(int n)
Sets the frame number.

Parameters:
n - the desired frame number

setStepNumber

public void setStepNumber(int n)
Sets the step number.

Parameters:
n - the desired step number

getStepNumber

public int getStepNumber()
Gets the step number.

Returns:
the current step number

setRate

public void setRate(double newRate)
Sets the play rate.

Parameters:
newRate - the desired rate

getRate

public double getRate()
Gets the play rate.

Returns:
the current rate

setLooping

public void setLooping(boolean loops)
Turns on/off looping.

Parameters:
loops - true to turn looping on

isLooping

public boolean isLooping()
Gets the looping status.

Returns:
true if looping is on

getFrameNumber

public int getFrameNumber()
Gets the current frame number.

Returns:
the frame number

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the property change event

isPlaying

public abstract boolean isPlaying()
Gets the playing status.

Returns:
true if playing

getTime

public abstract double getTime()
Gets the current time in milliseconds measured from step 0.

Returns:
the current time

getStepTime

public abstract double getStepTime(int stepNumber)
Gets the start time of the specified step measured from step 0.

Parameters:
stepNumber - the step number
Returns:
the step time

setFrameDuration

public abstract void setFrameDuration(double duration)
Sets the frame duration.

Parameters:
duration - the desired frame duration in milliseconds

getMeanFrameDuration

public abstract double getMeanFrameDuration()
Gets the average frame duration in milliseconds.

Returns:
the mean frame duration in milliseconds

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener.

Parameters:
listener - the object requesting property change notification

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String property,
                                      java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener.

Parameters:
property - the name of the property of interest
listener - the object requesting property change notification

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener.

Parameters:
listener - the listener requesting removal

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String property,
                                         java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener for a specified property.

Parameters:
property - the name of the property
listener - the listener to remove

dispose

public void dispose()
Empty dispose method.