Copyright 2013-01-06 Werner Randelshofer

org.monte.media.anim
Class ANIMPlayer

java.lang.Object
  extended by org.monte.media.AbstractPlayer
      extended by org.monte.media.anim.ANIMPlayer
All Implemented Interfaces:
java.lang.Runnable, ColorCyclePlayer, Player, StateModel

public class ANIMPlayer
extends AbstractPlayer
implements ColorCyclePlayer

Player for IFF cel animations.

Version:
3.0.2 2011-08-23 Frame duration was too long by one jiffie.
3.0.1 2010-12-25 Minor fixes for J2SE 5.
3.0 2010-08-04 Moved listener methods into inner class.
2.7 2010-08-03 Added support for blended color cycling.
2.6 2009-12-25 Added support for color cycling.
2.5 2009-11-20 Added support for bidirectional frames.
2.4 2006-10-01 Property "Debug" added.
2.3 2005-09-16 Property "SwapSpeakers" added.
2.2.1 2005-07-10 Do a full planar to chunky conversion if the palette changes regardless whether byte or integer chunky pixels are used.
2.2 2005-07-09 Made changes due to new threading model in class AbstractPlayer. Mute audio while timeModel value is adjusted by the user. Reimplemented support for preferred color model.
2.1.1 2005-05-04 Fixed a lifelock from occuring when no frames are contained in the animation file.
2.1 2004-01-22 Methods setPlayWrapupFrames and isPlayWrapupFrames added.
2.0 2003-04-26 Sound support added.
1.2.1 2003-04-02 Moved to package org.monte.media.anim from org.monte.media.
1.2 2003-03-30 More getters added.
1.1.1 2002-02-12 When player is started and playhead is at end, set playhead to start of timeline.
1.1 2000-10-02 Method #isPaused and #setPaused removed.
1.0 1999-10-19
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland

Field Summary
 
Fields inherited from class org.monte.media.AbstractPlayer
dispatcher, listenerList, propertyChangeSupport
 
Fields inherited from interface org.monte.media.Player
CLOSED, PREFETCHED, PREFETCHING, REALIZED, REALIZING, STARTED, UNREALIZED
 
Constructor Summary
ANIMPlayer(java.io.InputStream in)
           
ANIMPlayer(java.io.InputStream in, int inputFileSize, boolean loadAudio)
          Creates a new instance.
 
Method Summary
protected  void doClosed()
          Closes the player.
protected  void doPrefetched()
          Does the prefetched state.
protected  void doPrefetching()
          Does the prefetching state.
protected  void doRealized()
          Does the realized state.
protected  void doRealizing()
          Does the realizing state.
protected  void doStarted()
          Does the started state.
protected  void doUnrealized()
          Does the unrealized state.
 javax.swing.BoundedRangeModel getCachingModel()
          Returns the bounded range model that represents the amount of data being fetched from the file the movie is stored in.
 java.awt.Component getControlPanelComponent()
          Obtain the Component that provides the default user interface for controlling this Player.
 java.lang.String getDeltaOperationDescription()
           
