Spectrogram
Class SpectrogramDisplay

java.lang.Object
  extended by Layout.PamFramePlots
      extended by userDisplay.UserFramePlots
          extended by Spectrogram.SpectrogramDisplay
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.InternalFrameListener, DisplayPanelContainer, LoadObserver, PamObserver

public class SpectrogramDisplay
extends UserFramePlots
implements PamObserver, LoadObserver, javax.swing.event.InternalFrameListener, DisplayPanelContainer


Nested Class Summary
(package private)  class SpectrogramDisplay.AmplitudePanel
           
(package private)  class SpectrogramDisplay.MenuPlayAll
           
(package private)  class SpectrogramDisplay.PlayProgress
           
(package private)  class SpectrogramDisplay.SettingsAction
           
(package private)  class SpectrogramDisplay.SpecPanelMouse
           
(package private)  class SpectrogramDisplay.SpectrogramAxis
          Need to extend PamAxisPanel in order to override the axis drawing to allow for the plug in panels at the bottom of the display.
(package private)  class SpectrogramDisplay.SpectrogramOuterPanel
           
(package private)  class SpectrogramDisplay.SpectrogramPanel
          Inner panels showing a single spectrogram display.
(package private)  class SpectrogramDisplay.SpectrogramPlotPanel
          Outer panel which contains the spectrogram outer panel and also all the plug in plots a the bottom
(package private)  class SpectrogramDisplay.SplitPaneListener
           
(package private)  class SpectrogramDisplay.ViewScrollObserver
           
 
Field Summary
private  PamAxis amplitudeAxis
           
private  java.awt.image.BufferedImage amplitudeImage
           
private  SpectrogramDisplay.AmplitudePanel amplitudePanel
           
private  double[][] colorValues
           
private  ColourArray colourArray
           
private  java.awt.Point currentMousePoint
           
private  java.util.ArrayList<PamDataBlock> detectorDataBlocks
           
private  DirectDrawProjector directDrawProjector
           
(package private)  DisplayPanelProvider displayPanelProvider
           
(package private)  java.util.Vector<DisplayPanel> displayPanels
           
private  boolean firstUpdate
           
private  java.awt.Color freezeColour
           
private  java.awt.Color freezeColour2
           
private  int[] freqBinRange
           
private  PamAxis frequencyAxis
           
private  PamLabel frequencyLabel
           
private  boolean frozen
           
private  int imageHeight
           
private  int imageWidth
           
private  java.lang.Object innerPanelSynchObject
           
private static int instanceCount
           
private  long lastReqEnd
           
private  long lastReqStart
           
private  java.awt.Point mouseDownPoint
           
private  long mouseDownTime
           
private  int nMarkObservers
           
(package private)  java.util.Vector<DisplayPanel> oldDisplayPanels
           
private  SpectrogramParameters oldLayoutParameters
           
private  double[] overlayColour
           
protected  ClipboardCopier panelClipBoardCopier
           
private  java.awt.Dimension panelSize
           
private  int playbackStatus
           
private  long playbackTimeMillis
           
private  java.awt.event.MouseAdapter popupListener
           
private  java.awt.Rectangle r
           
private  float sampleRate
           
private  double scaleX
           
private  double scaleY
           
private  FFTDataBlock sourceFFTDataBlock
           
private  PamRawDataBlock sourceRawDataBlock
           
private  SpectrogramDisplay.SpectrogramAxis spectrogramAxis
           
private  SpectrogramDisplay spectrogramDisplay
           
private  SpectrogramDisplay.SpectrogramOuterPanel spectrogramOuterPanel
           
private  SpectrogramDisplay.SpectrogramPanel[] spectrogramPanels
           
private  SpectrogramParameters spectrogramParameters
           
private  SpectrogramDisplay.SpectrogramPlotPanel spectrogramPlotPanel
           
private  SpectrogramProjector spectrogramProjector
           
private  PamAxis timeAxis
           
private  UserDisplayControl userDisplayControl
           
private  boolean viewerMode
           
private  PamScroller viewerScroller
           
private  int xAxisExtent
           
private  int yAxisExtent
           
 
Fields inherited from class userDisplay.UserFramePlots
FRAME_TYPE_RADAR, FRAME_TYPE_SPECTROGRAM
 
Fields inherited from interface Layout.DisplayPanelContainer
DRAW_BORDER
 
Constructor Summary
SpectrogramDisplay(UserDisplayControl userDisplayControl, SpectrogramParameters spectrogramParameters)
           
 
Method Summary
 void createAllImages()
          Called whenever the display size changes so that buffered images can be recreated.
private  void createColours()
           
