|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gumbo.visualize.data.AbstractDataViewFactory | +--gumbo.visualize.data.impl.swing.SwingTreeViewFactory
A data view factory for a tree data presentation implemented using Swing native graphics. In a tree view, tree nodes (root, branch, leaf) correspond to vertex models, with the order specified by the edge models, in a GraphModel. The initial tree if formed by starting with the first source vertex in the whole view's graph model, followed by the head vertex of the edges of each subsequent vertex, ending when a loop or a sink node is found. All other part models in the whole model are ignored. The whole graphic views will be registered automatically as spatial targets of the factory Swing sensors. The part graphic views are proxies and, as such, require a special (non-spatial) picker.
The tree view created by this factory is based on SwingTreeView, which uses a JTree as its native graphic, and a TreeModel as its native data model. Instead of being a composite of Swing components, with one for each tree node, a JTree is a monolithic component that renders nodes as virtual components using a cell renderer. As such, spatial hit testing cannot be used for picking tree nodes. Instead, a special pick engine (SwingTreeView.SwingPickEngine) must be used to detect tree node hits. Since the native graphics associated with tree node graphic views (SwingTreeNode) are not picked directly, they are maintained as a Swing tree node "user object" and returned as pick hits.
Note that TreeModel is rather dumb regarding updates and must be carefully notified of the changes, otherwise it will try to update missing nodes or mess up the expansion state of old nodes.
Constructor Summary | |
SwingTreeViewFactory(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: If an edge model, adds its head end vertex and forward subtree as a child of its tail end vertex; if a vertex model, and the native model root is null, sets it as the root node, otherwise ignores it (and waits for an edge). |
protected void |
createdPartView(PartView partView)
Default implementation: Uses _partMap to find the tree node corresponding to the part view's vertex model, inits the graphic view with the graphic model and node, and sets the node's user object to the part view's graphic view. |
protected void |
createdWholeView()
Default implementation: Saves the new whole view and its associates; connects graph model change events to this factory; builds a Swing tree model and part map using SwingDataModels.toTreeModel(), with the first source vertex in the whole view's model as the seed; adds the whole view's graphic view as a sensor target; |
void |
disposeWholeView(WholeView wholeView)
Default implementation: Sets the graphic model root null, then calls the super method. |
protected GraphicView |
newPartViewGraphic(PartView partView)
Default implementation: If view is of a VertexModel, returns a SwingTreeNode shape; otherwise, throws an exception. |
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 GraphModel returns a SwingTreeView; otherwise, throws an exception. |
protected void |
removePartViews(java.util.Collection partModels)
Default implementation: For each part model, in iterator order: If an edge model, removes its head end vertex and forward subtree; if a vertex model, removes it and its forward subtree. |
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 |
public SwingTreeViewFactory(MouseSensor mouse, KeyboardSensor keyboard)
mouse
- Reference to the mouse sensor. Null if none.keyboard
- Reference to the keyboard sensor. Null if none.Method Detail |
public GraphicView newWholeViewGraphic()
newWholeViewGraphic
in class AbstractDataViewFactory
protected void createdWholeView()
createdWholeView
in class AbstractDataViewFactory
protected GraphicView newPartViewGraphic(PartView partView)
newPartViewGraphic
in class AbstractDataViewFactory
partView
- The part view. Never null.
protected void createdPartView(PartView partView)
createdPartView
in class AbstractDataViewFactory
partView
- The part view. Never null.protected java.util.Collection addPartViews(java.util.Collection partModels, java.util.Collection retVal)
addPartViews
in class AbstractDataViewFactory
partModels
- The part model group (PartModel). Never null.retVal
- Return value object. The added part views (PartView)
in iterator order. Null if none.
protected void removePartViews(java.util.Collection partModels)
removePartViews
in class AbstractDataViewFactory
partModels
- The part model group (PartModel). Never null.public WholeView newWholeView(WholeModel wholeModel)
newWholeView
in interface DataViewFactory
newWholeView
in class AbstractDataViewFactory
wholeModel
- The whole model. Never null.
public void disposeWholeView(WholeView wholeView)
disposeWholeView
in interface DataViewFactory
disposeWholeView
in class AbstractDataViewFactory
wholeView
- The whole view. Never null.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |