gumbo.visualize.data.impl.swing
Class SwingGraphViewFactory

java.lang.Object
  |
  +--gumbo.visualize.data.AbstractDataViewFactory
        |
        +--gumbo.visualize.data.impl.swing.SwingGraphViewFactory
All Implemented Interfaces:
DataViewFactory

public class SwingGraphViewFactory
extends AbstractDataViewFactory

A data view factory for a graph data presentation implemented using Swing native graphics. In a graph view, graph vertices and edges correspond to vertex and edge models, with the order specified by the edge models, in a GraphModel. The initial graph if formed by adding all vertex and edge models. The default implementation ignores non-vertex port models. The whole and part view graphic views will be registered automatically as spatial targets of the factory Swing sensors.

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

Constructor Summary
SwingGraphViewFactory(MouseSensor mouse, KeyboardSensor keyboard)
          Creates and instance.
 
Method Summary
protected  java.util.Collection addPartViews(java.util.Collection partModels, java.util.Collection retVal)
          Default implementation: For each part model, in iterator order: Calls the super method to create and add the part views, then calls prepare and realize on the whole graphic view to update the view presentation.
protected  void createdPartView(PartView view)
          Default implementation: calls the super method, then adds the part view's graphic view as a sensor target.
protected  void createdWholeView()
          Default implementation: Adds the whole view's graphic view as a sensor target, calls addPartViews() with all the whole model's part models, then calls newWholeLayoutEngine() to lay out the whole view.
 void disposeWholeView(WholeView wholeView)
          Default implementation: Sets the layout engine null, then calls the super method.
 WholeLayoutEngine getWholeLayoutEngine()
          Gets the layout engine for the current whole view.
protected  GraphicView newPartViewGraphic(PartView view)
          Default implementation: If view is of a VertexModel returns a SwingGraphVertex, if an EdgeShape returns a SwingGraphEdge; otherwise, returns a NullGraphicView.
protected  WholeLayoutEngine newWholeLayoutEngine()
          Called by the system when a new whole view layout engine is needed.
 WholeView newWholeView(WholeModel wholeModel)
          Default implementation: Throws an exception if the whole model is not a GraphModel, then calls the super method.
 GraphicView newWholeViewGraphic()
          Default implementation: If view is of a WholeModel, returns a SwingGraphView; otherwise, throws an exception.
protected  void removePartViews(java.util.Collection partModels)
          Default implementation: For each part model, in iterator order: Calls the super method to remove and dispose the part views, then calls prepare and realize on the whole graphic view to update the view presentation.
 
Methods inherited from class gumbo.visualize.data.AbstractDataViewFactory
getAddedPartModelIn, getRemovingPartModelIn, getWholeView, newPartView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingGraphViewFactory

public SwingGraphViewFactory(MouseSensor mouse,
                             KeyboardSensor keyboard)
Creates and instance. Sensors should be able to handle targets with Swing/AWT native graphics.

Parameters:
mouse - Reference to the mouse sensor. Null if none.
keyboard - Reference to the keyboard sensor. Null if none.
Method Detail

getWholeLayoutEngine

public WholeLayoutEngine getWholeLayoutEngine()
Gets the layout engine for the current whole view.

Returns:
Reference to the layout engine. Null if none yet or whole view has been disposed.

newWholeLayoutEngine

protected WholeLayoutEngine newWholeLayoutEngine()
Called by the system when a new whole view layout engine is needed. Default implementation: Creates and returns a KinkyGraphLayoutEngine.


newWholeViewGraphic

public GraphicView newWholeViewGraphic()
Default implementation: If view is of a WholeModel, returns a SwingGraphView; otherwise, throws an exception.

Overrides:
newWholeViewGraphic in class AbstractDataViewFactory
Returns:
Reference to the whole view graphic. Never null.

createdWholeView

protected void createdWholeView()
Default implementation: Adds the whole view's graphic view as a sensor target, calls addPartViews() with all the whole model's part models, then calls newWholeLayoutEngine() to lay out the whole view.

Overrides:
createdWholeView in class AbstractDataViewFactory

newPartViewGraphic

protected GraphicView newPartViewGraphic(PartView view)
Default implementation: If view is of a VertexModel returns a SwingGraphVertex, if an EdgeShape returns a SwingGraphEdge; otherwise, returns a NullGraphicView.

Overrides:
newPartViewGraphic in class AbstractDataViewFactory
Parameters:
view - The part view. Never null.
Returns:
The part view graphic. Never null.

createdPartView

protected void createdPartView(PartView view)
Default implementation: calls the super method, then adds the part view's graphic view as a sensor target.

Overrides:
createdPartView in class AbstractDataViewFactory
Parameters:
view - The part view. Never null.

addPartViews

protected java.util.Collection addPartViews(java.util.Collection partModels,
                                            java.util.Collection retVal)
Default implementation: For each part model, in iterator order: Calls the super method to create and add the part views, then calls prepare and realize on the whole graphic view to update the view presentation.

Overrides:
addPartViews in class AbstractDataViewFactory
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)
Default implementation: For each part model, in iterator order: Calls the super method to remove and dispose the part views, then calls prepare and realize on the whole graphic view to update the view presentation.

Overrides:
removePartViews in class AbstractDataViewFactory
Parameters:
partModels - The part model group (PartModel). Never null.

newWholeView

public WholeView newWholeView(WholeModel wholeModel)
Default implementation: Throws an exception if the whole model is not a GraphModel, then calls the super method.

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

disposeWholeView

public void disposeWholeView(WholeView wholeView)
Default implementation: Sets the layout engine null, then calls the super method. Throws an exception if whole view is not the current one being managed by this factory.

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