com.tensegrity.gui.swing.control.tree.strategy
Class DefaultVisualGraphTreeStrategy

java.lang.Object
  extended bycom.tensegrity.gui.swing.control.tree.strategy.AbstractTreeStrategy
      extended bycom.tensegrity.gui.swing.control.tree.strategy.AbstractVisualGraphTreeStrategy
          extended bycom.tensegrity.gui.swing.control.tree.strategy.DefaultVisualGraphTreeStrategy
All Implemented Interfaces:
EventListenerTag, OutlinerStrategy, TreeStrategy, VisualGraphListener

public class DefaultVisualGraphTreeStrategy
extends AbstractVisualGraphTreeStrategy

This is the default javax.swing implementation of the abstract AbstractVisualGraphTreeStrategy. It has a one-to-one relationship with DefaultVisualGraphTreeModel

Note that the assertion is made that the Documents passed to/used into this class are in fact SwingGraphDocuments.

Version:
$Id: DefaultVisualGraphTreeStrategy.java,v 1.31 2006/03/23 11:17:08 MichaelKegel Exp $
Author:
S�bastien Guyon
See Also:
AbstractVisualGraphTreeStrategy, OutlinerStrategy, TreeOutliner, DefaultVisualGraphTreeModel

Field Summary
 
Fields inherited from class com.tensegrity.gui.swing.control.tree.strategy.AbstractVisualGraphTreeStrategy
DOCUMENT_TYPE_KEY, VISUAL_EDGE_TREE_NODE, VISUAL_NODE_TREE_NODE, VISUAL_SUBGRAPH_TREE_NODE
 
Constructor Summary
DefaultVisualGraphTreeStrategy(UIManager uiManager)
           Initialises instances of this class with the passed UIManager instance.
 
Method Summary
 javax.swing.tree.DefaultMutableTreeNode findNodeByID(javax.swing.tree.DefaultMutableTreeNode parent, long id)
          Utility method.
 javax.swing.tree.DefaultMutableTreeNode findNodeByID(long id)
           This method retrieves the DefaultMutableTreeNode associated to a VisualGraphObject given its unique ID.
 int getParentIndex(javax.swing.tree.DefaultMutableTreeNode parent)
          Returns the index reserved for the given parent node.
protected  javax.swing.tree.DefaultMutableTreeNode getVisualSubgraphTreeNode(VisualSubgraph vsg)
           Returns the DefaultMutableTreeNode associated to vsg
 javax.swing.tree.DefaultTreeModel initializeModel(java.util.Map uiMap, Document document, java.lang.String name, boolean recreateModelEvenIfExists)
          Note that the assertion is made that the Documents passed to/used into this method are in fact SwingGraphDocuments.
 void isolatedVisualEdgeAdded(VisualGraphEvent event)
          An isolated VisualEdge was added to the VisualGraph.
protected  void isolatedVisualEdgeAddedToSubgraph(VisualSubgraph vsg, VisualEdge ve)
           Routine used when an isolated VisualEdge is added to a VisualSubgraph.
protected  void isolatedVisualEdgeAddedToVisualgraph(VisualGraph vgv, VisualEdge ve)
           Routine used when an isolated VisualEdge is added to a VisualGraph.
 void isolatedVisualEdgeRemoved(VisualGraphEvent event)
          An isolated VisualEdge was removed from the VisualGraph.
 void layout(VisualGraphEvent visualgraphevent)
          Do nothing
 void removeNode(javax.swing.tree.DefaultMutableTreeNode parent, long id)
          Method removeNode removes a Node from the TreeModel identified by the given id.
 void removeNode(long id)
           Removes from the TreeOutliner the DefaultMutableTreeNode with ID id.
protected  void setModel(javax.swing.tree.DefaultTreeModel model)
           Locally stores the passed model.
protected  void setSelectionOnTree(java.util.List selection)
           Selects on the TreeOutliner the DefaultMutableTreeNode s corresponding to the BaseComposite s contained in selection.
 void visualEdgeAdded(VisualGraphEvent event)
          A VisualEdge was added to the VisualGraph.
protected  void visualEdgeAddedToSubgraph(VisualSubgraph vsg, VisualEdge ve)
           Routine used when a VisualEdge is added to a VisualSubgraph.
