2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2005, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* COA2DViewer.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on October 11, 2004, 3:24 PM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
package org.tigr.microarray.mev.cluster.gui.impl.coa; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.BasicStroke; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.FontMetrics; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Rectangle; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.geom.Ellipse2D; |
2 |
26 Feb 07 |
jari |
26 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
27 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
28 |
import java.text.DecimalFormat; |
2 |
26 Feb 07 |
jari |
29 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.event.MouseInputAdapter; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.clusterUtil.Cluster; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
42 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
43 |
import org.tigr.microarray.mev.cluster.gui.IDisplayMenu; |
2 |
26 Feb 07 |
jari |
44 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentUtil; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
/** |
2 |
26 Feb 07 |
jari |
52 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
54 |
*/ |
2 |
26 Feb 07 |
jari |
55 |
public class COA2DViewer extends JPanel implements IViewer { |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
private static final String SAVE_CMD = "save-cmd"; |
2 |
26 Feb 07 |
jari |
58 |
private static final String SAVE_GENE_CLUSTER_CMD = "save-genes-cmd"; |
2 |
26 Feb 07 |
jari |
59 |
private static final String SAVE_EXPT_CLUSTER_CMD = "save-expts-cmd"; |
2 |
26 Feb 07 |
jari |
60 |
private static final String SHOW_TEXT_CMD = "show-text-cmd"; |
2 |
26 Feb 07 |
jari |
61 |
private static final String SHOW_TICK_LABELS_CMD = "show-tick-labels-cmd"; |
2 |
26 Feb 07 |
jari |
62 |
private static final String STORE_CLUSTER_CMD = "store-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
63 |
private static final String STORE_GENE_CLUSTER_CMD = "store-gene-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
64 |
private static final String STORE_EXPT_CLUSTER_CMD = "store-expt-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
65 |
private static final String LAUNCH_NEW_SESSION_CMD = "launch-new-session-cmd"; |
2 |
26 Feb 07 |
jari |
66 |
private static final String LAUNCH_NEW_GENE_SESSION_CMD = "launch-new-gene-session-cmd"; |
2 |
26 Feb 07 |
jari |
67 |
private static final String LAUNCH_NEW_EXPT_SESSION_CMD = "launch-new-expt-session-cmd"; |
2 |
26 Feb 07 |
jari |
68 |
private static final String DISPLAY_EXPT_NAMES_CMD = "display-expt-names-cmd"; |
2 |
26 Feb 07 |
jari |
69 |
private static final String SHOW_LARGER_POINTS_CMD = "show-larger-points-cmd"; |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
private float[] yArray, xArray; |
2 |
26 Feb 07 |
jari |
//int originX, originY; |
2 |
26 Feb 07 |
jari |
73 |
private int geneOrExpt, axis1, axis2; |
2 |
26 Feb 07 |
jari |
74 |
private FloatMatrix UMatrix, geneUMatrix, exptUMatrix, scaledGeneUMatrix, scaledExptUMatrix; |
2 |
26 Feb 07 |
jari |
75 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
76 |
private IFramework framework; |
2 |
26 Feb 07 |
jari |
77 |
private Frame frame; |
2 |
26 Feb 07 |
jari |
78 |
private IData data; |
2 |
26 Feb 07 |
jari |
79 |
private JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
80 |
private Ellipse2D.Double ellipse; |
2 |
26 Feb 07 |
jari |
81 |
private boolean displayExptNames, showLargePoints, showTickLabels; |
2 |
26 Feb 07 |
jari |
82 |
Rectangle currentRect = null; |
2 |
26 Feb 07 |
jari |
83 |
Rectangle rectToDraw = null; |
2 |
26 Feb 07 |
jari |
84 |
Rectangle previousRectDrawn = new Rectangle(); |
2 |
26 Feb 07 |
jari |
85 |
private int exptID = 0; |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of COA2DViewer */ |
2 |
26 Feb 07 |
jari |
88 |
public COA2DViewer(Experiment experiment, float[] xArray, float[] yArray, int geneOrExpt, int axis1, int axis2) { |
2 |
26 Feb 07 |
jari |
89 |
this.yArray = yArray; |
2 |
26 Feb 07 |
jari |
90 |
this.xArray = xArray; |
2 |
26 Feb 07 |
jari |
91 |
this.displayExptNames = false; |
2 |
26 Feb 07 |
jari |
92 |
this.showLargePoints = false; |
2 |
26 Feb 07 |
jari |
93 |
this.showTickLabels = true; |
2 |
26 Feb 07 |
jari |
94 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
95 |
this.axis1 = axis1; |
2 |
26 Feb 07 |
jari |
96 |
this.axis2 = axis2; |
2 |
26 Feb 07 |
jari |
97 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
98 |
this.exptID = experiment.getId(); |
2 |
26 Feb 07 |
jari |
99 |
this.ellipse = new Ellipse2D.Double(); |
2 |
26 Feb 07 |
jari |
100 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
103 |
|
2 |
26 Feb 07 |
jari |
104 |
GraphListener graphListener = new GraphListener(); |
2 |
26 Feb 07 |
jari |
105 |
addMouseListener(graphListener); |
2 |
26 Feb 07 |
jari |
106 |
addMouseMotionListener(graphListener); |
2 |
26 Feb 07 |
jari |
107 |
} |
2 |
26 Feb 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of COA2DViewer */ |
2 |
26 Feb 07 |
jari |
110 |
public COA2DViewer(Experiment experiment, FloatMatrix UMatrix, int geneOrExpt, int axis1, int axis2) { |
2 |
26 Feb 07 |
jari |
111 |
this.UMatrix = UMatrix; |
2 |
26 Feb 07 |
jari |
112 |
this.axis1 = axis1; |
2 |
26 Feb 07 |
jari |
113 |
this.axis2 = axis2; |
2 |
26 Feb 07 |
jari |
114 |
this.xArray = getFloatArray(UMatrix, axis1); |
2 |
26 Feb 07 |
jari |
115 |
this.yArray = getFloatArray(UMatrix, axis2); |
2 |
26 Feb 07 |
jari |
116 |
this.displayExptNames = false; |
2 |
26 Feb 07 |
jari |
117 |
this.showLargePoints = false; |
2 |
26 Feb 07 |
jari |
118 |
this.showTickLabels = true; |
2 |
26 Feb 07 |
jari |
119 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
120 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
121 |
this.exptID = experiment.getId(); |
2 |
26 Feb 07 |
jari |
122 |
this.ellipse = new Ellipse2D.Double(); |
2 |
26 Feb 07 |
jari |
123 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
124 |
|
2 |
26 Feb 07 |
jari |
125 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
GraphListener graphListener = new GraphListener(); |
2 |
26 Feb 07 |
jari |
128 |
addMouseListener(graphListener); |
2 |
26 Feb 07 |
jari |
129 |
addMouseMotionListener(graphListener); |
2 |
26 Feb 07 |
jari |
130 |
} |
2 |
26 Feb 07 |
jari |
131 |
|
2 |
26 Feb 07 |
jari |
132 |
public COA2DViewer(Experiment experiment, FloatMatrix geneUMatrix, FloatMatrix exptUMatrix, int geneOrExpt, int axis1, int axis2) { |
2 |
26 Feb 07 |
jari |
133 |
this.geneUMatrix = geneUMatrix; |
2 |
26 Feb 07 |
jari |
134 |
this.exptUMatrix = exptUMatrix; |
2 |
26 Feb 07 |
jari |
//scaleMatrices(geneUMatrix, exptUMatrix); |
2 |
26 Feb 07 |
jari |
136 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
137 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
138 |
this.UMatrix = combineMatrices(scaledGeneUMatrix, scaledExptUMatrix); |
2 |
26 Feb 07 |
jari |
139 |
this.axis1 = axis1; |
2 |
26 Feb 07 |
jari |
140 |
this.axis2 = axis2; |
2 |
26 Feb 07 |
jari |
141 |
this.xArray = getFloatArray(UMatrix, axis1); |
2 |
26 Feb 07 |
jari |
142 |
this.yArray = getFloatArray(UMatrix, axis2); |
2 |
26 Feb 07 |
jari |
143 |
this.displayExptNames = false; |
2 |
26 Feb 07 |
jari |
144 |
this.showLargePoints = false; |
2 |
26 Feb 07 |
jari |
145 |
this.showTickLabels = true; |
2 |
26 Feb 07 |
jari |
146 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
147 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
148 |
this.exptID = experiment.getId(); |
2 |
26 Feb 07 |
jari |
149 |
this.ellipse = new Ellipse2D.Double(); |
2 |
26 Feb 07 |
jari |
150 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
153 |
|
2 |
26 Feb 07 |
jari |
154 |
GraphListener graphListener = new GraphListener(); |
2 |
26 Feb 07 |
jari |
155 |
addMouseListener(graphListener); |
2 |
26 Feb 07 |
jari |
156 |
addMouseMotionListener(graphListener); |
2 |
26 Feb 07 |
jari |
157 |
} |
2 |
26 Feb 07 |
jari |
158 |
/** |
2 |
26 Feb 07 |
jari |
* XMLEncoder/Decoder constructor |
2 |
26 Feb 07 |
jari |
* @param exptID |
2 |
26 Feb 07 |
jari |
* @param geneUMatrix |
2 |
26 Feb 07 |
jari |
* @param expUMatrix |
2 |
26 Feb 07 |
jari |
* @param xArray |
2 |
26 Feb 07 |
jari |
* @param yArray |
2 |
26 Feb 07 |
jari |
* @param geneOrExpt |
2 |
26 Feb 07 |
jari |
* @param axis1 |
2 |
26 Feb 07 |
jari |
* @param axis2 |
2 |
26 Feb 07 |
jari |
168 |
*/ |
2 |
26 Feb 07 |
jari |
169 |
public COA2DViewer(Experiment e, FloatMatrix geneUMatrix, FloatMatrix expUMatrix, float[] xArray, float[] yArray, Integer geneOrExpt, Integer axis1, Integer axis2) { |
2 |
26 Feb 07 |
jari |
170 |
this.xArray = xArray; |
2 |
26 Feb 07 |
jari |
171 |
this.yArray = yArray; |
2 |
26 Feb 07 |
jari |
172 |
this.axis1 = axis1.intValue(); |
2 |
26 Feb 07 |
jari |
173 |
this.axis2 = axis2.intValue(); |
2 |
26 Feb 07 |
jari |
174 |
this.displayExptNames = false; |
2 |
26 Feb 07 |
jari |
175 |
this.showLargePoints = false; |
2 |
26 Feb 07 |
jari |
176 |
this.showTickLabels = true; |
2 |
26 Feb 07 |
jari |
177 |
this.geneOrExpt = geneOrExpt.intValue(); |
2 |
26 Feb 07 |
jari |
178 |
if(geneUMatrix != null) |
2 |
26 Feb 07 |
jari |
179 |
this.geneUMatrix = geneUMatrix; |
2 |
26 Feb 07 |
jari |
180 |
if(expUMatrix != null) |
2 |
26 Feb 07 |
jari |
181 |
this.exptUMatrix = expUMatrix; |
2 |
26 Feb 07 |
jari |
182 |
if (this.geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
183 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
184 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
185 |
} |
2 |
26 Feb 07 |
jari |
186 |
this.ellipse = new Ellipse2D.Double(); |
2 |
26 Feb 07 |
jari |
187 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
188 |
|
2 |
26 Feb 07 |
jari |
189 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
191 |
GraphListener graphListener = new GraphListener(); |
2 |
26 Feb 07 |
jari |
192 |
addMouseListener(graphListener); |
2 |
26 Feb 07 |
jari |
193 |
addMouseMotionListener(graphListener); |
2 |
26 Feb 07 |
jari |
194 |
setExperiment(e); |
2 |
26 Feb 07 |
jari |
195 |
} |
2 |
26 Feb 07 |
jari |
196 |
/** |
2 |
26 Feb 07 |
jari |
* @inheritDoc |
2 |
26 Feb 07 |
jari |
198 |
*/ |
2 |
26 Feb 07 |
jari |
199 |
public Expression getExpression(){ |
2 |
26 Feb 07 |
jari |
200 |
return new Expression(this, this.getClass(), "new", |
2 |
26 Feb 07 |
jari |
201 |
new Object[]{this.experiment, geneUMatrix, exptUMatrix, xArray, yArray, new Integer(geneOrExpt), new Integer(axis1), new Integer(axis2)}); |
2 |
26 Feb 07 |
jari |
202 |
} |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#setExperiment(org.tigr.microarray.mev.cluster.gui.Experiment) |
2 |
26 Feb 07 |
jari |
206 |
*/ |
2 |
26 Feb 07 |
jari |
207 |
public void setExperiment(Experiment e) { |
2 |
26 Feb 07 |
jari |
208 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
209 |
this.exptID = experiment.getId(); |
2 |
26 Feb 07 |
jari |
210 |
} |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
private void scaleMatrices(FloatMatrix U1, FloatMatrix U2) { //brings them both to the same scale for plotting |
2 |
26 Feb 07 |
jari |
213 |
float max1 = 0f; |
2 |
26 Feb 07 |
jari |
214 |
float max2 = 0f; |
2 |
26 Feb 07 |
jari |
215 |
final int rows1 = U1.getRowDimension(); |
2 |
26 Feb 07 |
jari |
216 |
final int rows2 = U2.getRowDimension(); |
2 |
26 Feb 07 |
jari |
217 |
for (int i = rows1; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
218 |
max1 = Math.max(max1, Math.max(Math.max(Math.abs(U1.get(i, 0)), Math.abs(U1.get(i, 1))), Math.abs(U1.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
219 |
} |
2 |
26 Feb 07 |
jari |
220 |
for (int i = rows2; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
221 |
max2 = Math.max(max2, Math.max(Math.max(Math.abs(U2.get(i, 0)), Math.abs(U2.get(i, 1))), Math.abs(U2.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
222 |
} |
2 |
26 Feb 07 |
jari |
223 |
|
2 |
26 Feb 07 |
jari |
224 |
float max = Math.max(max1, max2); |
2 |
26 Feb 07 |
jari |
225 |
|
2 |
26 Feb 07 |
jari |
226 |
if (max1 == max2) { |
2 |
26 Feb 07 |
jari |
227 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
228 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
229 |
} else if (max1 > max2) { |
2 |
26 Feb 07 |
jari |
230 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
231 |
float scalingFactor = (float)(max1/max2); |
2 |
26 Feb 07 |
jari |
232 |
scaledExptUMatrix = exptUMatrix.times(scalingFactor); |
2 |
26 Feb 07 |
jari |
233 |
} else { |
2 |
26 Feb 07 |
jari |
234 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
235 |
float scalingFactor = (float)(max2/max1); |
2 |
26 Feb 07 |
jari |
236 |
scaledGeneUMatrix = geneUMatrix.times(scalingFactor); |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
} |
2 |
26 Feb 07 |
jari |
239 |
|
2 |
26 Feb 07 |
jari |
240 |
private FloatMatrix combineMatrices(FloatMatrix U1, FloatMatrix U2) { |
2 |
26 Feb 07 |
jari |
241 |
FloatMatrix combinedMatrix = new FloatMatrix(U1.getRowDimension() + U2.getRowDimension(), U1.getColumnDimension()); |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
for (int i = 0; i < U1.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
244 |
for (int j = 0; j < U1.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
245 |
combinedMatrix.A[i][j] =U1.A[i][j]; |
2 |
26 Feb 07 |
jari |
246 |
} |
2 |
26 Feb 07 |
jari |
247 |
} |
2 |
26 Feb 07 |
jari |
248 |
int counter = U1.getRowDimension(); |
2 |
26 Feb 07 |
jari |
249 |
for (int i = 0; i < U2.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
250 |
for (int j = 0; j < U2.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
251 |
combinedMatrix.A[counter + i][j] = U2.A[i][j]; |
2 |
26 Feb 07 |
jari |
252 |
} |
2 |
26 Feb 07 |
jari |
253 |
} |
2 |
26 Feb 07 |
jari |
254 |
return combinedMatrix; |
2 |
26 Feb 07 |
jari |
255 |
} |
2 |
26 Feb 07 |
jari |
256 |
|
2 |
26 Feb 07 |
jari |
257 |
private float[] getFloatArray(FloatMatrix matrix, int column) { |
2 |
26 Feb 07 |
jari |
258 |
float[] array = new float[matrix.getRowDimension()]; |
2 |
26 Feb 07 |
jari |
259 |
for (int i = 0; i < array.length; i++) { |
2 |
26 Feb 07 |
jari |
260 |
array[i] = matrix.A[i][column]; |
2 |
26 Feb 07 |
jari |
261 |
} |
2 |
26 Feb 07 |
jari |
262 |
return array; |
2 |
26 Feb 07 |
jari |
263 |
} |
2 |
26 Feb 07 |
jari |
264 |
|
2 |
26 Feb 07 |
jari |
265 |
|
2 |
26 Feb 07 |
jari |
266 |
public void paint(Graphics g) { |
2 |
26 Feb 07 |
jari |
267 |
super.paint(g); |
2 |
26 Feb 07 |
jari |
268 |
Graphics2D g2D = (Graphics2D)g; |
2 |
26 Feb 07 |
jari |
269 |
int panelWidth = this.getWidth(); |
2 |
26 Feb 07 |
jari |
270 |
int panelHeight = this.getHeight(); |
2 |
26 Feb 07 |
jari |
271 |
int originX = (int)Math.round((double)(this.getWidth()/2)); |
2 |
26 Feb 07 |
jari |
272 |
int originY = (int)Math.round((double)(this.getHeight()/2)); |
2 |
26 Feb 07 |
jari |
273 |
double origMaxXValue = getMax(xArray); |
2 |
26 Feb 07 |
jari |
274 |
double origMaxYValue = getMax(yArray); |
2 |
26 Feb 07 |
jari |
275 |
double origMinXValue = getMin(xArray); |
2 |
26 Feb 07 |
jari |
276 |
double origMinYValue = getMin(yArray); |
2 |
26 Feb 07 |
jari |
277 |
|
2 |
26 Feb 07 |
jari |
278 |
double xScalingFactor = getXScalingFactor(origMaxXValue, origMinXValue); // relative to originX and originY |
2 |
26 Feb 07 |
jari |
279 |
double yScalingFactor = getYScalingFactor(origMaxYValue, origMinYValue); // relative to originX and originY |
2 |
26 Feb 07 |
jari |
280 |
|
2 |
26 Feb 07 |
jari |
//draw axes |
2 |
26 Feb 07 |
jari |
282 |
g2D.setStroke(new BasicStroke(2.0f)); |
2 |
26 Feb 07 |
jari |
283 |
g2D.drawLine(0, (int)Math.round((double)(this.getHeight()/2)), this.getWidth(), (int)Math.round((double)(this.getHeight()/2))); |
2 |
26 Feb 07 |
jari |
284 |
g2D.drawLine((int)Math.round((double)(this.getWidth()/2)), 0, (int)Math.round((double)(this.getWidth()/2)), this.getHeight()); |
2 |
26 Feb 07 |
jari |
285 |
|
2 |
26 Feb 07 |
jari |
286 |
double[] xIntervalArray = new double[6]; |
2 |
26 Feb 07 |
jari |
287 |
double[] yIntervalArray = new double[6]; |
2 |
26 Feb 07 |
jari |
288 |
|
2 |
26 Feb 07 |
jari |
289 |
double xIncrement = 0.0d; |
2 |
26 Feb 07 |
jari |
290 |
double yIncrement = 0.0d; |
2 |
26 Feb 07 |
jari |
291 |
|
2 |
26 Feb 07 |
jari |
292 |
if (Math.abs(origMaxXValue) > Math.abs(origMinXValue)) { |
2 |
26 Feb 07 |
jari |
293 |
xIncrement = Math.abs((double)(origMaxXValue/5.0d)); |
2 |
26 Feb 07 |
jari |
294 |
} else { |
2 |
26 Feb 07 |
jari |
295 |
xIncrement = Math.abs((double)(origMinXValue/5.0d)); |
2 |
26 Feb 07 |
jari |
296 |
} |
2 |
26 Feb 07 |
jari |
297 |
|
2 |
26 Feb 07 |
jari |
298 |
if (Math.abs(origMaxYValue) > Math.abs(origMinYValue)) { |
2 |
26 Feb 07 |
jari |
299 |
yIncrement = Math.abs((double)(origMaxYValue/5.0d)); |
2 |
26 Feb 07 |
jari |
300 |
} else { |
2 |
26 Feb 07 |
jari |
301 |
yIncrement = Math.abs((double)(origMinYValue/5.0d)); |
2 |
26 Feb 07 |
jari |
302 |
} |
2 |
26 Feb 07 |
jari |
303 |
|
2 |
26 Feb 07 |
jari |
304 |
double xCounter = 0.0d; |
2 |
26 Feb 07 |
jari |
305 |
double yCounter = 0.0d; |
2 |
26 Feb 07 |
jari |
306 |
for (int i = 0; i < xIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
307 |
xIntervalArray[i] = xCounter; |
2 |
26 Feb 07 |
jari |
308 |
xCounter = xCounter + xIncrement; |
2 |
26 Feb 07 |
jari |
309 |
yIntervalArray[i] = yCounter; |
2 |
26 Feb 07 |
jari |
310 |
yCounter = yCounter + yIncrement; |
2 |
26 Feb 07 |
jari |
311 |
} |
2 |
26 Feb 07 |
jari |
312 |
|
2 |
26 Feb 07 |
jari |
313 |
if (this.showTickLabels) { |
2 |
26 Feb 07 |
jari |
//draw x tick marks |
2 |
26 Feb 07 |
jari |
315 |
|
2 |
26 Feb 07 |
jari |
316 |
for (int i = 1; i < xIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
317 |
g2D.drawLine((int)Math.round(xIntervalArray[i]*xScalingFactor) +this.getWidth()/2, this.getHeight()/2 - 5, (int)Math.round(xIntervalArray[i]*xScalingFactor) +this.getWidth()/2, this.getHeight()/2 + 5); |
2 |
26 Feb 07 |
jari |
318 |
} |
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
for (int i = 1; i < xIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
321 |
g2D.drawLine(this.getWidth()/2 - (int)Math.round(xIntervalArray[i]*xScalingFactor), this.getHeight()/2 - 5, this.getWidth()/2 - (int)Math.round(xIntervalArray[i]*xScalingFactor), this.getHeight()/2 + 5); |
2 |
26 Feb 07 |
jari |
322 |
} |
2 |
26 Feb 07 |
jari |
323 |
|
2 |
26 Feb 07 |
jari |
//draw y tick marks |
2 |
26 Feb 07 |
jari |
325 |
for (int i = 1; i < yIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
326 |
g2D.drawLine(this.getWidth()/2 - 5, this.getHeight()/2 + (int)Math.round(yIntervalArray[i]*yScalingFactor), this.getWidth()/2 + 5, this.getHeight()/2 + (int)Math.round(yIntervalArray[i]*yScalingFactor)); |
2 |
26 Feb 07 |
jari |
327 |
} |
2 |
26 Feb 07 |
jari |
328 |
|
2 |
26 Feb 07 |
jari |
329 |
for (int i = 1; i < yIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
330 |
g2D.drawLine(this.getWidth()/2 - 5, this.getHeight()/2 - (int)Math.round(yIntervalArray[i]*yScalingFactor), this.getWidth()/2 + 5, this.getHeight()/2 - (int)Math.round(yIntervalArray[i]*yScalingFactor)); |
2 |
26 Feb 07 |
jari |
331 |
} |
2 |
26 Feb 07 |
jari |
332 |
|
2 |
26 Feb 07 |
jari |
333 |
g2D.setStroke(new BasicStroke(2.0f)); |
2 |
26 Feb 07 |
jari |
334 |
g2D.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
335 |
|
2 |
26 Feb 07 |
jari |
336 |
DecimalFormat nf = new DecimalFormat(); |
2 |
26 Feb 07 |
jari |
//nf.setMaximumFractionDigits(2); |
2 |
26 Feb 07 |
jari |
338 |
|
2 |
26 Feb 07 |
jari |
//tick labels |
2 |
26 Feb 07 |
jari |
340 |
for (int i = 1; i < xIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
341 |
double stringWidth = (g2D.getFontMetrics()).stringWidth(nf.format(xIntervalArray[i])); |
2 |
26 Feb 07 |
jari |
342 |
g2D.drawString(nf.format((double)xIntervalArray[i]), (int)Math.round(xIntervalArray[i]*xScalingFactor) +this.getWidth()/2 - (int)Math.round(0.5d*stringWidth), this.getHeight()/2 + 20); |
2 |
26 Feb 07 |
jari |
343 |
} |
2 |
26 Feb 07 |
jari |
344 |
|
2 |
26 Feb 07 |
jari |
345 |
for (int i = 1; i < xIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
346 |
double stringWidth = (g2D.getFontMetrics()).stringWidth("-" + nf.format(xIntervalArray[i])); |
2 |
26 Feb 07 |
jari |
347 |
g2D.drawString("-" + nf.format((double)xIntervalArray[i]), this.getWidth()/2 - (int)Math.round(xIntervalArray[i]*xScalingFactor) - (int)Math.round(0.5d*stringWidth), this.getHeight()/2 + 20); |
2 |
26 Feb 07 |
jari |
348 |
} |
2 |
26 Feb 07 |
jari |
349 |
|
2 |
26 Feb 07 |
jari |
350 |
for (int i = 1; i < yIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
351 |
g2D.drawString(nf.format((double)yIntervalArray[i]), this.getWidth()/2 + 10, this.getHeight()/2 - (int)Math.round(yIntervalArray[i]*yScalingFactor) ); |
2 |
26 Feb 07 |
jari |
352 |
} |
2 |
26 Feb 07 |
jari |
353 |
|
2 |
26 Feb 07 |
jari |
354 |
for (int i = 1; i < yIntervalArray.length; i++) { |
2 |
26 Feb 07 |
jari |
355 |
g2D.drawString("-" + nf.format((double)yIntervalArray[i]), this.getWidth()/2 + 10, this.getHeight()/2 + (int)Math.round(yIntervalArray[i]*yScalingFactor) ); |
2 |
26 Feb 07 |
jari |
356 |
} |
2 |
26 Feb 07 |
jari |
357 |
} |
2 |
26 Feb 07 |
jari |
//Color[] pointColor = new Color[xArray.length]; |
2 |
26 Feb 07 |
jari |
359 |
|
2 |
26 Feb 07 |
jari |
360 |
if ((geneOrExpt == COAGUI.GENES) || (geneOrExpt == COAGUI.EXPTS)) { |
2 |
26 Feb 07 |
jari |
361 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < pointColor.length; i++) { |
2 |
26 Feb 07 |
jari |
pointColor[i] = Color.black; //just for now, will add cluster colors later |
2 |
26 Feb 07 |
jari |
364 |
} |
2 |
26 Feb 07 |
jari |
365 |
*/ |
2 |
26 Feb 07 |
jari |
//draw data points |
2 |
26 Feb 07 |
jari |
367 |
for (int i = 0; i < xArray.length; i++) { |
2 |
26 Feb 07 |
jari |
368 |
Color currPointColor = Color.black; |
2 |
26 Feb 07 |
jari |
369 |
if (geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
370 |
currPointColor = this.data.getProbeColor(this.experiment.getGeneIndexMappedToData(i)); |
2 |
26 Feb 07 |
jari |
371 |
if (currPointColor == null) currPointColor = Color.black; |
2 |
26 Feb 07 |
jari |
372 |
} else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
373 |
currPointColor = this.data.getExperimentColor(i); |
2 |
26 Feb 07 |
jari |
374 |
if (currPointColor == null) currPointColor = Color.black; |
2 |
26 Feb 07 |
jari |
375 |
} |
2 |
26 Feb 07 |
jari |
376 |
g2D.setColor(currPointColor); |
2 |
26 Feb 07 |
jari |
377 |
if (showLargePoints) { |
2 |
26 Feb 07 |
jari |
378 |
drawRectPoint(g2D, xArray[i], yArray[i], getXScalingFactor(origMaxXValue, origMinXValue), getYScalingFactor(origMaxYValue, origMinYValue), 8); |
2 |
26 Feb 07 |
jari |
379 |
} else { |
2 |
26 Feb 07 |
jari |
380 |
drawPoint(g2D, xArray[i], yArray[i], getXScalingFactor(origMaxXValue, origMinXValue), getYScalingFactor(origMaxYValue, origMinYValue), 5); |
2 |
26 Feb 07 |
jari |
381 |
} |
2 |
26 Feb 07 |
jari |
382 |
g2D.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
//g2D.drawOval((midX + expectedXArray[i]), |
2 |
26 Feb 07 |
jari |
384 |
} |
2 |
26 Feb 07 |
jari |
385 |
g2D.drawString( "X axis = " + (axis1 + 1) + ", Y axis = " + (axis2 + 1), this.getWidth()/2 + 25, this.getHeight() - 25); |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
} else { // if (geneOrExpt == COAGUI.BOTH) |
2 |
26 Feb 07 |
jari |
388 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < geneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
pointColor[i] = Color.black; //just for now, will add cluster colors later |
2 |
26 Feb 07 |
jari |
391 |
} |
2 |
26 Feb 07 |
jari |
for (int i = geneUMatrix.getRowDimension(); i < pointColor.length; i++) { |
2 |
26 Feb 07 |
jari |
pointColor[i] = Color.gray; |
2 |
26 Feb 07 |
jari |
394 |
} |
2 |
26 Feb 07 |
jari |
395 |
*/ |
2 |
26 Feb 07 |
jari |
//draw data points |
2 |
26 Feb 07 |
jari |
397 |
Color currPointColor = Color.black; |
2 |
26 Feb 07 |
jari |
398 |
for (int i = 0; i < geneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
399 |
currPointColor = this.data.getProbeColor(this.experiment.getGeneIndexMappedToData(i)); |
2 |
26 Feb 07 |
jari |
400 |
if (currPointColor == null) currPointColor = Color.gray; |
2 |
26 Feb 07 |
jari |
401 |
g2D.setColor(currPointColor); |
2 |
26 Feb 07 |
jari |
402 |
drawPoint(g2D, xArray[i], yArray[i], getXScalingFactor(origMaxXValue, origMinXValue), getYScalingFactor(origMaxYValue, origMinYValue), 5); |
2 |
26 Feb 07 |
jari |
403 |
g2D.setColor(Color.gray); |
2 |
26 Feb 07 |
jari |
//g2D.drawOval((midX + expectedXArray[i]), |
2 |
26 Feb 07 |
jari |
405 |
} |
2 |
26 Feb 07 |
jari |
//g2D.setColor(Color.lightGray); |
2 |
26 Feb 07 |
jari |
407 |
for (int i = geneUMatrix.getRowDimension(); i < xArray.length; i++) { |
2 |
26 Feb 07 |
jari |
408 |
currPointColor = this.data.getExperimentColor(i - geneUMatrix.getRowDimension()); |
2 |
26 Feb 07 |
jari |
409 |
if (currPointColor == null) currPointColor = Color.black; |
2 |
26 Feb 07 |
jari |
410 |
g2D.setColor(currPointColor); |
2 |
26 Feb 07 |
jari |
411 |
drawRectPoint(g2D, xArray[i], yArray[i], getXScalingFactor(origMaxXValue, origMinXValue), getYScalingFactor(origMaxYValue, origMinYValue), 8); |
2 |
26 Feb 07 |
jari |
412 |
g2D.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
413 |
} |
2 |
26 Feb 07 |
jari |
414 |
g2D.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
415 |
g2D.drawString( "X axis = " + (axis1 + 1) + ", Y axis = " + (axis2 + 1), this.getWidth()/2 + 25, this.getHeight() - 25); |
2 |
26 Feb 07 |
jari |
416 |
} |
2 |
26 Feb 07 |
jari |
417 |
|
2 |
26 Feb 07 |
jari |
// display expt names |
2 |
26 Feb 07 |
jari |
419 |
|
2 |
26 Feb 07 |
jari |
420 |
if (this.geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
421 |
if (this.displayExptNames) { |
2 |
26 Feb 07 |
jari |
422 |
FontMetrics fmet = g2D.getFontMetrics(g2D.getFont()); |
2 |
26 Feb 07 |
jari |
423 |
double ascent = (double)(fmet.getAscent()); |
2 |
26 Feb 07 |
jari |
424 |
double advance = (double)(fmet.getMaxAdvance()); |
2 |
26 Feb 07 |
jari |
425 |
for (int i = 0; i < xArray.length; i++) { |
2 |
26 Feb 07 |
jari |
426 |
double currCoords[] = getCoords(xArray[i], yArray[i]); |
2 |
26 Feb 07 |
jari |
427 |
String currName = data.getSampleName(i); |
2 |
26 Feb 07 |
jari |
428 |
double stringWidth = (double)(fmet.stringWidth(currName)); |
2 |
26 Feb 07 |
jari |
429 |
if ((currCoords[0] + 0.5d*advance + stringWidth) > (double)(this.getWidth())) { |
2 |
26 Feb 07 |
jari |
430 |
g2D.drawString(currName, (float)(currCoords[0] - stringWidth - 0.25d*advance), (float)(currCoords[1] + 0.5d*ascent)); |
2 |
26 Feb 07 |
jari |
431 |
} |
2 |
26 Feb 07 |
jari |
432 |
else { |
2 |
26 Feb 07 |
jari |
433 |
g2D.drawString(currName, (float)(currCoords[0] + 0.5d*advance), (float)(currCoords[1] + 0.5d*ascent)); |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
//g2D.drawString(currName, (float)(currCoords[0] + 0.5d*advance), (float)(currCoords[1] + 0.5d*ascent)); |
2 |
26 Feb 07 |
jari |
436 |
} |
2 |
26 Feb 07 |
jari |
437 |
} |
2 |
26 Feb 07 |
jari |
438 |
} |
2 |
26 Feb 07 |
jari |
439 |
|
2 |
26 Feb 07 |
jari |
440 |
if (this.geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
441 |
if (this.displayExptNames) { |
2 |
26 Feb 07 |
jari |
442 |
FontMetrics fmet = g2D.getFontMetrics(g2D.getFont()); |
2 |
26 Feb 07 |
jari |
443 |
double ascent = (double)(fmet.getAscent()); |
2 |
26 Feb 07 |
jari |
444 |
double advance = (double)(fmet.getMaxAdvance()); |
2 |
26 Feb 07 |
jari |
445 |
for (int i = geneUMatrix.getRowDimension(); i < xArray.length; i++) { |
2 |
26 Feb 07 |
jari |
446 |
double currCoords[] = getCoords(xArray[i], yArray[i]); |
2 |
26 Feb 07 |
jari |
447 |
String currName = data.getSampleName(i - geneUMatrix.getRowDimension()); |
2 |
26 Feb 07 |
jari |
448 |
double stringWidth = (double)(fmet.stringWidth(currName)); |
2 |
26 Feb 07 |
jari |
449 |
if ((currCoords[0] + 0.5d*advance + stringWidth) > (double)(this.getWidth())) { |
2 |
26 Feb 07 |
jari |
450 |
g2D.drawString(currName, (float)(currCoords[0] - stringWidth - 0.25d*advance), (float)(currCoords[1] + 0.5d*ascent)); |
2 |
26 Feb 07 |
jari |
451 |
} |
2 |
26 Feb 07 |
jari |
452 |
else { |
2 |
26 Feb 07 |
jari |
453 |
g2D.drawString(currName, (float)(currCoords[0] + 0.5d*advance), (float)(currCoords[1] + 0.5d*ascent)); |
2 |
26 Feb 07 |
jari |
454 |
} |
2 |
26 Feb 07 |
jari |
455 |
} |
2 |
26 Feb 07 |
jari |
456 |
} |
2 |
26 Feb 07 |
jari |
457 |
} |
2 |
26 Feb 07 |
jari |
458 |
|
2 |
26 Feb 07 |
jari |
459 |
if (currentRect != null) { |
2 |
26 Feb 07 |
jari |
460 |
g2D.setXORMode(Color.white);//Color of line varies |
2 |
26 Feb 07 |
jari |
//depending on image colors |
2 |
26 Feb 07 |
jari |
462 |
g2D.draw(ellipse); |
2 |
26 Feb 07 |
jari |
463 |
} |
2 |
26 Feb 07 |
jari |
464 |
} |
2 |
26 Feb 07 |
jari |
465 |
|
2 |
26 Feb 07 |
jari |
466 |
private void drawPoint(Graphics2D g2D, double xValue, double yValue, double xScale, double yScale, int diameter) { |
2 |
26 Feb 07 |
jari |
467 |
int xRaw = (int)Math.round(xValue*xScale); |
2 |
26 Feb 07 |
jari |
468 |
int yRaw = (int)Math.round(yValue*yScale); |
2 |
26 Feb 07 |
jari |
//System.out.println("xValue = " + xValue + " , yValue = " + yValue + ", xRaw = " + xRaw + ", yRaw = " + yRaw); |
2 |
26 Feb 07 |
jari |
470 |
|
2 |
26 Feb 07 |
jari |
471 |
int xCoord = (int)Math.round((double)(this.getWidth()/2)) + xRaw; |
2 |
26 Feb 07 |
jari |
472 |
int yCoord = (int)Math.round((double)(this.getHeight()/2)) - yRaw; |
2 |
26 Feb 07 |
jari |
473 |
|
2 |
26 Feb 07 |
jari |
474 |
g2D.fillOval(xCoord, yCoord, diameter, diameter); |
2 |
26 Feb 07 |
jari |
475 |
} |
2 |
26 Feb 07 |
jari |
476 |
|
2 |
26 Feb 07 |
jari |
477 |
private void drawRectPoint(Graphics2D g2D, double xValue, double yValue, double xScale, double yScale, int dim) { |
2 |
26 Feb 07 |
jari |
478 |
int xRaw = (int)Math.round(xValue*xScale); |
2 |
26 Feb 07 |
jari |
479 |
int yRaw = (int)Math.round(yValue*yScale); |
2 |
26 Feb 07 |
jari |
//System.out.println("xValue = " + xValue + " , yValue = " + yValue + ", xRaw = " + xRaw + ", yRaw = " + yRaw); |
2 |
26 Feb 07 |
jari |
481 |
|
2 |
26 Feb 07 |
jari |
482 |
int xCoord = (int)Math.round((double)(this.getWidth()/2)) + xRaw; |
2 |
26 Feb 07 |
jari |
483 |
int yCoord = (int)Math.round((double)(this.getHeight()/2)) - yRaw; |
2 |
26 Feb 07 |
jari |
484 |
|
2 |
26 Feb 07 |
jari |
485 |
g2D.fillRect(xCoord, yCoord, dim, dim); |
2 |
26 Feb 07 |
jari |
486 |
} |
2 |
26 Feb 07 |
jari |
487 |
|
2 |
26 Feb 07 |
jari |
488 |
private double getMax(float[] array) { |
2 |
26 Feb 07 |
jari |
489 |
float max = Float.NEGATIVE_INFINITY; |
2 |
26 Feb 07 |
jari |
490 |
for (int i = 0; i < array.length; i++) { |
2 |
26 Feb 07 |
jari |
491 |
if (max < array[i]) { |
2 |
26 Feb 07 |
jari |
492 |
max = array[i]; |
2 |
26 Feb 07 |
jari |
493 |
} |
2 |
26 Feb 07 |
jari |
494 |
} |
2 |
26 Feb 07 |
jari |
495 |
return (double)max; |
2 |
26 Feb 07 |
jari |
496 |
} |
2 |
26 Feb 07 |
jari |
497 |
|
2 |
26 Feb 07 |
jari |
498 |
private double getMin(float[] array) { |
2 |
26 Feb 07 |
jari |
499 |
float min = Float.POSITIVE_INFINITY; |
2 |
26 Feb 07 |
jari |
500 |
for (int i = 0; i < array.length; i++) { |
2 |
26 Feb 07 |
jari |
501 |
if (min > array[i]) { |
2 |
26 Feb 07 |
jari |
502 |
min = array[i]; |
2 |
26 Feb 07 |
jari |
503 |
} |
2 |
26 Feb 07 |
jari |
504 |
} |
2 |
26 Feb 07 |
jari |
505 |
return (double)min; |
2 |
26 Feb 07 |
jari |
506 |
} |
2 |
26 Feb 07 |
jari |
507 |
|
2 |
26 Feb 07 |
jari |
508 |
private double getXScalingFactor(double maxValue, double minValue) { |
2 |
26 Feb 07 |
jari |
509 |
double largest = 1; |
2 |
26 Feb 07 |
jari |
510 |
if ((maxValue > 0)&&(minValue > 0)) { |
2 |
26 Feb 07 |
jari |
511 |
largest = maxValue; |
2 |
26 Feb 07 |
jari |
512 |
} else if ((maxValue > 0)&&(minValue < 0)) { |
2 |
26 Feb 07 |
jari |
513 |
if (maxValue > Math.abs(minValue)) { |
2 |
26 Feb 07 |
jari |
514 |
largest = maxValue; |
2 |
26 Feb 07 |
jari |
515 |
} else { |
2 |
26 Feb 07 |
jari |
516 |
largest = Math.abs(minValue); |
2 |
26 Feb 07 |
jari |
517 |
} |
2 |
26 Feb 07 |
jari |
518 |
} else if (maxValue <= 0) { |
2 |
26 Feb 07 |
jari |
519 |
largest = Math.abs(minValue); |
2 |
26 Feb 07 |
jari |
520 |
} else if (minValue == 0) { |
2 |
26 Feb 07 |
jari |
521 |
largest = maxValue; |
2 |
26 Feb 07 |
jari |
522 |
} |
2 |
26 Feb 07 |
jari |
523 |
|
2 |
26 Feb 07 |
jari |
524 |
double scalingFactor =0; |
2 |
26 Feb 07 |
jari |
525 |
scalingFactor = (this.getWidth()/2 - 50)/largest; |
2 |
26 Feb 07 |
jari |
526 |
return scalingFactor; |
2 |
26 Feb 07 |
jari |
527 |
} |
2 |
26 Feb 07 |
jari |
528 |
|
2 |
26 Feb 07 |
jari |
529 |
private double getYScalingFactor(double maxValue, double minValue) { |
2 |
26 Feb 07 |
jari |
530 |
double largest = 1; |
2 |
26 Feb 07 |
jari |
531 |
if ((maxValue > 0)&&(minValue > 0)) { |
2 |
26 Feb 07 |
jari |
532 |
largest = maxValue; |
2 |
26 Feb 07 |
jari |
533 |
} else if ((maxValue > 0)&&(minValue < 0)) { |
2 |
26 Feb 07 |
jari |
534 |
if (maxValue > Math.abs(minValue)) { |
2 |
26 Feb 07 |
jari |
535 |
largest = maxValue; |
2 |
26 Feb 07 |
jari |
536 |
} else { |
2 |
26 Feb 07 |
jari |
537 |
largest = Math.abs(minValue); |
2 |
26 Feb 07 |
jari |
538 |
} |
2 |
26 Feb 07 |
jari |
539 |
} else if (maxValue <= 0) { |
2 |
26 Feb 07 |
jari |
540 |
largest = Math.abs(minValue); |
2 |
26 Feb 07 |
jari |
541 |
} else if (minValue == 0) { |
2 |
26 Feb 07 |
jari |
542 |
largest = maxValue; |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
double scalingFactor = 0; |
2 |
26 Feb 07 |
jari |
546 |
scalingFactor = (this.getHeight()/2 - 50)/largest; |
2 |
26 Feb 07 |
jari |
547 |
return scalingFactor; |
2 |
26 Feb 07 |
jari |
548 |
} |
2 |
26 Feb 07 |
jari |
549 |
|
2 |
26 Feb 07 |
jari |
/** Returns the viewer's clusters or null |
2 |
26 Feb 07 |
jari |
551 |
*/ |
2 |
26 Feb 07 |
jari |
552 |
public int[][] getClusters() { |
2 |
26 Feb 07 |
jari |
553 |
return null; |
2 |
26 Feb 07 |
jari |
554 |
} |
2 |
26 Feb 07 |
jari |
555 |
|
2 |
26 Feb 07 |
jari |
556 |
public int[] getSelectedPoints() { |
2 |
26 Feb 07 |
jari |
557 |
Vector selPointsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
558 |
for (int i = 0; i < UMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
559 |
double[] currCoords = getCoords(xArray[i], yArray[i]); |
2 |
26 Feb 07 |
jari |
560 |
if (ellipse.contains(currCoords[0], currCoords[1])) { |
2 |
26 Feb 07 |
jari |
561 |
if (geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
562 |
selPointsVector.add(new Integer(experiment.getGeneIndexMappedToData(i))); |
2 |
26 Feb 07 |
jari |
563 |
} else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
564 |
selPointsVector.add(new Integer(experiment.getSampleIndex(i))); |
2 |
26 Feb 07 |
jari |
565 |
} |
2 |
26 Feb 07 |
jari |
566 |
} |
2 |
26 Feb 07 |
jari |
567 |
} |
2 |
26 Feb 07 |
jari |
568 |
|
2 |
26 Feb 07 |
jari |
569 |
int[] selPoints = new int[selPointsVector.size()]; |
2 |
26 Feb 07 |
jari |
570 |
for (int i = 0; i < selPoints.length; i++) { |
2 |
26 Feb 07 |
jari |
571 |
selPoints[i] = ((Integer)(selPointsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
572 |
} |
2 |
26 Feb 07 |
jari |
573 |
|
2 |
26 Feb 07 |
jari |
574 |
return selPoints; |
2 |
26 Feb 07 |
jari |
575 |
} |
2 |
26 Feb 07 |
jari |
576 |
|
2 |
26 Feb 07 |
jari |
577 |
public int[] getSelectedGenesFromBoth() { |
2 |
26 Feb 07 |
jari |
578 |
Vector selPointsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
579 |
for (int i = 0; i < geneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
580 |
double[] currCoords = getCoords(xArray[i], yArray[i]); |
2 |
26 Feb 07 |
jari |
581 |
if (ellipse.contains(currCoords[0], currCoords[1])) { |
2 |
26 Feb 07 |
jari |
582 |
selPointsVector.add(new Integer(experiment.getGeneIndexMappedToData(i))); |
2 |
26 Feb 07 |
jari |
583 |
} |
2 |
26 Feb 07 |
jari |
584 |
} |
2 |
26 Feb 07 |
jari |
585 |
|
2 |
26 Feb 07 |
jari |
586 |
int[] selPoints = new int[selPointsVector.size()]; |
2 |
26 Feb 07 |
jari |
587 |
for (int i = 0; i < selPoints.length; i++) { |
2 |
26 Feb 07 |
jari |
588 |
selPoints[i] = ((Integer)(selPointsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
589 |
} |
2 |
26 Feb 07 |
jari |
590 |
|
2 |
26 Feb 07 |
jari |
591 |
return selPoints; |
2 |
26 Feb 07 |
jari |
592 |
} |
2 |
26 Feb 07 |
jari |
593 |
|
2 |
26 Feb 07 |
jari |
594 |
public int[] getSelectedExptsFromBoth() { |
2 |
26 Feb 07 |
jari |
595 |
Vector selPointsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
596 |
for (int i = geneUMatrix.getRowDimension(); i < UMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
597 |
double[] currCoords = getCoords(xArray[i], yArray[i]); |
2 |
26 Feb 07 |
jari |
598 |
if (ellipse.contains(currCoords[0], currCoords[1])) { |
2 |
26 Feb 07 |
jari |
599 |
selPointsVector.add(new Integer(experiment.getSampleIndex(i - geneUMatrix.getRowDimension()))); |
2 |
26 Feb 07 |
jari |
600 |
} |
2 |
26 Feb 07 |
jari |
601 |
} |
2 |
26 Feb 07 |
jari |
602 |
|
2 |
26 Feb 07 |
jari |
603 |
int[] selPoints = new int[selPointsVector.size()]; |
2 |
26 Feb 07 |
jari |
604 |
for (int i = 0; i < selPoints.length; i++) { |
2 |
26 Feb 07 |
jari |
605 |
selPoints[i] = ((Integer)(selPointsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
606 |
} |
2 |
26 Feb 07 |
jari |
607 |
|
2 |
26 Feb 07 |
jari |
608 |
return selPoints; |
2 |
26 Feb 07 |
jari |
609 |
} |
2 |
26 Feb 07 |
jari |
610 |
|
2 |
26 Feb 07 |
jari |
611 |
private double[] getCoords(double xValue, double yValue) { |
2 |
26 Feb 07 |
jari |
612 |
double origMaxXValue = getMax(xArray); |
2 |
26 Feb 07 |
jari |
613 |
double origMaxYValue = getMax(yArray); |
2 |
26 Feb 07 |
jari |
614 |
double origMinXValue = getMin(xArray); |
2 |
26 Feb 07 |
jari |
615 |
double origMinYValue = getMin(yArray); |
2 |
26 Feb 07 |
jari |
616 |
|
2 |
26 Feb 07 |
jari |
617 |
double xScalingFactor = getXScalingFactor(origMaxXValue, origMinXValue); // relative to originX and originY |
2 |
26 Feb 07 |
jari |
618 |
double yScalingFactor = getYScalingFactor(origMaxYValue, origMinYValue); // relative to originX and originY |
2 |
26 Feb 07 |
jari |
619 |
|
2 |
26 Feb 07 |
jari |
620 |
double xRaw = Math.round(xValue*xScalingFactor); |
2 |
26 Feb 07 |
jari |
621 |
double yRaw= Math.round(yValue*yScalingFactor); |
2 |
26 Feb 07 |
jari |
622 |
|
2 |
26 Feb 07 |
jari |
623 |
double xCoord = Math.round((double)(this.getWidth()/2)) + xRaw; |
2 |
26 Feb 07 |
jari |
624 |
double yCoord = Math.round((double)(this.getHeight()/2)) - yRaw; |
2 |
26 Feb 07 |
jari |
625 |
|
2 |
26 Feb 07 |
jari |
626 |
double[] coords = {xCoord, yCoord}; |
2 |
26 Feb 07 |
jari |
627 |
return coords; |
2 |
26 Feb 07 |
jari |
628 |
} |
2 |
26 Feb 07 |
jari |
629 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into scroll pane view port. |
2 |
26 Feb 07 |
jari |
631 |
*/ |
2 |
26 Feb 07 |
jari |
632 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
633 |
return this; |
2 |
26 Feb 07 |
jari |
634 |
} |
2 |
26 Feb 07 |
jari |
635 |
|
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 |
638 |
*/ |
2 |
26 Feb 07 |
jari |
639 |
public JComponent getCornerComponent(int cornerIndex) { |
2 |
26 Feb 07 |
jari |
640 |
return null; |
2 |
26 Feb 07 |
jari |
641 |
} |
2 |
26 Feb 07 |
jari |
642 |
|
2 |
26 Feb 07 |
jari |
/** Returns the viewer's experiment or null |
2 |
26 Feb 07 |
jari |
644 |
*/ |
2 |
26 Feb 07 |
jari |
645 |
public Experiment getExperiment() { |
2 |
26 Feb 07 |
jari |
646 |
return experiment; |
2 |
26 Feb 07 |
jari |
647 |
} |
2 |
26 Feb 07 |
jari |
648 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into scroll pane header. |
2 |
26 Feb 07 |
jari |
650 |
*/ |
2 |
26 Feb 07 |
jari |
651 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
652 |
return null; |
2 |
26 Feb 07 |
jari |
653 |
} |
2 |
26 Feb 07 |
jari |
654 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework to save or to print viewer image. |
2 |
26 Feb 07 |
jari |
656 |
*/ |
2 |
26 Feb 07 |
jari |
657 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
658 |
return null; |
2 |
26 Feb 07 |
jari |
659 |
} |
2 |
26 Feb 07 |
jari |
660 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into the scroll pane row header |
2 |
26 Feb 07 |
jari |
662 |
*/ |
2 |
26 Feb 07 |
jari |
663 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
664 |
return null; |
2 |
26 Feb 07 |
jari |
665 |
} |
2 |
26 Feb 07 |
jari |
666 |
|
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 |
669 |
*/ |
2 |
26 Feb 07 |
jari |
670 |
public int getViewerType() { |
2 |
26 Feb 07 |
jari |
671 |
return -1; |
2 |
26 Feb 07 |
jari |
672 |
} |
2 |
26 Feb 07 |
jari |
673 |
|
2 |
26 Feb 07 |
jari |
/** Invoked when the framework is going to be closed. |
2 |
26 Feb 07 |
jari |
675 |
*/ |
2 |
26 Feb 07 |
jari |
676 |
public void onClosed() { |
2 |
26 Feb 07 |
jari |
677 |
} |
2 |
26 Feb 07 |
jari |
678 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when data is changed, |
2 |
26 Feb 07 |
jari |
* if this viewer is selected. |
2 |
26 Feb 07 |
jari |
* @see IData |
2 |
26 Feb 07 |
jari |
682 |
*/ |
2 |
26 Feb 07 |
jari |
683 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
684 |
setData(data); |
2 |
26 Feb 07 |
jari |
685 |
} |
2 |
26 Feb 07 |
jari |
686 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when this viewer was deselected. |
2 |
26 Feb 07 |
jari |
688 |
*/ |
2 |
26 Feb 07 |
jari |
689 |
public void onDeselected() { |
2 |
26 Feb 07 |
jari |
690 |
} |
2 |
26 Feb 07 |
jari |
691 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when display menu is changed, |
2 |
26 Feb 07 |
jari |
* if this viewer is selected. |
2 |
26 Feb 07 |
jari |
* @see IDisplayMenu |
2 |
26 Feb 07 |
jari |
695 |
*/ |
2 |
26 Feb 07 |
jari |
696 |
public void onMenuChanged(IDisplayMenu menu) { |
2 |
26 Feb 07 |
jari |
697 |
} |
2 |
26 Feb 07 |
jari |
698 |
|
2 |
26 Feb 07 |
jari |
/** Invoked by the framework when this viewer is selected. |
2 |
26 Feb 07 |
jari |
700 |
*/ |
2 |
26 Feb 07 |
jari |
701 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
702 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
703 |
this.frame = framework.getFrame(); |
2 |
26 Feb 07 |
jari |
704 |
setData(framework.getData()); |
2 |
26 Feb 07 |
jari |
705 |
|
2 |
26 Feb 07 |
jari |
//In case it is viewed after serialization |
2 |
26 Feb 07 |
jari |
707 |
if(popup == null){ |
2 |
26 Feb 07 |
jari |
708 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
709 |
DefaultMutableTreeNode node = framework.getCurrentNode(); |
2 |
26 Feb 07 |
jari |
710 |
if(node != null){ |
2 |
26 Feb 07 |
jari |
711 |
if(node.getUserObject() instanceof LeafInfo){ |
2 |
26 Feb 07 |
jari |
712 |
LeafInfo leafInfo = (LeafInfo) node.getUserObject(); |
2 |
26 Feb 07 |
jari |
713 |
leafInfo.setPopupMenu(this.popup); |
2 |
26 Feb 07 |
jari |
714 |
} |
2 |
26 Feb 07 |
jari |
715 |
} |
2 |
26 Feb 07 |
jari |
716 |
} |
2 |
26 Feb 07 |
jari |
717 |
} |
2 |
26 Feb 07 |
jari |
718 |
|
2 |
26 Feb 07 |
jari |
719 |
public void setData(IData data) { |
2 |
26 Feb 07 |
jari |
720 |
this.data = data; |
2 |
26 Feb 07 |
jari |
721 |
} |
2 |
26 Feb 07 |
jari |
722 |
|
2 |
26 Feb 07 |
jari |
723 |
private class GraphListener extends MouseInputAdapter { |
2 |
26 Feb 07 |
jari |
724 |
|
2 |
26 Feb 07 |
jari |
725 |
public void mousePressed(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
726 |
int x = e.getX(); |
2 |
26 Feb 07 |
jari |
727 |
int y = e.getY(); |
2 |
26 Feb 07 |
jari |
728 |
currentRect = new Rectangle(x, y, 0, 0); |
2 |
26 Feb 07 |
jari |
729 |
updateDrawableRect(getWidth(), getHeight()); |
2 |
26 Feb 07 |
jari |
730 |
repaint(); |
2 |
26 Feb 07 |
jari |
731 |
onShowSelection(); |
2 |
26 Feb 07 |
jari |
732 |
} |
2 |
26 Feb 07 |
jari |
733 |
|
2 |
26 Feb 07 |
jari |
734 |
public void mouseDragged(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
735 |
updateSize(e); |
2 |
26 Feb 07 |
jari |
736 |
} |
2 |
26 Feb 07 |
jari |
737 |
|
2 |
26 Feb 07 |
jari |
738 |
public void mouseReleased(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
739 |
updateSize(e); |
2 |
26 Feb 07 |
jari |
740 |
} |
2 |
26 Feb 07 |
jari |
741 |
|
2 |
26 Feb 07 |
jari |
742 |
void updateSize(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
743 |
int x = e.getX(); |
2 |
26 Feb 07 |
jari |
744 |
int y = e.getY(); |
2 |
26 Feb 07 |
jari |
745 |
currentRect.setSize(x - currentRect.x, |
2 |
26 Feb 07 |
jari |
746 |
y - currentRect.y); |
2 |
26 Feb 07 |
jari |
747 |
updateDrawableRect(getWidth(), getHeight()); |
2 |
26 Feb 07 |
jari |
748 |
Rectangle totalRepaint = rectToDraw.union(previousRectDrawn); |
2 |
26 Feb 07 |
jari |
749 |
ellipse.setFrame(totalRepaint.getX(), totalRepaint.getY(), totalRepaint.getWidth(), totalRepaint.getHeight()); |
2 |
26 Feb 07 |
jari |
750 |
COA2DViewer.this.repaint(); |
2 |
26 Feb 07 |
jari |
751 |
onShowSelection(); |
2 |
26 Feb 07 |
jari |
//repaint(totalRepaint.x, totalRepaint.y, |
2 |
26 Feb 07 |
jari |
//totalRepaint.width, totalRepaint.height); |
2 |
26 Feb 07 |
jari |
754 |
} |
2 |
26 Feb 07 |
jari |
755 |
|
2 |
26 Feb 07 |
jari |
756 |
private void updateDrawableRect(int compWidth, int compHeight) { |
2 |
26 Feb 07 |
jari |
757 |
int x = currentRect.x; |
2 |
26 Feb 07 |
jari |
758 |
int y = currentRect.y; |
2 |
26 Feb 07 |
jari |
759 |
int width = currentRect.width; |
2 |
26 Feb 07 |
jari |
760 |
int height = currentRect.height; |
2 |
26 Feb 07 |
jari |
761 |
|
2 |
26 Feb 07 |
jari |
//Make the width and height positive, if necessary. |
2 |
26 Feb 07 |
jari |
763 |
if (width < 0) { |
2 |
26 Feb 07 |
jari |
764 |
width = 0 - width; |
2 |
26 Feb 07 |
jari |
765 |
x = x - width + 1; |
2 |
26 Feb 07 |
jari |
766 |
if (x < 0) { |
2 |
26 Feb 07 |
jari |
767 |
width += x; |
2 |
26 Feb 07 |
jari |
768 |
x = 0; |
2 |
26 Feb 07 |
jari |
769 |
} |
2 |
26 Feb 07 |
jari |
770 |
} |
2 |
26 Feb 07 |
jari |
771 |
if (height < 0) { |
2 |
26 Feb 07 |
jari |
772 |
height = 0 - height; |
2 |
26 Feb 07 |
jari |
773 |
y = y - height + 1; |
2 |
26 Feb 07 |
jari |
774 |
if (y < 0) { |
2 |
26 Feb 07 |
jari |
775 |
height += y; |
2 |
26 Feb 07 |
jari |
776 |
y = 0; |
2 |
26 Feb 07 |
jari |
777 |
} |
2 |
26 Feb 07 |
jari |
778 |
} |
2 |
26 Feb 07 |
jari |
779 |
|
2 |
26 Feb 07 |
jari |
//The rectangle shouldn't extend past the drawing area. |
2 |
26 Feb 07 |
jari |
781 |
if ((x + width) > compWidth) { |
2 |
26 Feb 07 |
jari |
782 |
width = compWidth - x; |
2 |
26 Feb 07 |
jari |
783 |
} |
2 |
26 Feb 07 |
jari |
784 |
if ((y + height) > compHeight) { |
2 |
26 Feb 07 |
jari |
785 |
height = compHeight - y; |
2 |
26 Feb 07 |
jari |
786 |
} |
2 |
26 Feb 07 |
jari |
787 |
|
2 |
26 Feb 07 |
jari |
//Update rectToDraw after saving old value. |
2 |
26 Feb 07 |
jari |
789 |
if (rectToDraw != null) { |
2 |
26 Feb 07 |
jari |
790 |
previousRectDrawn.setBounds( |
2 |
26 Feb 07 |
jari |
791 |
rectToDraw.x, rectToDraw.y, |
2 |
26 Feb 07 |
jari |
792 |
rectToDraw.width, rectToDraw.height); |
2 |
26 Feb 07 |
jari |
793 |
rectToDraw.setBounds(x, y, width, height); |
2 |
26 Feb 07 |
jari |
794 |
} else { |
2 |
26 Feb 07 |
jari |
795 |
rectToDraw = new Rectangle(x, y, width, height); |
2 |
26 Feb 07 |
jari |
796 |
} |
2 |
26 Feb 07 |
jari |
797 |
} |
2 |
26 Feb 07 |
jari |
798 |
|
2 |
26 Feb 07 |
jari |
799 |
} |
2 |
26 Feb 07 |
jari |
800 |
|
2 |
26 Feb 07 |
jari |
801 |
|
2 |
26 Feb 07 |
jari |
802 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the viewer popup menu. |
2 |
26 Feb 07 |
jari |
804 |
*/ |
2 |
26 Feb 07 |
jari |
805 |
public JPopupMenu getJPopupMenu() { |
2 |
26 Feb 07 |
jari |
806 |
return popup; |
2 |
26 Feb 07 |
jari |
807 |
} |
2 |
26 Feb 07 |
jari |
808 |
|
2 |
26 Feb 07 |
jari |
809 |
/** |
2 |
26 Feb 07 |
jari |
* Creates the viewer popup menu. |
2 |
26 Feb 07 |
jari |
811 |
*/ |
2 |
26 Feb 07 |
jari |
812 |
private JPopupMenu createJPopupMenu() { |
2 |
26 Feb 07 |
jari |
813 |
JPopupMenu popup = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
814 |
addMenuItems(popup); |
2 |
26 Feb 07 |
jari |
815 |
return popup; |
2 |
26 Feb 07 |
jari |
816 |
} |
2 |
26 Feb 07 |
jari |
817 |
|
2 |
26 Feb 07 |
jari |
818 |
|
2 |
26 Feb 07 |
jari |
819 |
/** |
2 |
26 Feb 07 |
jari |
* Adds the viewer specific menu items. |
2 |
26 Feb 07 |
jari |
821 |
*/ |
2 |
26 Feb 07 |
jari |
822 |
private void addMenuItems(JPopupMenu menu) { |
2 |
26 Feb 07 |
jari |
823 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
824 |
JMenuItem menuItem; |
2 |
26 Feb 07 |
jari |
825 |
|
2 |
26 Feb 07 |
jari |
826 |
if (this.geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
827 |
menuItem = new JMenuItem("Store gene cluster...", GUIFactory.getIcon("new16.gif")); |
2 |
26 Feb 07 |
jari |
828 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
829 |
menuItem.setActionCommand(STORE_GENE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
830 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
831 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
832 |
|
2 |
26 Feb 07 |
jari |
833 |
menuItem = new JMenuItem("Launch new session with selected genes", GUIFactory.getIcon("launch_new_mav.gif")); |
2 |
26 Feb 07 |
jari |
834 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
835 |
menuItem.setActionCommand(LAUNCH_NEW_GENE_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
836 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
837 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
838 |
|
2 |
26 Feb 07 |
jari |
839 |
menuItem = new JMenuItem("Save gene cluster...", GUIFactory.getIcon("save16.gif")); |
2 |
26 Feb 07 |
jari |
840 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
841 |
menuItem.setActionCommand(SAVE_GENE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
842 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
843 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
844 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
845 |
|
2 |
26 Feb 07 |
jari |
846 |
menuItem = new JMenuItem("Store sample cluster...", GUIFactory.getIcon("new16.gif")); |
2 |
26 Feb 07 |
jari |
847 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
848 |
menuItem.setActionCommand(STORE_EXPT_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
849 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
850 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
851 |
|
2 |
26 Feb 07 |
jari |
852 |
menuItem = new JMenuItem("Launch new session with selected samples", GUIFactory.getIcon("launch_new_mav.gif")); |
2 |
26 Feb 07 |
jari |
853 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
854 |
menuItem.setActionCommand(LAUNCH_NEW_EXPT_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
855 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
856 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
857 |
|
2 |
26 Feb 07 |
jari |
858 |
menuItem = new JMenuItem("Save sample cluster...", GUIFactory.getIcon("save16.gif")); |
2 |
26 Feb 07 |
jari |
859 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
860 |
menuItem.setActionCommand(SAVE_EXPT_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
861 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
862 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
//menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
864 |
} |
2 |
26 Feb 07 |
jari |
865 |
else { |
2 |
26 Feb 07 |
jari |
866 |
menuItem = new JMenuItem("Store cluster...", GUIFactory.getIcon("new16.gif")); |
2 |
26 Feb 07 |
jari |
867 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
868 |
menuItem.setActionCommand(STORE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
869 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
870 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
871 |
|
2 |
26 Feb 07 |
jari |
872 |
menuItem = new JMenuItem("Launch new session", GUIFactory.getIcon("launch_new_mav.gif")); |
2 |
26 Feb 07 |
jari |
873 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
874 |
menuItem.setActionCommand(LAUNCH_NEW_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
875 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
876 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
877 |
|
2 |
26 Feb 07 |
jari |
878 |
menuItem = new JMenuItem("Save cluster...", GUIFactory.getIcon("save16.gif")); |
2 |
26 Feb 07 |
jari |
879 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
880 |
menuItem.setActionCommand(SAVE_CMD); |
2 |
26 Feb 07 |
jari |
881 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
882 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
//menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
884 |
} |
2 |
26 Feb 07 |
jari |
885 |
if ((this.geneOrExpt == COAGUI.EXPTS)|| (this.geneOrExpt == COAGUI.BOTH)) { |
2 |
26 Feb 07 |
jari |
886 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
887 |
menuItem = new JCheckBoxMenuItem("Show sample names"); |
2 |
26 Feb 07 |
jari |
888 |
menuItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
889 |
menuItem.setActionCommand(DISPLAY_EXPT_NAMES_CMD); |
2 |
26 Feb 07 |
jari |
890 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
891 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
892 |
} |
2 |
26 Feb 07 |
jari |
893 |
|
2 |
26 Feb 07 |
jari |
894 |
if ((this.geneOrExpt == COAGUI.EXPTS)|| (this.geneOrExpt == COAGUI.GENES)) { |
2 |
26 Feb 07 |
jari |
895 |
menuItem = new JCheckBoxMenuItem("Larger point size"); |
2 |
26 Feb 07 |
jari |
896 |
menuItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
897 |
menuItem.setActionCommand(SHOW_LARGER_POINTS_CMD); |
2 |
26 Feb 07 |
jari |
898 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
899 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
900 |
} |
2 |
26 Feb 07 |
jari |
901 |
|
2 |
26 Feb 07 |
jari |
902 |
menuItem = new JCheckBoxMenuItem("Show tick marks and labels"); |
2 |
26 Feb 07 |
jari |
903 |
menuItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
904 |
menuItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
905 |
menuItem.setActionCommand(SHOW_TICK_LABELS_CMD); |
2 |
26 Feb 07 |
jari |
906 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
907 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
908 |
} |
2 |
26 Feb 07 |
jari |
909 |
|
2 |
26 Feb 07 |
jari |
910 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a menu item by specified action command. |
2 |
26 Feb 07 |
jari |
912 |
*/ |
2 |
26 Feb 07 |
jari |
913 |
private JMenuItem getJMenuItem(String command) { |
2 |
26 Feb 07 |
jari |
914 |
JMenuItem item; |
2 |
26 Feb 07 |
jari |
915 |
Component[] components = popup.getComponents(); |
2 |
26 Feb 07 |
jari |
916 |
for (int i=0; i<components.length; i++) { |
2 |
26 Feb 07 |
jari |
917 |
if (components[i] instanceof JMenuItem) { |
2 |
26 Feb 07 |
jari |
918 |
if (((JMenuItem)components[i]).getActionCommand().equals(command)) |
2 |
26 Feb 07 |
jari |
919 |
return(JMenuItem)components[i]; |
2 |
26 Feb 07 |
jari |
920 |
} |
2 |
26 Feb 07 |
jari |
921 |
} |
2 |
26 Feb 07 |
jari |
922 |
return null; |
2 |
26 Feb 07 |
jari |
923 |
} |
2 |
26 Feb 07 |
jari |
924 |
|
2 |
26 Feb 07 |
jari |
925 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a menu item state. |
2 |
26 Feb 07 |
jari |
927 |
*/ |
2 |
26 Feb 07 |
jari |
928 |
private void setEnableMenuItem(String command, boolean enable) { |
2 |
26 Feb 07 |
jari |
929 |
JMenuItem item = getJMenuItem(command); |
2 |
26 Feb 07 |
jari |
930 |
if (item == null) { |
2 |
26 Feb 07 |
jari |
931 |
return; |
2 |
26 Feb 07 |
jari |
932 |
} |
2 |
26 Feb 07 |
jari |
933 |
item.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
934 |
} |
2 |
26 Feb 07 |
jari |
935 |
|
2 |
26 Feb 07 |
jari |
936 |
/** |
2 |
26 Feb 07 |
jari |
* Saves selected genes. |
2 |
26 Feb 07 |
jari |
938 |
*/ |
2 |
26 Feb 07 |
jari |
939 |
private void onSave() { |
2 |
26 Feb 07 |
jari |
940 |
try { |
2 |
26 Feb 07 |
jari |
941 |
if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
942 |
ExperimentUtil.saveExperiment(frame, experiment, data, getSelectedPoints()); |
2 |
26 Feb 07 |
jari |
943 |
else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
944 |
ExperimentUtil.saveExperimentCluster(frame, experiment, data, getSelectedPoints()); |
2 |
26 Feb 07 |
jari |
945 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
946 |
JOptionPane.showMessageDialog(frame, "Can not save matrix!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
947 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
948 |
} |
2 |
26 Feb 07 |
jari |
949 |
} |
2 |
26 Feb 07 |
jari |
950 |
|
2 |
26 Feb 07 |
jari |
951 |
private void onSaveGenesFromBoth() { |
2 |
26 Feb 07 |
jari |
952 |
try { |
2 |
26 Feb 07 |
jari |
953 |
ExperimentUtil.saveExperiment(frame, experiment, data, getSelectedGenesFromBoth()); |
2 |
26 Feb 07 |
jari |
954 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
955 |
JOptionPane.showMessageDialog(frame, "Can not save matrix!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
956 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
957 |
} |
2 |
26 Feb 07 |
jari |
958 |
} |
2 |
26 Feb 07 |
jari |
959 |
|
2 |
26 Feb 07 |
jari |
960 |
private void onSaveExptsFromBoth() { |
2 |
26 Feb 07 |
jari |
961 |
try { |
2 |
26 Feb 07 |
jari |
962 |
ExperimentUtil.saveExperimentCluster(frame, experiment, data, getSelectedExptsFromBoth()); |
2 |
26 Feb 07 |
jari |
963 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
964 |
JOptionPane.showMessageDialog(frame, "Can not save matrix!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
965 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
966 |
} |
2 |
26 Feb 07 |
jari |
967 |
} |
2 |
26 Feb 07 |
jari |
968 |
|
2 |
26 Feb 07 |
jari |
969 |
/** |
2 |
26 Feb 07 |
jari |
* Stores the selected cluster |
2 |
26 Feb 07 |
jari |
971 |
*/ |
2 |
26 Feb 07 |
jari |
972 |
private void storeCluster(){ |
2 |
26 Feb 07 |
jari |
973 |
if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
974 |
framework.storeSubCluster(getSelectedPoints(), experiment, Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
975 |
else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
976 |
framework.storeSubCluster(getSelectedPoints(), experiment, Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
//content.setSelection(false); |
2 |
26 Feb 07 |
jari |
//onHideSelection(); |
2 |
26 Feb 07 |
jari |
979 |
this.onDataChanged(this.data); |
2 |
26 Feb 07 |
jari |
980 |
this.repaint(); |
2 |
26 Feb 07 |
jari |
//content.updateScene(); |
2 |
26 Feb 07 |
jari |
982 |
} |
2 |
26 Feb 07 |
jari |
983 |
|
2 |
26 Feb 07 |
jari |
984 |
private void storeGeneClusterFromBoth() { |
2 |
26 Feb 07 |
jari |
985 |
framework.storeSubCluster(getSelectedGenesFromBoth(), experiment, Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
//content.setSelection(false); |
2 |
26 Feb 07 |
jari |
//onHideSelection(); |
2 |
26 Feb 07 |
jari |
988 |
this.onDataChanged(this.data); |
2 |
26 Feb 07 |
jari |
989 |
this.repaint(); |
2 |
26 Feb 07 |
jari |
//content.updateScene(); |
2 |
26 Feb 07 |
jari |
991 |
} |
2 |
26 Feb 07 |
jari |
992 |
|
2 |
26 Feb 07 |
jari |
993 |
private void storeExptClusterFromBoth() { |
2 |
26 Feb 07 |
jari |
994 |
framework.storeSubCluster(getSelectedExptsFromBoth(), experiment, Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
//content.setSelection(false); |
2 |
26 Feb 07 |
jari |
//onHideSelection(); |
2 |
26 Feb 07 |
jari |
997 |
this.onDataChanged(this.data); |
2 |
26 Feb 07 |
jari |
998 |
this.repaint(); |
2 |
26 Feb 07 |
jari |
//content.updateScene(); |
2 |
26 Feb 07 |
jari |
1000 |
} |
2 |
26 Feb 07 |
jari |
1001 |
|
2 |
26 Feb 07 |
jari |
1002 |
/** |
2 |
26 Feb 07 |
jari |
* Launches a new MultipleArrayViewer using selected elements |
2 |
26 Feb 07 |
jari |
1004 |
*/ |
2 |
26 Feb 07 |
jari |
1005 |
private void launchNewSession(){ |
2 |
26 Feb 07 |
jari |
1006 |
if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
1007 |
framework.launchNewMAV(getSelectedPoints(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
1008 |
else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
1009 |
framework.launchNewMAV(getSelectedPoints(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
1010 |
} |
2 |
26 Feb 07 |
jari |
1011 |
|
2 |
26 Feb 07 |
jari |
1012 |
private void launchNewGeneSessionFromBoth() { |
2 |
26 Feb 07 |
jari |
1013 |
framework.launchNewMAV(getSelectedGenesFromBoth(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
1014 |
} |
2 |
26 Feb 07 |
jari |
1015 |
|
2 |
26 Feb 07 |
jari |
1016 |
private void launchNewExptSessionFromBoth() { |
2 |
26 Feb 07 |
jari |
1017 |
framework.launchNewMAV(getSelectedExptsFromBoth(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
1018 |
} |
2 |
26 Feb 07 |
jari |
1019 |
|
2 |
26 Feb 07 |
jari |
1020 |
/** |
2 |
26 Feb 07 |
jari |
* Handles the selection box state. |
2 |
26 Feb 07 |
jari |
1022 |
*/ |
2 |
26 Feb 07 |
jari |
1023 |
private void onShowSelection() { |
2 |
26 Feb 07 |
jari |
1024 |
if ((geneOrExpt == COAGUI.GENES) || (geneOrExpt == COAGUI.EXPTS)) { |
2 |
26 Feb 07 |
jari |
1025 |
JMenuItem saveClusterItem = getJMenuItem(SAVE_CMD); |
2 |
26 Feb 07 |
jari |
1026 |
JMenuItem storeClusterItem = getJMenuItem(STORE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
1027 |
JMenuItem launchNewItem = getJMenuItem(LAUNCH_NEW_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
1028 |
if (!ellipse.isEmpty()) { |
2 |
26 Feb 07 |
jari |
//content.setSelection(true); |
2 |
26 Feb 07 |
jari |
//content.setSelectionBox(!hideBoxItem.isSelected()); |
2 |
26 Feb 07 |
jari |
//selectionAreaItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1032 |
saveClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
//hideBoxItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1034 |
storeClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1035 |
launchNewItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1036 |
} else { |
2 |
26 Feb 07 |
jari |
//content.setSelection(false); |
2 |
26 Feb 07 |
jari |
//content.setSelectionBox(false); |
2 |
26 Feb 07 |
jari |
//selectionAreaItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1040 |
saveClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//hideBoxItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1042 |
storeClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1043 |
launchNewItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1044 |
} |
2 |
26 Feb 07 |
jari |
1045 |
} else { |
2 |
26 Feb 07 |
jari |
1046 |
JMenuItem saveGeneClusterItem = getJMenuItem(SAVE_GENE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
1047 |
JMenuItem storeGeneClusterItem = getJMenuItem(STORE_GENE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
1048 |
JMenuItem launchNewGeneItem = getJMenuItem(LAUNCH_NEW_GENE_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
1049 |
JMenuItem saveExptClusterItem = getJMenuItem(SAVE_EXPT_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
1050 |
JMenuItem storeExptClusterItem = getJMenuItem(STORE_EXPT_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
1051 |
JMenuItem launchNewExptItem = getJMenuItem(LAUNCH_NEW_EXPT_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
1052 |
if (!ellipse.isEmpty()) { |
2 |
26 Feb 07 |
jari |
//content.setSelection(true); |
2 |
26 Feb 07 |
jari |
//content.setSelectionBox(!hideBoxItem.isSelected()); |
2 |
26 Feb 07 |
jari |
//selectionAreaItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1056 |
saveGeneClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1057 |
saveExptClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
//hideBoxItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1059 |
storeGeneClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1060 |
storeExptClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1061 |
launchNewGeneItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1062 |
launchNewExptItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1063 |
} else { |
2 |
26 Feb 07 |
jari |
//content.setSelection(false); |
2 |
26 Feb 07 |
jari |
//content.setSelectionBox(false); |
2 |
26 Feb 07 |
jari |
//selectionAreaItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1067 |
saveGeneClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1068 |
saveExptClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//hideBoxItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1070 |
storeGeneClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1071 |
storeExptClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1072 |
launchNewGeneItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1073 |
launchNewExptItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1074 |
} |
2 |
26 Feb 07 |
jari |
1075 |
} |
2 |
26 Feb 07 |
jari |
//content.updateScene(); |
2 |
26 Feb 07 |
jari |
1077 |
} |
2 |
26 Feb 07 |
jari |
1078 |
|
2 |
26 Feb 07 |
jari |
1079 |
private void showExptNames() { |
2 |
26 Feb 07 |
jari |
1080 |
displayExptNames = !(displayExptNames); |
2 |
26 Feb 07 |
jari |
1081 |
this.repaint(); |
2 |
26 Feb 07 |
jari |
1082 |
} |
2 |
26 Feb 07 |
jari |
1083 |
|
2 |
26 Feb 07 |
jari |
1084 |
private void displayLargePoints() { |
2 |
26 Feb 07 |
jari |
1085 |
showLargePoints = !(showLargePoints); |
2 |
26 Feb 07 |
jari |
1086 |
this.repaint(); |
2 |
26 Feb 07 |
jari |
1087 |
} |
2 |
26 Feb 07 |
jari |
1088 |
|
2 |
26 Feb 07 |
jari |
1089 |
private void displayTickLabels() { |
2 |
26 Feb 07 |
jari |
1090 |
showTickLabels = !(showTickLabels); |
2 |
26 Feb 07 |
jari |
1091 |
this.repaint(); |
2 |
26 Feb 07 |
jari |
1092 |
} |
2 |
26 Feb 07 |
jari |
1093 |
|
2 |
26 Feb 07 |
jari |
1094 |
/** |
2 |
26 Feb 07 |
jari |
* The listener to listen to menu items events. |
2 |
26 Feb 07 |
jari |
1096 |
*/ |
2 |
26 Feb 07 |
jari |
1097 |
private class Listener extends MouseAdapter implements ActionListener { |
2 |
26 Feb 07 |
jari |
1098 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
1099 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
1100 |
if (command.equals(SAVE_GENE_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
1101 |
onSaveGenesFromBoth(); |
2 |
26 Feb 07 |
jari |
1102 |
} else if (command.equals(SAVE_EXPT_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
1103 |
onSaveExptsFromBoth(); |
2 |
26 Feb 07 |
jari |
1104 |
} else if (command.equals(SAVE_CMD)) { |
2 |
26 Feb 07 |
jari |
1105 |
onSave(); |
2 |
26 Feb 07 |
jari |
1106 |
} else if (command.equals(STORE_CLUSTER_CMD)){ |
2 |
26 Feb 07 |
jari |
1107 |
storeCluster(); |
2 |
26 Feb 07 |
jari |
1108 |
} else if (command.equals(STORE_GENE_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
1109 |
storeGeneClusterFromBoth(); |
2 |
26 Feb 07 |
jari |
1110 |
} else if (command.equals(STORE_EXPT_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
1111 |
storeExptClusterFromBoth(); |
2 |
26 Feb 07 |
jari |
1112 |
} else if (command.equals(LAUNCH_NEW_SESSION_CMD)){ |
2 |
26 Feb 07 |
jari |
1113 |
launchNewSession(); |
2 |
26 Feb 07 |
jari |
1114 |
} else if (command.equals(LAUNCH_NEW_GENE_SESSION_CMD)) { |
2 |
26 Feb 07 |
jari |
1115 |
launchNewGeneSessionFromBoth(); |
2 |
26 Feb 07 |
jari |
1116 |
} else if (command.equals(LAUNCH_NEW_EXPT_SESSION_CMD)) { |
2 |
26 Feb 07 |
jari |
1117 |
launchNewExptSessionFromBoth(); |
2 |
26 Feb 07 |
jari |
1118 |
} else if (command.equals(DISPLAY_EXPT_NAMES_CMD)) { |
2 |
26 Feb 07 |
jari |
1119 |
showExptNames(); |
2 |
26 Feb 07 |
jari |
1120 |
} else if (command.equals(SHOW_LARGER_POINTS_CMD)) { |
2 |
26 Feb 07 |
jari |
1121 |
displayLargePoints(); |
2 |
26 Feb 07 |
jari |
1122 |
} else if (command.equals(SHOW_TICK_LABELS_CMD)) { |
2 |
26 Feb 07 |
jari |
1123 |
displayTickLabels(); |
2 |
26 Feb 07 |
jari |
1124 |
} |
2 |
26 Feb 07 |
jari |
1125 |
} |
2 |
26 Feb 07 |
jari |
1126 |
} |
2 |
26 Feb 07 |
jari |
1127 |
|
2 |
26 Feb 07 |
jari |
1128 |
|
2 |
26 Feb 07 |
jari |
1129 |
|
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 |
1132 |
*/ |
2 |
26 Feb 07 |
jari |
1133 |
public int getExperimentID() { |
2 |
26 Feb 07 |
jari |
1134 |
return exptID; |
2 |
26 Feb 07 |
jari |
1135 |
} |
2 |
26 Feb 07 |
jari |
1136 |
|
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 |
1139 |
*/ |
2 |
26 Feb 07 |
jari |
1140 |
public void setExperimentID(int id) { |
2 |
26 Feb 07 |
jari |
1141 |
this.exptID = id; |
2 |
26 Feb 07 |
jari |
1142 |
} |
2 |
26 Feb 07 |
jari |
1143 |
|
2 |
26 Feb 07 |
jari |
1144 |
} |