com.groovemanager.sampled.waveform
Class SavePeakWaveFormThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.groovemanager.thread.ProgressThread
          extended by com.groovemanager.sampled.waveform.SavePeakWaveFormThread
All Implemented Interfaces:
java.lang.Runnable

public class SavePeakWaveFormThread
extends ProgressThread

This ProgressThread implementation can be used to save the data from a WaveForm into a peak file

Author:
Manu Robledo

Nested Class Summary
 
Nested classes inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int iSize
          The interval size
protected  long lastModified
          The last modification date of the audio file or -1, if it is not known
protected  java.io.OutputStream out
          The OutputStream to write to
protected  WaveForm source
          The WaveForm to get the peak data from
protected  int written
          The number of snapshots written so far
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SavePeakWaveFormThread(ProgressListener mon, WaveForm source, int iSize, java.io.OutputStream out, long lastModified)
          Create a new SavePeakWaveFormThread using the given interval size that will be monitored by the given ProgressListener
SavePeakWaveFormThread(WaveForm source, int iSize, java.io.OutputStream out, long lastModified)
          Create a new SavePeakWaveFormThread using the given interval size
SavePeakWaveFormThread(WaveForm source, java.io.OutputStream out, long lastModified)
          Create a new SavePeakWaveFormThread using the interval size of the given WaveForm.
 
Method Summary
protected  boolean breakCondition()
          The break condition to indicate that the operation has finished
protected  void cleanUp()
          Free any ressources and perform clean up operations.
protected  void init()
          Any kind of initialization in the moment right before starting the operation should be performed here
protected  void processNext()
          Perform the next step.
protected  java.lang.Object result()
          Specify the result of this operation, if any.
protected  int tellElapsed()
          Tell the length of the operation elapsed so for
protected  int tellTotal()
          Tell the total length of the operation
 
Methods inherited from class com.groovemanager.thread.ProgressThread
cancelOperation, getElapsed, getErrorMessage, getResult, getTotal, hasFinished, run, setMonitor
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iSize

protected int iSize
The interval size


lastModified

protected long lastModified
The last modification date of the audio file or -1, if it is not known


out

protected java.io.OutputStream out
The OutputStream to write to


source

protected WaveForm source
The WaveForm to get the peak data from


written

protected int written
The number of snapshots written so far

Constructor Detail

SavePeakWaveFormThread

public SavePeakWaveFormThread(ProgressListener mon,
                              WaveForm source,
                              int iSize,
                              java.io.OutputStream out,
                              long lastModified)
Create a new SavePeakWaveFormThread using the given interval size that will be monitored by the given ProgressListener

Parameters:
mon - The ProgressListener to monitor the progress
source - The WaveForm to get the peak data from
iSize - The interval size to use
out - The OutputStream to write to
lastModified - last modification date of the audio file or -1, if it is not known

SavePeakWaveFormThread

public SavePeakWaveFormThread(WaveForm source,
                              int iSize,
                              java.io.OutputStream out,
                              long lastModified)
Create a new SavePeakWaveFormThread using the given interval size

Parameters:
source - The WaveForm to get the peak data from
iSize - The interval size to use
out - The OutputStream to write to
lastModified - last modification date of the audio file or -1, if it is not known

SavePeakWaveFormThread

public SavePeakWaveFormThread(WaveForm source,
                              java.io.OutputStream out,
                              long lastModified)
Create a new SavePeakWaveFormThread using the interval size of the given WaveForm.

Parameters:
source - The WaveForm to get the peak data from
out - The OutputStream to write to
lastModified - last modification date of the audio file or -1, if it is not known
Method Detail

breakCondition

protected boolean breakCondition()
Description copied from class: ProgressThread
The break condition to indicate that the operation has finished

Specified by:
breakCondition in class ProgressThread
Returns:
true, if the operation has finished and the thread should therefore come to its end, false otherwise

cleanUp

protected void cleanUp()
Description copied from class: ProgressThread
Free any ressources and perform clean up operations. This methos will be called, if the operation has been cancelled, if an Exception is thrown by processNext(), or if the operation has been finished as expected.

Specified by:
cleanUp in class ProgressThread

init

protected void init()
Description copied from class: ProgressThread
Any kind of initialization in the moment right before starting the operation should be performed here

Specified by:
init in class ProgressThread

processNext

protected void processNext()
                    throws java.io.IOException
Description copied from class: ProgressThread
Perform the next step. This method will be called repeatedly as long as
- tellElpased() < tellTotal() and
- breakCondition() != true and
- The thread has not been cancelled

Specified by:
processNext in class ProgressThread
Throws:
java.io.IOException

result

protected java.lang.Object result()
Description copied from class: ProgressThread
Specify the result of this operation, if any.

Specified by:
result in class ProgressThread
Returns:
Any kind of object representing the result of the performed operation. null should onlx be returned, if the operation didnīt finish correctly. If it did finish correctly, but it has no result, a dummy object should be returned.

tellElapsed

protected int tellElapsed()
Description copied from class: ProgressThread
Tell the length of the operation elapsed so for

Specified by:
tellElapsed in class ProgressThread
Returns:
The elapsed length of the operation. The unit to use for this value is free defineable

tellTotal

protected int tellTotal()
Description copied from class: ProgressThread
Tell the total length of the operation

Specified by:
tellTotal in class ProgressThread
Returns:
The total length of the operation. The unit to use for this value is free defineable