clickDetector
Class ClickBTDisplay

java.lang.Object
  extended by Layout.PamFramePlots
      extended by clickDetector.ClickDisplay
          extended by clickDetector.ClickBTDisplay
All Implemented Interfaces:
PamSettings, PamObserver

public class ClickBTDisplay
extends ClickDisplay
implements PamObserver, PamSettings


Nested Class Summary
private  class ClickBTDisplay.AmplitudeScaleManager
           
(package private)  class ClickBTDisplay.AxesMenuAction
           
private  class ClickBTDisplay.BearingScaleManager
           
(package private)  class ClickBTDisplay.BTAxis
           
(package private)  class ClickBTDisplay.BTListener
           
(package private)  class ClickBTDisplay.BTPlot
           
(package private)  class ClickBTDisplay.BTPlotFrame
          Panel which sits around the BTPlot panel and primarily acts as a container for the scroll bars
(package private)  class ClickBTDisplay.ChannelGroupAction
           
private  class ClickBTDisplay.ClassifyClick
           
private  class ClickBTDisplay.clickPUListener
           
(package private)  class ClickBTDisplay.ColourBySpeciesAction
           
(package private)  class ClickBTDisplay.ColourByTrainAction
           
 class ClickBTDisplay.FollowBoxListener
           
(package private)  class ClickBTDisplay.HScrollManager
           
(package private)  class ClickBTDisplay.HScrollObserver
           
private  class ClickBTDisplay.ICIScaleManager
           
(package private)  class ClickBTDisplay.OfflineScrollManager
           
 class ClickBTDisplay.PlotKeyListener
           
(package private)  class ClickBTDisplay.PlotMouse
           
(package private)  class ClickBTDisplay.RealTimeScrollManager
           
(package private)  class ClickBTDisplay.SettingsMenuAction
           
(package private)  class ClickBTDisplay.ShowKeyAction
           
private  class ClickBTDisplay.TimeRangeListener
           
(package private)  class ClickBTDisplay.TopControls
           
(package private)  class ClickBTDisplay.VScaleManager
          Class for managing vertical scales and scrolls which will either be bearing, ICI or Amplitude.
(package private)  class ClickBTDisplay.VScrollListener
           
(package private)  class ClickBTDisplay.ZoomableInterface
          setup the horizontal scroll bar
 
Field Summary
private  ClickBTDisplay.BTAxis btAxis
           
private  BTDisplayParameters btDisplayParameters
           
private  ClickBTDisplay.BTPlot btPlot
           
private  ClickControl clickControl
           
private  javax.swing.JPopupMenu clickPopupMenu
           
 PamLabel cursorLabel
           
private static PamSymbol defaultSymbol
           
private  boolean didFollow
           
private  long displayLengthMillis
          Current Display length in samples.
private  int displayNumber
           
private  long displayStartMillis
          Current Display Window start time in milliseconds
private  javax.swing.JCheckBox followCheckBox
           
private  boolean hasData
           
private  PamSymbol highlightSymbol
           
private  PamScroller hScrollBar
           
private  ClickBTDisplay.HScrollManager hScrollManager
           
private  int lastAxisType
           
(package private)  long lastRawScrollCheck
           
private  java.util.ArrayList<ClickDetection> markedClicks
           
private static int minPaintTime
           
private  boolean mouseDown
           
private  OfflineEventDataBlock offlineEventDatablock
           
private  ClickDetection popupClick
           
 RangeSpinner rangeSpinner
           
private  float sampleRate
           
private  int scrollChecks
           
private  ClickDetection selectedClick
           
private  javax.swing.JLabel timeLabel
           
private  int[] timeRanges
          Available time ranges for the BT display in seconds.
private  ClickBTDisplay.TopControls topControls
           
private  PamDataBlock<ClickDetection> trackedClicks
           
private  ClickBTDisplay.VScaleManager[] vScaleManagers
           
private  javax.swing.JScrollBar vScrollBar
           
private  PamAxis xAxis
           
private  double xScale
           
private  PamAxis yAxis
           
private  double yScale
           
private  double yStart
           
private  Zoomer zoomer
           
 
Fields inherited from class clickDetector.ClickDisplay
clickDisplayInfo, clickDisplayManager
 
Constructor Summary
ClickBTDisplay(ClickControl clickControl, ClickDisplayManager clickDisplayManager, ClickDisplayManager.ClickDisplayInfo clickDisplayInfo)
           
 
Method Summary
private  double amplitudeFromYPos(int yPos)
           
private  double angleFromYPos(int yPos)
           
private  void changedEvent(OfflineEventDataUnit event)
           
private  double clickAmplitudeToY(ClickDetection click)
           
private  double clickAngleToY(ClickDetection click)
           
 void clickedOnClick(ClickDetection click)
           
