com.tensegrity.gui.swing.control.tree.strategy
Interface TreeStrategy

All Superinterfaces:
OutlinerStrategy
All Known Implementing Classes:
AbstractTreeStrategy

public interface TreeStrategy
extends OutlinerStrategy

This is the interface for the TreeStrategy. This is part of a concrete implementation of the Strategy Design Pattern which is used here in order to facilitate adding customized Tree models to the TreeOutliner instances. Note that there is a one-to-one relationship between an TreeStrategy and its DefaultTreeModel. In other words, if the client custom application requires a new model to be set for the TreeOutliner, it is necessary to provide both a new DefaultTreeModel and AbstractTreeStrategy implementation. This interface defines the following factory method in order to retrieve the correct instance of DefaultMutableTreeNode associated to an object which needs to be outlined in the Outliner.

See AbstractTreeStrategy for a partial implementation of this interface. AbstractTreeStrategy should be the only direct implementor of TreeStrategy. Concrete implementations are provided at the next level of inheritance (See AbstractVisualGraphTreeStrategy for example).

Version:
$Id: TreeStrategy.java,v 1.4 2004/10/15 09:01:00 SebastienGuyon Exp $
Author:
S�bastien Guyon
See Also:
TreeOutliner, OutlinerStrategy, AbstractTreeStrategy, AbstractVisualGraphTreeStrategy

Method Summary
 void addNode(javax.swing.tree.DefaultMutableTreeNode parent, javax.swing.tree.DefaultMutableTreeNode node)
          Method addNode adds the given node the the given parent.
 javax.swing.tree.DefaultMutableTreeNode getNewTreeNode(int subClassType, java.lang.Object documentObject)
           Simple factory method returning a new instance of DefaultMutableTreeNode corresponding to documentObject depending on the passed subClassType parameter.
 int getParentIndex(javax.swing.tree.DefaultMutableTreeNode parent)
          Returns the index reserved for the given parent node.
 void removeNode(javax.swing.tree.DefaultMutableTreeNode parent, long id)
          Method removeNode removes a Node from the TreeModel identified by the given id.
 void updateNode(javax.swing.tree.TreeNode node)
          Method updateNode reflects the changes made on the passed TreeNode on the TreeModel
 
Methods inherited from interface com.tensegrity.gui.swing.control.tree.strategy.OutlinerStrategy
getComparator
 

Method Detail

getParentIndex

public int getParentIndex(javax.swing.tree.DefaultMutableTreeNode parent)
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.

addNode

public void addNode(javax.swing.tree.DefaultMutableTreeNode parent,
                    javax.swing.tree.DefaultMutableTreeNode node)
Method addNode adds the given node the the given parent. If parent s childcount is 0 before the adding, its added to the root. The current expanded TreePath instances are saved and restored after the sucessful adding.

Parameters:
parent - the DefaultMutableTreeNode of which node is going to be added as a child
node - the DefaultMutableTreeNode to add.

removeNode

public void removeNode(javax.swing.tree.DefaultMutableTreeNode parent,
                       long id)
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.

updateNode

public void updateNode(javax.swing.tree.TreeNode node)

Method updateNode reflects the changes made on the passed TreeNode on the TreeModel

Parameters:
node - The TreeNode which requires to be updated

getNewTreeNode

public javax.swing.tree.DefaultMutableTreeNode getNewTreeNode(int subClassType,
                                                              java.lang.Object documentObject)

Simple factory method returning a new instance of DefaultMutableTreeNode corresponding to documentObject depending on the passed subClassType parameter. Refer to the implementation provided in AbstractVisualGraphTreeStrategy as an example on how is this method meant to be implemented.

Parameters:
subClassType - To be defined will implementing this method. This parameter should allow distinguishing possible subClasses of DefaultMutableTreeNode required by the caller.
documentObject - This is the object located on the active document for which a TreeNode is required.
Returns:
a new instance of DefaultMutableTreeNode (usually a subClass)


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