jAER project on SourceForge

ch.unizh.ini.jaer.projects.opticalflow.graphics
Class MotionViewer.Player

java.lang.Object
  extended by ch.unizh.ini.jaer.projects.opticalflow.graphics.MotionViewer.Player
All Implemented Interfaces:
InputDataFileInterface
Enclosing class:
MotionViewer

public class MotionViewer.Player
extends java.lang.Object
implements InputDataFileInterface

this class handles file input of AEs to control the number of events/sample or period of time in the sample, etc. It handles the file input stream, opening a dialog box, etc. It also handles synchronization of different viewers as follows:

If the viwer is not synchronized, then all calls from the GUI are passed directly to this instance of AEPlayer. Thus local control always happens.

If the viewer is sychronized, then all GUI calls pass instead to the CaviarViewer instance that contains (or started) this viewer. Then the CaviarViewer AEPlayer calls all the viewers to take the player action (e.g. rewind, go to next slice, change direction).

Thus whichever controls the user uses to control playback, the viewers are all sychronized properly without recursively. The "master" is indicated by the GUI action, which routes the request either to this instance's AEPlayer or to the CaviarViewer AEPlayer.


Nested Class Summary
 class MotionViewer.Player.FileDeleter
           
 
Constructor Summary
MotionViewer.Player()
           
 
Method Summary
 float getFractionalPosition()
           
 MotionInputStream getMotionInputStream()
           
 MotionData getNextData()
           
 int getTime()
           
 boolean isChoosingFile()
           
 boolean isPaused()
          gets the MotionViewer paused flag
 boolean isPlayingForwards()
           
 void mark()
          mark the current position.
 void openInputFileDialog()
          called when user asks to open data file file dialog
 void pause()
           
 int position()
          return position in events
 void position(int event)
          set position in units of the file, e.g.
 void resume()
           
 void rewind()
          rewind to the start, or to the marked position, if it has been set
 void setFractionalPosition(float frac)
          Sets fractional position in units of the file
 void setPaused(boolean yes)
          sets the MotionViewer paused flag
 void setTime(int time)
           
 long size()
           
 void slowDown()
           
 void speedUp()
           
 void startPlayback(java.io.File file)
           
 void stopPlayback()
          stops playback.
 void toggleDirection()
           
 void unmark()
          clear any marked position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MotionViewer.Player

public MotionViewer.Player()
Method Detail

isChoosingFile

public boolean isChoosingFile()

openInputFileDialog

public void openInputFileDialog()
called when user asks to open data file file dialog


startPlayback

public void startPlayback(java.io.File file)
                   throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

stopPlayback

public void stopPlayback()
stops playback. If not in PLAYBACK mode, then just returns. If playing back, could be waiting during sleep or during CyclicBarrier.await call in CaviarViewer. In case this is the case, we send an interrupt to the the ViewLoop thread to stop this waiting.


rewind

public void rewind()
Description copied from interface: InputDataFileInterface
rewind to the start, or to the marked position, if it has been set

Specified by:
rewind in interface InputDataFileInterface

pause

public void pause()

resume

public void resume()

setPaused

public void setPaused(boolean yes)
sets the MotionViewer paused flag


isPaused

public boolean isPaused()
gets the MotionViewer paused flag


getNextData

public MotionData getNextData()

toggleDirection

public void toggleDirection()

speedUp

public void speedUp()

slowDown

public void slowDown()

isPlayingForwards

public boolean isPlayingForwards()

getFractionalPosition

public float getFractionalPosition()
Specified by:
getFractionalPosition in interface InputDataFileInterface
Returns:
fractional position in total events

mark

public void mark()
          throws java.io.IOException
Description copied from interface: InputDataFileInterface
mark the current position.

Specified by:
mark in interface InputDataFileInterface
Throws:
java.io.IOException - if there is some error in reading the data

position

public int position()
Description copied from interface: InputDataFileInterface
return position in events

Specified by:
position in interface InputDataFileInterface

position

public void position(int event)
Description copied from interface: InputDataFileInterface
set position in units of the file, e.g. events or frames

Specified by:
position in interface InputDataFileInterface
Parameters:
event - the number to position to

size

public long size()
Specified by:
size in interface InputDataFileInterface
Returns:
size in units of the file

unmark

public void unmark()
Description copied from interface: InputDataFileInterface
clear any marked position

Specified by:
unmark in interface InputDataFileInterface

setFractionalPosition

public void setFractionalPosition(float frac)
Description copied from interface: InputDataFileInterface
Sets fractional position in units of the file

Specified by:
setFractionalPosition in interface InputDataFileInterface
Parameters:
frac - 0-1 float range, 0 at start, 1 at end

setTime

public void setTime(int time)

getTime

public int getTime()

getMotionInputStream

public MotionInputStream getMotionInputStream()

jAER project on SourceForge