Graphic overlays all make use of sub classes of the Pamview.GeneralProjector which provides functions to convert units such as Latitude, Longitude, Frequency, Time, etc. into screen coordinates.
The programmer wishing to overlay information must implement the Pamview.PanelOverlayDraw interface and attach that implementation to a PamDataBlock using the command setOverlayDraw.
Each display that implements graphic overlays will check which PamDataBlocks are capable of drawing with their Projector. This is done using the canDraw command in PanelOverlayDraw.
Generally, this decision is made based on the axis types for the Projector.
For example, the following code is taken from the whistle detector which is capable of overlaying graphics on spectrogram displays having time and frequency as their axis.
public boolean canDraw(GeneralProjector projector) { if (projector.getParmeterType(0) == ParameterType.TIME && projector.getParmeterType(1) == ParameterType.FREQUENCY) return true; return false; }
Each display should also have implemented a menu or dialog box which will allow the user to set which graphics to overlay on a particular display.
The contents of
this menu or dialog box will have been populated by examining all
PamDataBlocks
and including all those that returned true to
canDraw
for the given
projector.
The display will then subscribe to
PamDataBlocks
that it wishes to use as graphic overlays.
It is possible for data from a single data block to be drawn on several different types of display, for example maps and spectrograms.
If data are to be drawn on multiple display types, then the canDraw function should return true for all of those display types.
At the top of the drawDataUnit function, check the types of coordinates being used by the projector to determine the display type and then call appropriate drawing routines depending on the axis.
For example, the following code can be found in WhistleGraphics which allows drawing on both the map and spectrogram displays.
public Rectangle drawDataUnit(Graphics g, PamDataUnit pamDataUnit, GeneralProjector projector) { if (projector.getParmeterType(0) == ParameterType.LONGITUDE && projector.getParmeterType(1) == ParameterType.LATITUDE) { return drawWhistleOnMap(g, pamDataUnit, projector); } else if (projector.getParmeterType(0) == ParameterType.TIME && projector.getParmeterType(1) == ParameterType.FREQUENCY) { return drawWhistleShape(g, pamDataUnit, projector); } return null; } Rectangle drawWhistleOnMap(Graphics g, PamDataUnit pamDataUnit, GeneralProjector projector) { ... etc.