private  double clickICIToY(ClickDetection click)
           
private  boolean clickInMarkedArea(ClickDetection click)
          Test whether or not a click is within a marked area on the screen
(package private)  boolean clickInTimeWindow(ClickDetection click)
           
private  int clickXPos(ClickDetection click)
           
private  java.awt.Point clickXYPos(ClickDetection click)
          check horizontal scroll bar during real time operation.
private  int clickYPos(ClickDetection click)
           
 void created()
           
protected  void finalize()
           
(package private)  ClickDetection findClick(int x, int y, int maxdist)
           
private  double getClickHeight(ClickDetection click)
           
private  javax.swing.JPopupMenu getClickPUMenu(ClickDetection click)
           
(package private) static PamSymbol getClickSymbol(ClickDetection click)
           
(package private) static PamSymbol getClickSymbol(ClickIdentifier clickIdentifier, ClickDetection click)
           
(package private) static PamSymbol getClickSymbol(ClickIdentifier clickIdentifier, ClickDetection click, int colourType)
           
(package private) static PamSymbol getClickSymbol(int eventId)
           
private  double getClickWidth(ClickDetection click)
           
(package private) static PamSymbol getDefaultSymbol()
           
(package private) static PamSymbol getDefaultSymbol(boolean makeClone)
           
 int getDisplayChannels()
           
private  long getDisplayLength()
           
private  long getDisplayStartMillis()
           
private  ClickDetection getFirstSelectableClick()
           
private  ClickDetection getLastSelectableClick()
           
 java.util.ArrayList<ClickDetection> getMarkedClicks()
           
 java.lang.String getName()
           
 java.lang.String getObserverName()
           
 PamObserver getObserverObject()
           
private  javax.swing.JPopupMenu getPopupMenu(ClickDetection clickedClick)
           
 long getRequiredDataHistory(PamObservable o, java.lang.Object arg)
           
 ClickDetection getSelectedClick()
           
 java.io.Serializable getSettingsReference()
           
 long getSettingsVersion()
           
private  int getTimeRangeMillis()
           
private  double getTimeRangeSeconds()
          Get the display time range
 java.lang.String getUnitName()
           
 java.lang.String getUnitType()
           
private  ClickBTDisplay.VScaleManager getVScaleManager()
           
private  ClickBTDisplay.VScaleManager getVScaleManager(int vScaleType)
           
 void gotoEvent(OfflineEventDataUnit event)
          Scroll the display to a specific event.
private  double iciFromYPos(int yPos)
           
 void makeMarkedClickList()
          Called when a zoom polygon has been completed and immediately makes a list of all marked clicks.
 void masterClockUpdate(long milliSeconds, long sampleNumber)
           
private  void maybeShowPopup(java.awt.event.MouseEvent e)
           
private  long millisFromXPos(int xPos)
           
 void newClick(ClickDetection clickDataUnit)
           
 void newRawData(PamDataBlock rawDataBlock, RawDataUnit newRawData)
           
 void noteNewSettings()
           
 void notifyNewStorage(java.lang.String storageName)
           
 void offlineDataChanged()
          Called from clicksOffline when data have changed (eg from re doing click id).
 void pamStart()
           
 void removeObservable(PamObservable o)
          called when an Observable (PamDataBlock) is removed from the system
private  void repaintBoth()
          Repaints both the plot and the axis panel
 void reset()
          Called just before data collection starts
 boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
           
private  void sayCursorInfo(java.awt.Point pt)
           
private  boolean selectClick(int relClick)
          Select the next or the preceding click
 void setDisplayChannels(int displayChannels)
           
 void setSampleRate(float sampleRate, boolean notify)
          New sample rate
private  void setScales()
          Sets the x and y scales.
 void setSelectedClick(ClickDetection selectedClick)
           
(package private)  void setVScale(int scaleType)
           
(package private)  boolean shouldPlot(ClickDetection click)
          Return true if the click should be plotted on the current display using the following tests:
(package private)  boolean shouldPlotSpecies(int iSpecies)
           
private  void trackClick(ClickDetection click)
           
private  boolean trackClick(java.awt.event.MouseEvent e)
          See if the mouse is on a click to be tracked with the mouse.
private  void trackClickMenu(java.awt.event.MouseEvent e, ClickDetection click)
           
 void update(PamObservable obs, PamDataUnit newData)
          Informs the PamObserver that new data have been added to the Observable class
private  boolean view360()
           
 
Methods inherited from class clickDetector.ClickDisplay
getClickDisplayInfo
 
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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clickControl

private ClickControl clickControl

btDisplayParameters

private BTDisplayParameters btDisplayParameters

hScrollBar

private PamScroller hScrollBar

