2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* GOTreeViewer.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on August 11, 2004, 10:31 AM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
package org.tigr.microarray.mev.cluster.gui.impl.ease.gotree; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
23 |
import java.io.BufferedReader; |
2 |
26 Feb 07 |
jari |
24 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.FileNotFoundException; |
2 |
26 Feb 07 |
jari |
26 |
import java.io.FileReader; |
2 |
26 Feb 07 |
jari |
27 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
28 |
import java.io.ObjectInputStream; |
2 |
26 Feb 07 |
jari |
29 |
import java.io.ObjectOutputStream; |
2 |
26 Feb 07 |
jari |
30 |
import java.io.Serializable; |
2 |
26 Feb 07 |
jari |
31 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
32 |
import java.util.Iterator; |
2 |
26 Feb 07 |
jari |
33 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JMenu; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
44 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
46 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
47 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.microarray.mev.TMEV; |
2 |
26 Feb 07 |
jari |
50 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
51 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
52 |
import org.tigr.microarray.mev.cluster.gui.IDisplayMenu; |
2 |
26 Feb 07 |
jari |
53 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
54 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
55 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
56 |
import org.tigr.microarray.mev.cluster.gui.helpers.ktree.ITreeNode; |
2 |
26 Feb 07 |
jari |
57 |
import org.tigr.microarray.mev.cluster.gui.helpers.ktree.ITreeNodeRenderer; |
2 |
26 Feb 07 |
jari |
58 |
import org.tigr.microarray.mev.cluster.gui.helpers.ktree.Ktree; |
2 |
26 Feb 07 |
jari |
59 |
|
2 |
26 Feb 07 |
jari |
60 |
/** |
2 |
26 Feb 07 |
jari |
61 |
* |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
63 |
*/ |
2 |
26 Feb 07 |
jari |
64 |
public class GOTreeViewer extends JPanel implements IViewer { |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
private String category; |
2 |
26 Feb 07 |
jari |
67 |
private Ktree tree; |
2 |
26 Feb 07 |
jari |
68 |
private Vector nodes; |
2 |
26 Feb 07 |
jari |
69 |
private DefaultMutableTreeNode viewerNode; |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
private int selectionPolarity = 0; |
2 |
26 Feb 07 |
jari |
72 |
private JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
73 |
private boolean verbose = false; |
2 |
26 Feb 07 |
jari |
74 |
private GOTreeHeader header; |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
private JMenu newTreeMenu; |
2 |
26 Feb 07 |
jari |
77 |
private JMenu launchMenu; |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
private IFramework framework; |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
private double upper = 0.05; |
2 |
26 Feb 07 |
jari |
82 |
private double lower = 0.01; |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
private String baseFileSystem; |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
private GONode[][] storedNodes; |
2 |
26 Feb 07 |
jari |
87 |
private String[] headerFields; |
2 |
26 Feb 07 |
jari |
88 |
private int exptID = 0; |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of GOTreeViewer */ |
2 |
26 Feb 07 |
jari |
91 |
public GOTreeViewer() { |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
93 |
} |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
public GOTreeViewer(GONode root) { |
2 |
26 Feb 07 |
jari |
96 |
super(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
97 |
tree = new Ktree(root); |
2 |
26 Feb 07 |
jari |
98 |
add(tree, new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0)); |
2 |
26 Feb 07 |
jari |
99 |
} |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
public GOTreeViewer(GONode [][] data, DefaultMutableTreeNode viewerNode, String baseFileSystem) { |
2 |
26 Feb 07 |
jari |
103 |
super(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
104 |
this.storedNodes = data; |
2 |
26 Feb 07 |
jari |
105 |
this.baseFileSystem = baseFileSystem; |
2 |
26 Feb 07 |
jari |
106 |
tree = new Ktree(data); |
2 |
26 Feb 07 |
jari |
107 |
header = new GOTreeHeader(data[0][0], this, upper, lower); |
2 |
26 Feb 07 |
jari |
108 |
this.viewerNode = viewerNode; |
2 |
26 Feb 07 |
jari |
109 |
add(tree, new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0)); |
2 |
26 Feb 07 |
jari |
110 |
nodes = new Vector(); |
2 |
26 Feb 07 |
jari |
111 |
for(int i = 0; i < data.length; i++) { |
2 |
26 Feb 07 |
jari |
112 |
for(int j = 0; j < data[i].length; j++) { |
2 |
26 Feb 07 |
jari |
113 |
nodes.addElement(data[i][j]); |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
} |
2 |
26 Feb 07 |
jari |
116 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
117 |
tree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
118 |
this.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
119 |
createPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
120 |
} |
2 |
26 Feb 07 |
jari |
121 |
|
2 |
26 Feb 07 |
jari |
122 |
|
2 |
26 Feb 07 |
jari |
123 |
public GOTreeViewer(String goCategory, String [] headerFields, String [][] data, DefaultMutableTreeNode viewerNode, String baseFileSystem) { |
2 |
26 Feb 07 |
jari |
124 |
super(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
126 |
this.viewerNode = viewerNode; |
2 |
26 Feb 07 |
jari |
127 |
this.baseFileSystem = baseFileSystem; |
2 |
26 Feb 07 |
jari |
128 |
category = goCategory; |
2 |
26 Feb 07 |
jari |
129 |
this.storedNodes = constructTree(goCategory, headerFields, data); |
2 |
26 Feb 07 |
jari |
130 |
this.headerFields = headerFields; |
2 |
26 Feb 07 |
jari |
131 |
tree = new Ktree(storedNodes); |
2 |
26 Feb 07 |
jari |
132 |
header = new GOTreeHeader(storedNodes[0][0], this, upper, lower); |
2 |
26 Feb 07 |
jari |
133 |
add(tree, new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0)); |
2 |
26 Feb 07 |
jari |
134 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
135 |
tree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
136 |
this.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
137 |
createPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
138 |
setVerboseNodeStyle(false); |
2 |
26 Feb 07 |
jari |
139 |
} |
2 |
26 Feb 07 |
jari |
140 |
/** |
2 |
26 Feb 07 |
jari |
* @inheritDoc |
2 |
26 Feb 07 |
jari |
142 |
*/ |
2 |
26 Feb 07 |
jari |
143 |
public Expression getExpression(){ |
2 |
26 Feb 07 |
jari |
144 |
return new Expression(this, this.getClass(), "new", |
2 |
26 Feb 07 |
jari |
145 |
new Object[]{storedNodes, baseFileSystem, |
2 |
26 Feb 07 |
jari |
146 |
category, headerFields, new Integer(selectionPolarity), |
2 |
26 Feb 07 |
jari |
147 |
new Boolean(verbose), new Double(upper), new Double(lower)}); |
2 |
26 Feb 07 |
jari |
148 |
} |
2 |
26 Feb 07 |
jari |
149 |
/** |
2 |
26 Feb 07 |
jari |
* Re-creates a GOTreeViewer from stored data in an XMLEncoded file. |
2 |
26 Feb 07 |
jari |
151 |
* |
2 |
26 Feb 07 |
jari |
* @param exptID |
2 |
26 Feb 07 |
jari |
* @param storedNodes |
2 |
26 Feb 07 |
jari |
* @param baseFileSystem |
2 |
26 Feb 07 |
jari |
* @param category |
2 |
26 Feb 07 |
jari |
* @param headerFields |
2 |
26 Feb 07 |
jari |
* @param selectionPolarity |
2 |
26 Feb 07 |
jari |
* @param verbose |
2 |
26 Feb 07 |
jari |
* @param upper |
2 |
26 Feb 07 |
jari |
* @param lower |
2 |
26 Feb 07 |
jari |
161 |
*/ |
2 |
26 Feb 07 |
jari |
162 |
public GOTreeViewer(GONode[][] storedNodes, String baseFileSystem, |
2 |
26 Feb 07 |
jari |
163 |
String category, String [] headerFields, Integer selectionPolarity, |
2 |
26 Feb 07 |
jari |
164 |
Boolean verbose, Double upper, Double lower){ |
2 |
26 Feb 07 |
jari |
165 |
this.storedNodes = storedNodes; |
2 |
26 Feb 07 |
jari |
166 |
this.headerFields = headerFields; |
2 |
26 Feb 07 |
jari |
167 |
this.baseFileSystem = baseFileSystem; |
2 |
26 Feb 07 |
jari |
168 |
this.category = category; |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
this.tree = new Ktree(this.storedNodes); |
2 |
26 Feb 07 |
jari |
171 |
this.selectionPolarity = selectionPolarity.intValue(); |
2 |
26 Feb 07 |
jari |
172 |
this.verbose = verbose.booleanValue(); |
2 |
26 Feb 07 |
jari |
173 |
this.upper = upper.doubleValue(); |
2 |
26 Feb 07 |
jari |
174 |
this.lower = lower.doubleValue(); |
2 |
26 Feb 07 |
jari |
175 |
this.header = new GOTreeHeader(this.storedNodes[0][0], this, this.upper, this.lower); |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
this.nodes = new Vector(); |
2 |
26 Feb 07 |
jari |
178 |
for(int i = 0; i < storedNodes.length; i++) { |
2 |
26 Feb 07 |
jari |
179 |
for(int j = 0; j < storedNodes[i].length; j++) { |
2 |
26 Feb 07 |
jari |
180 |
nodes.addElement(storedNodes[i][j]); |
2 |
26 Feb 07 |
jari |
181 |
} |
2 |
26 Feb 07 |
jari |
182 |
} |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
184 |
this.setVerboseNodeStyle(this.verbose); |
2 |
26 Feb 07 |
jari |
185 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
186 |
tree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
187 |
this.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
188 |
createPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
189 |
} |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
191 |
|
2 |
26 Feb 07 |
jari |
192 |
private GONode [][] constructTree(String goCategory, String [] header, String [][] data) { |
2 |
26 Feb 07 |
jari |
193 |
Hashtable termHash = new Hashtable(data.length); |
2 |
26 Feb 07 |
jari |
194 |
int goAccIndex= 0, termIndex = 0, listHitIndex = 0, popHitIndex = 0, statIndex = 0, catIndex = 0; |
2 |
26 Feb 07 |
jari |
195 |
String [] keys = { "Acc.", "Term", "List Hits", "Pop. Hits", "File"}; |
2 |
26 Feb 07 |
jari |
196 |
boolean haveAcc = false; |
2 |
26 Feb 07 |
jari |
197 |
GONode currNode; |
2 |
26 Feb 07 |
jari |
//find the indices for the key fields |
2 |
26 Feb 07 |
jari |
199 |
int index = 0; |
2 |
26 Feb 07 |
jari |
200 |
for(int i = 0; i < keys.length; i++) { |
2 |
26 Feb 07 |
jari |
201 |
for(int j = 0; j < header.length; j++) { |
2 |
26 Feb 07 |
jari |
202 |
if(header[j].equals(keys[i])) { |
2 |
26 Feb 07 |
jari |
203 |
index = j; |
2 |
26 Feb 07 |
jari |
204 |
} |
2 |
26 Feb 07 |
jari |
205 |
} |
2 |
26 Feb 07 |
jari |
206 |
if(i == 0) |
2 |
26 Feb 07 |
jari |
207 |
goAccIndex = index; |
2 |
26 Feb 07 |
jari |
208 |
else if(i == 1) |
2 |
26 Feb 07 |
jari |
209 |
termIndex = index; |
2 |
26 Feb 07 |
jari |
210 |
else if(i == 2) |
2 |
26 Feb 07 |
jari |
211 |
listHitIndex = index; |
2 |
26 Feb 07 |
jari |
212 |
else if(i == 3) |
2 |
26 Feb 07 |
jari |
213 |
popHitIndex = index; |
2 |
26 Feb 07 |
jari |
214 |
else |
2 |
26 Feb 07 |
jari |
215 |
catIndex = index; |
2 |
26 Feb 07 |
jari |
216 |
} |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
if(goAccIndex < 4) { |
2 |
26 Feb 07 |
jari |
219 |
haveAcc = true; |
2 |
26 Feb 07 |
jari |
220 |
statIndex = 8; |
2 |
26 Feb 07 |
jari |
221 |
} else { |
2 |
26 Feb 07 |
jari |
222 |
statIndex = 7; |
2 |
26 Feb 07 |
jari |
223 |
} |
2 |
26 Feb 07 |
jari |
224 |
|
2 |
26 Feb 07 |
jari |
//accumulate primary nodes. |
2 |
26 Feb 07 |
jari |
226 |
nodes = new Vector(data.length); |
2 |
26 Feb 07 |
jari |
227 |
for(int i = 0; i < data.length; i++) { |
2 |
26 Feb 07 |
jari |
228 |
if(data[i][catIndex].indexOf(category) != -1) { //row of interest |
2 |
26 Feb 07 |
jari |
229 |
GONode node = new GONode(data[i][goAccIndex], data[i][termIndex], category, Double.parseDouble(data[i][statIndex]), Integer.parseInt(data[i][listHitIndex]), |
2 |
26 Feb 07 |
jari |
230 |
Integer.parseInt(data[i][listHitIndex+1]), Integer.parseInt(data[i][popHitIndex]), Integer.parseInt(data[i][popHitIndex+1]), i); |
2 |
26 Feb 07 |
jari |
231 |
node.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_MINIMAL); |
2 |
26 Feb 07 |
jari |
232 |
node.setLowerThr(0.01d); |
2 |
26 Feb 07 |
jari |
233 |
node.setUpperThr(0.05d); |
2 |
26 Feb 07 |
jari |
234 |
nodes.addElement(node); |
2 |
26 Feb 07 |
jari |
235 |
} |
2 |
26 Feb 07 |
jari |
236 |
} |
2 |
26 Feb 07 |
jari |
237 |
|
2 |
26 Feb 07 |
jari |
238 |
makeAssociations(nodes); |
2 |
26 Feb 07 |
jari |
239 |
|
2 |
26 Feb 07 |
jari |
//nodes know associations and depth in tree |
2 |
26 Feb 07 |
jari |
//now construct the 2D GONode array structure |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
//make a root, will need to set parameters later. |
2 |
26 Feb 07 |
jari |
244 |
GONode myRoot = new GONode("GO:00000001", category, category, 1.0, 100,100,100,100,-1); |
2 |
26 Feb 07 |
jari |
245 |
myRoot.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_MINIMAL); |
2 |
26 Feb 07 |
jari |
246 |
|
2 |
26 Feb 07 |
jari |
//?? if a node does not have a parent, should it connect to the main root ?? |
2 |
26 Feb 07 |
jari |
248 |
|
2 |
26 Feb 07 |
jari |
//maybe look for nodes without parents and attach them to the root |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
251 |
for(int i = 0; i < nodes.size(); i++){ |
2 |
26 Feb 07 |
jari |
252 |
currNode = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
253 |
if(!currNode.hasParents()) { |
2 |
26 Feb 07 |
jari |
254 |
currNode.addParent(myRoot); |
2 |
26 Feb 07 |
jari |
255 |
myRoot.addChild(currNode); |
2 |
26 Feb 07 |
jari |
256 |
} |
2 |
26 Feb 07 |
jari |
257 |
} |
2 |
26 Feb 07 |
jari |
258 |
|
2 |
26 Feb 07 |
jari |
//OK, everyonne is connected, hopefully, now set the levels |
2 |
26 Feb 07 |
jari |
260 |
nodes.addElement(myRoot); |
2 |
26 Feb 07 |
jari |
261 |
setLevelIndex(nodes); |
2 |
26 Feb 07 |
jari |
262 |
|
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
264 |
|
2 |
26 Feb 07 |
jari |
//get maximum depth |
2 |
26 Feb 07 |
jari |
266 |
|
2 |
26 Feb 07 |
jari |
267 |
int maxDepth = 0; |
2 |
26 Feb 07 |
jari |
268 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
269 |
currNode = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
270 |
maxDepth = Math.max(maxDepth, currNode.getLevel()); |
2 |
26 Feb 07 |
jari |
271 |
} |
2 |
26 Feb 07 |
jari |
272 |
|
2 |
26 Feb 07 |
jari |
//max depth gives the height of the tree |
2 |
26 Feb 07 |
jari |
274 |
GONode [][] nodeData = new GONode[maxDepth+1][]; |
2 |
26 Feb 07 |
jari |
275 |
|
2 |
26 Feb 07 |
jari |
276 |
for(int i = 0; i < nodeData.length; i++) { |
2 |
26 Feb 07 |
jari |
277 |
nodeData[i] = getLevelNodes(nodes, i); |
2 |
26 Feb 07 |
jari |
278 |
} |
2 |
26 Feb 07 |
jari |
279 |
|
2 |
26 Feb 07 |
jari |
//set real stats for the root |
2 |
26 Feb 07 |
jari |
281 |
|
2 |
26 Feb 07 |
jari |
//Set parmeters for the root |
2 |
26 Feb 07 |
jari |
283 |
ITreeNode [] children = myRoot.getChildren(); |
2 |
26 Feb 07 |
jari |
284 |
|
2 |
26 Feb 07 |
jari |
285 |
if(children.length > 0) { |
2 |
26 Feb 07 |
jari |
286 |
myRoot.setListSize(((GONode)children[0]).getListSize()); |
2 |
26 Feb 07 |
jari |
287 |
myRoot.setListHits(((GONode)children[0]).getListSize()); //root has size number of hits |
2 |
26 Feb 07 |
jari |
288 |
|
2 |
26 Feb 07 |
jari |
289 |
myRoot.setPopSize(((GONode)children[0]).getPopSize()); |
2 |
26 Feb 07 |
jari |
290 |
myRoot.setPopHits(((GONode)children[0]).getPopSize()); //root has size number of hits |
2 |
26 Feb 07 |
jari |
291 |
} |
2 |
26 Feb 07 |
jari |
292 |
|
2 |
26 Feb 07 |
jari |
293 |
|
2 |
26 Feb 07 |
jari |
294 |
return nodeData; |
2 |
26 Feb 07 |
jari |
295 |
} |
2 |
26 Feb 07 |
jari |
296 |
|
2 |
26 Feb 07 |
jari |
297 |
private GONode [] getLevelNodes(Vector nodes, int level) { |
2 |
26 Feb 07 |
jari |
298 |
Vector levelNodes = new Vector(); |
2 |
26 Feb 07 |
jari |
299 |
GONode node; |
2 |
26 Feb 07 |
jari |
300 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
301 |
node = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
302 |
if(node.getLevel() == level) |
2 |
26 Feb 07 |
jari |
303 |
levelNodes.addElement(node); |
2 |
26 Feb 07 |
jari |
304 |
} |
2 |
26 Feb 07 |
jari |
305 |
|
2 |
26 Feb 07 |
jari |
306 |
GONode [] n = new GONode[levelNodes.size()]; |
2 |
26 Feb 07 |
jari |
307 |
|
2 |
26 Feb 07 |
jari |
308 |
for(int i = 0; i < n.length; i++) { |
2 |
26 Feb 07 |
jari |
309 |
n[i] = (GONode)(levelNodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
310 |
} |
2 |
26 Feb 07 |
jari |
311 |
return n; |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
|
2 |
26 Feb 07 |
jari |
314 |
private boolean makeAssociations(Vector nodes) { |
2 |
26 Feb 07 |
jari |
//Get hash table of association vectors |
2 |
26 Feb 07 |
jari |
//key will be a term string, associations (parents) will be |
2 |
26 Feb 07 |
jari |
// terms in the value Vector key; |
2 |
26 Feb 07 |
jari |
318 |
|
2 |
26 Feb 07 |
jari |
319 |
Hashtable impliesTable = null; |
2 |
26 Feb 07 |
jari |
320 |
try { |
2 |
26 Feb 07 |
jari |
321 |
impliesTable= getAllAssociations(); |
2 |
26 Feb 07 |
jari |
322 |
} catch (FileNotFoundException fnfe) { |
2 |
26 Feb 07 |
jari |
323 |
System.out.println("fnfe"); |
2 |
26 Feb 07 |
jari |
324 |
fnfe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
325 |
return false; |
2 |
26 Feb 07 |
jari |
326 |
} catch (IOException ioe) { |
2 |
26 Feb 07 |
jari |
327 |
System.out.println("ioe"); |
2 |
26 Feb 07 |
jari |
328 |
ioe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
329 |
return false; |
2 |
26 Feb 07 |
jari |
330 |
} |
2 |
26 Feb 07 |
jari |
331 |
|
2 |
26 Feb 07 |
jari |
332 |
if(impliesTable == null || impliesTable.size() == 0) |
2 |
26 Feb 07 |
jari |
333 |
return false; |
2 |
26 Feb 07 |
jari |
334 |
|
2 |
26 Feb 07 |
jari |
335 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
336 |
makeAssociations(impliesTable, nodes, (GONode)(nodes.elementAt(i))); |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
return true; |
2 |
26 Feb 07 |
jari |
339 |
} |
2 |
26 Feb 07 |
jari |
340 |
|
2 |
26 Feb 07 |
jari |
341 |
|
2 |
26 Feb 07 |
jari |
342 |
private void makeAssociations(Hashtable impTable, Vector nodes, GONode baseNode) { |
2 |
26 Feb 07 |
jari |
343 |
String term = baseNode.getTerm(); |
2 |
26 Feb 07 |
jari |
344 |
Vector termVector; |
2 |
26 Feb 07 |
jari |
345 |
if(!impTable.containsKey(term)) |
2 |
26 Feb 07 |
jari |
346 |
return; |
2 |
26 Feb 07 |
jari |
347 |
else { |
2 |
26 Feb 07 |
jari |
348 |
termVector = (Vector)impTable.get(term); |
2 |
26 Feb 07 |
jari |
349 |
|
2 |
26 Feb 07 |
jari |
350 |
if(termVector == null) |
2 |
26 Feb 07 |
jari |
351 |
return; |
2 |
26 Feb 07 |
jari |
352 |
|
2 |
26 Feb 07 |
jari |
353 |
GONode currParent, parentNode; |
2 |
26 Feb 07 |
jari |
354 |
|
2 |
26 Feb 07 |
jari |
355 |
for(int i = 0; i < termVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
356 |
parentNode = this.getNode(nodes, (String)(termVector.elementAt(i))); |
2 |
26 Feb 07 |
jari |
357 |
if(parentNode != null) { |
2 |
26 Feb 07 |
jari |
//make the associations, note that !ifContains will apply on these adds |
2 |
26 Feb 07 |
jari |
359 |
baseNode.addParent(parentNode); |
2 |
26 Feb 07 |
jari |
360 |
parentNode.addChild(baseNode); |
2 |
26 Feb 07 |
jari |
//recurse |
2 |
26 Feb 07 |
jari |
362 |
makeAssociations(impTable, nodes, parentNode); |
2 |
26 Feb 07 |
jari |
363 |
} |
2 |
26 Feb 07 |
jari |
364 |
} |
2 |
26 Feb 07 |
jari |
365 |
} |
2 |
26 Feb 07 |
jari |
366 |
} |
2 |
26 Feb 07 |
jari |
367 |
|
2 |
26 Feb 07 |
jari |
368 |
public int getViewerWidth() { |
2 |
26 Feb 07 |
jari |
369 |
return tree.getTreePixelWidth(); |
2 |
26 Feb 07 |
jari |
370 |
} |
2 |
26 Feb 07 |
jari |
371 |
|
2 |
26 Feb 07 |
jari |
372 |
private void setLevelIndex(Vector nodes) { |
2 |
26 Feb 07 |
jari |
373 |
GONode currNode; |
2 |
26 Feb 07 |
jari |
374 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
375 |
currNode = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
376 |
currNode.setLevel(currNode.getMaxPathLengthToRoot()-1); |
2 |
26 Feb 07 |
jari |
377 |
} |
2 |
26 Feb 07 |
jari |
378 |
} |
2 |
26 Feb 07 |
jari |
379 |
|
2 |
26 Feb 07 |
jari |
380 |
private Hashtable getAllAssociations() throws FileNotFoundException, IOException { |
2 |
26 Feb 07 |
jari |
//create hash table for implies using (implies_associator) |
2 |
26 Feb 07 |
jari |
//This will then be used to add implied categories |
2 |
26 Feb 07 |
jari |
383 |
int idx; |
2 |
26 Feb 07 |
jari |
384 |
String impliesFile, line; |
2 |
26 Feb 07 |
jari |
385 |
Hashtable implied_associations = new Hashtable(10000); |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
File impliesFolder = TMEV.getFile(baseFileSystem+"/Data/Class/Implies/"); |
2 |
26 Feb 07 |
jari |
388 |
String folderPath = impliesFolder.getPath(); |
2 |
26 Feb 07 |
jari |
389 |
impliesFile = folderPath+"/"+category+".txt"; |
2 |
26 Feb 07 |
jari |
390 |
|
2 |
26 Feb 07 |
jari |
391 |
File file = new File(impliesFile); |
2 |
26 Feb 07 |
jari |
392 |
if(!file.exists() || !file.isFile()) //if implies file is missing move on |
2 |
26 Feb 07 |
jari |
393 |
return null; |
2 |
26 Feb 07 |
jari |
394 |
|
2 |
26 Feb 07 |
jari |
395 |
BufferedReader in = new BufferedReader(new FileReader(impliesFile)); |
2 |
26 Feb 07 |
jari |
396 |
|
2 |
26 Feb 07 |
jari |
397 |
while((line = in.readLine()) != null){ |
2 |
26 Feb 07 |
jari |
398 |
idx = line.indexOf('\t'); |
2 |
26 Feb 07 |
jari |
399 |
|
2 |
26 Feb 07 |
jari |
400 |
if(idx >= line.length() || idx < 1) //must include a tab |
2 |
26 Feb 07 |
jari |
401 |
continue; |
2 |
26 Feb 07 |
jari |
402 |
|
2 |
26 Feb 07 |
jari |
403 |
if(!implied_associations.containsKey(line.substring(0,idx).trim())) { |
2 |
26 Feb 07 |
jari |
404 |
implied_associations.put(line.substring(0,idx).trim(), new Vector()); |
2 |
26 Feb 07 |
jari |
405 |
((Vector)(implied_associations.get(line.substring(0,idx).trim()))).addElement(line.substring(idx, line.length()).trim()); |
2 |
26 Feb 07 |
jari |
406 |
} else { |
2 |
26 Feb 07 |
jari |
407 |
((Vector)(implied_associations.get(line.substring(0,idx).trim()))).addElement(line.substring(idx, line.length()).trim()); |
2 |
26 Feb 07 |
jari |
408 |
} |
2 |
26 Feb 07 |
jari |
409 |
} |
2 |
26 Feb 07 |
jari |
410 |
return implied_associations; |
2 |
26 Feb 07 |
jari |
411 |
} |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
|
2 |
26 Feb 07 |
jari |
414 |
|
2 |
26 Feb 07 |
jari |
415 |
private GONode getNode(Vector nodes, String key) { |
2 |
26 Feb 07 |
jari |
416 |
Iterator iter = nodes.iterator(); |
2 |
26 Feb 07 |
jari |
417 |
GONode currNode; |
2 |
26 Feb 07 |
jari |
418 |
GONode foundNode = null; |
2 |
26 Feb 07 |
jari |
419 |
boolean found = false; |
2 |
26 Feb 07 |
jari |
420 |
|
2 |
26 Feb 07 |
jari |
421 |
while(!found && iter.hasNext()) { |
2 |
26 Feb 07 |
jari |
422 |
currNode = (GONode)(iter.next()); |
2 |
26 Feb 07 |
jari |
423 |
if(key.equals(currNode.getTerm())) { |
2 |
26 Feb 07 |
jari |
424 |
foundNode = currNode; |
2 |
26 Feb 07 |
jari |
425 |
found = true; |
2 |
26 Feb 07 |
jari |
426 |
} |
2 |
26 Feb 07 |
jari |
427 |
} |
2 |
26 Feb 07 |
jari |
428 |
return foundNode; |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
431 |
|
2 |
26 Feb 07 |
jari |
432 |
|
2 |
26 Feb 07 |
jari |
433 |
/* |
2 |
26 Feb 07 |
jari |
public static void main(String [] args) { |
2 |
26 Feb 07 |
jari |
435 |
|
2 |
26 Feb 07 |
jari |
// GONode node = new GONode("GO:0001234", "mitotic spindle formation, biological process", "biological process", 0.000012, 10, 12, 14, 5067); |
2 |
26 Feb 07 |
jari |
// GONode node = new GONode("GO:0001234", "transmembrane receptor protein tyrosine kinase signaling pathway", "biological process", 0.000012, 10, 12, 14, 5067); |
2 |
26 Feb 07 |
jari |
GONode node = new GONode("GO:0001234", "G-protein signaling, coupled to IP3 second messenger (phospholipase C activating)", "biological process", 0.00124, 23, 33, 63, 25067,-1); |
2 |
26 Feb 07 |
jari |
GONode node1 = new GONode("GO:0001234", "transmembrane receptor protein tyrosine kinase signaling pathway", "biological process", 0.000012, 10, 12, 14, 5067, -1); |
2 |
26 Feb 07 |
jari |
GONode node2 = new GONode("GO:0001234", "transmembrane receptor protein tyrosine kinase signaling pathway", "biological process", 0.000012, 10, 12, 14, 5067, -1); |
2 |
26 Feb 07 |
jari |
GONode node3 = new GONode("GO:0001234", "transmembrane receptor protein tyrosine kinase signaling pathway", "biological process", 0.000012, 10, 12, 14, 5067, -1); |
2 |
26 Feb 07 |
jari |
442 |
|
2 |
26 Feb 07 |
jari |
GONode [][] nodes = new GONode[2][]; |
2 |
26 Feb 07 |
jari |
GONode [] lev1 = new GONode[1]; |
2 |
26 Feb 07 |
jari |
GONode [] lev2 = new GONode[3]; |
2 |
26 Feb 07 |
jari |
446 |
|
2 |
26 Feb 07 |
jari |
lev1[0] = node; |
2 |
26 Feb 07 |
jari |
lev2[0] = node1; |
2 |
26 Feb 07 |
jari |
lev2[1] = node2; |
2 |
26 Feb 07 |
jari |
lev2[2] = node3; |
2 |
26 Feb 07 |
jari |
451 |
|
2 |
26 Feb 07 |
jari |
nodes[0] = lev1; |
2 |
26 Feb 07 |
jari |
nodes[1] = lev2; |
2 |
26 Feb 07 |
jari |
454 |
|
2 |
26 Feb 07 |
jari |
node.addChild(node1); |
2 |
26 Feb 07 |
jari |
node.addChild(node2); |
2 |
26 Feb 07 |
jari |
node.addChild(node3); |
2 |
26 Feb 07 |
jari |
458 |
|
2 |
26 Feb 07 |
jari |
node1.addParent(node); |
2 |
26 Feb 07 |
jari |
node2.addParent(node); |
2 |
26 Feb 07 |
jari |
node3.addParent(node); |
2 |
26 Feb 07 |
jari |
462 |
/* |
2 |
26 Feb 07 |
jari |
node.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_MINIMAL); |
2 |
26 Feb 07 |
jari |
node1.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_MINIMAL); |
2 |
26 Feb 07 |
jari |
node2.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_MINIMAL); |
2 |
26 Feb 07 |
jari |
node3.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_MINIMAL); |
2 |
26 Feb 07 |
jari |
467 |
|
2 |
26 Feb 07 |
jari |
468 |
*/ |
2 |
26 Feb 07 |
jari |
469 |
/* |
2 |
26 Feb 07 |
jari |
node.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_VERBOSE); |
2 |
26 Feb 07 |
jari |
node1.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_VERBOSE); |
2 |
26 Feb 07 |
jari |
node2.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_VERBOSE); |
2 |
26 Feb 07 |
jari |
node3.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_VERBOSE); |
2 |
26 Feb 07 |
jari |
474 |
|
2 |
26 Feb 07 |
jari |
GOTreeViewer viewer = new GOTreeViewer(nodes, new DefaultMutableTreeNode(), baseFileSystem); |
2 |
26 Feb 07 |
jari |
476 |
|
2 |
26 Feb 07 |
jari |
viewer.setVerboseNodeStyle(false); |
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
javax.swing.JFrame frame = new javax.swing.JFrame(); |
2 |
26 Feb 07 |
jari |
frame.getContentPane().add(viewer); |
2 |
26 Feb 07 |
jari |
frame.setSize(200, 400); |
2 |
26 Feb 07 |
jari |
frame.setVisible(true); |
2 |
26 Feb 07 |
jari |
483 |
} |
2 |
26 Feb 07 |
jari |
484 |
*/ |
2 |
26 Feb 07 |
jari |
485 |
|
2 |
26 Feb 07 |
jari |
/** Returns the viewer's clusters or null |
2 |
26 Feb 07 |
jari |
487 |
*/ |
2 |
26 Feb 07 |
jari |
488 |
public int[][] getClusters() { |
2 |
26 Feb 07 |
jari |
489 |
return null; |
2 |
26 Feb 07 |
jari |
490 |
} |
2 |
26 Feb 07 |
jari |
491 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into scroll pane view port. |
2 |
26 Feb 07 |
jari |
493 |
*/ |
2 |
26 Feb 07 |
jari |
494 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
495 |
return this.tree; |
2 |
26 Feb 07 |
jari |
496 |
} |
2 |
26 Feb 07 |
jari |
497 |
|
2 |
26 Feb 07 |
jari |
/** Returns the corner component corresponding to the indicated corner, |
2 |
26 Feb 07 |
jari |
* posibly null |
2 |
26 Feb 07 |
jari |
500 |
*/ |
2 |
26 Feb 07 |
jari |
501 |
public JComponent getCornerComponent(int cornerIndex) { |
2 |
26 Feb 07 |
jari |
502 |
return null; |
2 |
26 Feb 07 |
jari |
503 |
} |
2 |
26 Feb 07 |
jari |
504 |
|
2 |
26 Feb 07 |
jari |
/** Returns the viewer's experiment or null |
2 |
26 Feb 07 |
jari |
506 |
*/ |
2 |
26 Feb 07 |
jari |
507 |
public Experiment getExperiment() { |
2 |
26 Feb 07 |
jari |
508 |
return null; |
2 |
26 Feb 07 |
jari |
509 |
} |
2 |
26 Feb 07 |
jari |
510 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into scroll pane header. |
2 |
26 Feb 07 |
jari |
512 |
*/ |
2 |
26 Feb 07 |
jari |
513 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
// if(!this.verbose) |
2 |
26 Feb 07 |
jari |
515 |
return header; |
2 |
26 Feb 07 |
jari |
// return null; |
2 |
26 Feb 07 |
jari |
517 |
} |
2 |
26 Feb 07 |
jari |
518 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework to save or to print viewer image. |
2 |
26 Feb 07 |
jari |
520 |
*/ |
2 |
26 Feb 07 |
jari |
521 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
522 |
return null; |
2 |
26 Feb 07 |
jari |
523 |
} |
2 |
26 Feb 07 |
jari |
524 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into the scroll pane row header |
2 |
26 Feb 07 |
jari |
526 |
*/ |
2 |
26 Feb 07 |
jari |
527 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
528 |
return null; |
2 |
26 Feb 07 |
jari |
529 |
} |
2 |
26 Feb 07 |
jari |
530 |
|
2 |
26 Feb 07 |
jari |
/** Invoked when the framework is going to be closed. |
2 |
26 Feb 07 |
jari |
532 |
*/ |
2 |
26 Feb 07 |
jari |
533 |
public void onClosed() { |
2 |
26 Feb 07 |
jari |
534 |
} |
2 |
26 Feb 07 |
jari |
535 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when data is changed, |
2 |
26 Feb 07 |
jari |
* if this viewer is selected. |
2 |
26 Feb 07 |
jari |
* @see IData |
2 |
26 Feb 07 |
jari |
539 |
*/ |
2 |
26 Feb 07 |
jari |
540 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when this viewer was deselected. |
2 |
26 Feb 07 |
jari |
544 |
*/ |
2 |
26 Feb 07 |
jari |
545 |
public void onDeselected() { |
2 |
26 Feb 07 |
jari |
546 |
} |
2 |
26 Feb 07 |
jari |
547 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when display menu is changed, |
2 |
26 Feb 07 |
jari |
* if this viewer is selected. |
2 |
26 Feb 07 |
jari |
* @see IDisplayMenu |
2 |
26 Feb 07 |
jari |
551 |
*/ |
2 |
26 Feb 07 |
jari |
552 |
public void onMenuChanged(IDisplayMenu menu) { |
2 |
26 Feb 07 |
jari |
553 |
} |
2 |
26 Feb 07 |
jari |
554 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when this viewer is selected. |
2 |
26 Feb 07 |
jari |
556 |
*/ |
2 |
26 Feb 07 |
jari |
557 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
558 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
559 |
header.update(); |
2 |
26 Feb 07 |
jari |
560 |
|
2 |
26 Feb 07 |
jari |
561 |
if(this.viewerNode == null) |
2 |
26 Feb 07 |
jari |
562 |
this.viewerNode = (DefaultMutableTreeNode)(framework.getCurrentNode().getParent()); |
2 |
26 Feb 07 |
jari |
563 |
} |
2 |
26 Feb 07 |
jari |
564 |
|
2 |
26 Feb 07 |
jari |
565 |
private void setStraightConnectorStyle(boolean isStraight) { |
2 |
26 Feb 07 |
jari |
566 |
tree.setStraightConnectorStyle(isStraight); |
2 |
26 Feb 07 |
jari |
567 |
tree.repaint(); |
2 |
26 Feb 07 |
jari |
568 |
} |
2 |
26 Feb 07 |
jari |
569 |
|
2 |
26 Feb 07 |
jari |
570 |
private void setVerboseNodeStyle(boolean isVerbose) { |
2 |
26 Feb 07 |
jari |
571 |
int rendering; |
2 |
26 Feb 07 |
jari |
572 |
if(isVerbose) { |
2 |
26 Feb 07 |
jari |
573 |
rendering = ITreeNodeRenderer.RENDERING_HINT_VERBOSE; |
2 |
26 Feb 07 |
jari |
574 |
tree.setInterNodeHeight(60); |
2 |
26 Feb 07 |
jari |
575 |
tree.setInterNodeWidth(30); |
2 |
26 Feb 07 |
jari |
576 |
} else { |
2 |
26 Feb 07 |
jari |
577 |
rendering = ITreeNodeRenderer.RENDERING_HINT_MINIMAL; |
2 |
26 Feb 07 |
jari |
578 |
tree.setInterNodeHeight(40); |
2 |
26 Feb 07 |
jari |
579 |
tree.setInterNodeWidth(15); |
2 |
26 Feb 07 |
jari |
580 |
} |
2 |
26 Feb 07 |
jari |
581 |
|
2 |
26 Feb 07 |
jari |
582 |
verbose = isVerbose; |
2 |
26 Feb 07 |
jari |
583 |
|
2 |
26 Feb 07 |
jari |
584 |
for(int i =0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
585 |
((GONode)(nodes.elementAt(i))).setRenderingHint(rendering); |
2 |
26 Feb 07 |
jari |
586 |
} |
2 |
26 Feb 07 |
jari |
587 |
|
2 |
26 Feb 07 |
jari |
588 |
tree.updateSize(); //update tree size |
2 |
26 Feb 07 |
jari |
589 |
header.update(); //THEN update header size |
2 |
26 Feb 07 |
jari |
590 |
tree.repaint(); |
2 |
26 Feb 07 |
jari |
591 |
} |
2 |
26 Feb 07 |
jari |
592 |
|
2 |
26 Feb 07 |
jari |
593 |
|
2 |
26 Feb 07 |
jari |
594 |
private void setThresholds() { |
2 |
26 Feb 07 |
jari |
595 |
EaseThresholdDialog dialog = new EaseThresholdDialog((JFrame)framework.getFrame(), this.lower, this.upper); |
2 |
26 Feb 07 |
jari |
596 |
if(dialog.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
597 |
|
2 |
26 Feb 07 |
jari |
598 |
setThresholds(dialog.getUpperThreshold(), dialog.getLowerThreshold()); |
2 |
26 Feb 07 |
jari |
599 |
|
2 |
26 Feb 07 |
jari |
600 |
tree.repaint(); |
2 |
26 Feb 07 |
jari |
601 |
header.repaint(); |
2 |
26 Feb 07 |
jari |
602 |
} |
2 |
26 Feb 07 |
jari |
603 |
} |
2 |
26 Feb 07 |
jari |
604 |
|
2 |
26 Feb 07 |
jari |
605 |
|
2 |
26 Feb 07 |
jari |
606 |
public void setThresholds(double upper, double lower) { |
2 |
26 Feb 07 |
jari |
607 |
this.lower = lower; |
2 |
26 Feb 07 |
jari |
608 |
this.upper = upper; |
2 |
26 Feb 07 |
jari |
609 |
|
2 |
26 Feb 07 |
jari |
610 |
GONode currNode; |
2 |
26 Feb 07 |
jari |
611 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
612 |
currNode = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
613 |
currNode.setLowerThr(lower); |
2 |
26 Feb 07 |
jari |
614 |
currNode.setUpperThr(upper); |
2 |
26 Feb 07 |
jari |
615 |
} |
2 |
26 Feb 07 |
jari |
616 |
header.setThresholds(upper, lower); |
2 |
26 Feb 07 |
jari |
617 |
} |
2 |
26 Feb 07 |
jari |
618 |
|
2 |
26 Feb 07 |
jari |
619 |
|
2 |
26 Feb 07 |
jari |
620 |
private void setSelected(int x, int y) { |
2 |
26 Feb 07 |
jari |
621 |
if(tree.checkSelection(x, y, selectionPolarity)) { |
2 |
26 Feb 07 |
jari |
622 |
newTreeMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
623 |
launchMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
624 |
header.updateInfo(new GONode((GONode)tree.getSelectedNode())); |
2 |
26 Feb 07 |
jari |
625 |
} else { |
2 |
26 Feb 07 |
jari |
626 |
header.updateInfo((new GONode((GONode)this.tree.getRoot()))); |
2 |
26 Feb 07 |
jari |
627 |
newTreeMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
628 |
launchMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
629 |
} |
2 |
26 Feb 07 |
jari |
630 |
tree.repaint(); |
2 |
26 Feb 07 |
jari |
631 |
} |
2 |
26 Feb 07 |
jari |
632 |
|
2 |
26 Feb 07 |
jari |
633 |
private void launchNewGOTreeViewer() { |
2 |
26 Feb 07 |
jari |
634 |
Vector selectedNodes = tree.getSelectedPathNodes(); |
2 |
26 Feb 07 |
jari |
635 |
if(selectedNodes.isEmpty()) |
2 |
26 Feb 07 |
jari |
636 |
return; |
2 |
26 Feb 07 |
jari |
637 |
|
2 |
26 Feb 07 |
jari |
638 |
Vector nodes = new Vector(); |
2 |
26 Feb 07 |
jari |
639 |
GONode node; |
2 |
26 Feb 07 |
jari |
// int maxLevel = 0; |
2 |
26 Feb 07 |
jari |
641 |
int minLevel = Integer.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
//get selected nodes, make a new set of nodes and get the max level. |
2 |
26 Feb 07 |
jari |
643 |
for(int i = 0 ; i < selectedNodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
644 |
node = (GONode)(selectedNodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
// maxLevel = Math.max(maxLevel, node.getLevel()); |
2 |
26 Feb 07 |
jari |
646 |
minLevel = Math.min(minLevel, node.getLevel()); |
2 |
26 Feb 07 |
jari |
647 |
nodes.add(new GONode(node)); |
2 |
26 Feb 07 |
jari |
648 |
} |
2 |
26 Feb 07 |
jari |
649 |
|
2 |
26 Feb 07 |
jari |
650 |
int newDepth = 0; |
2 |
26 Feb 07 |
jari |
651 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
652 |
node = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
653 |
node.setLevel(node.getLevel()-minLevel); |
2 |
26 Feb 07 |
jari |
654 |
newDepth = Math.max(newDepth, node.getLevel()); |
2 |
26 Feb 07 |
jari |
655 |
node.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_VERBOSE); |
2 |
26 Feb 07 |
jari |
656 |
} |
2 |
26 Feb 07 |
jari |
657 |
|
2 |
26 Feb 07 |
jari |
//take off unselected nodes from children and parents. |
2 |
26 Feb 07 |
jari |
659 |
pruneExtraNodes(nodes, selectedNodes, newDepth); |
2 |
26 Feb 07 |
jari |
660 |
|
2 |
26 Feb 07 |
jari |
661 |
Vector levelArrayVector = new Vector(); |
2 |
26 Feb 07 |
jari |
662 |
|
2 |
26 Feb 07 |
jari |
663 |
for(int i = 0; i < newDepth+1; i++) { |
2 |
26 Feb 07 |
jari |
664 |
levelArrayVector.addElement(getLevelNodes(nodes, i)); |
2 |
26 Feb 07 |
jari |
665 |
} |
2 |
26 Feb 07 |
jari |
666 |
|
2 |
26 Feb 07 |
jari |
//have nodes by level, need to compress levels |
2 |
26 Feb 07 |
jari |
668 |
GONode [] array; |
2 |
26 Feb 07 |
jari |
669 |
Vector toRemove = new Vector(); |
2 |
26 Feb 07 |
jari |
670 |
for(int i = 0; i < levelArrayVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
671 |
array = (GONode [])(levelArrayVector.elementAt(i)); |
2 |
26 Feb 07 |
jari |
672 |
if( array.length < 1) { |
2 |
26 Feb 07 |
jari |
673 |
toRemove.add(array); |
2 |
26 Feb 07 |
jari |
674 |
} |
2 |
26 Feb 07 |
jari |
675 |
} |
2 |
26 Feb 07 |
jari |
676 |
|
2 |
26 Feb 07 |
jari |
//remove empty levels from the array |
2 |
26 Feb 07 |
jari |
678 |
for(int i = 0; i < toRemove.size(); i++) { |
2 |
26 Feb 07 |
jari |
679 |
levelArrayVector.remove(toRemove.elementAt(i)); |
2 |
26 Feb 07 |
jari |
680 |
} |
2 |
26 Feb 07 |
jari |
681 |
|
2 |
26 Feb 07 |
jari |
//new data, and set level. |
2 |
26 Feb 07 |
jari |
683 |
GONode [][] data = new GONode[levelArrayVector.size()][]; |
2 |
26 Feb 07 |
jari |
684 |
for(int i = 0; i < data.length; i++) { |
2 |
26 Feb 07 |
jari |
685 |
data[i] = (GONode [])(levelArrayVector.elementAt(i)); |
2 |
26 Feb 07 |
jari |
686 |
for(int j = 0; j < data[i].length; j++) { |
2 |
26 Feb 07 |
jari |
687 |
data[i][j].setLevel(i); |
2 |
26 Feb 07 |
jari |
688 |
} |
2 |
26 Feb 07 |
jari |
689 |
} |
2 |
26 Feb 07 |
jari |
690 |
|
2 |
26 Feb 07 |
jari |
691 |
GOTreeViewer viewer = new GOTreeViewer(data, viewerNode, baseFileSystem); |
2 |
26 Feb 07 |
jari |
692 |
viewer.setThresholds(upper, lower); |
2 |
26 Feb 07 |
jari |
693 |
|
2 |
26 Feb 07 |
jari |
694 |
JFrame frame = new JFrame(); |
2 |
26 Feb 07 |
jari |
695 |
|
2 |
26 Feb 07 |
jari |
696 |
JScrollPane pane = new JScrollPane(viewer.getContentComponent()); |
2 |
26 Feb 07 |
jari |
697 |
pane.setColumnHeaderView(viewer.getHeaderComponent()); |
2 |
26 Feb 07 |
jari |
698 |
frame.getContentPane().add(pane); |
2 |
26 Feb 07 |
jari |
699 |
|
2 |
26 Feb 07 |
jari |
700 |
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
701 |
|
2 |
26 Feb 07 |
jari |
702 |
frame.setSize( (int)(screenDim.width/3), (int)(screenDim.height/2) ); |
2 |
26 Feb 07 |
jari |
703 |
frame.setVisible(true); |
2 |
26 Feb 07 |
jari |
704 |
viewer.onSelected(framework); |
2 |
26 Feb 07 |
jari |
705 |
} |
2 |
26 Feb 07 |
jari |
706 |
|
2 |
26 Feb 07 |
jari |
707 |
private void pruneExtraNodes(Vector nodes, Vector selectedNodes, int depth) { |
2 |
26 Feb 07 |
jari |
708 |
GONode currNode, nodeToAdd; |
2 |
26 Feb 07 |
jari |
709 |
|
2 |
26 Feb 07 |
jari |
710 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
711 |
currNode = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
712 |
|
2 |
26 Feb 07 |
jari |
//handle parents first |
2 |
26 Feb 07 |
jari |
714 |
if(currNode.getLevel() == 0) { |
2 |
26 Feb 07 |
jari |
715 |
currNode.clearParents(); |
2 |
26 Feb 07 |
jari |
716 |
} else { |
2 |
26 Feb 07 |
jari |
717 |
ITreeNode [] parents = (ITreeNode []) (currNode.getParents()); |
2 |
26 Feb 07 |
jari |
718 |
Vector parentsToKeep = new Vector(); |
2 |
26 Feb 07 |
jari |
719 |
for(int j = 0; j < parents.length; j++) { |
2 |
26 Feb 07 |
jari |
720 |
nodeToAdd = null; |
2 |
26 Feb 07 |
jari |
721 |
if(selectedNodes.contains(parents[j])) { |
2 |
26 Feb 07 |
jari |
722 |
nodeToAdd = findNode(nodes, ((GONode)(parents[j])).getGOID()); |
2 |
26 Feb 07 |
jari |
723 |
if(nodeToAdd != null) |
2 |
26 Feb 07 |
jari |
724 |
parentsToKeep.addElement(nodeToAdd); |
2 |
26 Feb 07 |
jari |
725 |
} |
2 |
26 Feb 07 |
jari |
726 |
} |
2 |
26 Feb 07 |
jari |
727 |
currNode.setParents(parentsToKeep); |
2 |
26 Feb 07 |
jari |
728 |
} |
2 |
26 Feb 07 |
jari |
729 |
|
2 |
26 Feb 07 |
jari |
//now children |
2 |
26 Feb 07 |
jari |
731 |
if(currNode.getLevel() == depth) { |
2 |
26 Feb 07 |
jari |
732 |
currNode.clearChildren(); |
2 |
26 Feb 07 |
jari |
733 |
} else { |
2 |
26 Feb 07 |
jari |
734 |
ITreeNode [] children = (ITreeNode[])(currNode.getChildren()); |
2 |
26 Feb 07 |
jari |
735 |
Vector childrenToKeep = new Vector(); |
2 |
26 Feb 07 |
jari |
736 |
for(int j = 0; j < children.length; j++) { |
2 |
26 Feb 07 |
jari |
737 |
nodeToAdd = null; |
2 |
26 Feb 07 |
jari |
738 |
if(selectedNodes.contains(children[j])) { |
2 |
26 Feb 07 |
jari |
739 |
nodeToAdd = findNode(nodes, ((GONode)(children[j])).getGOID()); |
2 |
26 Feb 07 |
jari |
740 |
if(nodeToAdd != null) |
2 |
26 Feb 07 |
jari |
741 |
childrenToKeep.addElement(nodeToAdd); |
2 |
26 Feb 07 |
jari |
742 |
} |
2 |
26 Feb 07 |
jari |
743 |
} |
2 |
26 Feb 07 |
jari |
744 |
currNode.setChildren(childrenToKeep); |
2 |
26 Feb 07 |
jari |
745 |
} |
2 |
26 Feb 07 |
jari |
746 |
} |
2 |
26 Feb 07 |
jari |
747 |
} |
2 |
26 Feb 07 |
jari |
748 |
|
2 |
26 Feb 07 |
jari |
/** Handles opening cluster viewers. |
2 |
26 Feb 07 |
jari |
750 |
*/ |
2 |
26 Feb 07 |
jari |
751 |
private void onOpenViewer(String viewerType){ |
2 |
26 Feb 07 |
jari |
752 |
|
2 |
26 Feb 07 |
jari |
753 |
GONode selNode = (GONode)(tree.getSelectedNode()); |
2 |
26 Feb 07 |
jari |
754 |
|
2 |
26 Feb 07 |
jari |
755 |
if(selNode == null) |
2 |
26 Feb 07 |
jari |
756 |
return; |
2 |
26 Feb 07 |
jari |
757 |
|
2 |
26 Feb 07 |
jari |
758 |
int index = selNode.getClusterIndex(); |
2 |
26 Feb 07 |
jari |
759 |
|
2 |
26 Feb 07 |
jari |
760 |
if(index == -1 || viewerNode == null) |
2 |
26 Feb 07 |
jari |
761 |
return; |
2 |
26 Feb 07 |
jari |
762 |
|
2 |
26 Feb 07 |
jari |
763 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode)viewerNode.getChildAt(1); |
2 |
26 Feb 07 |
jari |
764 |
if(node.getChildCount() < index) |
2 |
26 Feb 07 |
jari |
765 |
return; |
2 |
26 Feb 07 |
jari |
766 |
node = (DefaultMutableTreeNode)(node.getChildAt(index)); |
2 |
26 Feb 07 |
jari |
767 |
|
2 |
26 Feb 07 |
jari |
768 |
if(viewerType.equals("expression image")){ |
2 |
26 Feb 07 |
jari |
769 |
node = (DefaultMutableTreeNode)(node.getChildAt(0)); |
2 |
26 Feb 07 |
jari |
770 |
} else if(viewerType.equals("centroid graph")){ |
2 |
26 Feb 07 |
jari |
771 |
node = (DefaultMutableTreeNode)(node.getChildAt(1)); |
2 |
26 Feb 07 |
jari |
772 |
} else if(viewerType.equals("expression graph")){ |
2 |
26 Feb 07 |
jari |
773 |
node = (DefaultMutableTreeNode)(node.getChildAt(2)); |
2 |
26 Feb 07 |
jari |
774 |
} |
2 |
26 Feb 07 |
jari |
775 |
|
2 |
26 Feb 07 |
jari |
776 |
if(framework != null) |
2 |
26 Feb 07 |
jari |
777 |
framework.setTreeNode(node); |
2 |
26 Feb 07 |
jari |
778 |
} |
2 |
26 Feb 07 |
jari |
779 |
|
2 |
26 Feb 07 |
jari |
780 |
private void createDockedGOTreeViewer() { |
2 |
26 Feb 07 |
jari |
781 |
Vector selectedNodes = tree.getSelectedPathNodes(); |
2 |
26 Feb 07 |
jari |
782 |
if(selectedNodes.isEmpty()) |
2 |
26 Feb 07 |
jari |
783 |
return; |
2 |
26 Feb 07 |
jari |
784 |
|
2 |
26 Feb 07 |
jari |
785 |
Vector nodes = new Vector(); |
2 |
26 Feb 07 |
jari |
786 |
GONode node; |
2 |
26 Feb 07 |
jari |
// int maxLevel = 0; |
2 |
26 Feb 07 |
jari |
788 |
int minLevel = Integer.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
//get selected nodes, make a new set of nodes and get the max level. |
2 |
26 Feb 07 |
jari |
790 |
for(int i = 0 ; i < selectedNodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
791 |
node = (GONode)(selectedNodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
// maxLevel = Math.max(maxLevel, node.getLevel()); |
2 |
26 Feb 07 |
jari |
793 |
minLevel = Math.min(minLevel, node.getLevel()); |
2 |
26 Feb 07 |
jari |
794 |
nodes.add(new GONode(node)); |
2 |
26 Feb 07 |
jari |
795 |
} |
2 |
26 Feb 07 |
jari |
796 |
|
2 |
26 Feb 07 |
jari |
//set levels |
2 |
26 Feb 07 |
jari |
798 |
int newDepth = 0; |
2 |
26 Feb 07 |
jari |
799 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
800 |
node = (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
801 |
node.setLevel(node.getLevel()-minLevel); |
2 |
26 Feb 07 |
jari |
802 |
newDepth = Math.max(newDepth, node.getLevel()); |
2 |
26 Feb 07 |
jari |
803 |
node.setRenderingHint(ITreeNodeRenderer.RENDERING_HINT_VERBOSE); |
2 |
26 Feb 07 |
jari |
804 |
} |
2 |
26 Feb 07 |
jari |
805 |
|
2 |
26 Feb 07 |
jari |
//take off unselected nodes from children and parents. |
2 |
26 Feb 07 |
jari |
807 |
pruneExtraNodes(nodes, selectedNodes, newDepth); |
2 |
26 Feb 07 |
jari |
808 |
|
2 |
26 Feb 07 |
jari |
809 |
Vector levelArrayVector = new Vector(); |
2 |
26 Feb 07 |
jari |
810 |
|
2 |
26 Feb 07 |
jari |
811 |
for(int i = 0; i < newDepth+1; i++) { |
2 |
26 Feb 07 |
jari |
812 |
levelArrayVector.addElement(getLevelNodes(nodes, i)); |
2 |
26 Feb 07 |
jari |
813 |
} |
2 |
26 Feb 07 |
jari |
814 |
|
2 |
26 Feb 07 |
jari |
//have nodes by level, need to compress levels |
2 |
26 Feb 07 |
jari |
816 |
GONode [] array; |
2 |
26 Feb 07 |
jari |
817 |
Vector toRemove = new Vector(); |
2 |
26 Feb 07 |
jari |
818 |
for(int i = 0; i < levelArrayVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
819 |
array = (GONode [])(levelArrayVector.elementAt(i)); |
2 |
26 Feb 07 |
jari |
820 |
if( array.length < 1) { |
2 |
26 Feb 07 |
jari |
821 |
toRemove.add(array); |
2 |
26 Feb 07 |
jari |
822 |
} |
2 |
26 Feb 07 |
jari |
823 |
} |
2 |
26 Feb 07 |
jari |
824 |
|
2 |
26 Feb 07 |
jari |
//remove empty levels from the array |
2 |
26 Feb 07 |
jari |
826 |
for(int i = 0; i < toRemove.size(); i++) { |
2 |
26 Feb 07 |
jari |
827 |
levelArrayVector.remove(toRemove.elementAt(i)); |
2 |
26 Feb 07 |
jari |
828 |
} |
2 |
26 Feb 07 |
jari |
829 |
|
2 |
26 Feb 07 |
jari |
//new data, and set level. |
2 |
26 Feb 07 |
jari |
831 |
GONode [][] data = new GONode[levelArrayVector.size()][]; |
2 |
26 Feb 07 |
jari |
832 |
for(int i = 0; i < data.length; i++) { |
2 |
26 Feb 07 |
jari |
833 |
data[i] = (GONode [])(levelArrayVector.elementAt(i)); |
2 |
26 Feb 07 |
jari |
834 |
for(int j = 0; j < data[i].length; j++) { |
2 |
26 Feb 07 |
jari |
835 |
data[i][j].setLevel(i); |
2 |
26 Feb 07 |
jari |
836 |
} |
2 |
26 Feb 07 |
jari |
837 |
} |
2 |
26 Feb 07 |
jari |
838 |
|
2 |
26 Feb 07 |
jari |
839 |
GOTreeViewer viewer = new GOTreeViewer(data, viewerNode, baseFileSystem); |
2 |
26 Feb 07 |
jari |
840 |
viewer.setThresholds(upper, lower); |
2 |
26 Feb 07 |
jari |
841 |
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(new LeafInfo("GO Subtree", viewer)); |
2 |
26 Feb 07 |
jari |
842 |
|
2 |
26 Feb 07 |
jari |
843 |
framework.addNode(viewerNode, newNode); |
2 |
26 Feb 07 |
jari |
844 |
framework.setTreeNode(newNode); |
2 |
26 Feb 07 |
jari |
845 |
} |
2 |
26 Feb 07 |
jari |
846 |
|
2 |
26 Feb 07 |
jari |
847 |
|
2 |
26 Feb 07 |
jari |
848 |
|
2 |
26 Feb 07 |
jari |
849 |
private GONode findNode(Vector nodes, String goID) { |
2 |
26 Feb 07 |
jari |
850 |
for(int i = 0; i < nodes.size(); i++) { |
2 |
26 Feb 07 |
jari |
851 |
if( ((GONode)(nodes.elementAt(i))).getGOID().equals(goID)) |
2 |
26 Feb 07 |
jari |
852 |
return (GONode)(nodes.elementAt(i)); |
2 |
26 Feb 07 |
jari |
853 |
} |
2 |
26 Feb 07 |
jari |
854 |
return null; |
2 |
26 Feb 07 |
jari |
855 |
} |
2 |
26 Feb 07 |
jari |
856 |
|
2 |
26 Feb 07 |
jari |
857 |
private void createPopupMenu(ActionListener listener) { |
2 |
26 Feb 07 |
jari |
858 |
popup = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
859 |
|
2 |
26 Feb 07 |
jari |
860 |
JMenuItem item; |
2 |
26 Feb 07 |
jari |
861 |
JCheckBoxMenuItem checkBoxItem; |
2 |
26 Feb 07 |
jari |
862 |
ButtonGroup bg; |
2 |
26 Feb 07 |
jari |
863 |
|
2 |
26 Feb 07 |
jari |
//node style |
2 |
26 Feb 07 |
jari |
865 |
JMenu menu = new JMenu("Node Style"); |
2 |
26 Feb 07 |
jari |
866 |
|
2 |
26 Feb 07 |
jari |
867 |
bg = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
868 |
checkBoxItem = new JCheckBoxMenuItem("Minimal", true); |
2 |
26 Feb 07 |
jari |
869 |
checkBoxItem.setActionCommand("simple-node-command"); |
2 |
26 Feb 07 |
jari |
870 |
checkBoxItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
871 |
bg.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
872 |
menu.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
873 |
|
2 |
26 Feb 07 |
jari |
874 |
checkBoxItem = new JCheckBoxMenuItem("Verbose"); |
2 |
26 Feb 07 |
jari |
875 |
checkBoxItem.setActionCommand("verbose-node-command"); |
2 |
26 Feb 07 |
jari |
876 |
checkBoxItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
877 |
bg.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
878 |
menu.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
879 |
|
2 |
26 Feb 07 |
jari |
880 |
popup.add(menu); |
2 |
26 Feb 07 |
jari |
881 |
popup.addSeparator(); |
2 |
26 Feb 07 |
jari |
882 |
|
2 |
26 Feb 07 |
jari |
883 |
|
2 |
26 Feb 07 |
jari |
//Connector style |
2 |
26 Feb 07 |
jari |
885 |
menu = new JMenu("Connector Style"); |
2 |
26 Feb 07 |
jari |
886 |
bg = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
887 |
|
2 |
26 Feb 07 |
jari |
888 |
checkBoxItem = new JCheckBoxMenuItem("Curved", true); |
2 |
26 Feb 07 |
jari |
889 |
checkBoxItem.setActionCommand("curved-connector-command"); |
2 |
26 Feb 07 |
jari |
890 |
checkBoxItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
891 |
bg.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
892 |
menu.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
893 |
|
2 |
26 Feb 07 |
jari |
894 |
checkBoxItem = new JCheckBoxMenuItem("Straight"); |
2 |
26 Feb 07 |
jari |
895 |
checkBoxItem.setActionCommand("straight-connector-command"); |
2 |
26 Feb 07 |
jari |
896 |
checkBoxItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
897 |
bg.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
898 |
menu.add(checkBoxItem); |
2 |
26 Feb 07 |
jari |
899 |
|
2 |
26 Feb 07 |
jari |
900 |
popup.add(menu); |
2 |
26 Feb 07 |
jari |
901 |
popup.addSeparator(); |
2 |
26 Feb 07 |
jari |
902 |
|
2 |
26 Feb 07 |
jari |
903 |
item = new JMenuItem("Set Thresholds"); |
2 |
26 Feb 07 |
jari |
904 |
item.setActionCommand("set-thresholds-command"); |
2 |
26 Feb 07 |
jari |
905 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
906 |
|
2 |
26 Feb 07 |
jari |
907 |
popup.add(item); |
2 |
26 Feb 07 |
jari |
908 |
popup.addSeparator(); |
2 |
26 Feb 07 |
jari |
909 |
|
2 |
26 Feb 07 |
jari |
910 |
menu = new JMenu("Selection Polarity"); |
2 |
26 Feb 07 |
jari |
911 |
|
2 |
26 Feb 07 |
jari |
912 |
bg = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
913 |
|
2 |
26 Feb 07 |
jari |
914 |
JCheckBoxMenuItem box = new JCheckBoxMenuItem("Select Ancestors"); |
2 |
26 Feb 07 |
jari |
915 |
box.setActionCommand("ancestor-selection-command"); |
2 |
26 Feb 07 |
jari |
916 |
box.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
917 |
bg.add(box); |
2 |
26 Feb 07 |
jari |
918 |
menu.add(box); |
2 |
26 Feb 07 |
jari |
919 |
|
2 |
26 Feb 07 |
jari |
920 |
box = new JCheckBoxMenuItem("Select Successors"); |
2 |
26 Feb 07 |
jari |
921 |
box.setActionCommand("successor-selection-command"); |
2 |
26 Feb 07 |
jari |
922 |
box.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
923 |
bg.add(box); |
2 |
26 Feb 07 |
jari |
924 |
menu.add(box); |
2 |
26 Feb 07 |
jari |
925 |
|
2 |
26 Feb 07 |
jari |
926 |
box = new JCheckBoxMenuItem("Bipolar Selection", true); |
2 |
26 Feb 07 |
jari |
927 |
box.setActionCommand("bipolar-selection-command"); |
2 |
26 Feb 07 |
jari |
928 |
box.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
929 |
bg.add(box); |
2 |
26 Feb 07 |
jari |
930 |
menu.add(box); |
2 |
26 Feb 07 |
jari |
931 |
|
2 |
26 Feb 07 |
jari |
932 |
popup.add(menu); |
2 |
26 Feb 07 |
jari |
933 |
popup.addSeparator(); |
2 |
26 Feb 07 |
jari |
934 |
|
2 |
26 Feb 07 |
jari |
935 |
newTreeMenu = new JMenu("Create Subset Viewer"); |
2 |
26 Feb 07 |
jari |
936 |
newTreeMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
937 |
|
2 |
26 Feb 07 |
jari |
938 |
item = new JMenuItem("In New Window..."); |
2 |
26 Feb 07 |
jari |
939 |
item.setActionCommand("new-subtree-command"); |
2 |
26 Feb 07 |
jari |
940 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
941 |
newTreeMenu.add(item); |
2 |
26 Feb 07 |
jari |
942 |
|
2 |
26 Feb 07 |
jari |
943 |
item = new JMenuItem("Docked in Result Tree..."); |
2 |
26 Feb 07 |
jari |
944 |
item.setActionCommand("new-docked-subtree-command"); |
2 |
26 Feb 07 |
jari |
945 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
946 |
newTreeMenu.add(item); |
2 |
26 Feb 07 |
jari |
947 |
|
2 |
26 Feb 07 |
jari |
948 |
popup.add(newTreeMenu); |
2 |
26 Feb 07 |
jari |
949 |
popup.addSeparator(); |
2 |
26 Feb 07 |
jari |
950 |
|
2 |
26 Feb 07 |
jari |
951 |
launchMenu = new JMenu("Open Viewer"); |
2 |
26 Feb 07 |
jari |
952 |
launchMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
953 |
|
2 |
26 Feb 07 |
jari |
954 |
item = new JMenuItem("Expression Image"); |
2 |
26 Feb 07 |
jari |
955 |
item.setActionCommand("launch-expression-image-command"); |
2 |
26 Feb 07 |
jari |
956 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
957 |
launchMenu.add(item); |
2 |
26 Feb 07 |
jari |
958 |
|
2 |
26 Feb 07 |
jari |
959 |
item = new JMenuItem("Centroid Graph"); |
2 |
26 Feb 07 |
jari |
960 |
item.setActionCommand("launch-centroid-graph-command"); |
2 |
26 Feb 07 |
jari |
961 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
962 |
launchMenu.add(item); |
2 |
26 Feb 07 |
jari |
963 |
|
2 |
26 Feb 07 |
jari |
964 |
item = new JMenuItem("Expression Graph"); |
2 |
26 Feb 07 |
jari |
965 |
item.setActionCommand("launch-expression-graph-command"); |
2 |
26 Feb 07 |
jari |
966 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
967 |
launchMenu.add(item); |
2 |
26 Feb 07 |
jari |
968 |
|
2 |
26 Feb 07 |
jari |
969 |
popup.add(launchMenu); |
2 |
26 Feb 07 |
jari |
970 |
} |
2 |
26 Feb 07 |
jari |
971 |
|
2 |
26 Feb 07 |
jari |
972 |
private class Listener extends MouseAdapter implements ActionListener { |
2 |
26 Feb 07 |
jari |
973 |
|
2 |
26 Feb 07 |
jari |
974 |
public void actionPerformed(ActionEvent ae) { |
2 |
26 Feb 07 |
jari |
975 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
976 |
|
2 |
26 Feb 07 |
jari |
977 |
if(command.equals("verbose-node-command")) { |
2 |
26 Feb 07 |
jari |
978 |
setVerboseNodeStyle(true); |
2 |
26 Feb 07 |
jari |
979 |
} else if (command.equals("simple-node-command")) { |
2 |
26 Feb 07 |
jari |
980 |
setVerboseNodeStyle(false); |
2 |
26 Feb 07 |
jari |
981 |
} else if (command.equals("straight-connector-command")) { |
2 |
26 Feb 07 |
jari |
982 |
setStraightConnectorStyle(true); |
2 |
26 Feb 07 |
jari |
983 |
} else if (command.equals("curved-connector-command")) { |
2 |
26 Feb 07 |
jari |
984 |
setStraightConnectorStyle(false); |
2 |
26 Feb 07 |
jari |
985 |
} else if (command.equals("set-thresholds-command")) { |
2 |
26 Feb 07 |
jari |
986 |
setThresholds(); |
2 |
26 Feb 07 |
jari |
987 |
} else if (command.equals("bipolar-selection-command")) { |
2 |
26 Feb 07 |
jari |
988 |
selectionPolarity = 0; |
2 |
26 Feb 07 |
jari |
989 |
} else if (command.equals("ancestor-selection-command")) { |
2 |
26 Feb 07 |
jari |
990 |
selectionPolarity = 1; |
2 |
26 Feb 07 |
jari |
991 |
} else if (command.equals("successor-selection-command")) { |
2 |
26 Feb 07 |
jari |
992 |
selectionPolarity = 2; |
2 |
26 Feb 07 |
jari |
993 |
} else if (command.equals("new-subtree-command")) { |
2 |
26 Feb 07 |
jari |
994 |
launchNewGOTreeViewer(); |
2 |
26 Feb 07 |
jari |
995 |
} else if (command.equals("new-docked-subtree-command")) { |
2 |
26 Feb 07 |
jari |
996 |
createDockedGOTreeViewer(); |
2 |
26 Feb 07 |
jari |
997 |
} else if(command.equals("launch-expression-image-command")){ |
2 |
26 Feb 07 |
jari |
998 |
onOpenViewer("expression image"); |
2 |
26 Feb 07 |
jari |
999 |
} else if(command.equals("launch-centroid-graph-command")){ |
2 |
26 Feb 07 |
jari |
1000 |
onOpenViewer("centroid graph"); |
2 |
26 Feb 07 |
jari |
1001 |
} else if(command.equals("launch-expression-graph-command")){ |
2 |
26 Feb 07 |
jari |
1002 |
onOpenViewer("expression graph"); |
2 |
26 Feb 07 |
jari |
1003 |
} |
2 |
26 Feb 07 |
jari |
1004 |
|
2 |
26 Feb 07 |
jari |
1005 |
} |
2 |
26 Feb 07 |
jari |
1006 |
|
2 |
26 Feb 07 |
jari |
1007 |
public void mousePressed(MouseEvent evt) { |
2 |
26 Feb 07 |
jari |
1008 |
if(evt.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1009 |
popup.show(tree, evt.getX(), evt.getY()); |
2 |
26 Feb 07 |
jari |
1010 |
} else { |
2 |
26 Feb 07 |
jari |
1011 |
if(evt.getModifiers() == MouseEvent.BUTTON1_MASK) |
2 |
26 Feb 07 |
jari |
1012 |
setSelected(evt.getX(), evt.getY()); |
2 |
26 Feb 07 |
jari |
1013 |
} |
2 |
26 Feb 07 |
jari |
1014 |
} |
2 |
26 Feb 07 |
jari |
1015 |
|
2 |
26 Feb 07 |
jari |
1016 |
public void mouseClicked(MouseEvent evt) { |
2 |
26 Feb 07 |
jari |
1017 |
if(evt.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1018 |
popup.show(tree, evt.getX(), evt.getY()); |
2 |
26 Feb 07 |
jari |
1019 |
} else { |
2 |
26 Feb 07 |
jari |
1020 |
if(evt.getModifiers() == MouseEvent.BUTTON1_MASK) |
2 |
26 Feb 07 |
jari |
1021 |
setSelected(evt.getX(), evt.getY()); |
2 |
26 Feb 07 |
jari |
1022 |
} |
2 |
26 Feb 07 |
jari |
1023 |
} |
2 |
26 Feb 07 |
jari |
1024 |
|
2 |
26 Feb 07 |
jari |
1025 |
public void mouseReleased(MouseEvent evt) { |
2 |
26 Feb 07 |
jari |
1026 |
if(evt.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1027 |
popup.show(tree, evt.getX(), evt.getY()); |
2 |
26 Feb 07 |
jari |
1028 |
} else { |
2 |
26 Feb 07 |
jari |
1029 |
if(evt.getModifiers() == MouseEvent.BUTTON1_MASK) |
2 |
26 Feb 07 |
jari |
1030 |
setSelected(evt.getX(), evt.getY()); |
2 |
26 Feb 07 |
jari |
1031 |
} |
2 |
26 Feb 07 |
jari |
1032 |
} |
2 |
26 Feb 07 |
jari |
1033 |
|
2 |
26 Feb 07 |
jari |
1034 |
} |
2 |
26 Feb 07 |
jari |
1035 |
|
2 |
26 Feb 07 |
jari |
1036 |
|
2 |
26 Feb 07 |
jari |
/** Returns int value indicating viewer type |
2 |
26 Feb 07 |
jari |
* Cluster.GENE_CLUSTER, Cluster.EXPERIMENT_CLUSTER, or -1 for both or unspecified |
2 |
26 Feb 07 |
jari |
1039 |
*/ |
2 |
26 Feb 07 |
jari |
1040 |
public int getViewerType() { |
2 |
26 Feb 07 |
jari |
1041 |
return -1; |
2 |
26 Feb 07 |
jari |
1042 |
} |
2 |
26 Feb 07 |
jari |
1043 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#setExperiment(org.tigr.microarray.mev.cluster.gui.Experiment) |
2 |
26 Feb 07 |
jari |
1046 |
*/ |
2 |
26 Feb 07 |
jari |
1047 |
public void setExperiment(Experiment e) { |
2 |
26 Feb 07 |
jari |
1048 |
; |
2 |
26 Feb 07 |
jari |
1049 |
} |
2 |
26 Feb 07 |
jari |
1050 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#getExperimentID() |
2 |
26 Feb 07 |
jari |
1053 |
*/ |
2 |
26 Feb 07 |
jari |
1054 |
public int getExperimentID() { |
2 |
26 Feb 07 |
jari |
1055 |
return this.exptID; |
2 |
26 Feb 07 |
jari |
1056 |
} |
2 |
26 Feb 07 |
jari |
1057 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#setExperimentID(int) |
2 |
26 Feb 07 |
jari |
1060 |
*/ |
2 |
26 Feb 07 |
jari |
1061 |
public void setExperimentID(int id) { |
2 |
26 Feb 07 |
jari |
1062 |
this.exptID = id; |
2 |
26 Feb 07 |
jari |
1063 |
} |
2 |
26 Feb 07 |
jari |
1064 |
} |