protected  void visualEdgeAddedToVisualgraph(VisualGraph vgv, VisualEdge ve)
           Routine used when a VisualEdge is added to a VisualGraph.
 void visualEdgeAttachRejected(VisualGraphEvent visualgraphevent)
          Do nothing
 void visualEdgeRemoved(VisualGraphEvent event)
          A VisualEdge was removed from the VisualGraph.
 void visualEdgeSplit(VisualGraphEvent visualgraphevent)
          An edge-split was performed.
 void visualNodeAdded(VisualGraphEvent event)
          A VisualNode was added to the VisualGraph.
protected  void visualNodeAddedToSubgraph(VisualSubgraph vsg, VisualNode vn)
           Routine used when a VisualNode is added to a VisualSubgraph.
protected  void visualNodeAddedToVisualgraph(VisualGraph vgv, VisualNode vn)
           Routine used when a VisualNode is added to a VisualGraph.
 void visualNodeDeleteEdgeCascade(VisualGraphEvent visualgraphevent)
          An edge-cascade was performed.
 void visualNodeRemoved(VisualGraphEvent event)
          A VisualNode was added to the VisualGraph.
 
Methods inherited from class com.tensegrity.gui.swing.control.tree.strategy.AbstractVisualGraphTreeStrategy
addNode, getComparator, getNewTreeNode
 
Methods inherited from class com.tensegrity.gui.swing.control.tree.strategy.AbstractTreeStrategy
getActiveDocument, getDocumentIdNodeMap, getDocumentModelMap, getIdNodeMap, getModel, getRoot, getTree, getUIManager, removeModel, setActiveDocument, setTree, updateNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultVisualGraphTreeStrategy

public DefaultVisualGraphTreeStrategy(UIManager uiManager)

Initialises instances of this class with the passed UIManager instance.

Parameters:
uiManager - the application UIManager.
Method Detail

initializeModel

public javax.swing.tree.DefaultTreeModel initializeModel(java.util.Map uiMap,
                                                         Document document,
                                                         java.lang.String name,
                                                         boolean recreateModelEvenIfExists)
Note that the assertion is made that the Documents passed to/used into this method are in fact SwingGraphDocuments.

Specified by:
initializeModel in class AbstractTreeStrategy
Parameters:
uiMap - this is the UI Map.
document - The document of which the Model is required
name - The name of the document
recreateModelEvenIfExists - True if the Model should be recreated even if a Model is already associated to the document.
Returns:
the TreeModel associated to the passed Document.
See Also:
AbstractTreeStrategy.initializeModel(java.util.Map, com.tensegrity.gui.document.Document, java.lang.String, boolean)

setModel

protected void setModel(javax.swing.tree.DefaultTreeModel model)
Description copied from class: AbstractTreeStrategy

Locally stores the passed model.

Important Note

It is internally storing the model in a Map for which the key is the Document corresponding to the passed model.

It assumes that the Document local instance is set to the desired Document before this method is called. This is done by AbstractTreeStrategy.initializeModel(Map, Document, String, boolean).

Overrides:
setModel in class AbstractTreeStrategy
Parameters:
model - the DefaultTreeModel associated to the active Docuement, if any.

findNodeByID

public javax.swing.tree.DefaultMutableTreeNode findNodeByID(javax.swing.tree.DefaultMutableTreeNode parent,
                                                            long id)
Description copied from class: AbstractTreeStrategy
Utility method. It searches all nodes under the passed tree node and returns the DefaultMutableTreeNode which matches the given id. If no such node is found, null is returned.

Specified by:
findNodeByID in class AbstractTreeStrategy
Parameters:
parent - DefaultMutableTreeNode representing the parent of the DefaultMutableTreeNode we are looking for.
id - unique identifier for a tree node.
Returns:
DefaultMutableTreeNode the DefaultMutableTreeNode which matches the given id, or nulll/code> if no match is found.

findNodeByID

public javax.swing.tree.DefaultMutableTreeNode findNodeByID(long id)

This method retrieves the DefaultMutableTreeNode associated to a VisualGraphObject given its unique ID. The unique id is retrieve using System.identityHashCode(java.lang.Object).

Parameters:
id - Unique ID used to retrieve the DefaultMutableTreeNode associated to a VisualGraphObject.
Returns:
the DefaultMutableTreeNode associated with the VisualGraphObject with unique ID id.

