Layout
Class DisplayPanel

java.lang.Object
  extended by Layout.DisplayPanel
Direct Known Subclasses:
ClickSpectrogramPlugin.BTDisplayPanel, FFTPluginPanelProvider.FFTPluginPanel, IshDetGraphics.IshDisplayPanel, IshLocGraphics.IshDisplayPanel, RawDataDisplay.RawDisplayPanel, VetoPluginPanelProvider.VetoPluginPanel, WorkshopPluginPanelProvider.WorkshopPluginPanel

public abstract class DisplayPanel
extends java.lang.Object

A standard display panel that can be incorporated into other displays, eg. the Spectorgram window. Provides a JPanel and optionally axis to be drawn around it.

The programmer must always implement the function containerNotification in order to clear the display panel ahead of where the spectrogram is currently drawing.

There are two principle ways of drawing new data on the panel:

  1. For data which are continuous in nature, such as waveforms or data calculated from the spectrgram data itself, the new data can be drawn from within containerNotification.
  2. For data which arrive intermittently, such as detected clicks, it is better to draw those data as and when they arrive by subscribing to the appropriate PamDataBlock and implementing code in the update function in the PamObserver interface.

Author:
Doug Gillespie
See Also:
DisplayPanelContainer, DisplayPanelProvider, DisplayProviderList

Nested Class Summary
(package private)  class DisplayPanel.DisplayInnerPanel
           
(package private)  class DisplayPanel.PopupListener
           
 
Field Summary
private  java.awt.image.BufferedImage displayImage
           
protected  DisplayPanelContainer displayPanelContainer
           
protected  DisplayPanelProvider displayPanelProvider
           
private  int imageHeight
           
private  int imageWidth
           
private  DisplayPanel.DisplayInnerPanel innerPanel
           
private  javax.swing.JPanel outerPanel
           
private  java.awt.Insets panelInsets
           
protected  java.awt.Color plotBackground
           
private  javax.swing.JPopupMenu popupMenu
           
 
Constructor Summary
DisplayPanel(DisplayPanelProvider displayPanelProvider, DisplayPanelContainer displayPanelContainer)
          Standard Display panel constructor
 
Method Summary
 void clearImage()
          Clear the entire image
 void clearImage(int x1, int x2)
          Clear part of the image between x1 and x2
 void clearImage(int x1, int x2, boolean drawLine)
          Clear part of the image and draw a line just to the right of the cleared section
abstract  void containerNotification(DisplayPanelContainer displayContainer, int noteType)
          Called by the DisplayPanelContainer whenever the scales change - e.g.
private  void createImage()
          Creates a buffered image for the actual drawing.
protected  javax.swing.JPopupMenu createPopupMenu()
          Create a popup menu.
abstract  void destroyPanel()
          The displayPanelContainer should call destroyPanel when the panel is no longer required so that the displayPanel can unsubscribe to any data it was observing.
private  void floodImage(java.awt.Color col)
          Fill the entire image with the same comour
 java.awt.image.BufferedImage getDisplayImage()
           
 DisplayPanelContainer getDisplayPanelContainer()
           
 DisplayPanelProvider getDisplayPanelProvider()
           
 PamAxis getEastAxis()
           
 int getInnerHeight()
           
 javax.swing.JPanel getInnerPanel()
           
 int getInnerWidth()
           
 PamAxis getNorthAxis()
           
 javax.swing.JPanel getPanel()
          Each display panel must be able to provide a JPanel for incoropation into the display.
 java.awt.Insets getPanelBorder()
           
 PamAxis getSouthAxis()
           
 PamAxis getWestAxis()
           
 void repaint()
          repaints the display - needs to be called after any changes to the image
 void repaint(int t)
          repaints the display - needs to be called after any changes to the image
private  void setInnerPanel(DisplayPanel.DisplayInnerPanel innerPanel)
           
 void setPanelBorder(java.awt.Insets panelInsets)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

displayPanelProvider

protected DisplayPanelProvider displayPanelProvider

displayPanelContainer

protected DisplayPanelContainer displayPanelContainer

outerPanel

private javax.swing.JPanel outerPanel

innerPanel

private DisplayPanel.DisplayInnerPanel innerPanel

displayImage

private java.awt.image.BufferedImage displayImage

panelInsets

private java.awt.Insets panelInsets

imageWidth

private int imageWidth

imageHeight

private int imageHeight

plotBackground

protected java.awt.Color plotBackground

popupMenu

private javax.swing.JPopupMenu popupMenu
Constructor Detail

DisplayPanel

public DisplayPanel(DisplayPanelProvider displayPanelProvider,
                    DisplayPanelContainer displayPanelContainer)
Standard Display panel constructor

Creates two J Panels, one nested inside the other with a small border. The inner panel also has a BufferedImage drawn in it which can be used for any graphics.

Parameters:
displayPanelProvider -
displayPanelContainer -
Method Detail

createImage

private void createImage()
Creates a buffered image for the actual drawing.


floodImage

private void floodImage(java.awt.Color col)
Fill the entire image with the same comour

Parameters:
col -

createPopupMenu

protected javax.swing.JPopupMenu createPopupMenu()
Create a popup menu.

This should be overridden in any sub classes that want to present a menu for setting any display options.

Returns:
reference to the popup menu for the display panel

clearImage

public void clearImage()
Clear the entire image


clearImage

public void clearImage(int x1,
                       int x2)
Clear part of the image between x1 and x2

Parameters:
x1 -
x2 -

clearImage

public void clearImage(int x1,
                       int x2,
                       boolean drawLine)
Clear part of the image and draw a line just to the right of the cleared section

Parameters:
x1 - x position of start of clear
x2 - x position of end of clear
drawLine - draw a vertical line to show cleared region

getInnerWidth

public int getInnerWidth()
Returns:
the width in pixels of the image

getInnerHeight

public int getInnerHeight()
Returns:
the height in pixels of the image

getDisplayImage

public java.awt.image.BufferedImage getDisplayImage()
Returns:
The display image

getPanelBorder

public java.awt.Insets getPanelBorder()

setPanelBorder

public void setPanelBorder(java.awt.Insets panelInsets)

getPanel

public final javax.swing.JPanel getPanel()
Each display panel must be able to provide a JPanel for incoropation into the display.

Returns:
the outer panel

getInnerPanel

public javax.swing.JPanel getInnerPanel()

repaint

public void repaint()
repaints the display - needs to be called after any changes to the image


repaint

public void repaint(int t)
repaints the display - needs to be called after any changes to the image

Parameters:
t - time delay

setInnerPanel

private void setInnerPanel(DisplayPanel.DisplayInnerPanel innerPanel)

destroyPanel

public abstract void destroyPanel()
The displayPanelContainer should call destroyPanel when the panel is no longer required so that the displayPanel can unsubscribe to any data it was observing.


containerNotification

public abstract void containerNotification(DisplayPanelContainer displayContainer,
                                           int noteType)
Called by the DisplayPanelContainer whenever the scales change - e.g. every time new data is drawn on the spectrogram.

The display panel can use this information in two ways:

Firstly, it should clear the region of the display just ahead of the current spectrogram x coordinate. Secondly, it may draw additional data on the display.

Parameters:
displayContainer -
noteType -

getNorthAxis

public PamAxis getNorthAxis()

getSouthAxis

public PamAxis getSouthAxis()

getEastAxis

public PamAxis getEastAxis()

getWestAxis

public PamAxis getWestAxis()

getDisplayPanelContainer

public DisplayPanelContainer getDisplayPanelContainer()

getDisplayPanelProvider

public DisplayPanelProvider getDisplayPanelProvider()