private  void drawBackgroundImages()
          redraw the background images in viewer mode with new FFT data recreated from sound file data.
private  void fireMouseDownEvents(SpectrogramDisplay.SpectrogramPanel spectrogramPanel, java.awt.Point mouseDown)
           
private  void fireMouseUpEvents(SpectrogramDisplay.SpectrogramPanel spectrogramPanel, java.awt.Point mouseDown, java.awt.Point mouseUp)
           
private  void freezeImages(SpectrogramDisplay.SpectrogramPanel selectedPanel)
           
private  int getColourIndex(double dBLevel)
           
 double getCurrentXPixel()
          current pixel (need not be integer !
 long getCurrentXTime()
          get the time at the cursor in milliseconds
 int getFrameType()
           
 int getImageHeight()
           
 int getImageWidth()
          Width of the bitmap thats beeing drawn on - not the number of pixels, though these may often be the same.
 java.lang.String getName()
           
 java.lang.String getObserverName()
           
 PamObserver getObserverObject()
           
private  double getPixelFrequency(int pixel)
          convert a pixel number into a frequency.
private  long getPixelXTime(int pixel)
          Used to get the time in milliseconds from a pixel number when the user clicks on the display.
private  long getRelativePixelTime(int pixels)
           
 long getRequiredDataHistory(PamObservable o, java.lang.Object arg)
          Required data history depends on what's happening with the mouse.
 FFTDataBlock getSourceFFTDataBlock()
           
 PamRawDataBlock getSourceRawDataBlock()
           
 SpectrogramParameters getSpectrogramParameters()
           
(package private)  int getVariableWidth()
           
 double getXDuration()
          Get the display length in milliseconds.
 void internalFrameClosing(javax.swing.event.InternalFrameEvent e)
           
 void masterClockUpdate(long milliSeconds, long sampleNumber)
           
private  void newScrollTime()
           
 void noteNewSettings()
           
private  void notifyDisplayPanels(int noteType)
           
private  void notifyMarkObservers(int downUp, int channel, long startTime, long duration, double f1, double f2)
           
 void notifyModelChanged(int changeType)
           
 void PamToStart()
           
 void panelNotify(int noteType)
          notification from a display panel that it's necessary to perform some action - such as redrawing axis.
 void removeObservable(PamObservable o)
          called when an Observable (PamDataBlock) is removed from the system
 void repaintAll()
           
private  void requestFFTData()
           
private  void requestFFTData(long startMillis, long endMillis)
           
private  void setAxisLimits()
           
 void setLoadStatus(int loadState)
           
 void setParams(SpectrogramParameters newParameters)
           
 void setSampleRate(float sampleRate, boolean notify)
          New sample rate
 void setSettings()
           
private  void setupViewScroller()
          set up the page size on the view scroller and also sets up the range spinner
private  void subscribeDataBlocks()
          Create lists of data blocks that each panel is viewing so they can plot the data efficiently.
private  void subscribeViewScrollData()
          Subscribe overlaying data to the view scroller.
private  void unFreezeImages()
           
 void update(PamObservable obs, PamDataUnit newData)
          Informs the PamObserver that new data have been added to the Observable class
private  void updateChannel(PamObservable obs, AcousticDataUnit newData, int panelNumber)
           
 
Methods inherited from class userDisplay.UserFramePlots
getUserFrameParameters, internalFrameActivated, internalFrameClosed, internalFrameDeactivated, internalFrameDeiconified, internalFrameIconified, internalFrameOpened, setUserFrameParameters
 
Methods inherited from class Layout.PamFramePlots
getAxisPanel, getCopyMenuItem, getEastPanel, getFrame, getNorthPanel, getPlotPanel, getSouthPanel, getWestPanel, repaint, setAxisPanel, setEastPanel, setFrame, setNorthPanel, setPlotPanel, setSouthPanel, setWestPanel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.event.InternalFrameListener
internalFrameActivated, internalFrameClosed, internalFrameDeactivated, internalFrameDeiconified, internalFrameIconified, internalFrameOpened
 

Field Detail

spectrogramParameters

private SpectrogramParameters spectrogramParameters

oldLayoutParameters

private SpectrogramParameters oldLayoutParameters

spectrogramOuterPanel

private SpectrogramDisplay.SpectrogramOuterPanel spectrogramOuterPanel

spectrogramPanels

private SpectrogramDisplay.SpectrogramPanel[] spectrogramPanels

spectrogramAxis

private SpectrogramDisplay.SpectrogramAxis spectrogramAxis

amplitudePanel

private SpectrogramDisplay.AmplitudePanel amplitudePanel

spectrogramPlotPanel

private SpectrogramDisplay.SpectrogramPlotPanel spectrogramPlotPanel

sourceFFTDataBlock

private FFTDataBlock sourceFFTDataBlock

sourceRawDataBlock

private PamRawDataBlock sourceRawDataBlock

spectrogramDisplay

private SpectrogramDisplay spectrogramDisplay

amplitudeImage

private java.awt.image.BufferedImage amplitudeImage

imageWidth

private int imageWidth

imageHeight

private int imageHeight

colorValues

private double[][] colorValues

colourArray

private ColourArray colourArray

overlayColour

private double[] overlayColour

instanceCount

private static int instanceCount

sampleRate

private float sampleRate

timeAxis

private PamAxis timeAxis

frequencyAxis

private PamAxis frequencyAxis

amplitudeAxis

private PamAxis amplitudeAxis

freqBinRange

private int[] freqBinRange

scaleX

private double scaleX

scaleY

private double scaleY

panelSize

private java.awt.Dimension panelSize

r

private java.awt.Rectangle r

xAxisExtent

private int xAxisExtent

yAxisExtent

private int yAxisExtent

spectrogramProjector

private SpectrogramProjector spectrogramProjector

directDrawProjector

private DirectDrawProjector directDrawProjector

firstUpdate

private boolean firstUpdate

detectorDataBlocks

private java.util.ArrayList<PamDataBlock> detectorDataBlocks

popupListener

private java.awt.event.MouseAdapter popupListener

nMarkObservers

private int nMarkObservers

viewerScroller

private PamScroller viewerScroller

freezeColour

private java.awt.Color freezeColour

freezeColour2

private java.awt.Color freezeColour2

frozen

private boolean frozen

frequencyLabel

private PamLabel frequencyLabel

innerPanelSynchObject

private java.lang.Object innerPanelSynchObject

mouseDownPoint

private java.awt.Point mouseDownPoint

currentMousePoint

private java.awt.Point currentMousePoint

mouseDownTime

private long mouseDownTime

panelClipBoardCopier

protected ClipboardCopier panelClipBoardCopier

viewerMode

private boolean viewerMode

userDisplayControl

private UserDisplayControl userDisplayControl

playbackTimeMillis

private long playbackTimeMillis

playbackStatus

private int playbackStatus

lastReqStart

private long lastReqStart

lastReqEnd

private long lastReqEnd

displayPanelProvider

DisplayPanelProvider displayPanelProvider

displayPanels

java.util.Vector<DisplayPanel> displayPanels

oldDisplayPanels

java.util.Vector<DisplayPanel> oldDisplayPanels
Constructor Detail

SpectrogramDisplay

public SpectrogramDisplay(UserDisplayControl userDisplayControl,
                          SpectrogramParameters spectrogramParameters)
Method Detail

getObserverObject

public PamObserver getObserverObject()
Specified by:
getObserverObject in interface PamObserver
Returns:
the actual observer. In most cases concrete classes will just return 'this' in response. The exception is the Threaded observer, which will return the single thread observer.

getName

public java.lang.String getName()
Overrides:
getName in class UserFramePlots

setParams

public void setParams(SpectrogramParameters newParameters)

repaintAll

public void repaintAll()

getImageWidth

public int getImageWidth()
Width of the bitmap thats beeing drawn on - not the number of pixels, though these may often be the same.

Returns:
the width of the image in pixels

getImageHeight

public int getImageHeight()

createAllImages

public void createAllImages()
Called whenever the display size changes so that buffered images can be recreated.


setAxisLimits

private void setAxisLimits()

createColours

private void createColours()

getVariableWidth

int getVariableWidth()

setSampleRate

public void setSampleRate(float sampleRate,
                          boolean notify)
Description copied from interface: PamObserver
New sample rate

Specified by:
setSampleRate in interface PamObserver
notify - Notify other PamObservers and PamObservables in the chain.

masterClockUpdate

public void masterClockUpdate(long milliSeconds,
                              long sampleNumber)
Specified by:
masterClockUpdate in interface PamObserver

PamToStart

public void PamToStart()

getRequiredDataHistory

public long getRequiredDataHistory(PamObservable o,
                                   java.lang.Object arg)
Required data history depends on what's happening with the mouse. If the mouse is doing nothing and there are no SpectrogramMarkObservers then no data needs to be stored for drawing the spectrogram. If there are mark observers and the mouse is up, then make sure that at least one screen full of data is always in memory (both FFT data and Raw wave data). If the mouse is down, then keep the maximum of either one screen full of from whenever the mouse was pressed - the use may hold it down for a long time !

Specified by:
getRequiredDataHistory in interface PamObserver
Parameters:
o - PamObservable class requiring the data
arg - optional argument from PamObservable
Returns:
time in milliseconds requried by data held in PamObservable
See Also:
SpectrogramMarkObserver

getObserverName

public java.lang.String getObserverName()
Specified by:
getObserverName in interface PamObserver

update

public void update(PamObservable obs,
                   PamDataUnit newData)
Description copied from interface: PamObserver
Informs the PamObserver that new data have been added to the Observable class

Specified by:
update in interface PamObserver
Parameters:
obs - Reference to the Observable (a PamDataBlock)
newData - Reference to the new PamDataUnit

setLoadStatus

public void setLoadStatus(int loadState)
Specified by:
setLoadStatus in interface LoadObserver

updateChannel

private void updateChannel(PamObservable obs,
                           AcousticDataUnit newData,
                           int panelNumber)

getColourIndex

private int getColourIndex(double dBLevel)

setSettings

public void setSettings()

setupViewScroller

private void setupViewScroller()
set up the page size on the view scroller and also sets up the range spinner


subscribeDataBlocks

private void subscribeDataBlocks()
Create lists of data blocks that each panel is viewing so they can plot the data efficiently.


subscribeViewScrollData

private void subscribeViewScrollData()
Subscribe overlaying data to the view scroller.


requestFFTData

private void requestFFTData()

requestFFTData

private void requestFFTData(long startMillis,
                            long endMillis)

drawBackgroundImages

private void drawBackgroundImages()
redraw the background images in viewer mode with new FFT data recreated from sound file data.


freezeImages

private void freezeImages(SpectrogramDisplay.SpectrogramPanel selectedPanel)

unFreezeImages

private void unFreezeImages()

getSpectrogramParameters

public SpectrogramParameters getSpectrogramParameters()

notifyModelChanged

public void notifyModelChanged(int changeType)
Specified by:
notifyModelChanged in class UserFramePlots

newScrollTime

private void newScrollTime()

internalFrameClosing

public void internalFrameClosing(javax.swing.event.InternalFrameEvent e)
Specified by:
internalFrameClosing in interface javax.swing.event.InternalFrameListener
Overrides:
internalFrameClosing in class UserFramePlots

noteNewSettings

public void noteNewSettings()
Specified by:
noteNewSettings in interface PamObserver

removeObservable

public void removeObservable(PamObservable o)
Description copied from interface: PamObserver
called when an Observable (PamDataBlock) is removed from the system

Specified by:
removeObservable in interface PamObserver

getPixelXTime

private long getPixelXTime(int pixel)
Used to get the time in milliseconds from a pixel number when the user clicks on the display. Since the display is wrapping around, this time is always going to be less than the currentXTime below.

Parameters:
pixel -
Returns:
time in milliseconds

getRelativePixelTime

private long getRelativePixelTime(int pixels)
Parameters:
pixels -
Returns:
time in milliseconds

getPixelFrequency

private double getPixelFrequency(int pixel)
convert a pixel number into a frequency.

Parameters:
pixel -
Returns:
frequency in Hz

getCurrentXPixel

public double getCurrentXPixel()
Description copied from interface: DisplayPanelContainer
current pixel (need not be integer !

Specified by:
getCurrentXPixel in interface DisplayPanelContainer

getCurrentXTime

public long getCurrentXTime()
Description copied from interface: DisplayPanelContainer
get the time at the cursor in milliseconds

Specified by:
getCurrentXTime in interface DisplayPanelContainer

getXDuration

public double getXDuration()
Get the display length in milliseconds.

Specified by:
getXDuration in interface DisplayPanelContainer

panelNotify

public void panelNotify(int noteType)
Description copied from interface: DisplayPanelContainer
notification from a display panel that it's necessary to perform some action - such as redrawing axis.

Specified by:
panelNotify in interface DisplayPanelContainer

notifyDisplayPanels

private void notifyDisplayPanels(int noteType)

notifyMarkObservers

private void notifyMarkObservers(int downUp,
                                 int channel,
                                 long startTime,
                                 long duration,
                                 double f1,
                                 double f2)

getFrameType

public int getFrameType()
Specified by:
getFrameType in class UserFramePlots

fireMouseDownEvents

private void fireMouseDownEvents(SpectrogramDisplay.SpectrogramPanel spectrogramPanel,
                                 java.awt.Point mouseDown)

fireMouseUpEvents

private void fireMouseUpEvents(SpectrogramDisplay.SpectrogramPanel spectrogramPanel,
                               java.awt.Point mouseDown,
                               java.awt.Point mouseUp)

getSourceFFTDataBlock

public FFTDataBlock getSourceFFTDataBlock()

getSourceRawDataBlock

public PamRawDataBlock getSourceRawDataBlock()