jAER project on SourceForge

net.sf.jaer.graphics
Class AEViewer.AEPlayer

java.lang.Object
  extended by net.sf.jaer.graphics.AEViewer.AEPlayer
All Implemented Interfaces:
AEFileInputStreamInterface, InputDataFileInterface, AEPlayerInterface, PlayerInterface
Enclosing class:
AEViewer

public class AEViewer.AEPlayer
extends java.lang.Object
implements AEFileInputStreamInterface, AEPlayerInterface

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 AEViewers as follows (this refers to multiple-AEViewer time-locked playback sychronization, not java object locking):

If the viewer 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 synchronized, 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 AEViewer.AEPlayer.FileDeleter
           
 
Constructor Summary
AEViewer.AEPlayer()
           
 
Method Summary
 AEFileInputStream getAEInputStream()
           
 float getFractionalPosition()
           
 AEPacketRaw getNextPacket()
           
 AEPacketRaw getNextPacket(AEPlayerInterface player)
           
 int getSampleNumEvents()
           
 int getSamplePeriodUs()
           
 int getTime()
          Return time in us in player
 boolean isChoosingFile()
          returns true if user is choosing a file
 boolean isFlexTimeEnabled()
           
 boolean isNonMonotonicTimeExceptionsChecked()
          Checking for wrapped time exceptions can be disabled for reasons of speed or corrupted data files.
 boolean isPaused()
          gets the AEViewer paused flag
 boolean isPlayingForwards()
           
 void mark()
          mark the current position.
 void openAEInputFileDialog()
          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.
 AEPacketRaw readPacketByNumber(int n)
          Reads a raw event packet of n events
 AEPacketRaw readPacketByTime(int dt)
          returns an AEPacketRaw at least dt long up to the max size of the buffer or until end-of-file.
 void resume()
           
 void rewind()
          rewind to the start, or to the marked position, if it has been set
 void setFlexTimeEnabled(boolean flexTimeEnabled)
           
 void setFractionalPosition(float frac)
          Sets fractional position in units of the file
 void setNonMonotonicTimeExceptionsChecked(boolean yes)
          Sets whether the input stream is checked for timestamp nonmonotonicity.
 void setPaused(boolean yes)
          sets the AEViewer paused flag
 void setSampleNumEvents(int sampleNumEvents)
           
 void setSamplePeriodUs(int samplePeriodUs)
           
 void setTime(int time)
           
 long size()
           
 void slowDown()
           
 void speedUp()
           
 void startPlayback(java.io.File file)
          Starts playback on the data 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

AEViewer.AEPlayer

public AEViewer.AEPlayer()
Method Detail

isChoosingFile

public boolean isChoosingFile()
Description copied from interface: PlayerInterface
returns true if user is choosing a file

Specified by:
isChoosingFile in interface PlayerInterface

openAEInputFileDialog

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

Specified by:
openAEInputFileDialog in interface AEPlayerInterface

startPlayback

public void startPlayback(java.io.File file)
                   throws java.io.IOException
Starts playback on the data file. If the file is an index file, the JAERViewer is called to start playback of the set of data files. Fires a property change event "fileopen", after playMode is changed to PLAYBACK.

Specified by:
startPlayback in interface PlayerInterface
Parameters:
file - the File to play
Throws:
java.io.IOException

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.

Specified by:
stopPlayback in interface PlayerInterface

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
Specified by:
rewind in interface PlayerInterface

pause

public void pause()
Specified by:
pause in interface PlayerInterface

resume

public void resume()
Specified by:
resume in interface PlayerInterface

setPaused

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

Specified by:
setPaused in interface PlayerInterface

isPaused

public boolean isPaused()
gets the AEViewer paused flag

Specified by:
isPaused in interface PlayerInterface

getNextPacket

public AEPacketRaw getNextPacket()
Specified by:
getNextPacket in interface AEPlayerInterface

getNextPacket

public AEPacketRaw getNextPacket(AEPlayerInterface player)
Specified by:
getNextPacket in interface AEPlayerInterface

toggleDirection

public void toggleDirection()
Specified by:
toggleDirection in interface PlayerInterface

speedUp

public void speedUp()
Specified by:
speedUp in interface AEPlayerInterface

slowDown

public void slowDown()
Specified by:
slowDown in interface AEPlayerInterface

isPlayingForwards

public boolean isPlayingForwards()
Specified by:
isPlayingForwards in interface PlayerInterface

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
Specified by:
mark in interface PlayerInterface
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

readPacketByNumber

public AEPacketRaw readPacketByNumber(int n)
                               throws java.io.IOException
Description copied from interface: AEFileInputStreamInterface
Reads a raw event packet of n events

Specified by:
readPacketByNumber in interface AEFileInputStreamInterface
Parameters:
n - the number of events to read
Throws:
java.io.IOException - if there is a problem, e.g. end of file

readPacketByTime

public AEPacketRaw readPacketByTime(int dt)
                             throws java.io.IOException
Description copied from interface: AEFileInputStreamInterface
returns an AEPacketRaw at least dt long up to the max size of the buffer or until end-of-file. Events are read as long as the timestamp until (and including) the event whose timestamp is greater (for dt>0) than startTimestamp+dt, where startTimestamp is the last timestamp from the previous call.

Specified by:
readPacketByTime in interface AEFileInputStreamInterface
Parameters:
dt - the timestamp different in units of the timestamp (usually us)
Returns:
the packet, always at least one event even if there is no event in the interval dt.
Throws:
java.io.IOException - if there is any problem

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
Specified by:
unmark in interface PlayerInterface

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)
Specified by:
setTime in interface PlayerInterface

getTime

public int getTime()
Description copied from interface: PlayerInterface
Return time in us in player

Specified by:
getTime in interface PlayerInterface

isFlexTimeEnabled

public boolean isFlexTimeEnabled()

setFlexTimeEnabled

public void setFlexTimeEnabled(boolean flexTimeEnabled)

getSamplePeriodUs

public int getSamplePeriodUs()
Specified by:
getSamplePeriodUs in interface AEPlayerInterface

setSamplePeriodUs

public void setSamplePeriodUs(int samplePeriodUs)

getSampleNumEvents

public int getSampleNumEvents()
Specified by:
getSampleNumEvents in interface AEPlayerInterface

setSampleNumEvents

public void setSampleNumEvents(int sampleNumEvents)

getAEInputStream

public AEFileInputStream getAEInputStream()
Specified by:
getAEInputStream in interface AEPlayerInterface

isNonMonotonicTimeExceptionsChecked

public boolean isNonMonotonicTimeExceptionsChecked()
Description copied from interface: AEFileInputStreamInterface
Checking for wrapped time exceptions can be disabled for reasons of speed or corrupted data files.

Specified by:
isNonMonotonicTimeExceptionsChecked in interface AEFileInputStreamInterface
Returns:
true if exceptions are checked (default)

setNonMonotonicTimeExceptionsChecked

public void setNonMonotonicTimeExceptionsChecked(boolean yes)
Description copied from interface: AEFileInputStreamInterface
Sets whether the input stream is checked for timestamp nonmonotonicity.

Specified by:
setNonMonotonicTimeExceptionsChecked in interface AEFileInputStreamInterface
Parameters:
yes - true to check (default).

jAER project on SourceForge