protected  java.awt.image.ImageProducer getImageProducer()
          Returns the image producer that produces the animation frames.
 ANIMMovieTrack getMovieTrack()
          Returns the movie track.
 javax.swing.BoundedRangeModel getTimeModel()
          Returns the bounded range model that represents the time line of the player.
 long getTotalDuration()
          Returns the total duration in milliseconds.
 java.awt.Component getVisualComponent()
          Obtain the display Component for this Player.
 boolean isAudioAvailable()
          Returns true if audio is available.
 boolean isAudioEnabled()
          Returns true if audio playback is enabled.
 boolean isBlendedColorCycling()
          Returns true if colors are blended during color cycling.
 boolean isCached()
          Returns true when the player has completely cached all movie data.
 boolean isColorCyclingAvailable()
          Starts or stops color cycling.
 boolean isColorCyclingStarted()
          Returns true if color cycling is available in the movie track.
 boolean isLoop()
           
 boolean isPingPong()
           
 boolean isPlayEveryFrame()
           
 boolean isPlayWrapupFrames()
          Returns true, if the two wrapup frames at the end of the animation are treated like regular frames.
 boolean isSwapSpeakers()
          Returns true if left and right speakers are swapped.
 void setAudioEnabled(boolean newValue)
          Enables or disables audio playback.
 void setBlendedColorCycling(boolean newValue)
          Sets whether colors are blended during color cycling.
 void setColorCyclingStarted(boolean newValue)
          Starts or stops color cycling.
 void setDebug(boolean newValue)
          Set this to true to treat the two wrapup frames at the end of the animation like regular frames.
 void setFramesPerSecond(float framesPerSecond)
          Setting frames per second overrides all frame duration settings in the frames of the the movie track.
 void setGlobalFrameDuration(int frameDuration)
          Setting the global frame duration overrides all frame duration settings in the frames of the the movie track.
 void setLoop(boolean newValue)
           
 void setPingPong(boolean newValue)
           
 void setPlayEveryFrame(boolean newValue)
           
 void setPlayWrapupFrames(boolean newValue)
          Set this to true to treat the two wrapup frames at the end of the animation like regular frames.
 void setPreferredColorModel(java.awt.image.ColorModel cm)
          Sets the preferred color model.
 void setSwapSpeakers(boolean newValue)
          Swaps left and right speakers if set to true.
 
Methods inherited from class org.monte.media.AbstractPlayer
addChangeListener, addPropertyChangeListener, addStateListener, close, deallocate, fireStateChanged, fireStateChanged, getState, getTargetState, isActive, prefetch, realize, removeChangeListener, removePropertyChangeListener, removeStateListener, run, setTargetState, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.monte.media.Player
addChangeListener, addPropertyChangeListener, addStateListener, close, deallocate, getState, getTargetState, isActive, prefetch, realize, removeChangeListener, removePropertyChangeListener, removeStateListener, setTargetState, start, stop
 

Constructor Detail

ANIMPlayer

public ANIMPlayer(java.io.InputStream in)

ANIMPlayer

public ANIMPlayer(java.io.InputStream in,
                  int inputFileSize,
                  boolean loadAudio)
Creates a new instance.

Parameters:
in - InputStream containing an IFF ANIM file.
inputFileSize - The size of the input file. Provide the value -1 if this is not known.
loadAudio - Provide value false if this player should not load audio data.
Method Detail

setPreferredColorModel

public void setPreferredColorModel(java.awt.image.ColorModel cm)
Sets the preferred color model. If this color model is the same as the one used by the screen device showing the animation, then this may considerably improve the performance of the player. Setting this to null will let the player choose a color model that best suits the media being played. Calling this method has no effect, if the player is already realized.


getTimeModel

public javax.swing.BoundedRangeModel getTimeModel()
Returns the bounded range model that represents the time line of the player.

Specified by:
getTimeModel in interface Player

setAudioEnabled

public void setAudioEnabled(boolean newValue)
Enables or disables audio playback.

Specified by:
setAudioEnabled in interface Player

isAudioEnabled

public boolean isAudioEnabled()
Returns true if audio playback is enabled.

Specified by:
isAudioEnabled in interface Player

setSwapSpeakers

public void setSwapSpeakers(boolean newValue)
Swaps left and right speakers if set to true.


isSwapSpeakers

public boolean isSwapSpeakers()
Returns true if left and right speakers are swapped.


getCachingModel

public javax.swing.BoundedRangeModel getCachingModel()
Returns the bounded range model that represents the amount of data being fetched from the file the movie is stored in.

Specified by:
getCachingModel in interface Player

getImageProducer

protected java.awt.image.ImageProducer getImageProducer()
Returns the image producer that produces the animation frames.


getMovieTrack

public ANIMMovieTrack getMovieTrack()
Returns the movie track.


getVisualComponent

public java.awt.Component getVisualComponent()
Obtain the display Component for this Player. The display Component is where visual media is rendered. If this Player has no visual component, getVisualComponent returns null. For example, getVisualComponent might return null if the Player only plays audio.

