net.sourceforge.nite.tools.videolabeler
Class ViewFrameFactory

java.lang.Object
  extended by net.sourceforge.nite.tools.videolabeler.ViewFrameFactory
All Implemented Interfaces:
SelectionListener

public class ViewFrameFactory
extends java.lang.Object
implements SelectionListener

A view frame factory is a global singleton object. Before it is used it should be created with ViewFrameFactory.createInstance(). From then on the same factory can be retrieved with ViewFrameFactory.getInstance().

A view frame factory creates view frames for certain selected annotation layers. A view frame is an instance of ViewFrame. This factory does not only create view frames, but it also serves as a repository of the current view frames and it is responsible for laying out the view frames in a designated area of a desktop pane.

The factory implements the SelectionListener interface. The user should be able to select and deselect the layers for which view frames should be shown. Whenever the user selects or deselects an annotation layer, the method layerSelected() should be called, so that the view frame for the selected/deselected layer is created/removed and the view frames are layed out on the desktop.


Method Summary
 void agentSelected(NAgent agent, boolean selected)
          This method does nothing, because view frames are only associated with a layer, not with an agent.
static ViewFrameFactory createInstance(javax.swing.JDesktopPane desktop, java.awt.Rectangle area)
          Initialises the singleton view frame factory.
static ViewFrameFactory getInstance()
          Returns the singleton view frame factory.
 void layerSelected(AnnotationLayer layer, boolean selected)
          Selects or deselects a layer.
 void setArea(java.awt.Rectangle area)
          Sets the area of the desktop in which the view frames are layed out.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createInstance

public static ViewFrameFactory createInstance(javax.swing.JDesktopPane desktop,
                                              java.awt.Rectangle area)

Initialises the singleton view frame factory. The factory will display the view frames on the specified desktop. The frames will be layed out in the specified area of the desktop. The factory uses a FrameArranger to lay out the view frames.

If the singleton view frame factory has already been initialised, this method does not create a new factory, but simple returns the existing singleton factory.

Parameters:
desktop - the desktop where the view frames will be displayed
area - the area of the desktop in which the view frames will be layed out
Returns:
the singleton view frame factory

getInstance

public static ViewFrameFactory getInstance()

Returns the singleton view frame factory. The factory should have been initialised first with createInstance. If the factory has not been initialised yet, this method returns null.

Returns:
the singleton view frame factory or null

setArea

public void setArea(java.awt.Rectangle area)

Sets the area of the desktop in which the view frames are layed out. This method will set the area and lay out the current view frames in the specified area.

Parameters:
area - an area of the desktop

agentSelected

public void agentSelected(NAgent agent,
                          boolean selected)

This method does nothing, because view frames are only associated with a layer, not with an agent.

Specified by:
agentSelected in interface SelectionListener
Parameters:
agent - the agent that is selected or deselected
selected - true if the agent is selected, false if it is deselected

layerSelected

public void layerSelected(AnnotationLayer layer,
                          boolean selected)

Selects or deselects a layer. If a layer is selected, the view frame for that layer is created on the desktop. If a layer is deselected, the view frame for that layer is removed from the desktop. In either case the new set of selected view frames are layed out in the designated desktop area.

Specified by:
layerSelected in interface SelectionListener
Parameters:
layer - the layer that is selected or deselected
selected - true if the layer is selected, false if it is deselected