trackedClicks

private PamDataBlock<ClickDetection> trackedClicks

btPlot

private ClickBTDisplay.BTPlot btPlot

btAxis

private ClickBTDisplay.BTAxis btAxis

topControls

private ClickBTDisplay.TopControls topControls

timeLabel

private javax.swing.JLabel timeLabel

followCheckBox

private javax.swing.JCheckBox followCheckBox

yAxis

private PamAxis yAxis

xAxis

private PamAxis xAxis

lastAxisType

private int lastAxisType

displayNumber

private int displayNumber

hasData

private boolean hasData

zoomer

private Zoomer zoomer

vScrollBar

private javax.swing.JScrollBar vScrollBar

vScaleManagers

private ClickBTDisplay.VScaleManager[] vScaleManagers

offlineEventDatablock

private OfflineEventDataBlock offlineEventDatablock

timeRanges

private int[] timeRanges
Available time ranges for the BT display in seconds.


displayStartMillis

private long displayStartMillis
Current Display Window start time in milliseconds


displayLengthMillis

private long displayLengthMillis
Current Display length in samples.


sampleRate

private float sampleRate

xScale

private double xScale

yScale

private double yScale

yStart

private double yStart

mouseDown

private boolean mouseDown

didFollow

private boolean didFollow

defaultSymbol

private static PamSymbol defaultSymbol

scrollChecks

private int scrollChecks

selectedClick

private ClickDetection selectedClick

hScrollManager

private ClickBTDisplay.HScrollManager hScrollManager

minPaintTime

private static final int minPaintTime
See Also:
Constant Field Values

highlightSymbol

private PamSymbol highlightSymbol

cursorLabel

public PamLabel cursorLabel

lastRawScrollCheck

long lastRawScrollCheck

popupClick

private ClickDetection popupClick

clickPopupMenu

private javax.swing.JPopupMenu clickPopupMenu

rangeSpinner

public RangeSpinner rangeSpinner

markedClicks

private java.util.ArrayList<ClickDetection> markedClicks
Constructor Detail

ClickBTDisplay

public ClickBTDisplay(ClickControl clickControl,
                      ClickDisplayManager clickDisplayManager,
                      ClickDisplayManager.ClickDisplayInfo clickDisplayInfo)
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.

created

public void created()
Overrides:
created in class ClickDisplay

getRequiredDataHistory

public long getRequiredDataHistory(PamObservable o,
                                   java.lang.Object arg)
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

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

changedEvent

private void changedEvent(OfflineEventDataUnit event)

newClick

public void newClick(ClickDetection clickDataUnit)

getDisplayLength

private long getDisplayLength()
Returns:
display length in milliseconds

getDisplayStartMillis

private long getDisplayStartMillis()

newRawData

public void newRawData(PamDataBlock rawDataBlock,
                       RawDataUnit newRawData)

getObserverName

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

reset

public void reset()
Called just before data collection starts


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

setScales

private void setScales()
Sets the x and y scales. Should be used in the same way both in real time and offline.


getVScaleManager

private ClickBTDisplay.VScaleManager getVScaleManager()
Returns:
the appropriate manager for the vertical scale.

getVScaleManager

private ClickBTDisplay.VScaleManager getVScaleManager(int vScaleType)
Parameters:
vScaleType - type of vertical scaleS
Returns:
the appropriate manager for the vertical scale.

getTimeRangeSeconds

private double getTimeRangeSeconds()
Get the display time range

Returns:
time range in seconds.

getTimeRangeMillis

private int getTimeRangeMillis()

offlineDataChanged

public void offlineDataChanged()
Description copied from class: ClickDisplay
Called from clicksOffline when data have changed (eg from re doing click id). Needs to notify the display and maybe some other classes.

Overrides:
offlineDataChanged in class ClickDisplay

clickXYPos

private java.awt.Point clickXYPos(ClickDetection click)
check horizontal scroll bar during real time operation. gets called once a second, based on adc counts from the raw data clock.

Parameters:
lastSample -
Returns:

clickXPos

private int clickXPos(ClickDetection click)

millisFromXPos

private long millisFromXPos(int xPos)

clickYPos

private int clickYPos(ClickDetection click)

clickAngleToY

private double clickAngleToY(ClickDetection click)

angleFromYPos

private double angleFromYPos(int yPos)

clickAmplitudeToY

private double clickAmplitudeToY(ClickDetection click)

amplitudeFromYPos

private double amplitudeFromYPos(int yPos)

clickICIToY

private double clickICIToY(ClickDetection click)

iciFromYPos

private double iciFromYPos(int yPos)

getClickHeight

private double getClickHeight(ClickDetection click)

getClickWidth

private double getClickWidth(ClickDetection click)

