2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* Created on Aug 23, 2005 |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
package org.tigr.microarray.mev.cluster.gui.impl.tease; |
2 |
26 Feb 07 |
jari |
6 |
|
2 |
26 Feb 07 |
jari |
7 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
8 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
9 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
10 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
11 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
12 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.MouseMotionAdapter; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
20 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
21 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
22 |
import java.io.ObjectInputStream; |
2 |
26 Feb 07 |
jari |
23 |
import java.io.ObjectOutputStream; |
2 |
26 Feb 07 |
jari |
24 |
import java.util.ArrayList; |
2 |
26 Feb 07 |
jari |
25 |
import java.util.Arrays; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.SwingUtilities; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmData; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.clusterUtil.Cluster; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.IDisplayMenu; |
2 |
26 Feb 07 |
jari |
42 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
43 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
44 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.microarray.mev.cluster.gui.helpers.CentroidUserObject; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.microarray.mev.cluster.gui.helpers.ClusterTableViewer; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentClusterCentroidViewer; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentClusterTableViewer; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentClusterViewer; |
2 |
26 Feb 07 |
jari |
50 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentUtil; |
2 |
26 Feb 07 |
jari |
51 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentViewer; |
2 |
26 Feb 07 |
jari |
52 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
53 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLAnnotationBar; |
2 |
26 Feb 07 |
jari |
54 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLCentroidViewer; |
2 |
26 Feb 07 |
jari |
55 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLCentroidsViewer; |
2 |
26 Feb 07 |
jari |
56 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLClusterInfoViewer; |
2 |
26 Feb 07 |
jari |
57 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLColorBar; |
2 |
26 Feb 07 |
jari |
58 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLExperimentCentroidViewer; |
2 |
26 Feb 07 |
jari |
59 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLExperimentCentroidsViewer; |
2 |
26 Feb 07 |
jari |
60 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLExperimentClusterViewer; |
2 |
26 Feb 07 |
jari |
61 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLExperimentHeader; |
2 |
26 Feb 07 |
jari |
62 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLExperimentViewer; |
2 |
26 Feb 07 |
jari |
63 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
/** |
2 |
26 Feb 07 |
jari |
* @author Annie Liu |
2 |
26 Feb 07 |
jari |
* @version Aug 23, 2005 |
2 |
26 Feb 07 |
jari |
70 |
* |
2 |
26 Feb 07 |
jari |
* TEASEViewer display the result from TEASE analysis on the screen |
2 |
26 Feb 07 |
jari |
72 |
*/ |
2 |
26 Feb 07 |
jari |
73 |
public class TEASEViewer extends JPanel implements IViewer{ |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
protected static final String STORE_CLUSTER_CMD = "store-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
76 |
protected static final String LAUNCH_NEW_SESSION_CMD = "launch-new-session-cmd"; |
2 |
26 Feb 07 |
jari |
77 |
protected static final String SAVE_CLUSTER_CMD = "save-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
78 |
protected static final String DELETE_CLUSTER_CMD = "delete-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
79 |
protected static final String DELETE_ALL_CLUSTERS_CMD = "delete-all-clusters-cmd"; |
2 |
26 Feb 07 |
jari |
80 |
protected static final String GENE_TREE_PROPERTIES_CMD = "gene-tree-properties-cmd"; |
2 |
26 Feb 07 |
jari |
81 |
protected static final String SAMPLE_TREE_PROPERTIES_CMD = "sample-tree-properties-cmd"; |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
protected static final String SAVE_GENE_ORDER_CMD = "save-gene-order-cmd"; |
2 |
26 Feb 07 |
jari |
84 |
protected static final String SAVE_EXP_ORDER_CMD = "save-exp-order-cmd"; |
2 |
26 Feb 07 |
jari |
85 |
protected static final String SAVE_GENE_HEIGHT_CMD = "save-gene-height-cmd"; |
2 |
26 Feb 07 |
jari |
86 |
protected static final String SAVE_EXP_HEIGHT_CMD = "save-exp-height-cmd"; |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
88 |
protected static final String SAVE_GENE_NEWICK_CMD = "save-gene-newick-cmd"; |
2 |
26 Feb 07 |
jari |
89 |
protected static final String SAVE_SAMPLE_NEWICK_CMD = "save-sample-newick-cmd"; |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
protected static final String CHANGE_SCORE_BOUNDARY = "change-score-boundary"; |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
93 |
|
2 |
26 Feb 07 |
jari |
// wrapped viewers |
2 |
26 Feb 07 |
jari |
95 |
protected IViewer expViewer; //component to draw an experiment data |
2 |
26 Feb 07 |
jari |
96 |
protected HCLExperimentHeader header; //component to draw an experiment header |
2 |
26 Feb 07 |
jari |
97 |
protected HCLTree genesTree; //component to draw genes tree |
2 |
26 Feb 07 |
jari |
98 |
protected HCLTree sampleTree; //component to draw samples tree |
2 |
26 Feb 07 |
jari |
99 |
protected HCLColorBar colorBar; //component to draw hcl clusters colors and descriptions |
2 |
26 Feb 07 |
jari |
100 |
protected HCLAnnotationBar annotationBar; //component to draw an experiment annotations |
2 |
26 Feb 07 |
jari |
//protected MyGlassPane glassPane; |
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
protected IData data; |
2 |
26 Feb 07 |
jari |
104 |
protected Experiment experiment; |
2 |
26 Feb 07 |
jari |
105 |
protected ArrayList clusters = new ArrayList(); |
2 |
26 Feb 07 |
jari |
106 |
protected ArrayList experimentClusters = new ArrayList(); |
2 |
26 Feb 07 |
jari |
107 |
protected ArrayList dots; |
2 |
26 Feb 07 |
jari |
108 |
protected int [][] sampleClusters; |
2 |
26 Feb 07 |
jari |
109 |
public HCLCluster selectedCluster; |
2 |
26 Feb 07 |
jari |
110 |
protected int[] genesOrder; |
2 |
26 Feb 07 |
jari |
111 |
protected int[] samplesOrder; |
2 |
26 Feb 07 |
jari |
112 |
protected boolean isExperimentCluster = false; |
2 |
26 Feb 07 |
jari |
113 |
protected boolean featureListIsEmpty = false; |
2 |
26 Feb 07 |
jari |
114 |
protected boolean isHCLOnly = false; |
2 |
26 Feb 07 |
jari |
115 |
protected Dimension elementSize; |
2 |
26 Feb 07 |
jari |
116 |
protected int numberOfSamples; |
2 |
26 Feb 07 |
jari |
117 |
protected int offset = 0; |
2 |
26 Feb 07 |
jari |
118 |
protected int clusterIndex = 0; |
2 |
26 Feb 07 |
jari |
119 |
protected Listener listener; |
2 |
26 Feb 07 |
jari |
120 |
protected JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
121 |
protected JTextField box; |
2 |
26 Feb 07 |
jari |
122 |
|
2 |
26 Feb 07 |
jari |
123 |
protected DefaultMutableTreeNode node; |
2 |
26 Feb 07 |
jari |
124 |
protected IFramework framework; |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
//EH added to store items necessary for restoring state |
2 |
26 Feb 07 |
jari |
127 |
private int[] features; |
2 |
26 Feb 07 |
jari |
128 |
HCLTreeData genes_result, samples_result; |
2 |
26 Feb 07 |
jari |
129 |
boolean hclOnly; |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
|
2 |
26 Feb 07 |
jari |
132 |
|
2 |
26 Feb 07 |
jari |
133 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>HCLViewer</code> for specified results. |
2 |
26 Feb 07 |
jari |
135 |
*/ |
2 |
26 Feb 07 |
jari |
136 |
public TEASEViewer(JFrame frame, Experiment experiment, int[] features, |
2 |
26 Feb 07 |
jari |
137 |
HCLTreeData genes_result, HCLTreeData samples_result, |
2 |
26 Feb 07 |
jari |
138 |
DefaultMutableTreeNode node, boolean hclOnly, AlgorithmData data) { |
2 |
26 Feb 07 |
jari |
139 |
setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
140 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
141 |
|
2 |
26 Feb 07 |
jari |
142 |
this.genes_result = genes_result; |
2 |
26 Feb 07 |
jari |
143 |
this.samples_result = samples_result; |
2 |
26 Feb 07 |
jari |
144 |
this.hclOnly = hclOnly; |
2 |
26 Feb 07 |
jari |
145 |
this.features = features; |
2 |
26 Feb 07 |
jari |
146 |
this.dots = new ArrayList(); |
2 |
26 Feb 07 |
jari |
147 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
148 |
this.listener = new Listener(); |
2 |
26 Feb 07 |
jari |
149 |
this.addMouseListener(this.listener); |
2 |
26 Feb 07 |
jari |
150 |
this.node = node; |
2 |
26 Feb 07 |
jari |
151 |
features = features == null ? createDefaultFeatures(experiment) : features; |
2 |
26 Feb 07 |
jari |
152 |
this.expViewer = createExperimentViewer(experiment, features, genes_result, samples_result); |
2 |
26 Feb 07 |
jari |
153 |
this.expViewer.getContentComponent().addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
154 |
this.header = new HCLExperimentHeader(this.expViewer.getHeaderComponent()); |
2 |
26 Feb 07 |
jari |
155 |
this.header.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
156 |
this.colorBar = new HCLColorBar(this.clusters, features.length); |
2 |
26 Feb 07 |
jari |
157 |
this.colorBar.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
158 |
this.genesOrder = createGenesOrder(experiment, features, genes_result); |
2 |
26 Feb 07 |
jari |
159 |
this.annotationBar = new HCLAnnotationBar(this.genesOrder); |
2 |
26 Feb 07 |
jari |
160 |
this.annotationBar.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
161 |
if (genes_result != null && experiment.getNumberOfGenes() > 1 && genes_result.node_order.length > 1) { |
2 |
26 Feb 07 |
jari |
162 |
this.genesTree = new HCLTree(genes_result, HCLTree.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
163 |
this.genesTree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
164 |
this.genesTree.setListener(listener); |
2 |
26 Feb 07 |
jari |
165 |
} |
2 |
26 Feb 07 |
jari |
166 |
|
2 |
26 Feb 07 |
jari |
167 |
if (samples_result != null && experiment.getNumberOfSamples() > 1 && samples_result.node_order.length > 1) { |
2 |
26 Feb 07 |
jari |
168 |
this.sampleTree = new HCLTree(samples_result, HCLTree.VERTICAL); |
2 |
26 Feb 07 |
jari |
169 |
this.samplesOrder = createSamplesOrder(samples_result); |
2 |
26 Feb 07 |
jari |
170 |
if(genes_result == null) |
2 |
26 Feb 07 |
jari |
171 |
this.sampleTree.setHorizontalOffset(10); |
2 |
26 Feb 07 |
jari |
172 |
this.sampleTree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
173 |
this.sampleTree.setListener(listener); //added for selection of experiment hcl nodes |
2 |
26 Feb 07 |
jari |
174 |
} |
2 |
26 Feb 07 |
jari |
175 |
|
2 |
26 Feb 07 |
jari |
176 |
this.isExperimentCluster = false; |
2 |
26 Feb 07 |
jari |
177 |
this.numberOfSamples = experiment.getNumberOfSamples(); //know this is correct for gene clustering constructor |
2 |
26 Feb 07 |
jari |
178 |
addComponents(this.sampleTree, this.genesTree, this.expViewer.getContentComponent(), this.colorBar, this.annotationBar); |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
this.isHCLOnly = hclOnly; |
2 |
26 Feb 07 |
jari |
181 |
if (!this.isHCLOnly) { |
2 |
26 Feb 07 |
jari |
182 |
int[] nodes = data.getIntArray("node-list"); |
2 |
26 Feb 07 |
jari |
183 |
int root; |
2 |
26 Feb 07 |
jari |
184 |
int maxHeight = genesTree.pHeights[data.getIntArray("node-order").length*2-2]; |
2 |
26 Feb 07 |
jari |
185 |
for (int i = 0 ; i < nodes.length; i++) { |
2 |
26 Feb 07 |
jari |
186 |
root = nodes[i]; |
2 |
26 Feb 07 |
jari |
187 |
AlgorithmData single = data.getResultAlgorithmData(new Integer(root)); |
2 |
26 Feb 07 |
jari |
188 |
TEASEInfoBox infoBox = new TEASEInfoBox(maxHeight-genesTree.pHeights[root] + |
2 |
26 Feb 07 |
jari |
189 |
HCLTree.xOrigin, genesTree.positions[root], single, root); |
2 |
26 Feb 07 |
jari |
190 |
genesTree.addInfoBox(infoBox); |
2 |
26 Feb 07 |
jari |
191 |
this.dots.add(infoBox); |
2 |
26 Feb 07 |
jari |
192 |
} |
2 |
26 Feb 07 |
jari |
193 |
|
2 |
26 Feb 07 |
jari |
//this.glassPane = new MyGlassPane(frame.getContentPane()); |
2 |
26 Feb 07 |
jari |
//frame.setGlassPane(this.glassPane); |
2 |
26 Feb 07 |
jari |
196 |
genesTree.addMouseMotionListener(new MotionListener()); |
2 |
26 Feb 07 |
jari |
197 |
addMouseMotionListener(new MotionListener()); |
2 |
26 Feb 07 |
jari |
198 |
} |
2 |
26 Feb 07 |
jari |
199 |
this.popup = createJPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
200 |
} |
2 |
26 Feb 07 |
jari |
201 |
/** |
2 |
26 Feb 07 |
jari |
* State-saving constructor. Do not delete or modify. Create a new constructor |
2 |
26 Feb 07 |
jari |
* that calls this one instead. |
2 |
26 Feb 07 |
jari |
* @param frame |
2 |
26 Feb 07 |
jari |
* @param experiment |
2 |
26 Feb 07 |
jari |
* @param features |
2 |
26 Feb 07 |
jari |
* @param genes_result |
2 |
26 Feb 07 |
jari |
* @param samples_result |
2 |
26 Feb 07 |
jari |
* @param node |
2 |
26 Feb 07 |
jari |
* @param hclOnly |
2 |
26 Feb 07 |
jari |
* @param data |
2 |
26 Feb 07 |
jari |
212 |
*/ |
2 |
26 Feb 07 |
jari |
213 |
public TEASEViewer(JFrame frame, Experiment experiment, int[] features, |
2 |
26 Feb 07 |
jari |
214 |
HCLTree genesTree, HCLTree samplesTree, |
2 |
26 Feb 07 |
jari |
215 |
DefaultMutableTreeNode node, Boolean hclOnly, ArrayList dots) { |
2 |
26 Feb 07 |
jari |
216 |
setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
217 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
218 |
this.genesTree = genesTree; |
2 |
26 Feb 07 |
jari |
219 |
this.sampleTree = samplesTree; |
2 |
26 Feb 07 |
jari |
220 |
if(genesTree != null) |
2 |
26 Feb 07 |
jari |
221 |
this.genes_result = genesTree.getTreeData(); |
2 |
26 Feb 07 |
jari |
222 |
if(samplesTree != null) |
2 |
26 Feb 07 |
jari |
223 |
this.samples_result = samplesTree.getTreeData(); |
2 |
26 Feb 07 |
jari |
224 |
this.hclOnly = hclOnly.booleanValue(); |
2 |
26 Feb 07 |
jari |
225 |
this.features = features; |
2 |
26 Feb 07 |
jari |
226 |
this.dots = dots; |
2 |
26 Feb 07 |
jari |
227 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
228 |
this.listener = new Listener(); |
2 |
26 Feb 07 |
jari |
229 |
this.addMouseListener(this.listener); |
2 |
26 Feb 07 |
jari |
230 |
this.node = node; |
2 |
26 Feb 07 |
jari |
231 |
features = features == null ? createDefaultFeatures(experiment) : features; |
2 |
26 Feb 07 |
jari |
232 |
this.expViewer = createExperimentViewer(experiment, features, genes_result, samples_result); |
2 |
26 Feb 07 |
jari |
233 |
this.expViewer.getContentComponent().addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
234 |
this.header = new HCLExperimentHeader(this.expViewer.getHeaderComponent()); |
2 |
26 Feb 07 |
jari |
235 |
this.header.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
236 |
this.colorBar = new HCLColorBar(this.clusters, features.length); |
2 |
26 Feb 07 |
jari |
237 |
this.colorBar.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
238 |
this.genesOrder = createGenesOrder(experiment, features, genes_result); |
2 |
26 Feb 07 |
jari |
239 |
this.annotationBar = new HCLAnnotationBar(this.genesOrder); |
2 |
26 Feb 07 |
jari |
240 |
this.annotationBar.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
241 |
if (genes_result != null && experiment.getNumberOfGenes() > 1 && genes_result.node_order.length > 1) { |
2 |
26 Feb 07 |
jari |
242 |
this.genesTree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
243 |
this.genesTree.setListener(listener); |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
|
2 |
26 Feb 07 |
jari |
246 |
if (samples_result != null && experiment.getNumberOfSamples() > 1 && samples_result.node_order.length > 1) { |
2 |
26 Feb 07 |
jari |
247 |
this.samplesOrder = createSamplesOrder(samples_result); |
2 |
26 Feb 07 |
jari |
248 |
if(genes_result == null) |
2 |
26 Feb 07 |
jari |
249 |
this.sampleTree.setHorizontalOffset(10); |
2 |
26 Feb 07 |
jari |
250 |
this.sampleTree.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
251 |
this.sampleTree.setListener(listener); //added for selection of experiment hcl nodes |
2 |
26 Feb 07 |
jari |
252 |
} |
2 |
26 Feb 07 |
jari |
253 |
|
2 |
26 Feb 07 |
jari |
254 |
this.isExperimentCluster = false; |
2 |
26 Feb 07 |
jari |
255 |
this.numberOfSamples = experiment.getNumberOfSamples(); //know this is correct for gene clustering constructor |
2 |
26 Feb 07 |
jari |
256 |
addComponents(this.sampleTree, this.genesTree, this.expViewer.getContentComponent(), this.colorBar, this.annotationBar); |
2 |
26 Feb 07 |
jari |
257 |
|
2 |
26 Feb 07 |
jari |
258 |
if (!this.isHCLOnly) { |
2 |
26 Feb 07 |
jari |
259 |
for(int i=0; i<dots.size(); i++){ |
2 |
26 Feb 07 |
jari |
260 |
genesTree.addInfoBox((TEASEInfoBox)dots.get(i)); |
2 |
26 Feb 07 |
jari |
261 |
} |
2 |
26 Feb 07 |
jari |
262 |
|
2 |
26 Feb 07 |
jari |
263 |
genesTree.addMouseMotionListener(new MotionListener()); |
2 |
26 Feb 07 |
jari |
264 |
addMouseMotionListener(new MotionListener()); |
2 |
26 Feb 07 |
jari |
265 |
} |
2 |
26 Feb 07 |
jari |
266 |
this.popup = createJPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
267 |
} |
2 |
26 Feb 07 |
jari |
268 |
|
2 |
26 Feb 07 |
jari |
269 |
/** |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#getExpression() |
2 |
26 Feb 07 |
jari |
271 |
*/ |
2 |
26 Feb 07 |
jari |
272 |
public Expression getExpression(){ |
2 |
26 Feb 07 |
jari |
273 |
Expression e = new Expression(this, this.getClass(), "new", |
2 |
26 Feb 07 |
jari |
274 |
new Object[]{null, this.experiment, this.features, |
2 |
26 Feb 07 |
jari |
275 |
this.genesTree, this.sampleTree, |
2 |
26 Feb 07 |
jari |
276 |
this.node, new Boolean(this.hclOnly), this.dots}); |
2 |
26 Feb 07 |
jari |
277 |
return e; |
2 |
26 Feb 07 |
jari |
278 |
} |
2 |
26 Feb 07 |
jari |
279 |
|
2 |
26 Feb 07 |
jari |
280 |
/** |
2 |
26 Feb 07 |
jari |
* set tooltip text for the gene tree panel, depends on where the cursor is |
2 |
26 Feb 07 |
jari |
* @param x cursor x location |
2 |
26 Feb 07 |
jari |
* @param y cursor y location |
2 |
26 Feb 07 |
jari |
* @return true only when cursor falls on a dot. |
2 |
26 Feb 07 |
jari |
285 |
*/ |
2 |
26 Feb 07 |
jari |
286 |
private boolean setInfoText(int x, int y) { |
2 |
26 Feb 07 |
jari |
287 |
for (int i = 0; i < this.dots.size(); i++) { |
2 |
26 Feb 07 |
jari |
288 |
TEASEInfoBox dot = (TEASEInfoBox)dots.get(i); |
2 |
26 Feb 07 |
jari |
289 |
if (y < (dot.y+5) && y > (dot.y-5) && |
2 |
26 Feb 07 |
jari |
290 |
x < (dot.x+5) && x > (dot.x-5)) { |
2 |
26 Feb 07 |
jari |
291 |
this.genesTree.setToolTipText(dot.getInfoText()); |
2 |
26 Feb 07 |
jari |
292 |
return true; |
2 |
26 Feb 07 |
jari |
293 |
} |
2 |
26 Feb 07 |
jari |
294 |
} |
2 |
26 Feb 07 |
jari |
295 |
return false; |
2 |
26 Feb 07 |
jari |
296 |
} |
2 |
26 Feb 07 |
jari |
297 |
|
2 |
26 Feb 07 |
jari |
298 |
|
2 |
26 Feb 07 |
jari |
299 |
|
2 |
26 Feb 07 |
jari |
300 |
/** |
2 |
26 Feb 07 |
jari |
* Adds wrapped viewers. |
2 |
26 Feb 07 |
jari |
302 |
*/ |
2 |
26 Feb 07 |
jari |
303 |
protected void addComponents(JComponent sTree, JComponent gTree, JComponent exp, |
2 |
26 Feb 07 |
jari |
304 |
JComponent cBar, JComponent aBar) { |
2 |
26 Feb 07 |
jari |
305 |
final int rows = sTree == null ? 1 : 2; |
2 |
26 Feb 07 |
jari |
306 |
final int cols = gTree == null ? 3 : 4; |
2 |
26 Feb 07 |
jari |
307 |
if (sTree != null) { |
2 |
26 Feb 07 |
jari |
308 |
add(sTree, new GridBagConstraints(cols-3, rows-2, 1, 1, 0.0, 0.0, |
2 |
26 Feb 07 |
jari |
309 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); |
2 |
26 Feb 07 |
jari |
310 |
} |
2 |
26 Feb 07 |
jari |
311 |
if (gTree != null) { |
2 |
26 Feb 07 |
jari |
312 |
add(gTree, new GridBagConstraints(cols-4, rows-1, 1, 1, 0.0, 1.0, |
2 |
26 Feb 07 |
jari |
313 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); |
2 |
26 Feb 07 |
jari |
314 |
} |
2 |
26 Feb 07 |
jari |
315 |
add(exp, new GridBagConstraints(cols-3, rows-1, 1, 1, 1.0, 1.0, |
2 |
26 Feb 07 |
jari |
316 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); |
2 |
26 Feb 07 |
jari |
317 |
} |
2 |
26 Feb 07 |
jari |
318 |
|
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
|
2 |
26 Feb 07 |
jari |
321 |
protected IViewer createExperimentViewer(Experiment experiment, int[] features, |
2 |
26 Feb 07 |
jari |
322 |
HCLTreeData genes_result, HCLTreeData samples_result) { |
2 |
26 Feb 07 |
jari |
323 |
|
2 |
26 Feb 07 |
jari |
324 |
int[][] clusters = createClusters(experiment, features, genes_result); |
2 |
26 Feb 07 |
jari |
325 |
int [] samples = getLeafOrder(samples_result, null); |
2 |
26 Feb 07 |
jari |
326 |
IViewer viewer; |
2 |
26 Feb 07 |
jari |
327 |
if(genes_result != null){ |
2 |
26 Feb 07 |
jari |
328 |
offset = 0; |
2 |
26 Feb 07 |
jari |
329 |
viewer = new ExperimentViewer(experiment, clusters, samples, true, offset); |
2 |
26 Feb 07 |
jari |
330 |
} else{ |
2 |
26 Feb 07 |
jari |
331 |
offset = 10; |
2 |
26 Feb 07 |
jari |
332 |
viewer = new ExperimentViewer(experiment, clusters, samples, true, offset); |
2 |
26 Feb 07 |
jari |
333 |
} |
2 |
26 Feb 07 |
jari |
334 |
return viewer; |
2 |
26 Feb 07 |
jari |
335 |
} |
2 |
26 Feb 07 |
jari |
336 |
|
2 |
26 Feb 07 |
jari |
337 |
|
2 |
26 Feb 07 |
jari |
338 |
protected int[] createDefaultFeatures(Experiment experiment) { |
2 |
26 Feb 07 |
jari |
339 |
int[] features = new int[experiment.getNumberOfGenes()]; |
2 |
26 Feb 07 |
jari |
340 |
for (int i=0; i<features.length; i++) { |
2 |
26 Feb 07 |
jari |
341 |
features[i] = i; |
2 |
26 Feb 07 |
jari |
342 |
} |
2 |
26 Feb 07 |
jari |
343 |
return features; |
2 |
26 Feb 07 |
jari |
344 |
} |
2 |
26 Feb 07 |
jari |
345 |
|
2 |
26 Feb 07 |
jari |
346 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a cluster for wrapped experiment viewer. |
2 |
26 Feb 07 |
jari |
348 |
*/ |
2 |
26 Feb 07 |
jari |
349 |
private int[][] createClusters(Experiment experiment, int[] features, HCLTreeData genes_result) { |
2 |
26 Feb 07 |
jari |
350 |
int [][] clusters = new int[1][features.length]; |
2 |
26 Feb 07 |
jari |
351 |
clusters[0] = createGenesOrder(experiment, features, genes_result); |
2 |
26 Feb 07 |
jari |
352 |
return clusters; |
2 |
26 Feb 07 |
jari |
353 |
} |
2 |
26 Feb 07 |
jari |
354 |
|
2 |
26 Feb 07 |
jari |
355 |
protected int [] createSamplesOrder(HCLTreeData samples_result){ |
2 |
26 Feb 07 |
jari |
356 |
return createSamplesOrder(samples_result, null); |
2 |
26 Feb 07 |
jari |
357 |
} |
2 |
26 Feb 07 |
jari |
358 |
|
2 |
26 Feb 07 |
jari |
359 |
protected int [] createSamplesOrder(HCLTreeData samples_result, int [] indices){ |
2 |
26 Feb 07 |
jari |
360 |
return getLeafOrder(samples_result, indices); |
2 |
26 Feb 07 |
jari |
361 |
} |
2 |
26 Feb 07 |
jari |
362 |
|
2 |
26 Feb 07 |
jari |
363 |
protected int[] createGenesOrder(Experiment experiment, int[] features, HCLTreeData genes_result) { |
2 |
26 Feb 07 |
jari |
364 |
int[] order = getLeafOrder(genes_result, features); |
2 |
26 Feb 07 |
jari |
365 |
if (order == null) { |
2 |
26 Feb 07 |
jari |
366 |
order = features; |
2 |
26 Feb 07 |
jari |
367 |
} |
2 |
26 Feb 07 |
jari |
368 |
return order; |
2 |
26 Feb 07 |
jari |
369 |
} |
2 |
26 Feb 07 |
jari |
370 |
|
2 |
26 Feb 07 |
jari |
371 |
private int[] getLeafOrder(HCLTreeData result, int[] indices) { |
2 |
26 Feb 07 |
jari |
372 |
if (result == null || result.node_order.length < 2) { |
2 |
26 Feb 07 |
jari |
373 |
return null; |
2 |
26 Feb 07 |
jari |
374 |
} |
2 |
26 Feb 07 |
jari |
375 |
return getLeafOrder(result.node_order, result.child_1_array, result.child_2_array, indices); |
2 |
26 Feb 07 |
jari |
376 |
} |
2 |
26 Feb 07 |
jari |
377 |
|
2 |
26 Feb 07 |
jari |
378 |
private int[] getLeafOrder(int[] nodeOrder, int[] child1, int[] child2, int[] indices) { |
2 |
26 Feb 07 |
jari |
379 |
int[] leafOrder = new int[nodeOrder.length]; |
2 |
26 Feb 07 |
jari |
380 |
Arrays.fill(leafOrder, -1); |
2 |
26 Feb 07 |
jari |
381 |
|
2 |
26 Feb 07 |
jari |
382 |
fillLeafOrder(leafOrder, child1, child2, 0, child1.length-2, indices); |
2 |
26 Feb 07 |
jari |
383 |
return leafOrder; |
2 |
26 Feb 07 |
jari |
384 |
} |
2 |
26 Feb 07 |
jari |
385 |
|
2 |
26 Feb 07 |
jari |
386 |
private int fillLeafOrder(int[] leafOrder, int[] child1, int[] child2, int pos, int index, int[] indices) { |
2 |
26 Feb 07 |
jari |
387 |
if (child1[index] != -1) { |
2 |
26 Feb 07 |
jari |
388 |
pos = fillLeafOrder(leafOrder, child1, child2, pos, child1[index], indices); |
2 |
26 Feb 07 |
jari |
389 |
} |
2 |
26 Feb 07 |
jari |
390 |
if (child2[index] != -1) { |
2 |
26 Feb 07 |
jari |
391 |
pos = fillLeafOrder(leafOrder, child1, child2, pos, child2[index], indices); |
2 |
26 Feb 07 |
jari |
392 |
} else { |
2 |
26 Feb 07 |
jari |
393 |
leafOrder[pos] = indices == null ? index : indices[index]; |
2 |
26 Feb 07 |
jari |
394 |
pos++; |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
return pos; |
2 |
26 Feb 07 |
jari |
397 |
} |
2 |
26 Feb 07 |
jari |
398 |
|
2 |
26 Feb 07 |
jari |
399 |
/** |
2 |
26 Feb 07 |
jari |
* Returns this viewer to be inserted into the framework scroll pane. |
2 |
26 Feb 07 |
jari |
401 |
*/ |
2 |
26 Feb 07 |
jari |
402 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
403 |
return this; |
2 |
26 Feb 07 |
jari |
404 |
} |
2 |
26 Feb 07 |
jari |
405 |
|
2 |
26 Feb 07 |
jari |
406 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the viewer header. |
2 |
26 Feb 07 |
jari |
408 |
*/ |
2 |
26 Feb 07 |
jari |
409 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
410 |
return this.header; |
2 |
26 Feb 07 |
jari |
411 |
} |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
/** |
2 |
26 Feb 07 |
jari |
* Updates all wrapped viewers. |
2 |
26 Feb 07 |
jari |
415 |
*/ |
2 |
26 Feb 07 |
jari |
416 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
417 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
418 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
419 |
this.expViewer.onSelected(framework); |
2 |
26 Feb 07 |
jari |
420 |
|
2 |
26 Feb 07 |
jari |
// onDataChanged(this.data); |
2 |
26 Feb 07 |
jari |
422 |
|
2 |
26 Feb 07 |
jari |
423 |
Object userObject = framework.getUserObject(); |
2 |
26 Feb 07 |
jari |
424 |
this.clusterIndex = (userObject != null ? ((Integer)userObject).intValue():0); |
2 |
26 Feb 07 |
jari |
425 |
if (this.genesTree != null) { |
2 |
26 Feb 07 |
jari |
426 |
this.genesTree.onSelected(framework); |
2 |
26 Feb 07 |
jari |
427 |
for (int i = 0; i < this.dots.size(); i++) |
2 |
26 Feb 07 |
jari |
428 |
((TEASEInfoBox)this.dots.get(i)).updateSize(framework.getDisplayMenu().getElementSize()); |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
431 |
this.annotationBar.onSelected(framework); |
2 |
26 Feb 07 |
jari |
432 |
this.colorBar.onSelected(framework); |
2 |
26 Feb 07 |
jari |
// set expression header position |
2 |
26 Feb 07 |
jari |
434 |
if (this.genesTree != null) { |
2 |
26 Feb 07 |
jari |
435 |
this.header.setHeaderPosition(this.genesTree.getWidth()); |
2 |
26 Feb 07 |
jari |
436 |
} |
2 |
26 Feb 07 |
jari |
437 |
this.elementSize = framework.getDisplayMenu().getElementSize(); |
2 |
26 Feb 07 |
jari |
438 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
439 |
|
2 |
26 Feb 07 |
jari |
440 |
if(this.node == null) |
2 |
26 Feb 07 |
jari |
441 |
this.node = (DefaultMutableTreeNode)(framework.getCurrentNode().getParent()); |
2 |
26 Feb 07 |
jari |
442 |
|
2 |
26 Feb 07 |
jari |
443 |
verifyClusterExistence(this.data); |
2 |
26 Feb 07 |
jari |
444 |
updateTrees(); |
2 |
26 Feb 07 |
jari |
445 |
refreshViewer(); |
2 |
26 Feb 07 |
jari |
446 |
} |
2 |
26 Feb 07 |
jari |
447 |
|
2 |
26 Feb 07 |
jari |
448 |
/** |
2 |
26 Feb 07 |
jari |
* Calculate the viewer width. |
2 |
26 Feb 07 |
jari |
450 |
*/ |
2 |
26 Feb 07 |
jari |
451 |
protected int getCommonWidth() { |
2 |
26 Feb 07 |
jari |
452 |
int width = 0; |
2 |
26 Feb 07 |
jari |
453 |
if (this.genesTree != null) { |
2 |
26 Feb 07 |
jari |
454 |
width += this.genesTree.getWidth(); |
2 |
26 Feb 07 |
jari |
455 |
} |
2 |
26 Feb 07 |
jari |
456 |
if(this.isExperimentCluster) |
2 |
26 Feb 07 |
jari |
457 |
width += ((ExperimentClusterViewer)this.expViewer).getWidth(); |
2 |
26 Feb 07 |
jari |
458 |
else |
2 |
26 Feb 07 |
jari |
459 |
width += ((ExperimentViewer)this.expViewer).getWidth(); |
2 |
26 Feb 07 |
jari |
460 |
width += this.colorBar.getWidth(); |
2 |
26 Feb 07 |
jari |
461 |
width += this.annotationBar.getWidth(); |
2 |
26 Feb 07 |
jari |
462 |
return width + offset; |
2 |
26 Feb 07 |
jari |
463 |
} |
2 |
26 Feb 07 |
jari |
464 |
|
2 |
26 Feb 07 |
jari |
465 |
/** |
2 |
26 Feb 07 |
jari |
* Delegates this invokation to the wrapped experiment viewer. |
2 |
26 Feb 07 |
jari |
467 |
*/ |
2 |
26 Feb 07 |
jari |
468 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
469 |
this.expViewer.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
470 |
this.data = data; |
2 |
26 Feb 07 |
jari |
471 |
updateTrees(); |
2 |
26 Feb 07 |
jari |
472 |
} |
2 |
26 Feb 07 |
jari |
473 |
|
2 |
26 Feb 07 |
jari |
474 |
|
2 |
26 Feb 07 |
jari |
475 |
/** |
2 |
26 Feb 07 |
jari |
* Delegates this invokation to wrapped viewers. |
2 |
26 Feb 07 |
jari |
477 |
*/ |
2 |
26 Feb 07 |
jari |
478 |
public void onMenuChanged(IDisplayMenu menu) { |
2 |
26 Feb 07 |
jari |
479 |
this.expViewer.onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
480 |
if (this.genesTree != null) { |
2 |
26 Feb 07 |
jari |
481 |
this.genesTree.onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
482 |
for (int i = 0; i < this.dots.size(); i++) |
2 |
26 Feb 07 |
jari |
483 |
((TEASEInfoBox)this.dots.get(i)).updateSize(menu.getElementSize()); |
2 |
26 Feb 07 |
jari |
484 |
} |
2 |
26 Feb 07 |
jari |
485 |
this.annotationBar.onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
486 |
this.colorBar.onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
// expression header can change its size |
2 |
26 Feb 07 |
jari |
488 |
this.elementSize = menu.getElementSize(); |
2 |
26 Feb 07 |
jari |
489 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
490 |
} |
2 |
26 Feb 07 |
jari |
491 |
|
2 |
26 Feb 07 |
jari |
492 |
public void onDeselected() {} |
2 |
26 Feb 07 |
jari |
493 |
public void onClosed() {} |
2 |
26 Feb 07 |
jari |
494 |
|
2 |
26 Feb 07 |
jari |
495 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
496 |
return null; |
2 |
26 Feb 07 |
jari |
497 |
} |
2 |
26 Feb 07 |
jari |
498 |
|
2 |
26 Feb 07 |
jari |
499 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a popup menu. |
2 |
26 Feb 07 |
jari |
501 |
*/ |
2 |
26 Feb 07 |
jari |
502 |
private JPopupMenu createJPopupMenu(Listener listener) { |
2 |
26 Feb 07 |
jari |
503 |
JPopupMenu popup = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
504 |
addMenuItems(popup, listener); |
2 |
26 Feb 07 |
jari |
505 |
return popup; |
2 |
26 Feb 07 |
jari |
506 |
} |
2 |
26 Feb 07 |
jari |
507 |
|
2 |
26 Feb 07 |
jari |
508 |
/** |
2 |
26 Feb 07 |
jari |
* Adds menu items to the specified popup menu. |
2 |
26 Feb 07 |
jari |
510 |
*/ |
2 |
26 Feb 07 |
jari |
511 |
protected void addMenuItems(JPopupMenu menu, Listener listener) { |
2 |
26 Feb 07 |
jari |
512 |
JMenuItem menuItem; |
2 |
26 Feb 07 |
jari |
513 |
menuItem = new JMenuItem("Store Cluster", GUIFactory.getIcon("new16.gif")); |
2 |
26 Feb 07 |
jari |
514 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
515 |
menuItem.setActionCommand(STORE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
516 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
517 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
518 |
|
2 |
26 Feb 07 |
jari |
519 |
menuItem = new JMenuItem("Launch new session", GUIFactory.getIcon("launch_new_mav.gif")); |
2 |
26 Feb 07 |
jari |
520 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
521 |
menuItem.setActionCommand(LAUNCH_NEW_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
522 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
523 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
524 |
|
2 |
26 Feb 07 |
jari |
525 |
menuItem = new JMenuItem("Save cluster...", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
526 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
527 |
menuItem.setActionCommand(SAVE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
528 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
529 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
530 |
|
2 |
26 Feb 07 |
jari |
531 |
menuItem = new JMenuItem("Delete cluster", GUIFactory.getIcon("delete16.gif")); |
2 |
26 Feb 07 |
jari |
532 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
533 |
menuItem.setActionCommand(DELETE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
534 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
535 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
536 |
|
2 |
26 Feb 07 |
jari |
537 |
menuItem = new JMenuItem("Delete all clusters", GUIFactory.getIcon("delete16.gif")); |
2 |
26 Feb 07 |
jari |
538 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
539 |
menuItem.setActionCommand(DELETE_ALL_CLUSTERS_CMD); |
2 |
26 Feb 07 |
jari |
540 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
541 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
542 |
|
2 |
26 Feb 07 |
jari |
543 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
menuItem = new JMenuItem("GeneTree properties...", GUIFactory.getIcon("edit16.gif")); |
2 |
26 Feb 07 |
jari |
546 |
menuItem.setEnabled(this.genesTree != null); |
2 |
26 Feb 07 |
jari |
547 |
menuItem.setActionCommand(GENE_TREE_PROPERTIES_CMD); |
2 |
26 Feb 07 |
jari |
548 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
549 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
550 |
|
2 |
26 Feb 07 |
jari |
551 |
menuItem = new JMenuItem("SampleTree properties...", GUIFactory.getIcon("edit16.gif")); |
2 |
26 Feb 07 |
jari |
552 |
menuItem.setEnabled(this.sampleTree != null); |
2 |
26 Feb 07 |
jari |
553 |
menuItem.setActionCommand(SAMPLE_TREE_PROPERTIES_CMD); |
2 |
26 Feb 07 |
jari |
554 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
555 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
556 |
|
2 |
26 Feb 07 |
jari |
557 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
558 |
|
2 |
26 Feb 07 |
jari |
559 |
menuItem = new JMenuItem("Save Gene Node Heights", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
560 |
menuItem.setEnabled(this.genesTree != null); |
2 |
26 Feb 07 |
jari |
561 |
menuItem.setActionCommand(SAVE_GENE_HEIGHT_CMD); |
2 |
26 Feb 07 |
jari |
562 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
563 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
564 |
|
2 |
26 Feb 07 |
jari |
565 |
menuItem = new JMenuItem("Save Gene Order", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
566 |
menuItem.setEnabled(this.genesTree != null); |
2 |
26 Feb 07 |
jari |
567 |
menuItem.setActionCommand(SAVE_GENE_ORDER_CMD); |
2 |
26 Feb 07 |
jari |
568 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
569 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
570 |
|
2 |
26 Feb 07 |
jari |
571 |
menuItem = new JMenuItem("Save Sample Node Heights", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
572 |
menuItem.setEnabled(this.sampleTree != null); |
2 |
26 Feb 07 |
jari |
573 |
menuItem.setActionCommand(SAVE_EXP_HEIGHT_CMD); |
2 |
26 Feb 07 |
jari |
574 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
575 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
576 |
|
2 |
26 Feb 07 |
jari |
577 |
menuItem = new JMenuItem("Save Sample Order", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
578 |
menuItem.setEnabled(this.sampleTree != null); |
2 |
26 Feb 07 |
jari |
579 |
menuItem.setActionCommand(SAVE_EXP_ORDER_CMD); |
2 |
26 Feb 07 |
jari |
580 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
581 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
582 |
|
2 |
26 Feb 07 |
jari |
583 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
584 |
|
2 |
26 Feb 07 |
jari |
585 |
menuItem = new JMenuItem("Change Score Boundary", GUIFactory.getIcon("edit16.gif")); |
2 |
26 Feb 07 |
jari |
586 |
menuItem.setEnabled(!this.isHCLOnly); |
2 |
26 Feb 07 |
jari |
587 |
menuItem.setActionCommand(CHANGE_SCORE_BOUNDARY); |
2 |
26 Feb 07 |
jari |
588 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
589 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
590 |
|
2 |
26 Feb 07 |
jari |
591 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
592 |
|
2 |
26 Feb 07 |
jari |
593 |
if(this.genesTree != null) { |
2 |
26 Feb 07 |
jari |
594 |
menuItem = new JMenuItem("Save Gene Tree To Newick File", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
595 |
menuItem.setActionCommand(SAVE_GENE_NEWICK_CMD); |
2 |
26 Feb 07 |
jari |
596 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
597 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
598 |
} |
2 |
26 Feb 07 |
jari |
599 |
|
2 |
26 Feb 07 |
jari |
// if(this.sampleTree != null) { |
2 |
26 Feb 07 |
jari |
// menuItem = new JMenuItem("Save Sample Tree to Newick File", GUIFactory.getIcon("save_as16.gif")); |
2 |
26 Feb 07 |
jari |
// menuItem.setActionCommand(SAVE_SAMPLE_NEWICK_CMD); |
2 |
26 Feb 07 |
jari |
// menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
// menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
605 |
// } |
2 |
26 Feb 07 |
jari |
606 |
} |
2 |
26 Feb 07 |
jari |
607 |
|
2 |
26 Feb 07 |
jari |
608 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a menu item by specified action command. |
2 |
26 Feb 07 |
jari |
* @return null, if menu item was not found. |
2 |
26 Feb 07 |
jari |
611 |
*/ |
2 |
26 Feb 07 |
jari |
612 |
protected JMenuItem getJMenuItem(String command) { |
2 |
26 Feb 07 |
jari |
613 |
Component[] components = popup.getComponents(); |
2 |
26 Feb 07 |
jari |
614 |
for (int i=0; i<components.length; i++) { |
2 |
26 Feb 07 |
jari |
615 |
if (components[i] instanceof JMenuItem) { |
2 |
26 Feb 07 |
jari |
616 |
if (((JMenuItem)components[i]).getActionCommand().equals(command)) |
2 |
26 Feb 07 |
jari |
617 |
return(JMenuItem)components[i]; |
2 |
26 Feb 07 |
jari |
618 |
} |
2 |
26 Feb 07 |
jari |
619 |
} |
2 |
26 Feb 07 |
jari |
620 |
return null; |
2 |
26 Feb 07 |
jari |
621 |
} |
2 |
26 Feb 07 |
jari |
622 |
|
2 |
26 Feb 07 |
jari |
623 |
/** |
2 |
26 Feb 07 |
jari |
* Sets menu enabled flag. |
2 |
26 Feb 07 |
jari |
625 |
*/ |
2 |
26 Feb 07 |
jari |
626 |
protected void setEnableMenuItem(String command, boolean enable) { |
2 |
26 Feb 07 |
jari |
627 |
JMenuItem item = getJMenuItem(command); |
2 |
26 Feb 07 |
jari |
628 |
if (item == null) { |
2 |
26 Feb 07 |
jari |
629 |
return; |
2 |
26 Feb 07 |
jari |
630 |
} |
2 |
26 Feb 07 |
jari |
631 |
item.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
632 |
} |
2 |
26 Feb 07 |
jari |
633 |
|
2 |
26 Feb 07 |
jari |
634 |
/** |
2 |
26 Feb 07 |
jari |
* Selects the specified cluster. |
2 |
26 Feb 07 |
jari |
636 |
*/ |
2 |
26 Feb 07 |
jari |
637 |
protected void setSelectedCluster(HCLCluster cluster) { |
2 |
26 Feb 07 |
jari |
638 |
this.selectedCluster = cluster; |
2 |
26 Feb 07 |
jari |
639 |
if(this.isExperimentCluster){ //viewer type, |
2 |
26 Feb 07 |
jari |
640 |
if(cluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
641 |
((ExperimentClusterViewer)this.expViewer).selectRows(cluster.firstElem, cluster.lastElem); |
2 |
26 Feb 07 |
jari |
642 |
else |
2 |
26 Feb 07 |
jari |
643 |
((ExperimentClusterViewer)this.expViewer).selectColumns(cluster.firstElem, cluster.lastElem); |
2 |
26 Feb 07 |
jari |
644 |
} |
2 |
26 Feb 07 |
jari |
645 |
else{ |
2 |
26 Feb 07 |
jari |
646 |
if(cluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
647 |
((ExperimentViewer)this.expViewer).selectRows(cluster.firstElem, cluster.lastElem); |
2 |
26 Feb 07 |
jari |
648 |
else |
2 |
26 Feb 07 |
jari |
649 |
((ExperimentViewer)this.expViewer).selectColumns(cluster.firstElem, cluster.lastElem); |
2 |
26 Feb 07 |
jari |
650 |
} |
2 |
26 Feb 07 |
jari |
651 |
} |
2 |
26 Feb 07 |
jari |
652 |
|
2 |
26 Feb 07 |
jari |
653 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a <code>HCLCluster</code> for specified root node. |
2 |
26 Feb 07 |
jari |
655 |
*/ |
2 |
26 Feb 07 |
jari |
656 |
protected HCLCluster getCluster(HCLCluster selCluster) { |
2 |
26 Feb 07 |
jari |
657 |
int root = selCluster.root; |
2 |
26 Feb 07 |
jari |
658 |
HCLCluster cluster; |
2 |
26 Feb 07 |
jari |
659 |
if(selCluster.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
660 |
for (int i=0; i<this.clusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
661 |
cluster = (HCLCluster)this.clusters.get(i); |
2 |
26 Feb 07 |
jari |
662 |
if (cluster.root == root) { |
2 |
26 Feb 07 |
jari |
663 |
return cluster; |
2 |
26 Feb 07 |
jari |
664 |
} |
2 |
26 Feb 07 |
jari |
665 |
} |
2 |
26 Feb 07 |
jari |
666 |
} |
2 |
26 Feb 07 |
jari |
667 |
else { |
2 |
26 Feb 07 |
jari |
668 |
for (int i=0; i<this.experimentClusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
669 |
cluster = (HCLCluster)this.experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
670 |
if (cluster.root == root) { |
2 |
26 Feb 07 |
jari |
671 |
return cluster; |
2 |
26 Feb 07 |
jari |
672 |
} |
2 |
26 Feb 07 |
jari |
673 |
} |
2 |
26 Feb 07 |
jari |
674 |
} |
2 |
26 Feb 07 |
jari |
675 |
return null; |
2 |
26 Feb 07 |
jari |
676 |
} |
2 |
26 Feb 07 |
jari |
677 |
|
2 |
26 Feb 07 |
jari |
678 |
public void updateTrees(){ |
2 |
26 Feb 07 |
jari |
679 |
if(this.genesTree != null && this.data.getColors().length == 0){ |
2 |
26 Feb 07 |
jari |
680 |
this.genesTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
681 |
this.genesTree.resetNodeColors(); |
2 |
26 Feb 07 |
jari |
682 |
this.clusters.clear(); |
2 |
26 Feb 07 |
jari |
683 |
} |
2 |
26 Feb 07 |
jari |
684 |
if(this.sampleTree != null && this.data.getExperimentColors().length == 0){ |
2 |
26 Feb 07 |
jari |
685 |
this.sampleTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
686 |
this.sampleTree.resetNodeColors(); |
2 |
26 Feb 07 |
jari |
687 |
this.experimentClusters.clear(); |
2 |
26 Feb 07 |
jari |
688 |
} |
2 |
26 Feb 07 |
jari |
689 |
} |
2 |
26 Feb 07 |
jari |
690 |
|
2 |
26 Feb 07 |
jari |
691 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a <code>HCLCluster</code> for specified root node. |
2 |
26 Feb 07 |
jari |
693 |
*/ |
2 |
26 Feb 07 |
jari |
694 |
protected HCLCluster getExperimentCluster(int root) { |
2 |
26 Feb 07 |
jari |
695 |
HCLCluster cluster; |
2 |
26 Feb 07 |
jari |
696 |
for (int i=0; i<this.experimentClusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
697 |
cluster = (HCLCluster)this.experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
698 |
if (cluster.root == root) { |
2 |
26 Feb 07 |
jari |
699 |
return cluster; |
2 |
26 Feb 07 |
jari |
700 |
} |
2 |
26 Feb 07 |
jari |
701 |
} |
2 |
26 Feb 07 |
jari |
702 |
return null; |
2 |
26 Feb 07 |
jari |
703 |
} |
2 |
26 Feb 07 |
jari |
704 |
|
2 |
26 Feb 07 |
jari |
705 |
|
2 |
26 Feb 07 |
jari |
706 |
|
2 |
26 Feb 07 |
jari |
707 |
/** |
2 |
26 Feb 07 |
jari |
* Removes cluster for specified root. |
2 |
26 Feb 07 |
jari |
709 |
*/ |
2 |
26 Feb 07 |
jari |
710 |
protected void removeCluster(HCLCluster oldCluster) { |
2 |
26 Feb 07 |
jari |
711 |
HCLCluster cluster; |
2 |
26 Feb 07 |
jari |
712 |
if(oldCluster.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
713 |
for (int i=this.clusters.size(); --i>=0;) { |
2 |
26 Feb 07 |
jari |
714 |
cluster = (HCLCluster)this.clusters.get(i); |
2 |
26 Feb 07 |
jari |
715 |
if (cluster.root == oldCluster.root) { |
2 |
26 Feb 07 |
jari |
716 |
this.clusters.remove(i); |
2 |
26 Feb 07 |
jari |
717 |
return; |
2 |
26 Feb 07 |
jari |
718 |
} |
2 |
26 Feb 07 |
jari |
719 |
} |
2 |
26 Feb 07 |
jari |
720 |
} |
2 |
26 Feb 07 |
jari |
721 |
else { |
2 |
26 Feb 07 |
jari |
722 |
for (int i=this.experimentClusters.size(); --i>=0;) { |
2 |
26 Feb 07 |
jari |
723 |
cluster = (HCLCluster)this.experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
724 |
if (cluster.root == oldCluster.root) { |
2 |
26 Feb 07 |
jari |
725 |
this.experimentClusters.remove(i); |
2 |
26 Feb 07 |
jari |
726 |
return; |
2 |
26 Feb 07 |
jari |
727 |
} |
2 |
26 Feb 07 |
jari |
728 |
} |
2 |
26 Feb 07 |
jari |
729 |
} |
2 |
26 Feb 07 |
jari |
730 |
} |
2 |
26 Feb 07 |
jari |
731 |
|
2 |
26 Feb 07 |
jari |
732 |
/** |
2 |
26 Feb 07 |
jari |
* Returns true, if there is cluster for selected node. |
2 |
26 Feb 07 |
jari |
734 |
*/ |
2 |
26 Feb 07 |
jari |
735 |
protected boolean doesClusterExist() { |
2 |
26 Feb 07 |
jari |
736 |
if (this.selectedCluster == null) { |
2 |
26 Feb 07 |
jari |
737 |
return false; |
2 |
26 Feb 07 |
jari |
738 |
} |
2 |
26 Feb 07 |
jari |
739 |
return getCluster(this.selectedCluster) != null; |
2 |
26 Feb 07 |
jari |
740 |
} |
2 |
26 Feb 07 |
jari |
741 |
|
2 |
26 Feb 07 |
jari |
742 |
/** |
2 |
26 Feb 07 |
jari |
* Returns count of clusters. |
2 |
26 Feb 07 |
jari |
744 |
*/ |
2 |
26 Feb 07 |
jari |
745 |
protected int getClustersCount() { |
2 |
26 Feb 07 |
jari |
746 |
return this.clusters.size() + this.experimentClusters.size(); |
2 |
26 Feb 07 |
jari |
747 |
} |
2 |
26 Feb 07 |
jari |
748 |
|
2 |
26 Feb 07 |
jari |
749 |
private Frame getFrame() { |
2 |
26 Feb 07 |
jari |
750 |
return JOptionPane.getFrameForComponent(this); |
2 |
26 Feb 07 |
jari |
751 |
} |
2 |
26 Feb 07 |
jari |
752 |
|
2 |
26 Feb 07 |
jari |
753 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a public color for a selected cluster. |
2 |
26 Feb 07 |
jari |
755 |
*/ |
2 |
26 Feb 07 |
jari |
756 |
public void onSetCluster() { |
2 |
26 Feb 07 |
jari |
//Color newColor = JColorChooser.showDialog(getFrame(), "Choose color", new Color(128, 128, 128)); |
2 |
26 Feb 07 |
jari |
758 |
Color newColor = Color.white; |
2 |
26 Feb 07 |
jari |
759 |
if (newColor == null || this.selectedCluster == null) { |
2 |
26 Feb 07 |
jari |
760 |
return; |
2 |
26 Feb 07 |
jari |
761 |
} |
2 |
26 Feb 07 |
jari |
762 |
HCLCluster cluster = getCluster(this.selectedCluster); |
2 |
26 Feb 07 |
jari |
763 |
if (cluster != null) { //cluster already exists |
2 |
26 Feb 07 |
jari |
764 |
this.selectedCluster = cluster; |
2 |
26 Feb 07 |
jari |
765 |
} else { //new cluster, add to list |
2 |
26 Feb 07 |
jari |
766 |
if(selectedCluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
767 |
this.clusters.add(this.selectedCluster); |
2 |
26 Feb 07 |
jari |
768 |
else |
2 |
26 Feb 07 |
jari |
769 |
this.experimentClusters.add(this.selectedCluster); |
2 |
26 Feb 07 |
jari |
770 |
} |
2 |
26 Feb 07 |
jari |
771 |
|
2 |
26 Feb 07 |
jari |
772 |
this.selectedCluster.color = newColor; |
2 |
26 Feb 07 |
jari |
773 |
|
2 |
26 Feb 07 |
jari |
774 |
if(!this.isExperimentCluster){ |
2 |
26 Feb 07 |
jari |
775 |
if(!this.selectedCluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
776 |
this.selectedCluster.color = ((ExperimentViewer)(this.expViewer)).setHCLClusterColor(getSubTreeElements(),this.selectedCluster.color, this.selectedCluster.isGeneCluster); |
2 |
26 Feb 07 |
jari |
777 |
else |
2 |
26 Feb 07 |
jari |
778 |
this.selectedCluster.color = ((ExperimentViewer)(this.expViewer)).setHCLClusterColor(getArrayMappedToData(getSubTreeElements()),this.selectedCluster.color, this.selectedCluster.isGeneCluster); |
2 |
26 Feb 07 |
jari |
779 |
} |
2 |
26 Feb 07 |
jari |
780 |
else{ |
2 |
26 Feb 07 |
jari |
781 |
if(!this.selectedCluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
782 |
this.selectedCluster.color = ((ExperimentClusterViewer)(this.expViewer)).setHCLClusterColor(getSubTreeElements(),this.selectedCluster.color, this.selectedCluster.isGeneCluster); |
2 |
26 Feb 07 |
jari |
783 |
else |
2 |
26 Feb 07 |
jari |
784 |
this.selectedCluster.color = ((ExperimentClusterViewer)(this.expViewer)).setHCLClusterColor(getArrayMappedToData(getSubTreeElements()),this.selectedCluster.color, this.selectedCluster.isGeneCluster); |
2 |
26 Feb 07 |
jari |
785 |
} |
2 |
26 Feb 07 |
jari |
786 |
|
2 |
26 Feb 07 |
jari |
// if(!notANewNode) |
2 |
26 Feb 07 |
jari |
788 |
removeSubTreeClusters(this.selectedCluster); //need to remove clusters from the list if they are sub-trees |
2 |
26 Feb 07 |
jari |
789 |
|
2 |
26 Feb 07 |
jari |
790 |
if(selectedCluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
791 |
this.colorBar.onClustersChanged(this.clusters); |
2 |
26 Feb 07 |
jari |
792 |
|
2 |
26 Feb 07 |
jari |
793 |
refreshViewer(); |
2 |
26 Feb 07 |
jari |
794 |
|
2 |
26 Feb 07 |
jari |
795 |
this.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
796 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
797 |
revalidate(); |
2 |
26 Feb 07 |
jari |
798 |
} |
2 |
26 Feb 07 |
jari |
799 |
|
2 |
26 Feb 07 |
jari |
800 |
/** |
2 |
26 Feb 07 |
jari |
* Removes subtree clusters when an enclosing tree |
2 |
26 Feb 07 |
jari |
802 |
*/ |
2 |
26 Feb 07 |
jari |
803 |
private void removeSubTreeClusters(HCLCluster parent){ |
2 |
26 Feb 07 |
jari |
804 |
HCLCluster cluster; |
2 |
26 Feb 07 |
jari |
805 |
if(parent.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
// for(int i = 0; i < this.clusters.size(); i++){ |
2 |
26 Feb 07 |
jari |
807 |
for(int i = this.clusters.size()-1; i >= 0 ; i--){ |
2 |
26 Feb 07 |
jari |
808 |
cluster = (HCLCluster)clusters.get(i); |
2 |
26 Feb 07 |
jari |
809 |
if( !parent.equals(cluster) && isSubTree(parent, cluster) ){ |
2 |
26 Feb 07 |
jari |
810 |
this.removeCluster(cluster); |
2 |
26 Feb 07 |
jari |
811 |
} |
2 |
26 Feb 07 |
jari |
812 |
} |
2 |
26 Feb 07 |
jari |
813 |
} |
2 |
26 Feb 07 |
jari |
814 |
else { |
2 |
26 Feb 07 |
jari |
815 |
for(int i = 0; i < this.experimentClusters.size(); i++){ |
2 |
26 Feb 07 |
jari |
816 |
cluster = (HCLCluster)experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
817 |
if( parent != cluster && isSubTree(parent, cluster) ) |
2 |
26 Feb 07 |
jari |
818 |
this.removeCluster(cluster); |
2 |
26 Feb 07 |
jari |
819 |
} |
2 |
26 Feb 07 |
jari |
820 |
} |
2 |
26 Feb 07 |
jari |
821 |
} |
2 |
26 Feb 07 |
jari |
822 |
|
2 |
26 Feb 07 |
jari |
823 |
private boolean isSubTree(HCLCluster parent, HCLCluster child){ |
2 |
26 Feb 07 |
jari |
824 |
if( parent.size < child.size ) |
2 |
26 Feb 07 |
jari |
825 |
return false; |
2 |
26 Feb 07 |
jari |
826 |
if( child.firstElem >= parent.firstElem && |
2 |
26 Feb 07 |
jari |
827 |
child.firstElem < parent.lastElem) |
2 |
26 Feb 07 |
jari |
828 |
return true; |
2 |
26 Feb 07 |
jari |
829 |
else |
2 |
26 Feb 07 |
jari |
830 |
return false; |
2 |
26 Feb 07 |
jari |
831 |
} |
2 |
26 Feb 07 |
jari |
832 |
|
2 |
26 Feb 07 |
jari |
833 |
|
2 |
26 Feb 07 |
jari |
834 |
/** |
2 |
26 Feb 07 |
jari |
* Sets cluster description. |
2 |
26 Feb 07 |
jari |
836 |
*/ |
2 |
26 Feb 07 |
jari |
837 |
public void onSetClusterText() { |
2 |
26 Feb 07 |
jari |
838 |
HCLCluster cluster = getCluster(this.selectedCluster); |
2 |
26 Feb 07 |
jari |
839 |
if (cluster == null) { |
2 |
26 Feb 07 |
jari |
840 |
JOptionPane.showMessageDialog(getFrame(), "Not a cluster!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
841 |
} else { |
2 |
26 Feb 07 |
jari |
842 |
String text = JOptionPane.showInputDialog(getFrame(), "Cluster text"); |
2 |
26 Feb 07 |
jari |
843 |
if (text != null && text.length() > 0) { |
2 |
26 Feb 07 |
jari |
844 |
cluster.text = text; |
2 |
26 Feb 07 |
jari |
845 |
this.colorBar.onClustersChanged(this.clusters); |
2 |
26 Feb 07 |
jari |
846 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
847 |
revalidate(); |
2 |
26 Feb 07 |
jari |
848 |
} |
2 |
26 Feb 07 |
jari |
849 |
} |
2 |
26 Feb 07 |
jari |
850 |
} |
2 |
26 Feb 07 |
jari |
851 |
|
2 |
26 Feb 07 |
jari |
852 |
public void verifyClusterExistence(IData data){ |
2 |
26 Feb 07 |
jari |
853 |
HCLCluster currCluster; |
2 |
26 Feb 07 |
jari |
854 |
int geneIndex; |
2 |
26 Feb 07 |
jari |
855 |
boolean [] clusterGone = new boolean[this.clusters.size()]; |
2 |
26 Feb 07 |
jari |
856 |
boolean [] expClusterGone = new boolean[this.experimentClusters.size()]; |
2 |
26 Feb 07 |
jari |
857 |
|
2 |
26 Feb 07 |
jari |
858 |
for( int i = 0; i < this.clusters.size() ; i++){ |
2 |
26 Feb 07 |
jari |
859 |
currCluster = (HCLCluster)this.clusters.get(i); |
2 |
26 Feb 07 |
jari |
860 |
if(currCluster.firstElem == currCluster.lastElem) |
2 |
26 Feb 07 |
jari |
861 |
continue; |
2 |
26 Feb 07 |
jari |
862 |
geneIndex = experiment.getGeneIndexMappedToData(this.genesOrder[currCluster.firstElem]); |
2 |
26 Feb 07 |
jari |
863 |
if(data.getProbeColor(geneIndex) != currCluster.color){ |
2 |
26 Feb 07 |
jari |
864 |
clusterGone[i] = true; |
2 |
26 Feb 07 |
jari |
865 |
} |
2 |
26 Feb 07 |
jari |
866 |
} |
2 |
26 Feb 07 |
jari |
867 |
for(int i = clusterGone.length-1; i >= 0; i--){ |
2 |
26 Feb 07 |
jari |
868 |
if(clusterGone[i]){ |
2 |
26 Feb 07 |
jari |
869 |
this.genesTree.setNodeColor(((HCLCluster)this.clusters.get(i)).root, null); |
2 |
26 Feb 07 |
jari |
// this.clusters.remove(i); |
2 |
26 Feb 07 |
jari |
871 |
} |
2 |
26 Feb 07 |
jari |
872 |
} |
2 |
26 Feb 07 |
jari |
873 |
int expIndex; |
2 |
26 Feb 07 |
jari |
874 |
for( int i = 0; i < this.experimentClusters.size() ; i++){ |
2 |
26 Feb 07 |
jari |
875 |
currCluster = (HCLCluster)this.experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
876 |
if(currCluster.firstElem == currCluster.lastElem) |
2 |
26 Feb 07 |
jari |
877 |
continue; |
2 |
26 Feb 07 |
jari |
878 |
if(this.isExperimentCluster) |
2 |
26 Feb 07 |
jari |
879 |
expIndex = experiment.getSampleIndex(this.sampleClusters[this.clusterIndex][currCluster.firstElem]); |
2 |
26 Feb 07 |
jari |
880 |
else |
2 |
26 Feb 07 |
jari |
881 |
expIndex = experiment.getSampleIndex(this.samplesOrder[currCluster.firstElem]); |
2 |
26 Feb 07 |
jari |
882 |
if(data.getExperimentColor(expIndex) != currCluster.color){ |
2 |
26 Feb 07 |
jari |
883 |
expClusterGone[i] = true; |
2 |
26 Feb 07 |
jari |
884 |
} |
2 |
26 Feb 07 |
jari |
885 |
} |
2 |
26 Feb 07 |
jari |
886 |
for(int i = expClusterGone.length-1; i >= 0; i--){ |
2 |
26 Feb 07 |
jari |
887 |
if(expClusterGone[i]){ |
2 |
26 Feb 07 |
jari |
888 |
this.sampleTree.setNodeColor(((HCLCluster)this.experimentClusters.get(i)).root, null); |
2 |
26 Feb 07 |
jari |
// this.experimentClusters.remove(i); |
2 |
26 Feb 07 |
jari |
890 |
} |
2 |
26 Feb 07 |
jari |
891 |
} |
2 |
26 Feb 07 |
jari |
892 |
} |
2 |
26 Feb 07 |
jari |
893 |
|
2 |
26 Feb 07 |
jari |
894 |
private int[] getSubTreeElements() { |
2 |
26 Feb 07 |
jari |
895 |
return getSubTreeElements(this.selectedCluster); |
2 |
26 Feb 07 |
jari |
896 |
} |
2 |
26 Feb 07 |
jari |
897 |
|
2 |
26 Feb 07 |
jari |
898 |
private int[] getSubTreeElements(HCLCluster cluster) { |
2 |
26 Feb 07 |
jari |
899 |
int size = cluster.lastElem-cluster.firstElem+1; |
2 |
26 Feb 07 |
jari |
900 |
int[] elements = new int[size]; |
2 |
26 Feb 07 |
jari |
901 |
|
2 |
26 Feb 07 |
jari |
//cluster is a cluster of genes |
2 |
26 Feb 07 |
jari |
903 |
if(cluster.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
904 |
for (int i=0; i<size; i++) { |
2 |
26 Feb 07 |
jari |
905 |
elements[i] = this.genesOrder[cluster.firstElem+i]; |
2 |
26 Feb 07 |
jari |
906 |
} |
2 |
26 Feb 07 |
jari |
907 |
} |
2 |
26 Feb 07 |
jari |
908 |
|
2 |
26 Feb 07 |
jari |
//cluster is a cluster of experiments |
2 |
26 Feb 07 |
jari |
910 |
else { |
2 |
26 Feb 07 |
jari |
911 |
if(!this.isExperimentCluster){ //created by gene clustering algorithm |
2 |
26 Feb 07 |
jari |
912 |
for (int i= 0; i< size ; i++) { |
2 |
26 Feb 07 |
jari |
913 |
elements[i] = this.samplesOrder[cluster.firstElem+i]; |
2 |
26 Feb 07 |
jari |
914 |
} |
2 |
26 Feb 07 |
jari |
915 |
} |
2 |
26 Feb 07 |
jari |
916 |
else { //created by experiment clustering algorthm |
2 |
26 Feb 07 |
jari |
917 |
for (int i= 0; i< size ; i++) { |
2 |
26 Feb 07 |
jari |
918 |
elements[i] = this.sampleClusters[this.clusterIndex][cluster.firstElem+i]; |
2 |
26 Feb 07 |
jari |
919 |
} |
2 |
26 Feb 07 |
jari |
920 |
} |
2 |
26 Feb 07 |
jari |
921 |
} |
2 |
26 Feb 07 |
jari |
922 |
return elements; |
2 |
26 Feb 07 |
jari |
923 |
} |
2 |
26 Feb 07 |
jari |
924 |
|
2 |
26 Feb 07 |
jari |
925 |
public void saveGenesOrder(){ |
2 |
26 Feb 07 |
jari |
926 |
try{ |
2 |
26 Feb 07 |
jari |
927 |
ExperimentUtil.saveExperiment(getFrame(), this.experiment, this.data, this.genesOrder); |
2 |
26 Feb 07 |
jari |
928 |
}catch (Exception e){ |
2 |
26 Feb 07 |
jari |
929 |
JOptionPane.showMessageDialog(getFrame(), "Can not save data!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
930 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
931 |
} |
2 |
26 Feb 07 |
jari |
932 |
} |
2 |
26 Feb 07 |
jari |
933 |
public void saveExperimentOrder(){ |
2 |
26 Feb 07 |
jari |
934 |
try{ |
2 |
26 Feb 07 |
jari |
935 |
if(!this.isExperimentCluster) |
2 |
26 Feb 07 |
jari |
936 |
ExperimentUtil.saveExperimentCluster(getFrame(), this.experiment, this.data, this.samplesOrder); |
2 |
26 Feb 07 |
jari |
937 |
else{ |
2 |
26 Feb 07 |
jari |
938 |
int elements[] = new int[this.sampleClusters[this.clusterIndex].length]; |
2 |
26 Feb 07 |
jari |
939 |
for (int i= 0; i< this.sampleClusters[this.clusterIndex].length ; i++) { |
2 |
26 Feb 07 |
jari |
940 |
elements[i] = this.sampleClusters[this.clusterIndex][i]; |
2 |
26 Feb 07 |
jari |
941 |
} |
2 |
26 Feb 07 |
jari |
942 |
ExperimentUtil.saveExperimentCluster(getFrame(), this.experiment, this.data, elements); |
2 |
26 Feb 07 |
jari |
943 |
} |
2 |
26 Feb 07 |
jari |
944 |
}catch (Exception e){ |
2 |
26 Feb 07 |
jari |
945 |
JOptionPane.showMessageDialog(getFrame(), "Can not save data!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
946 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
947 |
} |
2 |
26 Feb 07 |
jari |
948 |
} |
2 |
26 Feb 07 |
jari |
949 |
|
2 |
26 Feb 07 |
jari |
950 |
/** |
2 |
26 Feb 07 |
jari |
* Saves cluster. |
2 |
26 Feb 07 |
jari |
952 |
*/ |
2 |
26 Feb 07 |
jari |
953 |
public void onSaveCluster() { |
2 |
26 Feb 07 |
jari |
954 |
if(this.selectedCluster == null) |
2 |
26 Feb 07 |
jari |
955 |
return; |
2 |
26 Feb 07 |
jari |
956 |
try { |
2 |
26 Feb 07 |
jari |
957 |
if(this.selectedCluster.isGeneCluster) |
2 |
26 Feb 07 |
jari |
958 |
ExperimentUtil.saveExperiment(getFrame(), this.experiment, this.data, getSubTreeElements()); |
2 |
26 Feb 07 |
jari |
959 |
else |
2 |
26 Feb 07 |
jari |
960 |
ExperimentUtil.saveExperimentCluster(getFrame(), this.experiment, this.data, getSubTreeElements()); |
2 |
26 Feb 07 |
jari |
961 |
|
2 |
26 Feb 07 |
jari |
962 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
963 |
JOptionPane.showMessageDialog(getFrame(), "Can not save cluster!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
964 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
965 |
} |
2 |
26 Feb 07 |
jari |
966 |
} |
2 |
26 Feb 07 |
jari |
967 |
|
2 |
26 Feb 07 |
jari |
968 |
/** |
2 |
26 Feb 07 |
jari |
* Deletes the selected cluster. |
2 |
26 Feb 07 |
jari |
970 |
*/ |
2 |
26 Feb 07 |
jari |
971 |
public void onDeleteCluster() { |
2 |
26 Feb 07 |
jari |
972 |
HCLCluster cluster; |
2 |
26 Feb 07 |
jari |
973 |
removeCluster(this.selectedCluster); |
2 |
26 Feb 07 |
jari |
974 |
|
2 |
26 Feb 07 |
jari |
975 |
this.colorBar.onClustersChanged(this.clusters); |
2 |
26 Feb 07 |
jari |
976 |
if(this.selectedCluster.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
977 |
this.genesTree.setNodeColor(this.selectedCluster.root, null); |
2 |
26 Feb 07 |
jari |
978 |
this.data.setProbesColor(getArrayMappedToData(getSubTreeElements()), null); |
2 |
26 Feb 07 |
jari |
979 |
this.framework.removeSubCluster(getArrayMappedToData(getSubTreeElements()), this.experiment, Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
// restore sub tree colors |
2 |
26 Feb 07 |
jari |
981 |
for (int i=0; i<this.clusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
982 |
cluster = (HCLCluster)this.clusters.get(i); |
2 |
26 Feb 07 |
jari |
983 |
this.data.setProbesColor(getArrayMappedToData(getSubTreeElements(cluster)), cluster.color); |
2 |
26 Feb 07 |
jari |
984 |
this.genesTree.setNodeColor(cluster.root, cluster.color); |
2 |
26 Feb 07 |
jari |
985 |
} |
2 |
26 Feb 07 |
jari |
986 |
} |
2 |
26 Feb 07 |
jari |
987 |
else{ //working on sample tree |
2 |
26 Feb 07 |
jari |
988 |
this.sampleTree.setNodeColor(this.selectedCluster.root, null); |
2 |
26 Feb 07 |
jari |
989 |
this.data.setExperimentColor(getSubTreeElements(), null); |
2 |
26 Feb 07 |
jari |
990 |
this.framework.removeSubCluster(getSubTreeElements(), this.experiment, Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
991 |
|
2 |
26 Feb 07 |
jari |
// restore sub tree colors |
2 |
26 Feb 07 |
jari |
993 |
for (int i=0; i<this.experimentClusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
994 |
cluster = (HCLCluster)this.experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
995 |
this.data.setExperimentColor(getSubTreeElements(cluster), cluster.color); |
2 |
26 Feb 07 |
jari |
996 |
this.sampleTree.setNodeColor(cluster.root, cluster.color); |
2 |
26 Feb 07 |
jari |
997 |
} |
2 |
26 Feb 07 |
jari |
998 |
} |
2 |
26 Feb 07 |
jari |
999 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
1000 |
this.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
1001 |
refreshViewer(); |
2 |
26 Feb 07 |
jari |
1002 |
revalidate(); |
2 |
26 Feb 07 |
jari |
1003 |
} |
2 |
26 Feb 07 |
jari |
1004 |
|
2 |
26 Feb 07 |
jari |
1005 |
private void refreshViewer(){ |
2 |
26 Feb 07 |
jari |
1006 |
HCLCluster cluster; |
2 |
26 Feb 07 |
jari |
1007 |
if(this.selectedCluster == null) |
2 |
26 Feb 07 |
jari |
1008 |
return; |
2 |
26 Feb 07 |
jari |
1009 |
|
2 |
26 Feb 07 |
jari |
1010 |
if(selectedCluster.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
1011 |
for (int i=0; i<this.clusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
1012 |
cluster = (HCLCluster)this.clusters.get(i); |
2 |
26 Feb 07 |
jari |
1013 |
this.genesTree.setNodeColor(cluster.root, cluster.color); |
2 |
26 Feb 07 |
jari |
1014 |
this.genesTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1015 |
} |
2 |
26 Feb 07 |
jari |
1016 |
} |
2 |
26 Feb 07 |
jari |
1017 |
else { |
2 |
26 Feb 07 |
jari |
1018 |
for (int i=0; i<this.experimentClusters.size(); i++) { |
2 |
26 Feb 07 |
jari |
1019 |
cluster = (HCLCluster)this.experimentClusters.get(i); |
2 |
26 Feb 07 |
jari |
1020 |
this.sampleTree.setNodeColor(cluster.root, cluster.color); |
2 |
26 Feb 07 |
jari |
1021 |
this.sampleTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1022 |
} |
2 |
26 Feb 07 |
jari |
1023 |
} |
2 |
26 Feb 07 |
jari |
1024 |
|
2 |
26 Feb 07 |
jari |
1025 |
if(this.isExperimentCluster){ |
2 |
26 Feb 07 |
jari |
1026 |
((ExperimentClusterViewer)(this.expViewer)).selectRows(-1,-1); |
2 |
26 Feb 07 |
jari |
1027 |
((ExperimentClusterViewer)(this.expViewer)).selectColumns(-1,-1); |
2 |
26 Feb 07 |
jari |
1028 |
} else { |
2 |
26 Feb 07 |
jari |
1029 |
((ExperimentViewer)(this.expViewer)).selectRows(-1,-1); |
2 |
26 Feb 07 |
jari |
1030 |
((ExperimentViewer)(this.expViewer)).selectColumns(-1,-1); |
2 |
26 Feb 07 |
jari |
1031 |
} |
2 |
26 Feb 07 |
jari |
1032 |
} |
2 |
26 Feb 07 |
jari |
1033 |
|
2 |
26 Feb 07 |
jari |
1034 |
private int [] getArrayMappedToData(int [] clusterIndices){ |
2 |
26 Feb 07 |
jari |
1035 |
if( clusterIndices == null || clusterIndices.length < 1) |
2 |
26 Feb 07 |
jari |
1036 |
return clusterIndices; |
2 |
26 Feb 07 |
jari |
1037 |
|
2 |
26 Feb 07 |
jari |
1038 |
int [] dataIndices = new int [clusterIndices.length]; |
2 |
26 Feb 07 |
jari |
1039 |
for(int i = 0; i < clusterIndices.length; i++){ |
2 |
26 Feb 07 |
jari |
1040 |
dataIndices[i] = this.experiment.getGeneIndexMappedToData(clusterIndices[i]); |
2 |
26 Feb 07 |
jari |
1041 |
} |
2 |
26 Feb 07 |
jari |
1042 |
return dataIndices; |
2 |
26 Feb 07 |
jari |
1043 |
} |
2 |
26 Feb 07 |
jari |
1044 |
|
2 |
26 Feb 07 |
jari |
1045 |
|
2 |
26 Feb 07 |
jari |
1046 |
/** |
2 |
26 Feb 07 |
jari |
* Created viewers for clusters and places them on the analysis tree |
2 |
26 Feb 07 |
jari |
1048 |
*/ |
2 |
26 Feb 07 |
jari |
1049 |
private void createAndAddClusterViews(HCLTree tree){ |
2 |
26 Feb 07 |
jari |
1050 |
int k = tree.getNumberOfTerminalNodes(); |
2 |
26 Feb 07 |
jari |
1051 |
|
2 |
26 Feb 07 |
jari |
1052 |
DefaultMutableTreeNode newNode; |
2 |
26 Feb 07 |
jari |
1053 |
if(tree == this.genesTree) |
2 |
26 Feb 07 |
jari |
1054 |
newNode = new DefaultMutableTreeNode("Gene Tree Cut: "+String.valueOf(k)+" Clusters"); |
2 |
26 Feb 07 |
jari |
1055 |
else |
2 |
26 Feb 07 |
jari |
1056 |
newNode = new DefaultMutableTreeNode("Sample Tree Cut: "+String.valueOf(k)+" Clusters"); |
2 |
26 Feb 07 |
jari |
1057 |
|
2 |
26 Feb 07 |
jari |
1058 |
int [][] clusters = tree.getClusterRowIndices(); |
2 |
26 Feb 07 |
jari |
1059 |
|
2 |
26 Feb 07 |
jari |
1060 |
if(tree == genesTree){ |
2 |
26 Feb 07 |
jari |
1061 |
for(int i = 0; i < clusters.length; i++){ |
2 |
26 Feb 07 |
jari |
1062 |
for(int j = 0; j < clusters[i].length; j++) |
2 |
26 Feb 07 |
jari |
1063 |
clusters[i][j] = this.genesOrder[clusters[i][j]]; |
2 |
26 Feb 07 |
jari |
1064 |
} |
2 |
26 Feb 07 |
jari |
1065 |
} else { |
2 |
26 Feb 07 |
jari |
1066 |
for(int i = 0; i < clusters.length; i++){ |
2 |
26 Feb 07 |
jari |
1067 |
for(int j = 0; j < clusters[i].length; j++) |
2 |
26 Feb 07 |
jari |
1068 |
clusters[i][j] = this.samplesOrder[clusters[i][j]]; |
2 |
26 Feb 07 |
jari |
1069 |
} |
2 |
26 Feb 07 |
jari |
1070 |
} |
2 |
26 Feb 07 |
jari |
1071 |
|
2 |
26 Feb 07 |
jari |
1072 |
addExpressionImages(newNode, clusters, tree == this.genesTree); |
2 |
26 Feb 07 |
jari |
1073 |
addCentroidViews(newNode, clusters, tree == this.genesTree); |
2 |
26 Feb 07 |
jari |
1074 |
addClusterTableViews(newNode, clusters, tree == this.genesTree); |
2 |
26 Feb 07 |
jari |
1075 |
addClusterInfo(newNode, clusters, tree == this.genesTree, tree.getZeroThreshold()); |
2 |
26 Feb 07 |
jari |
1076 |
addGeneralInfo(newNode, tree.getZeroThreshold(), k, tree == this.genesTree); |
2 |
26 Feb 07 |
jari |
1077 |
this.framework.addNode(this.node, newNode); |
2 |
26 Feb 07 |
jari |
1078 |
} |
2 |
26 Feb 07 |
jari |
1079 |
|
2 |
26 Feb 07 |
jari |
1080 |
private void addClusterTableViews(DefaultMutableTreeNode node, int [][] clusters, boolean geneClusters) { |
2 |
26 Feb 07 |
jari |
1081 |
DefaultMutableTreeNode tabNode = new DefaultMutableTreeNode("Table Views"); |
2 |
26 Feb 07 |
jari |
1082 |
IViewer tabViewer; |
2 |
26 Feb 07 |
jari |
1083 |
if (geneClusters) |
2 |
26 Feb 07 |
jari |
1084 |
tabViewer = new ClusterTableViewer(this.experiment, clusters, this.data); |
2 |
26 Feb 07 |
jari |
1085 |
else |
2 |
26 Feb 07 |
jari |
1086 |
tabViewer = new ExperimentClusterTableViewer(this.experiment, clusters, this.data); |
2 |
26 Feb 07 |
jari |
//return; // placeholder for ExptClusterTableViewer |
2 |
26 Feb 07 |
jari |
1088 |
|
2 |
26 Feb 07 |
jari |
1089 |
for(int i = 0; i < clusters.length; i++){ |
2 |
26 Feb 07 |
jari |
1090 |
tabNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), tabViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1091 |
} |
2 |
26 Feb 07 |
jari |
1092 |
node.add(tabNode); |
2 |
26 Feb 07 |
jari |
1093 |
} |
2 |
26 Feb 07 |
jari |
1094 |
|
2 |
26 Feb 07 |
jari |
1095 |
/** |
2 |
26 Feb 07 |
jari |
* Adds cluster expression images |
2 |
26 Feb 07 |
jari |
1097 |
*/ |
2 |
26 Feb 07 |
jari |
1098 |
private void addExpressionImages(DefaultMutableTreeNode node, int [][] clusters, boolean geneClusters){ |
2 |
26 Feb 07 |
jari |
1099 |
DefaultMutableTreeNode expNode = new DefaultMutableTreeNode("Expression Images"); |
2 |
26 Feb 07 |
jari |
1100 |
|
2 |
26 Feb 07 |
jari |
1101 |
IViewer expViewer; |
2 |
26 Feb 07 |
jari |
1102 |
if(geneClusters) |
2 |
26 Feb 07 |
jari |
1103 |
expViewer = new HCLExperimentViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1104 |
else |
2 |
26 Feb 07 |
jari |
1105 |
expViewer = new HCLExperimentClusterViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1106 |
|
2 |
26 Feb 07 |
jari |
1107 |
for(int i = 0; i < clusters.length; i++){ |
2 |
26 Feb 07 |
jari |
1108 |
expNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1109 |
} |
2 |
26 Feb 07 |
jari |
1110 |
node.add(expNode); |
2 |
26 Feb 07 |
jari |
1111 |
} |
2 |
26 Feb 07 |
jari |
1112 |
|
2 |
26 Feb 07 |
jari |
1113 |
|
2 |
26 Feb 07 |
jari |
1114 |
|
2 |
26 Feb 07 |
jari |
1115 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display centroid charts. |
2 |
26 Feb 07 |
jari |
1117 |
*/ |
2 |
26 Feb 07 |
jari |
1118 |
private void addCentroidViews(DefaultMutableTreeNode root, int [][] clusters, boolean clusterGenes) { |
2 |
26 Feb 07 |
jari |
1119 |
DefaultMutableTreeNode centroidNode = new DefaultMutableTreeNode("Centroid Graphs"); |
2 |
26 Feb 07 |
jari |
1120 |
DefaultMutableTreeNode expressionNode = new DefaultMutableTreeNode("Expression Graphs"); |
2 |
26 Feb 07 |
jari |
1121 |
FloatMatrix data = this.experiment.getMatrix(); |
2 |
26 Feb 07 |
jari |
1122 |
|
2 |
26 Feb 07 |
jari |
1123 |
if(!clusterGenes){ |
2 |
26 Feb 07 |
jari |
1124 |
data = data.transpose(); |
2 |
26 Feb 07 |
jari |
1125 |
} |
2 |
26 Feb 07 |
jari |
1126 |
|
2 |
26 Feb 07 |
jari |
1127 |
FloatMatrix means = getMeans(data, clusters); |
2 |
26 Feb 07 |
jari |
1128 |
FloatMatrix variances = getVariances(data, means, clusters); |
2 |
26 Feb 07 |
jari |
1129 |
|
2 |
26 Feb 07 |
jari |
1130 |
HCLCentroidViewer centroidViewer; |
2 |
26 Feb 07 |
jari |
1131 |
ExperimentClusterCentroidViewer expCentroidViewer; |
2 |
26 Feb 07 |
jari |
1132 |
if(clusterGenes){ |
2 |
26 Feb 07 |
jari |
1133 |
centroidViewer = new HCLCentroidViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1134 |
centroidViewer.setMeans(means.A); |
2 |
26 Feb 07 |
jari |
1135 |
centroidViewer.setVariances(variances.A); |
2 |
26 Feb 07 |
jari |
1136 |
for (int i=0; i<clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1137 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1138 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1139 |
} |
2 |
26 Feb 07 |
jari |
1140 |
|
2 |
26 Feb 07 |
jari |
1141 |
HCLCentroidsViewer centroidsViewer = new HCLCentroidsViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1142 |
centroidsViewer.setMeans(means.A); |
2 |
26 Feb 07 |
jari |
1143 |
centroidsViewer.setVariances(variances.A); |
2 |
26 Feb 07 |
jari |
1144 |
|
2 |
26 Feb 07 |
jari |
1145 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", centroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1146 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", centroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1147 |
|
2 |
26 Feb 07 |
jari |
1148 |
} |
2 |
26 Feb 07 |
jari |
1149 |
else{ |
2 |
26 Feb 07 |
jari |
1150 |
expCentroidViewer = new HCLExperimentCentroidViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1151 |
|
2 |
26 Feb 07 |
jari |
1152 |
expCentroidViewer.setMeans(means.A); |
2 |
26 Feb 07 |
jari |
1153 |
expCentroidViewer.setVariances(variances.A); |
2 |
26 Feb 07 |
jari |
1154 |
for (int i=0; i<clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1155 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1156 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1157 |
} |
2 |
26 Feb 07 |
jari |
1158 |
HCLExperimentCentroidsViewer expCentroidsViewer = new HCLExperimentCentroidsViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1159 |
expCentroidsViewer.setMeans(means.A); |
2 |
26 Feb 07 |
jari |
1160 |
expCentroidsViewer.setVariances(variances.A); |
2 |
26 Feb 07 |
jari |
1161 |
|
2 |
26 Feb 07 |
jari |
1162 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", expCentroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1163 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", expCentroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1164 |
} |
2 |
26 Feb 07 |
jari |
1165 |
root.add(centroidNode); |
2 |
26 Feb 07 |
jari |
1166 |
root.add(expressionNode); |
2 |
26 Feb 07 |
jari |
1167 |
} |
2 |
26 Feb 07 |
jari |
1168 |
|
2 |
26 Feb 07 |
jari |
1169 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates means for the clusters |
2 |
26 Feb 07 |
jari |
1171 |
*/ |
2 |
26 Feb 07 |
jari |
1172 |
private FloatMatrix getMeans(FloatMatrix data, int [][] clusters){ |
2 |
26 Feb 07 |
jari |
1173 |
FloatMatrix means = new FloatMatrix(clusters.length, data.getColumnDimension()); |
2 |
26 Feb 07 |
jari |
1174 |
for(int i = 0; i < clusters.length; i++){ |
2 |
26 Feb 07 |
jari |
1175 |
means.A[i] = getMeans(data, clusters[i]); |
2 |
26 Feb 07 |
jari |
1176 |
} |
2 |
26 Feb 07 |
jari |
1177 |
return means; |
2 |
26 Feb 07 |
jari |
1178 |
} |
2 |
26 Feb 07 |
jari |
1179 |
|
2 |
26 Feb 07 |
jari |
1180 |
|
2 |
26 Feb 07 |
jari |
1181 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a set of means for an element |
2 |
26 Feb 07 |
jari |
1183 |
*/ |
2 |
26 Feb 07 |
jari |
1184 |
private float [] getMeans(FloatMatrix data, int [] indices){ |
2 |
26 Feb 07 |
jari |
1185 |
int nSamples = data.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
1186 |
float [] means = new float[nSamples]; |
2 |
26 Feb 07 |
jari |
1187 |
float sum = 0; |
2 |
26 Feb 07 |
jari |
1188 |
float n = 0; |
2 |
26 Feb 07 |
jari |
1189 |
float value; |
2 |
26 Feb 07 |
jari |
1190 |
for(int i = 0; i < nSamples; i++){ |
2 |
26 Feb 07 |
jari |
1191 |
n = 0; |
2 |
26 Feb 07 |
jari |
1192 |
sum = 0; |
2 |
26 Feb 07 |
jari |
1193 |
for(int j = 0; j < indices.length; j++){ |
2 |
26 Feb 07 |
jari |
1194 |
value = data.get(indices[j],i); |
2 |
26 Feb 07 |
jari |
1195 |
if(!Float.isNaN(value)){ |
2 |
26 Feb 07 |
jari |
1196 |
sum += value; |
2 |
26 Feb 07 |
jari |
1197 |
n++; |
2 |
26 Feb 07 |
jari |
1198 |
} |
2 |
26 Feb 07 |
jari |
1199 |
} |
2 |
26 Feb 07 |
jari |
1200 |
if(n > 0) |
2 |
26 Feb 07 |
jari |
1201 |
means[i] = sum/n; |
2 |
26 Feb 07 |
jari |
1202 |
else |
2 |
26 Feb 07 |
jari |
1203 |
means[i] = Float.NaN; |
2 |
26 Feb 07 |
jari |
1204 |
} |
2 |
26 Feb 07 |
jari |
1205 |
return means; |
2 |
26 Feb 07 |
jari |
1206 |
} |
2 |
26 Feb 07 |
jari |
1207 |
|
2 |
26 Feb 07 |
jari |
1208 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a matrix of standard deviations grouped by cluster and element |
2 |
26 Feb 07 |
jari |
1210 |
*/ |
2 |
26 Feb 07 |
jari |
1211 |
private FloatMatrix getVariances(FloatMatrix data, FloatMatrix means, int [][] clusters){ |
2 |
26 Feb 07 |
jari |
1212 |
int nSamples = data.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
1213 |
FloatMatrix variances = new FloatMatrix(clusters.length, nSamples); |
2 |
26 Feb 07 |
jari |
1214 |
for(int i = 0; i < clusters.length; i++){ |
2 |
26 Feb 07 |
jari |
1215 |
variances.A[i] = getVariances(data, means, clusters[i], i); |
2 |
26 Feb 07 |
jari |
1216 |
} |
2 |
26 Feb 07 |
jari |
1217 |
return variances; |
2 |
26 Feb 07 |
jari |
1218 |
} |
2 |
26 Feb 07 |
jari |
1219 |
|
2 |
26 Feb 07 |
jari |
1220 |
private float [] getVariances(FloatMatrix data, FloatMatrix means, int [] indices, int clusterIndex){ |
2 |
26 Feb 07 |
jari |
1221 |
int nSamples = data.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
1222 |
float [] variances = new float[nSamples]; |
2 |
26 Feb 07 |
jari |
1223 |
float sse = 0; |
2 |
26 Feb 07 |
jari |
1224 |
float mean; |
2 |
26 Feb 07 |
jari |
1225 |
float value; |
2 |
26 Feb 07 |
jari |
1226 |
int n = 0; |
2 |
26 Feb 07 |
jari |
1227 |
for(int i = 0; i < nSamples; i++){ |
2 |
26 Feb 07 |
jari |
1228 |
mean = means.get(clusterIndex, i); |
2 |
26 Feb 07 |
jari |
1229 |
n = 0; |
2 |
26 Feb 07 |
jari |
1230 |
sse = 0; |
2 |
26 Feb 07 |
jari |
1231 |
for(int j = 0; j < indices.length; j++){ |
2 |
26 Feb 07 |
jari |
1232 |
value = data.get(indices[j], i); |
2 |
26 Feb 07 |
jari |
1233 |
if(!Float.isNaN(value)){ |
2 |
26 Feb 07 |
jari |
1234 |
sse += (float)Math.pow((value - mean),2); |
2 |
26 Feb 07 |
jari |
1235 |
n++; |
2 |
26 Feb 07 |
jari |
1236 |
} |
2 |
26 Feb 07 |
jari |
1237 |
} |
2 |
26 Feb 07 |
jari |
1238 |
if(n > 1) |
2 |
26 Feb 07 |
jari |
1239 |
variances[i] = (float)Math.sqrt(sse/(n-1)); |
2 |
26 Feb 07 |
jari |
1240 |
else |
2 |
26 Feb 07 |
jari |
1241 |
variances[i] = 0.0f; |
2 |
26 Feb 07 |
jari |
1242 |
} |
2 |
26 Feb 07 |
jari |
1243 |
return variances; |
2 |
26 Feb 07 |
jari |
1244 |
} |
2 |
26 Feb 07 |
jari |
1245 |
|
2 |
26 Feb 07 |
jari |
1246 |
/** |
2 |
26 Feb 07 |
jari |
* Adds node with cluster information. |
2 |
26 Feb 07 |
jari |
1248 |
*/ |
2 |
26 Feb 07 |
jari |
1249 |
private void addClusterInfo(DefaultMutableTreeNode root, int [][] clusters, boolean clusterGenes, float zThr) { |
2 |
26 Feb 07 |
jari |
1250 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Cluster Information"); |
2 |
26 Feb 07 |
jari |
1251 |
if(clusterGenes) |
2 |
26 Feb 07 |
jari |
1252 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Genes in Clusters (#,%)", new HCLClusterInfoViewer(clusters, this.experiment.getNumberOfGenes(), zThr)))); |
2 |
26 Feb 07 |
jari |
1253 |
else |
2 |
26 Feb 07 |
jari |
1254 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Sammples in Clusters (#,%)", new HCLClusterInfoViewer(clusters, this.experiment.getNumberOfSamples(), false, zThr)))); |
2 |
26 Feb 07 |
jari |
1255 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1256 |
} |
2 |
26 Feb 07 |
jari |
1257 |
|
2 |
26 Feb 07 |
jari |
1258 |
/** |
2 |
26 Feb 07 |
jari |
* Adds node with tree cut parameters |
2 |
26 Feb 07 |
jari |
1260 |
*/ |
2 |
26 Feb 07 |
jari |
1261 |
private void addGeneralInfo(DefaultMutableTreeNode root, float zThr, int k,boolean isGeneTree){ |
2 |
26 Feb 07 |
jari |
1262 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("General Info"); |
2 |
26 Feb 07 |
jari |
1263 |
node.add(new DefaultMutableTreeNode("Cluster Type: "+(isGeneTree ? "Gene Clusters" : "Sample Clusters"))); |
2 |
26 Feb 07 |
jari |
1264 |
node.add(new DefaultMutableTreeNode("Distance Threshold: "+ String.valueOf(zThr))); |
2 |
26 Feb 07 |
jari |
1265 |
node.add(new DefaultMutableTreeNode("Number of Clusters: "+String.valueOf(k))); |
2 |
26 Feb 07 |
jari |
1266 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1267 |
} |
2 |
26 Feb 07 |
jari |
1268 |
|
2 |
26 Feb 07 |
jari |
1269 |
/** |
2 |
26 Feb 07 |
jari |
* Removes all clusters. |
2 |
26 Feb 07 |
jari |
1271 |
*/ |
2 |
26 Feb 07 |
jari |
1272 |
public void onDeleteAllClusters() { |
2 |
26 Feb 07 |
jari |
1273 |
refreshViewer(); |
2 |
26 Feb 07 |
jari |
1274 |
this.clusters.clear(); |
2 |
26 Feb 07 |
jari |
1275 |
this.experimentClusters.clear(); |
2 |
26 Feb 07 |
jari |
1276 |
this.colorBar.onClustersChanged(this.clusters); |
2 |
26 Feb 07 |
jari |
1277 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
1278 |
if(this.genesTree != null) |
2 |
26 Feb 07 |
jari |
1279 |
this.genesTree.resetNodeColors(); |
2 |
26 Feb 07 |
jari |
1280 |
if(this.sampleTree != null) |
2 |
26 Feb 07 |
jari |
1281 |
this.sampleTree.resetNodeColors(); |
2 |
26 Feb 07 |
jari |
1282 |
this.data.deleteColors(); |
2 |
26 Feb 07 |
jari |
1283 |
this.data.deleteExperimentColors(); |
2 |
26 Feb 07 |
jari |
1284 |
this.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
1285 |
revalidate(); |
2 |
26 Feb 07 |
jari |
1286 |
repaint(); |
2 |
26 Feb 07 |
jari |
1287 |
} |
2 |
26 Feb 07 |
jari |
1288 |
|
2 |
26 Feb 07 |
jari |
1289 |
/** |
2 |
26 Feb 07 |
jari |
* Sets genes tree properties. |
2 |
26 Feb 07 |
jari |
1291 |
*/ |
2 |
26 Feb 07 |
jari |
1292 |
public void onGeneTreeProperties() { |
2 |
26 Feb 07 |
jari |
1293 |
setTreeProperties(this.genesTree); |
2 |
26 Feb 07 |
jari |
1294 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
1295 |
this.header.setHeaderPosition(this.genesTree.getWidth()); |
2 |
26 Feb 07 |
jari |
1296 |
revalidate(); |
2 |
26 Feb 07 |
jari |
1297 |
} |
2 |
26 Feb 07 |
jari |
1298 |
|
2 |
26 Feb 07 |
jari |
1299 |
/** |
2 |
26 Feb 07 |
jari |
* Sets samples tree properties. |
2 |
26 Feb 07 |
jari |
1301 |
*/ |
2 |
26 Feb 07 |
jari |
1302 |
public void onSampleTreeProperties() { |
2 |
26 Feb 07 |
jari |
1303 |
setTreeProperties(this.sampleTree); |
2 |
26 Feb 07 |
jari |
1304 |
revalidate(); |
2 |
26 Feb 07 |
jari |
1305 |
} |
2 |
26 Feb 07 |
jari |
1306 |
|
2 |
26 Feb 07 |
jari |
1307 |
private void setTreeProperties(HCLTree tree) { |
2 |
26 Feb 07 |
jari |
1308 |
Frame frame = JOptionPane.getFrameForComponent(this); |
2 |
26 Feb 07 |
jari |
1309 |
TEASEConfigDialog dialog = new TEASEConfigDialog(frame, this, tree.getZeroThreshold(), |
2 |
26 Feb 07 |
jari |
1310 |
tree.getMinDistance(), tree.getMaxDistance(), tree.getMinNodeDistance(), tree.getMaxNodeDistance()); |
2 |
26 Feb 07 |
jari |
1311 |
dialog.setTree(tree); |
2 |
26 Feb 07 |
jari |
1312 |
if (dialog.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
1313 |
tree.setProperties(dialog.getZeroThreshold(), dialog.getMinDistance(), dialog.getMaxDistance()); |
2 |
26 Feb 07 |
jari |
1314 |
if(dialog.isCreateClusterViews()) |
2 |
26 Feb 07 |
jari |
1315 |
createAndAddClusterViews(tree); |
2 |
26 Feb 07 |
jari |
1316 |
} |
2 |
26 Feb 07 |
jari |
1317 |
} |
2 |
26 Feb 07 |
jari |
1318 |
|
2 |
26 Feb 07 |
jari |
1319 |
private void getAndSetScoreBoundary() { |
2 |
26 Feb 07 |
jari |
1320 |
TEASEInfoBox dot = (TEASEInfoBox)this.dots.get(0); |
2 |
26 Feb 07 |
jari |
1321 |
Frame frame = JOptionPane.getFrameForComponent(this); |
2 |
26 Feb 07 |
jari |
1322 |
ScoreBoundaryDialog dialog = new ScoreBoundaryDialog(frame, dot.getUpperBound(), dot.getLowerBound()); |
2 |
26 Feb 07 |
jari |
1323 |
|
2 |
26 Feb 07 |
jari |
1324 |
if (dialog.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
1325 |
for (int i = 0; i < this.dots.size(); i++) { |
2 |
26 Feb 07 |
jari |
1326 |
TEASEInfoBox box = (TEASEInfoBox)this.dots.get(i); |
2 |
26 Feb 07 |
jari |
1327 |
box.setColorBoundary(Double.valueOf(dialog.getUpperBound()).doubleValue(), Double.valueOf(dialog.getLowerBound()).doubleValue()); |
2 |
26 Feb 07 |
jari |
1328 |
} |
2 |
26 Feb 07 |
jari |
1329 |
repaint(); |
2 |
26 Feb 07 |
jari |
1330 |
} |
2 |
26 Feb 07 |
jari |
1331 |
} |
2 |
26 Feb 07 |
jari |
1332 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the specified cluster as selected. |
2 |
26 Feb 07 |
jari |
1334 |
*/ |
2 |
26 Feb 07 |
jari |
1335 |
public void valueChanged(HCLTree source, HCLCluster cluster) { |
2 |
26 Feb 07 |
jari |
1336 |
setSelectedCluster(cluster); |
2 |
26 Feb 07 |
jari |
1337 |
} |
2 |
26 Feb 07 |
jari |
1338 |
|
2 |
26 Feb 07 |
jari |
1339 |
/** |
2 |
26 Feb 07 |
jari |
* Revalidates viewer components |
2 |
26 Feb 07 |
jari |
1341 |
*/ |
2 |
26 Feb 07 |
jari |
1342 |
public void revalidateViewer(){ |
2 |
26 Feb 07 |
jari |
1343 |
if(this.genesTree != null){ |
2 |
26 Feb 07 |
jari |
1344 |
this.header.updateSize(getCommonWidth(), this.elementSize.width); |
2 |
26 Feb 07 |
jari |
1345 |
this.header.setHeaderPosition(this.genesTree.getWidth()); |
2 |
26 Feb 07 |
jari |
1346 |
} |
2 |
26 Feb 07 |
jari |
1347 |
revalidate(); |
2 |
26 Feb 07 |
jari |
1348 |
} |
2 |
26 Feb 07 |
jari |
1349 |
|
2 |
26 Feb 07 |
jari |
1350 |
/** |
2 |
26 Feb 07 |
jari |
* Launches a new <code>MultipleExperimentViewer</code> containing the current cluster |
2 |
26 Feb 07 |
jari |
1352 |
*/ |
2 |
26 Feb 07 |
jari |
1353 |
public void launchNewSession(){ |
2 |
26 Feb 07 |
jari |
1354 |
if(this.selectedCluster == null) |
2 |
26 Feb 07 |
jari |
1355 |
return; |
2 |
26 Feb 07 |
jari |
1356 |
if(this.selectedCluster.isGeneCluster){ |
2 |
26 Feb 07 |
jari |
1357 |
framework.launchNewMAV(getArrayMappedToData(getSubTreeElements()), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
1358 |
} else { |
2 |
26 Feb 07 |
jari |
1359 |
framework.launchNewMAV(getSubTreeElements(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
1360 |
} |
2 |
26 Feb 07 |
jari |
1361 |
} |
2 |
26 Feb 07 |
jari |
1362 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into the scroll pane row header |
2 |
26 Feb 07 |
jari |
1364 |
*/ |
2 |
26 Feb 07 |
jari |
1365 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
1366 |
return null; |
2 |
26 Feb 07 |
jari |
1367 |
} |
2 |
26 Feb 07 |
jari |
1368 |
|
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 |
1371 |
*/ |
2 |
26 Feb 07 |
jari |
1372 |
public JComponent getCornerComponent(int cornerIndex) { |
2 |
26 Feb 07 |
jari |
1373 |
return null; |
2 |
26 Feb 07 |
jari |
1374 |
} |
2 |
26 Feb 07 |
jari |
1375 |
|
2 |
26 Feb 07 |
jari |
1376 |
public int[][] getClusters() { |
2 |
26 Feb 07 |
jari |
1377 |
int [][] leafClusters = new int[2][]; |
2 |
26 Feb 07 |
jari |
1378 |
if(this.genesTree != null) |
2 |
26 Feb 07 |
jari |
1379 |
leafClusters[0] = this.genesOrder; |
2 |
26 Feb 07 |
jari |
1380 |
else |
2 |
26 Feb 07 |
jari |
1381 |
leafClusters[0] = null; |
2 |
26 Feb 07 |
jari |
1382 |
if(this.sampleTree != null) |
2 |
26 Feb 07 |
jari |
1383 |
leafClusters[1] = this.samplesOrder; |
2 |
26 Feb 07 |
jari |
1384 |
else |
2 |
26 Feb 07 |
jari |
1385 |
leafClusters[1] = null; |
2 |
26 Feb 07 |
jari |
1386 |
return leafClusters; |
2 |
26 Feb 07 |
jari |
1387 |
} |
2 |
26 Feb 07 |
jari |
1388 |
|
2 |
26 Feb 07 |
jari |
1389 |
public Experiment getExperiment() { |
2 |
26 Feb 07 |
jari |
1390 |
return this.experiment; |
2 |
26 Feb 07 |
jari |
1391 |
} |
2 |
26 Feb 07 |
jari |
1392 |
|
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 |
1395 |
*/ |
2 |
26 Feb 07 |
jari |
1396 |
public int getViewerType() { |
2 |
26 Feb 07 |
jari |
1397 |
return -1; |
2 |
26 Feb 07 |
jari |
1398 |
} |
2 |
26 Feb 07 |
jari |
1399 |
|
2 |
26 Feb 07 |
jari |
/** Prototyping code for saving state as XML |
2 |
26 Feb 07 |
jari |
1401 |
* |
2 |
26 Feb 07 |
jari |
public void writeXML(XMLEncoder enc) { |
2 |
26 Feb 07 |
jari |
enc.setPersistenceDelegate(HCLViewer.class, |
2 |
26 Feb 07 |
jari |
new DefaultPersistenceDelegate( new String[]{ |
2 |
26 Feb 07 |
jari |
"experiment", "features", "genes_result", "samples_result", "node"})); |
2 |
26 Feb 07 |
jari |
1406 |
|
2 |
26 Feb 07 |
jari |
enc.writeObject( new HCLViewer(experiment, features, genes_result, samples_result, node) ); |
2 |
26 Feb 07 |
jari |
1408 |
|
2 |
26 Feb 07 |
jari |
1409 |
} |
2 |
26 Feb 07 |
jari |
1410 |
*/ |
2 |
26 Feb 07 |
jari |
1411 |
|
2 |
26 Feb 07 |
jari |
//*************************************inner class**********************************// |
2 |
26 Feb 07 |
jari |
1413 |
|
2 |
26 Feb 07 |
jari |
1414 |
/** |
2 |
26 Feb 07 |
jari |
* The class to listen to mouse, action and hcl tree events. |
2 |
26 Feb 07 |
jari |
1416 |
*/ |
2 |
26 Feb 07 |
jari |
1417 |
private class Listener extends MouseAdapter implements ActionListener, HCLTreeListener, java.io.Serializable { |
2 |
26 Feb 07 |
jari |
1418 |
|
2 |
26 Feb 07 |
jari |
1419 |
public void actionPerformed(ActionEvent e) { |
2 |
26 Feb 07 |
jari |
1420 |
String command = e.getActionCommand(); |
2 |
26 Feb 07 |
jari |
1421 |
if(command.equals(STORE_CLUSTER_CMD)){ |
2 |
26 Feb 07 |
jari |
1422 |
onSetCluster(); |
2 |
26 Feb 07 |
jari |
1423 |
} else if(command.equals(LAUNCH_NEW_SESSION_CMD)) { |
2 |
26 Feb 07 |
jari |
1424 |
launchNewSession(); |
2 |
26 Feb 07 |
jari |
1425 |
} if (command.equals(SAVE_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
1426 |
onSaveCluster(); |
2 |
26 Feb 07 |
jari |
1427 |
} else if (command.equals(DELETE_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
1428 |
onDeleteCluster(); |
2 |
26 Feb 07 |
jari |
1429 |
} else if (command.equals(DELETE_ALL_CLUSTERS_CMD)) { |
2 |
26 Feb 07 |
jari |
1430 |
onDeleteAllClusters(); |
2 |
26 Feb 07 |
jari |
1431 |
} else if (command.equals(GENE_TREE_PROPERTIES_CMD)) { |
2 |
26 Feb 07 |
jari |
1432 |
onGeneTreeProperties(); |
2 |
26 Feb 07 |
jari |
1433 |
} else if (command.equals(CHANGE_SCORE_BOUNDARY)) { |
2 |
26 Feb 07 |
jari |
1434 |
getAndSetScoreBoundary(); |
2 |
26 Feb 07 |
jari |
1435 |
} else if (command.equals(SAMPLE_TREE_PROPERTIES_CMD)) { |
2 |
26 Feb 07 |
jari |
1436 |
onSampleTreeProperties(); |
2 |
26 Feb 07 |
jari |
1437 |
} else if (command.equals(SAVE_GENE_ORDER_CMD)){ |
2 |
26 Feb 07 |
jari |
1438 |
saveGenesOrder(); |
2 |
26 Feb 07 |
jari |
1439 |
} else if (command.equals(SAVE_GENE_HEIGHT_CMD)){ |
2 |
26 Feb 07 |
jari |
1440 |
genesTree.saveGeneNodeHeights(); |
2 |
26 Feb 07 |
jari |
1441 |
} else if (command.equals(SAVE_EXP_ORDER_CMD)){ |
2 |
26 Feb 07 |
jari |
1442 |
saveExperimentOrder(); |
2 |
26 Feb 07 |
jari |
1443 |
} else if (command.equals(SAVE_EXP_HEIGHT_CMD)){ |
2 |
26 Feb 07 |
jari |
1444 |
sampleTree.saveExperimentNodeHeights(); |
2 |
26 Feb 07 |
jari |
1445 |
} else if (command.equals(SAVE_GENE_NEWICK_CMD)) { |
2 |
26 Feb 07 |
jari |
1446 |
genesTree.saveAsNewickFile(); |
2 |
26 Feb 07 |
jari |
1447 |
} |
2 |
26 Feb 07 |
jari |
// else if (command.equals(SAVE_SAMPLE_NEWICK_CMD)) { |
2 |
26 Feb 07 |
jari |
// sampleTree.saveAsNewickFile(); |
2 |
26 Feb 07 |
jari |
1450 |
// } |
2 |
26 Feb 07 |
jari |
1451 |
} |
2 |
26 Feb 07 |
jari |
1452 |
|
2 |
26 Feb 07 |
jari |
1453 |
public void valueChanged(HCLTree source, HCLCluster cluster) { |
2 |
26 Feb 07 |
jari |
1454 |
if(source == sampleTree) |
2 |
26 Feb 07 |
jari |
1455 |
cluster.isGeneCluster = false; |
2 |
26 Feb 07 |
jari |
1456 |
TEASEViewer.this.valueChanged(source, cluster); |
2 |
26 Feb 07 |
jari |
1457 |
} |
2 |
26 Feb 07 |
jari |
1458 |
|
2 |
26 Feb 07 |
jari |
1459 |
public void mouseReleased(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1460 |
maybeShowPopup(event); |
2 |
26 Feb 07 |
jari |
// if (!isHCLOnly) { |
2 |
26 Feb 07 |
jari |
// maybeDisplay(event); |
2 |
26 Feb 07 |
jari |
1463 |
// } |
2 |
26 Feb 07 |
jari |
1464 |
} |
2 |
26 Feb 07 |
jari |
1465 |
|
2 |
26 Feb 07 |
jari |
1466 |
public void mousePressed(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1467 |
maybeShowPopup(event); |
2 |
26 Feb 07 |
jari |
1468 |
if (SwingUtilities.isRightMouseButton(event)) { |
2 |
26 Feb 07 |
jari |
1469 |
return; |
2 |
26 Feb 07 |
jari |
1470 |
} |
2 |
26 Feb 07 |
jari |
1471 |
deselect(event); |
2 |
26 Feb 07 |
jari |
1472 |
} |
2 |
26 Feb 07 |
jari |
1473 |
|
2 |
26 Feb 07 |
jari |
1474 |
private void maybeShowPopup(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
1475 |
if (!e.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1476 |
return; |
2 |
26 Feb 07 |
jari |
1477 |
} |
2 |
26 Feb 07 |
jari |
1478 |
int node = TEASEViewer.this.selectedCluster == null ? -1 : TEASEViewer.this.selectedCluster.root; |
2 |
26 Feb 07 |
jari |
1479 |
setEnableMenuItem(STORE_CLUSTER_CMD, node >= 0); |
2 |
26 Feb 07 |
jari |
1480 |
setEnableMenuItem(LAUNCH_NEW_SESSION_CMD, node >= 0); |
2 |
26 Feb 07 |
jari |
// setEnableMenuItem(SET_CLUSTER_TEXT_CMD, doesClusterExist() && node != -1 && HCLViewer.this.selectedCluster.isGeneCluster); |
2 |
26 Feb 07 |
jari |
1482 |
setEnableMenuItem(DELETE_CLUSTER_CMD, doesClusterExist()); |
2 |
26 Feb 07 |
jari |
1483 |
setEnableMenuItem(DELETE_ALL_CLUSTERS_CMD, doesClusterExist()); |
2 |
26 Feb 07 |
jari |
1484 |
setEnableMenuItem(SAVE_CLUSTER_CMD, TEASEViewer.this.selectedCluster != null && |
2 |
26 Feb 07 |
jari |
1485 |
TEASEViewer.this.selectedCluster.root != -1); |
2 |
26 Feb 07 |
jari |
1486 |
|
2 |
26 Feb 07 |
jari |
1487 |
popup.show(e.getComponent(), e.getX(), e.getY()); |
2 |
26 Feb 07 |
jari |
1488 |
} |
2 |
26 Feb 07 |
jari |
1489 |
|
2 |
26 Feb 07 |
jari |
// public void maybeDisplay(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// glassPane.setVisible(false); |
2 |
26 Feb 07 |
jari |
// int x = e.getX(); |
2 |
26 Feb 07 |
jari |
// int y = e.getY(); |
2 |
26 Feb 07 |
jari |
// //System.out.println("mouse released, x = " + x + " y = "+y); |
2 |
26 Feb 07 |
jari |
// for (int i = 0; i < dots.size(); i++) { |
2 |
26 Feb 07 |
jari |
// TEASEInfoBox dot = (TEASEInfoBox)dots.get(i); |
2 |
26 Feb 07 |
jari |
// if (y < (dot.y+10) && y > (dot.y-10) && |
2 |
26 Feb 07 |
jari |
// x < (dot.x+10) && x > (dot.x-10)) { |
2 |
26 Feb 07 |
jari |
// //System.out.println("supposed to prnit something now"); |
2 |
26 Feb 07 |
jari |
// glassPane.setDotInDisplay(dot); //set the dot info to display in the glasspane |
2 |
26 Feb 07 |
jari |
// glassPane.setDisplayText(dot.getMatrix()); |
2 |
26 Feb 07 |
jari |
// glassPane.setVisible(true); |
2 |
26 Feb 07 |
jari |
1503 |
// } |
2 |
26 Feb 07 |
jari |
1504 |
// } |
2 |
26 Feb 07 |
jari |
1505 |
// } |
2 |
26 Feb 07 |
jari |
1506 |
|
2 |
26 Feb 07 |
jari |
1507 |
|
2 |
26 Feb 07 |
jari |
1508 |
|
2 |
26 Feb 07 |
jari |
1509 |
private void deselect(MouseEvent e){ |
2 |
26 Feb 07 |
jari |
1510 |
Object source = e.getSource(); |
2 |
26 Feb 07 |
jari |
1511 |
|
2 |
26 Feb 07 |
jari |
1512 |
if(source instanceof HCLTree){ //in a tree don't deselect |
2 |
26 Feb 07 |
jari |
1513 |
if(source == genesTree) { //if colloring rows (genes) |
2 |
26 Feb 07 |
jari |
1514 |
|
2 |
26 Feb 07 |
jari |
1515 |
if(isExperimentCluster){ |
2 |
26 Feb 07 |
jari |
1516 |
((ExperimentClusterViewer)expViewer).selectColumns(-1, -1); |
2 |
26 Feb 07 |
jari |
1517 |
} |
2 |
26 Feb 07 |
jari |
1518 |
else{ |
2 |
26 Feb 07 |
jari |
1519 |
((ExperimentViewer)expViewer).selectColumns(-1, -1); |
2 |
26 Feb 07 |
jari |
1520 |
} |
2 |
26 Feb 07 |
jari |
1521 |
if(sampleTree != null) |
2 |
26 Feb 07 |
jari |
1522 |
sampleTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1523 |
} |
2 |
26 Feb 07 |
jari |
1524 |
else{ // coloring columns (experiment) |
2 |
26 Feb 07 |
jari |
1525 |
|
2 |
26 Feb 07 |
jari |
1526 |
if(isExperimentCluster){ |
2 |
26 Feb 07 |
jari |
1527 |
((ExperimentClusterViewer)expViewer).selectRows(-1, -1); |
2 |
26 Feb 07 |
jari |
1528 |
} |
2 |
26 Feb 07 |
jari |
1529 |
else{ |
2 |
26 Feb 07 |
jari |
1530 |
((ExperimentViewer)expViewer).selectRows(-1, -1); |
2 |
26 Feb 07 |
jari |
1531 |
} |
2 |
26 Feb 07 |
jari |
1532 |
if(genesTree != null) |
2 |
26 Feb 07 |
jari |
1533 |
genesTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1534 |
} |
2 |
26 Feb 07 |
jari |
1535 |
repaint(); |
2 |
26 Feb 07 |
jari |
1536 |
return; |
2 |
26 Feb 07 |
jari |
1537 |
} |
2 |
26 Feb 07 |
jari |
1538 |
|
2 |
26 Feb 07 |
jari |
1539 |
int x = e.getX(); |
2 |
26 Feb 07 |
jari |
1540 |
int y = e.getY(); |
2 |
26 Feb 07 |
jari |
1541 |
|
2 |
26 Feb 07 |
jari |
//now know we are not on a tree |
2 |
26 Feb 07 |
jari |
1543 |
if(!(source instanceof TEASEViewer) && (source != expViewer)){ |
2 |
26 Feb 07 |
jari |
1544 |
deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1545 |
repaint(); |
2 |
26 Feb 07 |
jari |
1546 |
} |
2 |
26 Feb 07 |
jari |
//know we are in the HCLViewer but not in the tree areas but above matrix |
2 |
26 Feb 07 |
jari |
1548 |
else if(source instanceof TEASEViewer && sampleTree != null && y < sampleTree.getHeight()){ |
2 |
26 Feb 07 |
jari |
1549 |
deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1550 |
repaint(); |
2 |
26 Feb 07 |
jari |
1551 |
} |
2 |
26 Feb 07 |
jari |
1552 |
else if(source == expViewer){ |
2 |
26 Feb 07 |
jari |
1553 |
int numSamples = numberOfSamples; |
2 |
26 Feb 07 |
jari |
1554 |
if(source instanceof ExperimentClusterViewer) |
2 |
26 Feb 07 |
jari |
1555 |
numSamples = ((ExperimentClusterViewer)expViewer).getCurrentNumberOfExperiments(); |
2 |
26 Feb 07 |
jari |
1556 |
if(x > elementSize.width * numSamples + offset || x < offset){ |
2 |
26 Feb 07 |
jari |
1557 |
deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1558 |
repaint(); |
2 |
26 Feb 07 |
jari |
1559 |
} |
2 |
26 Feb 07 |
jari |
1560 |
} |
2 |
26 Feb 07 |
jari |
1561 |
else if(((source == expViewer) || (source instanceof ExperimentClusterViewer)) && x < offset){ |
2 |
26 Feb 07 |
jari |
1562 |
deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1563 |
repaint(); |
2 |
26 Feb 07 |
jari |
1564 |
} |
2 |
26 Feb 07 |
jari |
1565 |
} |
2 |
26 Feb 07 |
jari |
1566 |
|
2 |
26 Feb 07 |
jari |
1567 |
|
2 |
26 Feb 07 |
jari |
1568 |
private void deselectAllNodes(){ |
2 |
26 Feb 07 |
jari |
1569 |
if(genesTree != null) |
2 |
26 Feb 07 |
jari |
1570 |
genesTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1571 |
if(sampleTree != null) |
2 |
26 Feb 07 |
jari |
1572 |
sampleTree.deselectAllNodes(); |
2 |
26 Feb 07 |
jari |
1573 |
if(isExperimentCluster){ |
2 |
26 Feb 07 |
jari |
1574 |
((ExperimentClusterViewer)expViewer).selectRows(-1, -1); |
2 |
26 Feb 07 |
jari |
1575 |
((ExperimentClusterViewer)expViewer).selectColumns(-1, -1); |
2 |
26 Feb 07 |
jari |
1576 |
} |
2 |
26 Feb 07 |
jari |
1577 |
else{ |
2 |
26 Feb 07 |
jari |
1578 |
((ExperimentViewer)expViewer).selectRows(-1, -1); |
2 |
26 Feb 07 |
jari |
1579 |
((ExperimentViewer)expViewer).selectColumns(-1, -1); |
2 |
26 Feb 07 |
jari |
1580 |
} |
2 |
26 Feb 07 |
jari |
1581 |
} |
2 |
26 Feb 07 |
jari |
1582 |
|
2 |
26 Feb 07 |
jari |
1583 |
} |
2 |
26 Feb 07 |
jari |
1584 |
|
2 |
26 Feb 07 |
jari |
1585 |
|
2 |
26 Feb 07 |
jari |
1586 |
private class MotionListener extends MouseMotionAdapter{ |
2 |
26 Feb 07 |
jari |
1587 |
public void mouseMoved(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
1588 |
int x = e.getX(); |
2 |
26 Feb 07 |
jari |
1589 |
int y = e.getY(); |
2 |
26 Feb 07 |
jari |
1590 |
|
2 |
26 Feb 07 |
jari |
1591 |
if (!setInfoText(x,y)) |
2 |
26 Feb 07 |
jari |
1592 |
genesTree.setToolTipText(null); |
2 |
26 Feb 07 |
jari |
// if (glassPane.dot != null) { |
2 |
26 Feb 07 |
jari |
// //give it some cushion |
2 |
26 Feb 07 |
jari |
// if (y > (glassPane.dot.y+5) || y < (glassPane.dot.y-5) || |
2 |
26 Feb 07 |
jari |
// x > (glassPane.dot.x+5) || x < (glassPane.dot.x-5)) |
2 |
26 Feb 07 |
jari |
// glassPane.setVisible(false); |
2 |
26 Feb 07 |
jari |
1598 |
// } |
2 |
26 Feb 07 |
jari |
1599 |
} |
2 |
26 Feb 07 |
jari |
1600 |
} |
2 |
26 Feb 07 |
jari |
1601 |
|
2 |
26 Feb 07 |
jari |
1602 |
|
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 |
1605 |
*/ |
2 |
26 Feb 07 |
jari |
1606 |
public int getExperimentID() { |
2 |
26 Feb 07 |
jari |
1607 |
return 0;//this.exptID; |
2 |
26 Feb 07 |
jari |
1608 |
} |
2 |
26 Feb 07 |
jari |
1609 |
|
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 |
1612 |
*/ |
2 |
26 Feb 07 |
jari |
1613 |
public void setExperimentID(int id) { |
2 |
26 Feb 07 |
jari |
//this.exptID = id; |
2 |
26 Feb 07 |
jari |
1615 |
|
2 |
26 Feb 07 |
jari |
1616 |
} |
2 |
26 Feb 07 |
jari |
1617 |
|
2 |
26 Feb 07 |
jari |
1618 |
|
2 |
26 Feb 07 |
jari |
1619 |
/** |
2 |
26 Feb 07 |
jari |
1620 |
* |
2 |
26 Feb 07 |
jari |
1621 |
*/ |
2 |
26 Feb 07 |
jari |
1622 |
public void setExperiment(Experiment e) { |
2 |
26 Feb 07 |
jari |
1623 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
//this.exptID = e.getId(); |
2 |
26 Feb 07 |
jari |
1625 |
|
2 |
26 Feb 07 |
jari |
1626 |
} |
2 |
26 Feb 07 |
jari |
1627 |
|
2 |
26 Feb 07 |
jari |
1628 |
|
2 |
26 Feb 07 |
jari |
1629 |
|
2 |
26 Feb 07 |
jari |
1630 |
// /** |
2 |
26 Feb 07 |
jari |
// * We have to provide our own glass pane so that it can paint. |
2 |
26 Feb 07 |
jari |
1632 |
// */ |
2 |
26 Feb 07 |
jari |
// public class MyGlassPane extends JComponent { |
2 |
26 Feb 07 |
jari |
// Point point; |
2 |
26 Feb 07 |
jari |
// TEASEInfoBox dot; |
2 |
26 Feb 07 |
jari |
// String[][] matrix; |
2 |
26 Feb 07 |
jari |
1637 |
// |
2 |
26 Feb 07 |
jari |
// protected void paintComponent(Graphics g) { |
2 |
26 Feb 07 |
jari |
// if (point != null) { |
2 |
26 Feb 07 |
jari |
// g.setColor(new Color(240, 240, 160)); |
2 |
26 Feb 07 |
jari |
// g.fill3DRect(point.x+10, point.y+10, 600, 90, true); |
2 |
26 Feb 07 |
jari |
// g.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
// g.drawRect(point.x+10, point.y+10, 600, 90); |
2 |
26 Feb 07 |
jari |
1644 |
// |
2 |
26 Feb 07 |
jari |
// for (int i = 0; i < TEASEInfoBox.displayLimit; i++) { |
2 |
26 Feb 07 |
jari |
// String text = ""; |
2 |
26 Feb 07 |
jari |
// for (int j = 1; j < 4; j++) { |
2 |
26 Feb 07 |
jari |
// text += matrix[i][j] + " "; |
2 |
26 Feb 07 |
jari |
1649 |
// } |
2 |
26 Feb 07 |
jari |
// //text += matrix[i][matrix[i].length-1]; |
2 |
26 Feb 07 |
jari |
// g.drawString(text, point.x+15, point.y+30+i*15); |
2 |
26 Feb 07 |
jari |
// if (matrix[i].length == 9) |
2 |
26 Feb 07 |
jari |
// g.drawString(matrix[i][matrix[i].length-1], point.x+545, point.y+30+i*15); |
2 |
26 Feb 07 |
jari |
// else |
2 |
26 Feb 07 |
jari |
// g.drawString(matrix[i][4] + " "+ matrix[i][5], point.x+545, point.y+30+i*15); |
2 |
26 Feb 07 |
jari |
1656 |
// } |
2 |
26 Feb 07 |
jari |
1657 |
// } |
2 |
26 Feb 07 |
jari |
1658 |
// } |
2 |
26 Feb 07 |
jari |
1659 |
// |
2 |
26 Feb 07 |
jari |
// public void setDisplayText(String[][] matrix) { |
2 |
26 Feb 07 |
jari |
// this.matrix = matrix; |
2 |
26 Feb 07 |
jari |
1662 |
// } |
2 |
26 Feb 07 |
jari |
1663 |
// |
2 |
26 Feb 07 |
jari |
// public void setPoint(Point p) { |
2 |
26 Feb 07 |
jari |
// this.point = p; |
2 |
26 Feb 07 |
jari |
1666 |
// } |
2 |
26 Feb 07 |
jari |
1667 |
// |
2 |
26 Feb 07 |
jari |
// public void setDotInDisplay(TEASEInfoBox dot) { |
2 |
26 Feb 07 |
jari |
// this.dot = dot; |
2 |
26 Feb 07 |
jari |
1670 |
// } |
2 |
26 Feb 07 |
jari |
1671 |
// |
2 |
26 Feb 07 |
jari |
// public MyGlassPane(Container contentPane) { |
2 |
26 Feb 07 |
jari |
// CBListener listener = new CBListener(this, contentPane); |
2 |
26 Feb 07 |
jari |
// addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
// addMouseMotionListener(listener); |
2 |
26 Feb 07 |
jari |
1676 |
// } |
2 |
26 Feb 07 |
jari |
1677 |
// } |
2 |
26 Feb 07 |
jari |
1678 |
// |
2 |
26 Feb 07 |
jari |
1679 |
// /** |
2 |
26 Feb 07 |
jari |
// * Listen for all events |
2 |
26 Feb 07 |
jari |
1681 |
// */ |
2 |
26 Feb 07 |
jari |
// class CBListener extends MouseInputAdapter { |
2 |
26 Feb 07 |
jari |
// java.awt.Toolkit toolkit; |
2 |
26 Feb 07 |
jari |
// MyGlassPane glassPane; |
2 |
26 Feb 07 |
jari |
// Container contentPane; |
2 |
26 Feb 07 |
jari |
1686 |
// |
2 |
26 Feb 07 |
jari |
// public CBListener(MyGlassPane glassPane, Container contentPane) { |
2 |
26 Feb 07 |
jari |
// this.glassPane = glassPane; |
2 |
26 Feb 07 |
jari |
// this.contentPane = contentPane; |
2 |
26 Feb 07 |
jari |
// toolkit = java.awt.Toolkit.getDefaultToolkit(); |
2 |
26 Feb 07 |
jari |
1691 |
// } |
2 |
26 Feb 07 |
jari |
1692 |
// |
2 |
26 Feb 07 |
jari |
// public void mouseMoved(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1695 |
// } |
2 |
26 Feb 07 |
jari |
1696 |
// |
2 |
26 Feb 07 |
jari |
// public void mouseDragged(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1699 |
// } |
2 |
26 Feb 07 |
jari |
1700 |
// |
2 |
26 Feb 07 |
jari |
// public void mouseClicked(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1703 |
// } |
2 |
26 Feb 07 |
jari |
1704 |
// |
2 |
26 Feb 07 |
jari |
// public void mouseEntered(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1707 |
// } |
2 |
26 Feb 07 |
jari |
1708 |
// |
2 |
26 Feb 07 |
jari |
// public void mouseExited(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1711 |
// } |
2 |
26 Feb 07 |
jari |
1712 |
// |
2 |
26 Feb 07 |
jari |
// public void mousePressed(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1715 |
// } |
2 |
26 Feb 07 |
jari |
1716 |
// |
2 |
26 Feb 07 |
jari |
// public void mouseReleased(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
// redispatchMouseEvent(e, true); |
2 |
26 Feb 07 |
jari |
1719 |
// } |
2 |
26 Feb 07 |
jari |
1720 |
// |
2 |
26 Feb 07 |
jari |
// //A more finished version of this method would |
2 |
26 Feb 07 |
jari |
// //handle mouse-dragged events specially. |
2 |
26 Feb 07 |
jari |
// private void redispatchMouseEvent(MouseEvent e, |
2 |
26 Feb 07 |
jari |
// boolean repaint) { |
2 |
26 Feb 07 |
jari |
// Point glassPanePoint = e.getPoint(); |
2 |
26 Feb 07 |
jari |
// Container container = contentPane; |
2 |
26 Feb 07 |
jari |
// Point containerPoint = SwingUtilities.convertPoint( |
2 |
26 Feb 07 |
jari |
// glassPane, |
2 |
26 Feb 07 |
jari |
// glassPanePoint, |
2 |
26 Feb 07 |
jari |
// contentPane); |
2 |
26 Feb 07 |
jari |
1731 |
// |
2 |
26 Feb 07 |
jari |
// //The mouse event is probably over the content pane. |
2 |
26 Feb 07 |
jari |
// //Find out exactly which component it's over. |
2 |
26 Feb 07 |
jari |
// Component component = |
2 |
26 Feb 07 |
jari |
// SwingUtilities.getDeepestComponentAt( |
2 |
26 Feb 07 |
jari |
// container, |
2 |
26 Feb 07 |
jari |
// containerPoint.x, |
2 |
26 Feb 07 |
jari |
// containerPoint.y); |
2 |
26 Feb 07 |
jari |
1739 |
// |
2 |
26 Feb 07 |
jari |
// if (component != null) { |
2 |
26 Feb 07 |
jari |
// //Forward events over the check box. |
2 |
26 Feb 07 |
jari |
// Point componentPoint = SwingUtilities.convertPoint( |
2 |
26 Feb 07 |
jari |
// glassPane, |
2 |
26 Feb 07 |
jari |
// glassPanePoint, |
2 |
26 Feb 07 |
jari |
// component); |
2 |
26 Feb 07 |
jari |
// component.dispatchEvent(new MouseEvent(component, |
2 |
26 Feb 07 |
jari |
// e.getID(), |
2 |
26 Feb 07 |
jari |
// e.getWhen(), |
2 |
26 Feb 07 |
jari |
// e.getModifiers(), |
2 |
26 Feb 07 |
jari |
// componentPoint.x, |
2 |
26 Feb 07 |
jari |
// componentPoint.y, |
2 |
26 Feb 07 |
jari |
// e.getClickCount(), |
2 |
26 Feb 07 |
jari |
// e.isPopupTrigger())); |
2 |
26 Feb 07 |
jari |
1754 |
// } |
2 |
26 Feb 07 |
jari |
1755 |
// |
2 |
26 Feb 07 |
jari |
// //Update the glass pane if requested. |
2 |
26 Feb 07 |
jari |
// if (repaint) { |
2 |
26 Feb 07 |
jari |
// glassPane.setPoint(glassPanePoint); |
2 |
26 Feb 07 |
jari |
// //System.out.println("repaint glass pane"); |
2 |
26 Feb 07 |
jari |
// glassPane.repaint(); |
2 |
26 Feb 07 |
jari |
1761 |
// } |
2 |
26 Feb 07 |
jari |
1762 |
// } |
2 |
26 Feb 07 |
jari |
1763 |
// } |
2 |
26 Feb 07 |
jari |
1764 |
|
2 |
26 Feb 07 |
jari |
1765 |
} |