1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
package ext.edu.ucsf.rbvi.strucviz2; |
34 |
|
|
35 |
|
|
36 |
|
import java.util.ArrayList; |
37 |
|
import java.util.Collection; |
38 |
|
import java.util.Collections; |
39 |
|
import java.util.List; |
40 |
|
|
41 |
|
import javax.swing.JTree; |
42 |
|
import javax.swing.tree.DefaultMutableTreeNode; |
43 |
|
import javax.swing.tree.DefaultTreeModel; |
44 |
|
import javax.swing.tree.TreePath; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@author |
53 |
|
@see |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 56 (56) |
Complexity: 8 |
Complexity Density: 0.17 |
|
55 |
|
public class ChimeraTreeModel extends DefaultTreeModel |
56 |
|
{ |
57 |
|
private ChimeraManager chimeraManager; |
58 |
|
|
59 |
|
private JTree navigationTree; |
60 |
|
|
61 |
|
private int residueDisplay = ChimeraResidue.THREE_LETTER; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@param |
67 |
|
|
68 |
|
@param |
69 |
|
|
70 |
|
@see |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
72 |
0 |
public ChimeraTreeModel(ChimeraManager chimeraManager, JTree tree)... |
73 |
|
{ |
74 |
0 |
super(new DefaultMutableTreeNode()); |
75 |
0 |
this.chimeraManager = chimeraManager; |
76 |
0 |
this.navigationTree = tree; |
77 |
0 |
DefaultMutableTreeNode rootNode = buildTree(); |
78 |
0 |
this.setRoot(rootNode); |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
@param |
88 |
|
|
89 |
|
@see |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
public void setResidueDisplay(int newDisplay)... |
92 |
|
{ |
93 |
0 |
this.residueDisplay = newDisplay; |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
99 |
0 |
public void reload()... |
100 |
|
{ |
101 |
|
|
102 |
0 |
DefaultMutableTreeNode rootNode = buildTree(); |
103 |
0 |
this.setRoot(rootNode); |
104 |
|
|
105 |
|
|
106 |
0 |
super.reload(); |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
112 |
0 |
public void rebuildTree()... |
113 |
|
{ |
114 |
0 |
DefaultMutableTreeNode rootNode = buildTree(); |
115 |
0 |
DefaultTreeModel model = (DefaultTreeModel) navigationTree.getModel(); |
116 |
0 |
model.setRoot(rootNode); |
117 |
0 |
model.reload(); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
@return |
124 |
|
|
125 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
126 |
0 |
private DefaultMutableTreeNode buildTree()... |
127 |
|
{ |
128 |
0 |
int modelCount = chimeraManager.getChimeraModelsCount(true); |
129 |
0 |
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( |
130 |
|
modelCount + " Open Chimera Models"); |
131 |
0 |
TreePath rootPath = new TreePath(rootNode); |
132 |
|
|
133 |
0 |
TreePath path = null; |
134 |
0 |
DefaultMutableTreeNode model = null; |
135 |
|
|
136 |
|
|
137 |
0 |
for (ChimeraModel chimeraModel : chimeraManager.getChimeraModels()) |
138 |
|
{ |
139 |
0 |
model = new DefaultMutableTreeNode(chimeraModel); |
140 |
0 |
path = rootPath.pathByAddingChild(model); |
141 |
0 |
chimeraModel.setUserData(path); |
142 |
0 |
addChainNodes(chimeraModel, model, path); |
143 |
0 |
rootNode.add(model); |
144 |
|
} |
145 |
0 |
return rootNode; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
@param |
152 |
|
|
153 |
|
@param |
154 |
|
|
155 |
|
@param |
156 |
|
|
157 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
158 |
0 |
private void addChainNodes(ChimeraModel chimeraModel,... |
159 |
|
DefaultMutableTreeNode treeModel, TreePath treePath) |
160 |
|
{ |
161 |
0 |
DefaultMutableTreeNode chain = null; |
162 |
0 |
TreePath chainPath = null; |
163 |
|
|
164 |
|
|
165 |
0 |
Collection<ChimeraChain> chainList = chimeraModel.getChains(); |
166 |
|
|
167 |
0 |
if (chainList.size() == 0) |
168 |
|
{ |
169 |
|
|
170 |
0 |
addResidues(chimeraModel.getResidues(), treeModel, treePath); |
171 |
0 |
return; |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
0 |
for (ChimeraChain chimeraChain : chainList) |
177 |
|
{ |
178 |
0 |
chain = new DefaultMutableTreeNode(chimeraChain); |
179 |
0 |
chainPath = treePath.pathByAddingChild(chain); |
180 |
0 |
chimeraChain.setUserData(chainPath); |
181 |
0 |
addResidues(chimeraChain.getResidues(), chain, chainPath); |
182 |
0 |
treeModel.add(chain); |
183 |
|
} |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
@param |
190 |
|
|
191 |
|
@param |
192 |
|
|
193 |
|
@param |
194 |
|
|
195 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
196 |
0 |
private void addResidues(Collection<ChimeraResidue> residues,... |
197 |
|
DefaultMutableTreeNode treeModel, TreePath treePath) |
198 |
|
{ |
199 |
0 |
DefaultMutableTreeNode residue = null; |
200 |
0 |
TreePath residuePath = null; |
201 |
|
|
202 |
0 |
List<ChimeraResidue> sortedResidues = new ArrayList<ChimeraResidue>( |
203 |
|
residues); |
204 |
0 |
Collections.sort(sortedResidues); |
205 |
|
|
206 |
|
|
207 |
0 |
for (ChimeraResidue res : sortedResidues) |
208 |
|
{ |
209 |
0 |
res.setDisplayType(this.residueDisplay); |
210 |
0 |
residue = new DefaultMutableTreeNode(res); |
211 |
0 |
residuePath = treePath.pathByAddingChild(residue); |
212 |
0 |
res.setUserData(residuePath); |
213 |
0 |
treeModel.add(residue); |
214 |
|
} |
215 |
|
} |
216 |
|
} |