view360

private boolean view360()
Returns:
true if want to and can view 360 degrees.

repaintBoth

private void repaintBoth()
Repaints both the plot and the axis panel


trackClick

private boolean trackClick(java.awt.event.MouseEvent e)
See if the mouse is on a click to be tracked with the mouse. If not, return false,

Parameters:
e - mouse event.
Returns:
true if a click was found and marked as tracked.

trackClickMenu

private void trackClickMenu(java.awt.event.MouseEvent e,
                            ClickDetection click)

getClickPUMenu

private javax.swing.JPopupMenu getClickPUMenu(ClickDetection click)

trackClick

private void trackClick(ClickDetection click)

getPopupMenu

private javax.swing.JPopupMenu getPopupMenu(ClickDetection clickedClick)

sayCursorInfo

private void sayCursorInfo(java.awt.Point pt)

maybeShowPopup

private void maybeShowPopup(java.awt.event.MouseEvent e)

setVScale

void setVScale(int scaleType)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getDefaultSymbol

static PamSymbol getDefaultSymbol()

getDefaultSymbol

static PamSymbol getDefaultSymbol(boolean makeClone)

getClickSymbol

static PamSymbol getClickSymbol(ClickIdentifier clickIdentifier,
                                ClickDetection click)

getClickSymbol

static PamSymbol getClickSymbol(ClickIdentifier clickIdentifier,
                                ClickDetection click,
                                int colourType)

getClickSymbol

static PamSymbol getClickSymbol(ClickDetection click)

getClickSymbol

static PamSymbol getClickSymbol(int eventId)

findClick

ClickDetection findClick(int x,
                         int y,
                         int maxdist)
Parameters:
x - Search X coordinate
y - Search y coordinate
maxdist - Maximum distance from (x,y) to the centre of the click.
Returns:
The closest click within maxDist of the point x, y or null if no click is close enough

shouldPlotSpecies

boolean shouldPlotSpecies(int iSpecies)

shouldPlot

boolean shouldPlot(ClickDetection click)
Return true if the click should be plotted on the current display using the following tests:

Click is within the display time window

If the display is ICI, does the click have ICI ?

If channels are selected, is if from the right ones ?

Checks of selected species types

Parameters:
click - click to test
Returns:
true if the click should be plotted

clickInTimeWindow

boolean clickInTimeWindow(ClickDetection click)
Parameters:
click - click detection
Returns:
true if the click is within the current time window.

getName

public java.lang.String getName()
Specified by:
getName in class PamFramePlots

noteNewSettings

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

notifyNewStorage

public void notifyNewStorage(java.lang.String storageName)

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

pamStart

public void pamStart()
Overrides:
pamStart in class ClickDisplay

getDisplayChannels

public int getDisplayChannels()

setDisplayChannels

public void setDisplayChannels(int displayChannels)

getSettingsReference

public java.io.Serializable getSettingsReference()
Specified by:
getSettingsReference in interface PamSettings
Returns:
The serialisable object that will be stored

getSettingsVersion

public long getSettingsVersion()
Specified by:
getSettingsVersion in interface PamSettings
Returns:
An integer version number for the settings

getUnitName

public java.lang.String getUnitName()
Specified by:
getUnitName in interface PamSettings
Returns:
A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.

getUnitType

public java.lang.String getUnitType()
Specified by:
getUnitType in interface PamSettings
Returns:
A Name specific to the type, e.g. Glick detector

restoreSettings

public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
Specified by:
restoreSettings in interface PamSettings
Returns:
true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required

getSelectedClick

public ClickDetection getSelectedClick()

setSelectedClick

public void setSelectedClick(ClickDetection selectedClick)

selectClick

private boolean selectClick(int relClick)
Select the next or the preceding click

Parameters:
relClick - +1 to move forwards, -1 to move backwards
Returns:
new selected click.

clickedOnClick

public void clickedOnClick(ClickDetection click)
Overrides:
clickedOnClick in class ClickDisplay

getFirstSelectableClick

private ClickDetection getFirstSelectableClick()

getLastSelectableClick

private ClickDetection getLastSelectableClick()

clickInMarkedArea

private boolean clickInMarkedArea(ClickDetection click)
Test whether or not a click is within a marked area on the screen

Parameters:
click -
Returns:
true if no mark or click is within the mark.

makeMarkedClickList

public void makeMarkedClickList()
Called when a zoom polygon has been completed and immediately makes a list of all marked clicks.


getMarkedClicks

public java.util.ArrayList<ClickDetection> getMarkedClicks()
Returns:
a list of clicks which are within a marked area.

gotoEvent

public void gotoEvent(OfflineEventDataUnit event)
Scroll the display to a specific event.

Parameters:
event - event to scroll to