Specified by:
getVisualComponent in interface Player

getControlPanelComponent

public java.awt.Component getControlPanelComponent()
Obtain the Component that provides the default user interface for controlling this Player. If this Player has no default control panel, getControlPanelComponent returns null.

Specified by:
getControlPanelComponent in interface Player

doUnrealized

protected void doUnrealized()
Does the unrealized state.

Specified by:
doUnrealized in class AbstractPlayer

doRealizing

protected void doRealizing()
Does the realizing state.

Specified by:
doRealizing in class AbstractPlayer

doRealized

protected void doRealized()
Does the realized state.

Specified by:
doRealized in class AbstractPlayer

doPrefetching

protected void doPrefetching()
Does the prefetching state.

Specified by:
doPrefetching in class AbstractPlayer

doPrefetched

protected void doPrefetched()
Does the prefetched state.

Specified by:
doPrefetched in class AbstractPlayer

setPlayEveryFrame

public void setPlayEveryFrame(boolean newValue)

setPlayWrapupFrames

public void setPlayWrapupFrames(boolean newValue)
Set this to true to treat the two wrapup frames at the end of the animation like regular frames.


setDebug

public void setDebug(boolean newValue)
Set this to true to treat the two wrapup frames at the end of the animation like regular frames.


isPlayWrapupFrames

public boolean isPlayWrapupFrames()
Returns true, if the two wrapup frames at the end of the animation are treated like regular frames.


setFramesPerSecond

public void setFramesPerSecond(float framesPerSecond)
Setting frames per second overrides all frame duration settings in the frames of the the movie track.

Parameters:
framesPerSecond - Frames per section. Set this to 0f if you do not want to override the frame durations in the frames of the movie track.

setGlobalFrameDuration

public void setGlobalFrameDuration(int frameDuration)
Setting the global frame duration overrides all frame duration settings in the frames of the the movie track.

Parameters:
frameDuration - Frame Duration in milliseconds. Set this to -1 if you do not want to override the frame durations in the frames of the movie track.

isPlayEveryFrame

public boolean isPlayEveryFrame()

setLoop

public void setLoop(boolean newValue)

isLoop

public boolean isLoop()

getDeltaOperationDescription

public java.lang.String getDeltaOperationDescription()

doStarted

protected void doStarted()
Does the started state. Is called by run(). Does not change the value of targetState but may change state in case of an error.

Specified by:
doStarted in class AbstractPlayer

doClosed

protected void doClosed()
Closes the player.

Specified by:
doClosed in class AbstractPlayer

getTotalDuration

public long getTotalDuration()
Returns the total duration in milliseconds.

Specified by:
getTotalDuration in interface Player

isCached

public boolean isCached()
Returns true when the player has completely cached all movie data. This player informs all property change listeners, when the value of this property changes. The name of the property is 'cached'.

Specified by:
isCached in interface Player

isAudioAvailable

public boolean isAudioAvailable()
Returns true if audio is available.

Specified by:
isAudioAvailable in interface Player

setPingPong

public void setPingPong(boolean newValue)

isPingPong

public boolean isPingPong()

isColorCyclingStarted

public boolean isColorCyclingStarted()
Returns true if color cycling is available in the movie track.

Specified by:
isColorCyclingStarted in interface ColorCyclePlayer

setColorCyclingStarted

public void setColorCyclingStarted(boolean newValue)
Starts or stops color cycling.

Specified by:
setColorCyclingStarted in interface ColorCyclePlayer

isColorCyclingAvailable

public boolean isColorCyclingAvailable()
Starts or stops color cycling.

Specified by:
isColorCyclingAvailable in interface ColorCyclePlayer

setBlendedColorCycling

public void setBlendedColorCycling(boolean newValue)
Sets whether colors are blended during color cycling.

Specified by:
setBlendedColorCycling in interface ColorCyclePlayer

isBlendedColorCycling

public boolean isBlendedColorCycling()
Returns true if colors are blended during color cycling.

Specified by:
isBlendedColorCycling in interface ColorCyclePlayer

Copyright 2013-01-06 Werner Randelshofer