gumbo.visualize.data
Class AbstractDataViewFactory

java.lang.Object
  |
  +--gumbo.visualize.data.AbstractDataViewFactory
All Implemented Interfaces:
DataViewFactory
Direct Known Subclasses:
SwingGraphViewFactory, SwingListViewFactory, SwingTreeViewFactory

public abstract class AbstractDataViewFactory
extends java.lang.Object
implements DataViewFactory

An abstract data view factory for non-nested whole models. The factory is stateful in that it manages a single current whole view, which must be disposed before a new one can be created. This implementation is independent of data presentation and graphics technology type. TODO: Should replace DataViewFactory interface with this class since clients can't implement the interface since the client can't add part views to a whole view.

Version:
$Revision: 1.1 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
protected AbstractDataViewFactory()
          Used by concrete factories to create an instance, which is typically a singleton.
 
Method Summary
protected  java.util.Collection addPartViews(java.util.Collection partModels, java.util.Collection retVal)
          Called by subclasses to add new part views corresponding to a group of part models to an existing whole view.
protected  void createdPartView(PartView partView)
          Called by the system after creating a new part view but before adding it to its whole.
protected  void createdWholeView()
          Called by the system after creating a new whole view, with a graphic view, but no part views.
 void disposeWholeView(WholeView wholeView)
          Default implementation: Breaks connections to the whole model for part model updates, then disposes the current whole view and nulls it.
protected  PartModelField.EventIn getAddedPartModelIn()
          Receives the part model after it is added to the current whole view's whole model.
protected  PartModelField.EventIn getRemovingPartModelIn()
          Receives the part model before it is removed from the current whole view's whole model.
 WholeView getWholeView()
          Gets the current whole view managed by this factory.
protected  PartView newPartView(PartModel partModel)
          Called by the system to create a new part view for a part model, and to add the view to a whole view.
protected  GraphicView newPartViewGraphic(PartView partView)
          Called by the system to create (but not set) a new part graphic for a part model.
 WholeView newWholeView(WholeModel wholeModel)
          Default implementation: Creates a new whole view, using newWholeViewGraphic() for the graphic, saves it as the current whole view, makes connections to the whole model for part model updates, then calls createdWholeView().
protected  GraphicView newWholeViewGraphic()
          Called by the system or subclasses to create (but not set) a new whole graphic for the current whole view and its model.
protected  void removePartViews(java.util.Collection partModels)
          Called by subclasses to remove a group of part views corresponding to a group of part models in an existing whole view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataViewFactory

protected AbstractDataViewFactory()
Used by concrete factories to create an instance, which is typically a singleton.

Method Detail

getWholeView

public final WholeView getWholeView()
Gets the current whole view managed by this factory.

Returns:
Reference to the whole view. Null if none.

newWholeViewGraphic

protected GraphicView newWholeViewGraphic()
Called by the system or subclasses to create (but not set) a new whole graphic for the current whole view and its model. If a subclass cannot create a whole graphic independent of the part graphics, then newWholeView() must be overridden instead of this method. Default implementation: Throws an unsupported operation exception.

Returns:
Reference to the whole view graphic. Never null.

createdWholeView

protected void createdWholeView()
Called by the system after creating a new whole view, with a graphic view, but no part views. Subclasses should add part views using addPartViews(), and finalize the whole view accordingly. Subclasses that are stateful should also set the current whole view. Default implementation: Throws an unsupported operation exception.


newPartView

protected PartView newPartView(PartModel partModel)
Called by the system to create a new part view for a part model, and to add the view to a whole view. Should not be responsible for updating the whole graphic view. Throws an exception if the part model is not in the whole view's model. Used during whole view creation and update. Default implementation: Creates a new part view, using newPartViewGraphic() for the graphic, then calls createdPartView().

Parameters:
partModel - The part model. Never null.
Returns:
Reference to the new part view.

newPartViewGraphic

protected GraphicView newPartViewGraphic(PartView partView)
Called by the system to create (but not set) a new part graphic for a part model. If a subclass cannot create a part graphic independent of the whole graphic, then addPartView() must be overridden instead of this method. Default implementation: Throws an unsupported operation exception.

Parameters:
partView - The part view. Never null.
Returns:
The part view graphic. Never null.

createdPartView

protected void createdPartView(PartView partView)
Called by the system after creating a new part view but before adding it to its whole. Default implementation: If the whole graphic view is a space node, adds the part graphic view as a space node; otherwise, does nothing. Subclasses should override as needed to (also) add the part native graphic to its whole.

Parameters:
partView - The part view. Never null.

addPartViews

protected java.util.Collection addPartViews(java.util.Collection partModels,
                                            java.util.Collection retVal)
Called by subclasses to add new part views corresponding to a group of part models to an existing whole view. Should be responsible for updating the affected part and whole graphic views. Throws an exception if a group member is not a part model in the whole view's model. Used during whole view creation and update. Default implementation: Calls newPartView() for each part model in the group, in iterator order. Subclasses should override this method, if needed, to update the affected graphic views when done.

Parameters:
partModels - The part model group (PartModel). Never null.
retVal - Return value object. The added part views (PartView) in iterator order. Null if none.
Returns:
Reference to retVal. Null if none.

removePartViews

protected void removePartViews(java.util.Collection partModels)
Called by subclasses to remove a group of part views corresponding to a group of part models in an existing whole view. Should be responsible for updating the affected whole and part graphic views. Throws an exception if a group member is not a part model in the whole view's model. Used during whole view update. Note that data models are not automatically disposed when their data views are disposed. Default implementation: For each part model in the group, in iterator order, checks if it is in the whole view and disposes it. Subclasses should override this method, if needed, to update the affected graphic views when done.

Parameters:
partModels - The part model group (PartModel). Never null.

getAddedPartModelIn

protected PartModelField.EventIn getAddedPartModelIn()
Receives the part model after it is added to the current whole view's whole model. Never null. Default implementation: Returns an event node that calls addPartViews() with the input part model.


getRemovingPartModelIn

protected PartModelField.EventIn getRemovingPartModelIn()
Receives the part model before it is removed from the current whole view's whole model. Never null. Default implementation: Returns an event node that calls removePartViews() with the input part model.


newWholeView

public WholeView newWholeView(WholeModel wholeModel)
Default implementation: Creates a new whole view, using newWholeViewGraphic() for the graphic, saves it as the current whole view, makes connections to the whole model for part model updates, then calls createdWholeView(). Throws an exception if the whole model is nested (has child whole models) or the previous whole view has not been disposed.

Specified by:
newWholeView in interface DataViewFactory
Parameters:
wholeModel - The whole model. Never null.
Returns:
A new whole view. Never null.

disposeWholeView

public void disposeWholeView(WholeView wholeView)
Default implementation: Breaks connections to the whole model for part model updates, then disposes the current whole view and nulls it. Throws an exception if not the current whole view.

Specified by:
disposeWholeView in interface DataViewFactory
Parameters:
wholeView - The whole view. Never null.