removeNode

public void removeNode(long id)

Removes from the TreeOutliner the DefaultMutableTreeNode with ID id.

Parameters:
id - ID of the DefaultMutableTreeNode to remove from the TreeOutliner.
See Also:
findNodeByID(long)

visualEdgeRemoved

public void visualEdgeRemoved(VisualGraphEvent event)
Description copied from interface: VisualGraphListener
A VisualEdge was removed from the VisualGraph.

Parameters:
event - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#visualEdgeRemoved(com.tensegrity.graph.event.VisualGraphEvent)

isolatedVisualEdgeAdded

public void isolatedVisualEdgeAdded(VisualGraphEvent event)
Description copied from interface: VisualGraphListener
An isolated VisualEdge was added to the VisualGraph.

Parameters:
event - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#isolatedVisualEdgeAdded(com.tensegrity.graph.event.VisualGraphEvent)

isolatedVisualEdgeRemoved

public void isolatedVisualEdgeRemoved(VisualGraphEvent event)
Description copied from interface: VisualGraphListener
An isolated VisualEdge was removed from the VisualGraph.

Parameters:
event - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#isolatedVisualEdgeRemoved(com.tensegrity.graph.event.VisualGraphEvent)

visualEdgeSplit

public void visualEdgeSplit(VisualGraphEvent visualgraphevent)
Description copied from interface: VisualGraphListener
An edge-split was performed.

Parameters:
visualgraphevent - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#visualEdgeSplit(com.tensegrity.graph.event.VisualGraphEvent)

visualNodeDeleteEdgeCascade

public void visualNodeDeleteEdgeCascade(VisualGraphEvent visualgraphevent)
Description copied from interface: VisualGraphListener
An edge-cascade was performed.

Parameters:
visualgraphevent - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#visualNodeDeleteEdgeCascade(com.tensegrity.graph.event.VisualGraphEvent)

visualNodeRemoved

public void visualNodeRemoved(VisualGraphEvent event)
Description copied from interface: VisualGraphListener
A VisualNode was added to the VisualGraph.

Parameters:
event - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#visualNodeRemoved(com.tensegrity.graph.event.VisualGraphEvent)

visualNodeAdded

public void visualNodeAdded(VisualGraphEvent event)
Description copied from interface: VisualGraphListener
A VisualNode was added to the VisualGraph.

Parameters:
event - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#visualNodeAdded(com.tensegrity.graph.event.VisualGraphEvent)

visualNodeAddedToVisualgraph

protected void visualNodeAddedToVisualgraph(VisualGraph vgv,
                                            VisualNode vn)

Routine used when a VisualNode is added to a VisualGraph. It is important to notice that if the passed VisualNode is in fact a VisualSubgraph, then the TreeOutliner will be registered as listener of this VisualSubgraph. See com.tensegrity.gui.swing.control.tree.TreeOutliner#doAddListeners(VisualSubgraph) for more information. Also, in such a case this routine iterates through the list of VisualGraphObject contained within vn and depending on their type calls isolatedVisualEdgeAddedToSubgraph(VisualSubgraph, VisualEdge), visualEdgeAddedToSubgraph(VisualSubgraph, VisualEdge) or visualNodeAddedToSubgraph(VisualSubgraph, VisualNode). This method is called by initializeModel(Map, Document, String, boolean) and visualNodeAdded(VisualGraphEvent).

Parameters:
vgv - a VisualGraph.
vn - a VisualNode which was added to vgv.

visualNodeAddedToSubgraph

protected void visualNodeAddedToSubgraph(VisualSubgraph vsg,
                                         VisualNode vn)

Routine used when a VisualNode is added to a VisualSubgraph. It is important to notice that if the passed VisualNode is in fact a VisualSubgraph, then the TreeOutliner will be registered as listener of this VisualSubgraph. See com.tensegrity.gui.swing.control.tree.TreeOutliner#doAddListeners(VisualSubgraph) for more information. Also, in such a case this routine iterates through the list of VisualGraphObject contained within vn and depending on their type calls isolatedVisualEdgeAddedToSubgraph(VisualSubgraph, VisualEdge), visualEdgeAddedToSubgraph(VisualSubgraph, VisualEdge) or visualNodeAddedToSubgraph(VisualSubgraph, VisualNode).

