View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.panels.projections;
17  
18  import java.util.Collection;
19  
20  import javax.swing.JTree;
21  import javax.swing.tree.DefaultTreeModel;
22  
23  import p3j.pppm.sets.Set;
24  
25  /**
26   * 
27   * Interface for all {@link ProjectionTreeNode} entities to manipulate and
28   * notify their projection tree.
29   * 
30   * Created: August 27, 2008
31   * 
32   * @author Christina Bohk
33   * @author Roland Ewald
34   * 
35   */
36  public interface IProjectionTree {
37  
38  	/**
39  	 * Get the model of the tree. Useful to propagate updates etc.
40  	 * 
41  	 * @return model of the projection tree
42  	 */
43  	DefaultTreeModel getTreeModel();
44  
45  	/**
46  	 * Get the actual tree component. Useful for selection updates etc.
47  	 * 
48  	 * @return actual tree component
49  	 */
50  	JTree getTree();
51  
52  	/**
53  	 * Refresh a single node in the tree.
54  	 * 
55  	 * @param node
56  	 *          the node to be refreshed
57  	 */
58  	void refreshNode(ProjectionTreeNode<?> node);
59  
60  	/**
61  	 * Refreshed the sub-structures of the node in the tree.
62  	 * 
63  	 * @param node
64  	 *          the node of which the sub-structures shall be refreshed
65  	 */
66  	void refreshNodeSubStructure(ProjectionTreeNode<?> node);
67  
68  	/**
69  	 * Notifies tree that the given node as a new child at the given index.
70  	 * 
71  	 * @param node
72  	 *          node with new child
73  	 * @param childIndex
74  	 *          index of the new child
75  	 */
76  	void nodeAdded(ParameterInstanceNode node, int childIndex);
77  
78  	/**
79  	 * Selects a given node.
80  	 * 
81  	 * @param node
82  	 *          the node to be selected
83  	 */
84  	void selectNode(ProjectionTreeNode<?> node);
85  
86  	/**
87  	 * Recursively refreshes the node names of node in the sub-tree below the
88  	 * given node.
89  	 * 
90  	 * @param node
91  	 *          the node of which the subtree shall be refreshed
92  	 */
93  	void recursiveRefresh(ProjectionTreeNode<?> node);
94  
95  	/**
96  	 * Removes given node.
97  	 * 
98  	 * @param node
99  	 *          the node to be removed
100 	 */
101 	void removeNode(ProjectionTreeNode<?> node);
102 
103 	/**
104 	 * Removes all nodes that represent the objects given in the collection.
105 	 * 
106 	 * @param node
107 	 *          the node from which to start looking
108 	 * @param repRemovObjects
109 	 *          collection of the represented object of the nodes to be removed
110 	 */
111 	void removeNodes(ProjectionTreeNode<?> node,
112 	    Collection<? extends Object> repRemovObjects);
113 
114 	/**
115 	 * Cleans the tree from unnecessary leaves. This could be an empty generation
116 	 * etc.
117 	 */
118 	void cleanTree();
119 
120 	/**
121 	 * Creates all substructures for displaying a set.
122 	 * 
123 	 * @param stNode
124 	 *          the Settype node the set belongs to
125 	 * @param set
126 	 *          the set for which the structure shall be created
127 	 * @return the set node at the top of the subtree
128 	 */
129 	SetNode createNewSetStructure(SetTypeNode stNode, Set set);
130 
131 	/**
132 	 * Totally refreshes the projection tree. All nodes beneath the
133 	 * {@link ProjectionNode} are re-created and re-initialized.
134 	 */
135 	void totalRefresh();
136 
137 }