public class PamObservable extends java.lang.Object implements PanelOverlayDraw
Similar functionality to the Observable Class, but works with the PamObserver interface which has a bit more functionality.
e.g. The PamDataBlock, which is the most common class of PamObservable asks the observers what the first required sample is for each observing process or view.
Modifier and Type | Method and Description |
---|---|
void |
addObserver(PamObserver o)
Adds a PamObserver, which will then receive notifications when data is
added.
|
void |
addObserver(PamObserver o,
boolean reThread) |
boolean |
canDraw(GeneralProjector projectorInfo) |
void |
clearchanged()
Set flag to say the data have changed
|
int |
countObservers() |
PamKeyItem |
createKeyItem(GeneralProjector generalProjector,
int keyType)
provide a graphics component (probably a JPanel) that can be incorporated
into a key panel for maps, and anything else that uses overlay graphics.
|
void |
deleteObserver(PamObserver o)
Removes an observer from the list
|
void |
deleteObservers()
Removes all observers from the list
|
java.awt.Rectangle |
drawDataUnit(java.awt.Graphics g,
PamDataUnit pamDataUnit,
GeneralProjector projectorInfo) |
ThreadedObserver |
findThreadedObserver(PamObserver o)
Go through the observer list and check inside any that
are wrapped in threaded observers,
|
double |
getCPUPercent(int objectIndex) |
double |
getCPUPercent(PamObserver pamObserver) |
java.lang.String |
getHoverText(GeneralProjector generalProjector,
PamDataUnit dataUnit,
int iSide)
Provides text for popup hover windows on displays.
|
PamObserver |
getLongestObserver() |
java.util.List<PamObserver> |
getPamObservers() |
long |
getRequiredHistory()
Goes through all observers and works out which requires data
the longest.
|
boolean |
hasOptionsDialog(GeneralProjector generalProjector) |
void |
notifyObservers()
Instruction to notify observers that data have changed, but not to send
them any information about the new data.
|
void |
notifyObservers(PamDataUnit o)
Notify observers that data have changed and send them a reference to the
new Data
Have tried to synchronise this, but it can cuase a lockup - not 100% sure what to do
|
void |
setChanged()
Set flag to say the data have changed
|
void |
setOverlayDraw(PanelOverlayDraw overlayDraw) |
boolean |
showOptions(java.awt.Window parentWindow,
GeneralProjector generalProjector)
Show an options dialog for a particular projector.
|
boolean |
waitForThreadedObservers(long timeOutms)
Go through all the threaded observers and wait for them to finish processing any
data remaining in their lists.
|
public void addObserver(PamObserver o)
o
- Reference to the observerpublic void addObserver(PamObserver o, boolean reThread)
public ThreadedObserver findThreadedObserver(PamObserver o)
o
- public boolean waitForThreadedObservers(long timeOutms)
timeOutms
- timeout in millisecondspublic void deleteObserver(PamObserver o)
o
- Observer to removepublic void deleteObservers()
public int countObservers()
public java.util.List<PamObserver> getPamObservers()
public void notifyObservers()
public void setChanged()
public void clearchanged()
public void notifyObservers(PamDataUnit o)
o
- Reference to the new PamDataUnitpublic double getCPUPercent(int objectIndex)
public double getCPUPercent(PamObserver pamObserver)
public long getRequiredHistory()
public PamObserver getLongestObserver()
public void setOverlayDraw(PanelOverlayDraw overlayDraw)
overlayDraw
- Instance of a concrete class implementing the PanelIverlayDraw
interface.
Called to set the class which can draw overlays of the PamDataUnits held in this data block.
public java.awt.Rectangle drawDataUnit(java.awt.Graphics g, PamDataUnit pamDataUnit, GeneralProjector projectorInfo)
drawDataUnit
in interface PanelOverlayDraw
g
- An awt Graphics object
projectorInfo
- Class implementing GeneralProjector which can convert data to
screen coordinates.
pamDataUnit
- PamDataUnit to drawAny PamObserver which has been notified by a PamObservable that a new PamDatUnit has been created can call this function to draw some arbitrary shape on the image, e.g. a whistle contour, a picture of a whale, etc.
This should be overridden in the concrete class if it is to do anything.
public boolean canDraw(GeneralProjector projectorInfo)
canDraw
in interface PanelOverlayDraw
public java.lang.String getHoverText(GeneralProjector generalProjector, PamDataUnit dataUnit, int iSide)
PanelOverlayDraw
getHoverText
in interface PanelOverlayDraw
generalProjector
- Projector associated with the display requiring the textdataUnit
- Data unit the mouse hovered overpublic PamKeyItem createKeyItem(GeneralProjector generalProjector, int keyType)
PanelOverlayDraw
Since multiple keys may be created in various displays, new ones should normally be created each time this is called.
The GeneralProjector reference is passed as a parameter since the type of symbol or shape drawn on a particular plot may depend on the type of coordinate system. For example, whistles are drawn as a contour on the spectrogram display, but as a point (PamSymbol) on the map.
It is possible that some PanelOverlayDraw implementations will be rather complicated and the keys consequently quite large. The extendedKey parameter may therefore be used to draw a full or a cut down version of the key. It is expected that most implementations will ignore this parameter !
createKeyItem
in interface PanelOverlayDraw
generalProjector
- Reference to a GeneralProjector responsible
for drawing with the PAnelOverlayDraw implementationkeyType
- Draw a more complicated key, giving more detailWhistleGraphics
,
PamSymbol
public boolean hasOptionsDialog(GeneralProjector generalProjector)
hasOptionsDialog
in interface PanelOverlayDraw
generalProjector
- projectorpublic boolean showOptions(java.awt.Window parentWindow, GeneralProjector generalProjector)
PanelOverlayDraw
showOptions
in interface PanelOverlayDraw
parentWindow
- parent window or framegeneralProjector
- projector