Parameters:
vsg - a VisualSubgraph.
vn - a VisualNode which was added to vsg.

getVisualSubgraphTreeNode

protected javax.swing.tree.DefaultMutableTreeNode getVisualSubgraphTreeNode(VisualSubgraph vsg)

Returns the DefaultMutableTreeNode associated to vsg

Parameters:
vsg - the VisualSubgraph of which the associated DefaultMutableTreeNode is requested.
Returns:
the DefaultMutableTreeNode associated to vsg

layout

public void layout(VisualGraphEvent visualgraphevent)
Do nothing

Parameters:
visualgraphevent - the VisualGraphEvent structure that contains the event information.
See Also:
VisualGraphListener.layout(com.tensegrity.graph.event.VisualGraphEvent)

visualEdgeAttachRejected

public void visualEdgeAttachRejected(VisualGraphEvent visualgraphevent)
Do nothing

Parameters:
visualgraphevent - the VisualGraphEvent structure that contains the event information.
See Also:
VisualGraphListener.visualEdgeAttachRejected(com.tensegrity.graph.event.VisualGraphEvent)

visualEdgeAdded

public void visualEdgeAdded(VisualGraphEvent event)
Description copied from interface: VisualGraphListener
A VisualEdge was added to the VisualGraph.

Parameters:
event - the VisualGraphEvent structure that contains the event information.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#visualEdgeAdded(com.tensegrity.graph.event.VisualGraphEvent)

getParentIndex

public int getParentIndex(javax.swing.tree.DefaultMutableTreeNode parent)
Description copied from interface: TreeStrategy
Returns the index reserved for the given parent node.

Parameters:
parent - the parent of which you want the index
Returns:
int the index of the given parent.
See Also:
com.tensegrity.component.organigram.gui.panels.tree.TreeStrategy#getParentIndex(javax.swing.tree.DefaultMutableTreeNode)

removeNode

public void removeNode(javax.swing.tree.DefaultMutableTreeNode parent,
                       long id)
Description copied from interface: TreeStrategy
Method removeNode removes a Node from the TreeModel identified by the given id. All Objects in the graph have a unique id. If the parent has no more children after the add, its removed too. The tree is updated and the expanded states are preserved.

Parameters:
parent - the parent of the node to be removed.
id - unique identifier for the node to be removed.
See Also:
TreeStrategy.removeNode(javax.swing.tree.DefaultMutableTreeNode, long), removeNode(long)

visualEdgeAddedToVisualgraph

protected void visualEdgeAddedToVisualgraph(VisualGraph vgv,
                                            VisualEdge ve)

Routine used when a VisualEdge is added to a VisualGraph. This method is called by initializeModel(Map, Document, String, boolean) and visualEdgeAdded(VisualGraphEvent).

Parameters:
vgv - a VisualGraph.
ve - a VisualEdge which was added to vgv.

visualEdgeAddedToSubgraph

protected void visualEdgeAddedToSubgraph(VisualSubgraph vsg,
                                         VisualEdge ve)

Routine used when a VisualEdge is added to a VisualSubgraph.

Parameters:
vsg - a VisualSubgraph.
ve - a VisualEdge which was added to vsg.

isolatedVisualEdgeAddedToVisualgraph

protected void isolatedVisualEdgeAddedToVisualgraph(VisualGraph vgv,
                                                    VisualEdge ve)

Routine used when an isolated VisualEdge is added to a VisualGraph. This method is called by initializeModel(Map, Document, String, boolean) and isolatedVisualEdgeAdded(VisualGraphEvent).

Parameters:
vgv - a VisualGraph.
ve - an isolated VisualEdge which was added to vgv.

isolatedVisualEdgeAddedToSubgraph

protected void isolatedVisualEdgeAddedToSubgraph(VisualSubgraph vsg,
                                                 VisualEdge ve)

Routine used when an isolated VisualEdge is added to a VisualSubgraph.

Parameters:
vsg - a VisualSubgraph.
ve - an isolated VisualEdge which was added to vsg.

setSelectionOnTree

protected void setSelectionOnTree(java.util.List selection)

Selects on the TreeOutliner the DefaultMutableTreeNode s corresponding to the BaseComposite s contained in selection.

Parameters:
selection - a list of BaseComposite s for which the corresponding DefaultMutableTreeNode of the TreeOutliner should be selected.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.