2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, 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 |
* $RCSfile: GDMGeneSpotInfoDisplay.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.3 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2005/03/10 20:22:01 $ |
2 |
26 Feb 07 |
jari |
* $Author: braistedj $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev.cluster.gui.impl.gdm; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Toolkit; |
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.KeyEvent; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
25 |
|
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JTextPane; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.ScrollPaneConstants; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.graph.GC; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.graph.GraphLine; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.graph.GraphPoint; |
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.graph.GraphTick; |
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.graph.GraphViewer; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
42 |
import org.tigr.util.awt.ActionInfoDialog; |
2 |
26 Feb 07 |
jari |
43 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
public class GDMGeneSpotInfoDisplay extends ActionInfoDialog { |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
private int colIndex; |
2 |
26 Feb 07 |
jari |
48 |
private int rowIndex; |
2 |
26 Feb 07 |
jari |
49 |
private int colNumber; |
2 |
26 Feb 07 |
jari |
50 |
private int rowNumber; |
2 |
26 Feb 07 |
jari |
51 |
private FloatMatrix geneDistMatrix; |
2 |
26 Feb 07 |
jari |
52 |
private FloatMatrix rawMatrix; |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
private int LINEAR = 0; // to return just ratio |
2 |
26 Feb 07 |
jari |
55 |
private int LOG = 1; //for log2(ratio) |
2 |
26 Feb 07 |
jari |
56 |
private String distanceMetric; |
2 |
26 Feb 07 |
jari |
57 |
private int vectorSize=0; |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
private int rowMissingValues=0; |
2 |
26 Feb 07 |
jari |
60 |
private int colMissingValues=0; |
2 |
26 Feb 07 |
jari |
61 |
private int distanceBasedOn=0; |
2 |
26 Feb 07 |
jari |
62 |
private IData expData; |
2 |
26 Feb 07 |
jari |
63 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
64 |
private Color rowGeneColor; |
2 |
26 Feb 07 |
jari |
65 |
private Color columnGeneColor; |
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
public static Color zeroColor = Color.black; |
2 |
26 Feb 07 |
jari |
68 |
public static Color NaNColor = Color.gray; |
2 |
26 Feb 07 |
jari |
69 |
public static Color diagColor = Color.white; |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
private boolean haveColor = true; |
2 |
26 Feb 07 |
jari |
72 |
FloatMatrix data; |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
public GDMGeneSpotInfoDisplay(JFrame parent, Experiment experiment, IData expData, FloatMatrix gdMatrix, |
2 |
26 Feb 07 |
jari |
75 |
FloatMatrix rawMatrix, String distMetric, int colIndex, int rowIndex, int column, int row) { |
2 |
26 Feb 07 |
jari |
76 |
super(parent, false); |
2 |
26 Feb 07 |
jari |
77 |
this.expData = expData; |
2 |
26 Feb 07 |
jari |
78 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
79 |
data = this.experiment.getMatrix(); |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
this.geneDistMatrix = gdMatrix; |
2 |
26 Feb 07 |
jari |
82 |
this.rawMatrix = rawMatrix; |
2 |
26 Feb 07 |
jari |
83 |
this.colIndex = colIndex; |
2 |
26 Feb 07 |
jari |
84 |
this.rowIndex = rowIndex; |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
this.colNumber = column; |
2 |
26 Feb 07 |
jari |
87 |
this.rowNumber = row; |
2 |
26 Feb 07 |
jari |
88 |
this.distanceMetric = distMetric; |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
this.vectorSize = this.expData.getFeaturesCount(); |
2 |
26 Feb 07 |
jari |
91 |
|
2 |
26 Feb 07 |
jari |
92 |
this.rowGeneColor = expData.getProbeColor(experiment.getGeneIndexMappedToData(rowIndex)); |
2 |
26 Feb 07 |
jari |
93 |
this.columnGeneColor = expData.getProbeColor(experiment.getGeneIndexMappedToData(colIndex)); |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
if(this.rowGeneColor == null && this.columnGeneColor == null) |
2 |
26 Feb 07 |
jari |
96 |
this.haveColor = false; |
2 |
26 Feb 07 |
jari |
97 |
else{ |
2 |
26 Feb 07 |
jari |
98 |
if(this.rowGeneColor == null) |
2 |
26 Feb 07 |
jari |
99 |
this.rowGeneColor = new Color(Integer.parseInt("FFFFCC",16)); |
2 |
26 Feb 07 |
jari |
100 |
if(this.columnGeneColor == null) |
2 |
26 Feb 07 |
jari |
101 |
this.columnGeneColor = new Color(Integer.parseInt("FFFFCC",16)); |
2 |
26 Feb 07 |
jari |
102 |
} |
2 |
26 Feb 07 |
jari |
103 |
|
2 |
26 Feb 07 |
jari |
104 |
this.setValues(colIndex, rowIndex); |
2 |
26 Feb 07 |
jari |
105 |
init(); |
2 |
26 Feb 07 |
jari |
106 |
} |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
private void init(){ |
2 |
26 Feb 07 |
jari |
109 |
|
2 |
26 Feb 07 |
jari |
110 |
Font infoDisplayFont = new Font("monospaced", Font.PLAIN, 10); |
2 |
26 Feb 07 |
jari |
111 |
JLabel spotImage = new JLabel(GUIFactory.getIcon("spot.gif")); |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
114 |
|
2 |
26 Feb 07 |
jari |
115 |
JTextPane infoDisplayTextPane = new JTextPane(); |
2 |
26 Feb 07 |
jari |
116 |
infoDisplayTextPane.setContentType("text/html"); |
2 |
26 Feb 07 |
jari |
117 |
infoDisplayTextPane.setFont(infoDisplayFont); |
2 |
26 Feb 07 |
jari |
118 |
infoDisplayTextPane.setEditable(false); |
2 |
26 Feb 07 |
jari |
119 |
infoDisplayTextPane.setBackground(new Color(Integer.parseInt("FFFFCC",16))); |
2 |
26 Feb 07 |
jari |
120 |
infoDisplayTextPane.setMargin(new Insets(10,15,10,10)); |
2 |
26 Feb 07 |
jari |
121 |
infoDisplayTextPane.setText(createMessage()); |
2 |
26 Feb 07 |
jari |
122 |
infoDisplayTextPane.setCaretPosition(0); |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
infoDisplayTextPane.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
125 |
JButton closeButton = new JButton("Close"); |
2 |
26 Feb 07 |
jari |
126 |
closeButton.setActionCommand("close"); |
2 |
26 Feb 07 |
jari |
127 |
closeButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
128 |
closeButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
129 |
JButton graphButton = new JButton("Expression Graph"); |
2 |
26 Feb 07 |
jari |
130 |
graphButton.setActionCommand("show-graph-command"); |
2 |
26 Feb 07 |
jari |
131 |
graphButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
132 |
graphButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
contentPane.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
135 |
JScrollPane scrollPane = new JScrollPane(infoDisplayTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
2 |
26 Feb 07 |
jari |
136 |
scrollPane.getViewport().setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
137 |
scrollPane.getVerticalScrollBar().setValues(0, 10, 0, 100); |
2 |
26 Feb 07 |
jari |
138 |
|
2 |
26 Feb 07 |
jari |
139 |
GBA gba = new GBA(); |
2 |
26 Feb 07 |
jari |
140 |
gba.add(contentPane, scrollPane, 0, 0, 3, 2, 1, 1, GBA.B, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
141 |
|
2 |
26 Feb 07 |
jari |
142 |
gba.add(contentPane, graphButton, 0, 3, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
143 |
gba.add(contentPane, closeButton, 1, 3, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
// gba.add(contentPane, spotImage, 2, 3, 1, 1, 0, 0, GBA.NONE, GBA.E, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
145 |
|
2 |
26 Feb 07 |
jari |
146 |
pack(); |
2 |
26 Feb 07 |
jari |
147 |
setSize(550, 600); |
2 |
26 Feb 07 |
jari |
148 |
setResizable(true); |
2 |
26 Feb 07 |
jari |
149 |
setTitle("Gene Distance Spot Information"); |
2 |
26 Feb 07 |
jari |
150 |
setLocation(400, 100); |
2 |
26 Feb 07 |
jari |
151 |
show(); |
2 |
26 Feb 07 |
jari |
152 |
} |
2 |
26 Feb 07 |
jari |
153 |
|
2 |
26 Feb 07 |
jari |
154 |
private String createMessage(){ |
2 |
26 Feb 07 |
jari |
155 |
int stringLength = 0; |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
int colTrueRow = expData.getProbeRow(0,this.colNumber); // eCol.getRow(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
158 |
int colTrueColumn = expData.getProbeColumn(0,this.colNumber);//= eCol.getColumn(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
160 |
int rowTrueRow = expData.getProbeRow(0,this.rowNumber); // eRow.getRow(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
161 |
int rowTrueColumn = expData.getProbeColumn(0,this.rowNumber);//eRow.getColumn(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
162 |
|
2 |
26 Feb 07 |
jari |
163 |
String[] fieldNames = expData.getFieldNames(); |
2 |
26 Feb 07 |
jari |
164 |
int num_fields = fieldNames.length; |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
int displayRowNum = this.rowNumber + 1; |
2 |
26 Feb 07 |
jari |
167 |
int displayColNum = this.colNumber + 1; |
2 |
26 Feb 07 |
jari |
168 |
|
2 |
26 Feb 07 |
jari |
169 |
String colColor= ""; |
2 |
26 Feb 07 |
jari |
170 |
String rowColor= ""; |
2 |
26 Feb 07 |
jari |
171 |
if(haveColor){ |
2 |
26 Feb 07 |
jari |
172 |
colColor = '#' + (Integer.toHexString(columnGeneColor.getRGB())).substring(2, 8); |
2 |
26 Feb 07 |
jari |
173 |
rowColor = '#' + (Integer.toHexString(rowGeneColor.getRGB())).substring(2, 8); |
2 |
26 Feb 07 |
jari |
174 |
} |
2 |
26 Feb 07 |
jari |
175 |
|
2 |
26 Feb 07 |
jari |
176 |
String message = "<h3>Annotation</h3>"; |
2 |
26 Feb 07 |
jari |
177 |
message += "<table border=2 cellpadding=4 valign=top>" + |
2 |
26 Feb 07 |
jari |
178 |
"<tr><td valign=top></td><td align=top><b>Column Gene</b></td><td align=top><b>Row Gene</b></td></tr>" + |
2 |
26 Feb 07 |
jari |
179 |
"<tr><td valign=top><b>Row</b></td><td valign=top>" + colTrueRow + "</td><td valign=top>" + rowTrueRow + "</td></tr>" + |
2 |
26 Feb 07 |
jari |
180 |
"<tr><td valign=top><b>Column</b></td><td valign=top>" + colTrueColumn + "</td><td valign=top>" + rowTrueColumn + "</td></tr>"; |
2 |
26 Feb 07 |
jari |
181 |
if(haveColor) |
2 |
26 Feb 07 |
jari |
182 |
message += "<tr><td valign=top><b>Gene Color</b></td><td valign=top bgcolor=" + colColor +"></td><td valign=top bgcolor=" + rowColor + "></td></tr>" ; |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
184 |
for (int i = 0; i < num_fields; i++) { |
2 |
26 Feb 07 |
jari |
185 |
message += "<tr><td valign=top><b>" + fieldNames[i] + "</b></td><td valign=top>" + expData.getElementAttribute(experiment.getGeneIndexMappedToData(colIndex), i) + "</td><td valign=top>" + expData.getElementAttribute(experiment.getGeneIndexMappedToData(rowIndex), i) + "</td></tr>"; |
2 |
26 Feb 07 |
jari |
186 |
} |
2 |
26 Feb 07 |
jari |
187 |
message += "</table>"; |
2 |
26 Feb 07 |
jari |
188 |
|
2 |
26 Feb 07 |
jari |
189 |
message += "<h3>Distance Information</h3>" + |
2 |
26 Feb 07 |
jari |
190 |
"<table border=2 cellpadding=4 valign=top>" + |
2 |
26 Feb 07 |
jari |
191 |
"<tr><td valign=top><b>GDM Matrix Row</b></td><td valign=top>" + displayRowNum + "</td></tr>" + |
2 |
26 Feb 07 |
jari |
192 |
"<tr><td valign=top><b>GDM Matrix Column</b></td><td valign=top>" + displayColNum + "</td></tr>" + |
2 |
26 Feb 07 |
jari |
193 |
"<tr><td valign=top><b>Scaled Gene Distance</b></td><td valign=top><b>" + geneDistMatrix.get(colIndex, rowIndex) + "<b></td></tr>" + |
2 |
26 Feb 07 |
jari |
194 |
"<tr><td valign=top><b>Actual Gene Distance</b></td><td valign=top><b>" + rawMatrix.get(colIndex, rowIndex) + "<b></td></tr>" + |
2 |
26 Feb 07 |
jari |
195 |
"<tr><td valign=top><b>Distance Metric</b></td><td valign=top>" + distanceMetric + "</td></tr>" + |
2 |
26 Feb 07 |
jari |
196 |
"<tr><td valign=top><b>Vector Size</b></td><td valign=top>" + this.vectorSize + "</td></tr>" + |
2 |
26 Feb 07 |
jari |
197 |
"<tr><td valign=top><b>Missing Values</b></td><td valign=top>" + colMissingValues + ", " + rowMissingValues + "</td></tr>"+ |
2 |
26 Feb 07 |
jari |
198 |
"<tr><td valign=top><b>Distance Based on</b></td><td valign=top>" + this.distanceBasedOn + "</td></tr>"; |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
return message; |
2 |
26 Feb 07 |
jari |
201 |
} |
2 |
26 Feb 07 |
jari |
202 |
|
2 |
26 Feb 07 |
jari |
203 |
public void createGeneGraph() { |
2 |
26 Feb 07 |
jari |
204 |
JFrame graphFrame; |
2 |
26 Feb 07 |
jari |
205 |
GraphViewer graph; |
2 |
26 Feb 07 |
jari |
206 |
GraphPoint gp; |
2 |
26 Feb 07 |
jari |
207 |
GraphLine gl; |
2 |
26 Feb 07 |
jari |
208 |
GraphTick gt; |
2 |
26 Feb 07 |
jari |
209 |
|
2 |
26 Feb 07 |
jari |
//accumulate data |
2 |
26 Feb 07 |
jari |
211 |
float [] rowData = this.data.A[rowIndex]; |
2 |
26 Feb 07 |
jari |
212 |
float [] colData = this.data.A[colIndex]; |
2 |
26 Feb 07 |
jari |
213 |
float rowMin = Float.POSITIVE_INFINITY; |
2 |
26 Feb 07 |
jari |
214 |
float rowMax = Float.NEGATIVE_INFINITY; |
2 |
26 Feb 07 |
jari |
215 |
float colMin = Float.POSITIVE_INFINITY; |
2 |
26 Feb 07 |
jari |
216 |
float colMax = Float.NEGATIVE_INFINITY; |
2 |
26 Feb 07 |
jari |
217 |
int numberOfExp = this.data.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
218 |
float val; |
2 |
26 Feb 07 |
jari |
//get min and max |
2 |
26 Feb 07 |
jari |
220 |
for (int i = 0; i < numberOfExp; i++) { |
2 |
26 Feb 07 |
jari |
221 |
if(!Float.isNaN(rowData[i])){ |
2 |
26 Feb 07 |
jari |
222 |
if(rowData[i] < rowMin) |
2 |
26 Feb 07 |
jari |
223 |
rowMin = rowData[i]; |
2 |
26 Feb 07 |
jari |
224 |
if(rowData[i] > rowMax) |
2 |
26 Feb 07 |
jari |
225 |
rowMax = rowData[i]; |
2 |
26 Feb 07 |
jari |
226 |
} |
2 |
26 Feb 07 |
jari |
227 |
if(!Float.isNaN(colData[i])){ |
2 |
26 Feb 07 |
jari |
228 |
if(colData[i] < colMin) |
2 |
26 Feb 07 |
jari |
229 |
colMin = colData[i]; |
2 |
26 Feb 07 |
jari |
230 |
if(colData[i] > colMax) |
2 |
26 Feb 07 |
jari |
231 |
colMax = colData[i]; |
2 |
26 Feb 07 |
jari |
232 |
} |
2 |
26 Feb 07 |
jari |
233 |
} |
2 |
26 Feb 07 |
jari |
234 |
|
2 |
26 Feb 07 |
jari |
235 |
rowMin = Math.min(rowMin, colMin); |
2 |
26 Feb 07 |
jari |
236 |
rowMax = Math.max(rowMax, colMax); //use new row values for limits |
2 |
26 Feb 07 |
jari |
237 |
rowMin = (int)(rowMin - 1); //extend the bounds |
2 |
26 Feb 07 |
jari |
238 |
rowMax = (int)(rowMax +1); |
2 |
26 Feb 07 |
jari |
239 |
if(rowMin > 0) |
2 |
26 Feb 07 |
jari |
240 |
rowMin = 0; |
2 |
26 Feb 07 |
jari |
241 |
if(rowMax < 0) |
2 |
26 Feb 07 |
jari |
242 |
rowMax = 0; |
2 |
26 Feb 07 |
jari |
243 |
|
2 |
26 Feb 07 |
jari |
244 |
graphFrame = new JFrame("Samples vs. Log Ratio"); |
2 |
26 Feb 07 |
jari |
245 |
graph = new GraphViewer(graphFrame, 0, 500, 0, 500, 1, numberOfExp, rowMin, rowMax, 100, 100, 100, 100, "Sample vs. Log Ratio", "Sample Name", "Log2 (Cy5 / Cy3)"); |
2 |
26 Feb 07 |
jari |
246 |
graph.setSubTitle("(red line = row gene, blue line = column gene)"); |
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
graph.setXAxisValue(0); |
2 |
26 Feb 07 |
jari |
249 |
graph.setYAxisValue(1); |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
251 |
|
2 |
26 Feb 07 |
jari |
//Add yellow grid lines |
2 |
26 Feb 07 |
jari |
253 |
for (int i = 1; i <= numberOfExp; i++) { |
2 |
26 Feb 07 |
jari |
254 |
gl = new GraphLine(i, rowMin, i, rowMax, Color.yellow); |
2 |
26 Feb 07 |
jari |
255 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
256 |
} |
2 |
26 Feb 07 |
jari |
257 |
for (int i = (int)rowMin; i <= rowMax; i++) { |
2 |
26 Feb 07 |
jari |
258 |
if (i != 0) { |
2 |
26 Feb 07 |
jari |
259 |
gl = new GraphLine(1, i, numberOfExp, i, Color.yellow); |
2 |
26 Feb 07 |
jari |
260 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
261 |
} |
2 |
26 Feb 07 |
jari |
262 |
} |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
//add graph lines |
2 |
26 Feb 07 |
jari |
265 |
for (int i = 0; i < numberOfExp - 1; i++) { |
2 |
26 Feb 07 |
jari |
266 |
if(!Float.isNaN(rowData[i]) && !Float.isNaN(rowData[i+1])) { |
2 |
26 Feb 07 |
jari |
267 |
gl = new GraphLine(i+1, rowData[i], i+2, rowData[i+1],Color.red); |
2 |
26 Feb 07 |
jari |
268 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
269 |
} |
2 |
26 Feb 07 |
jari |
270 |
if(!Float.isNaN(colData[i]) && !Float.isNaN(colData[i+1])) { |
2 |
26 Feb 07 |
jari |
271 |
gl = new GraphLine(i+1, colData[i], i+2, colData[i+1],Color.blue); |
2 |
26 Feb 07 |
jari |
272 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
273 |
} |
2 |
26 Feb 07 |
jari |
274 |
} |
2 |
26 Feb 07 |
jari |
275 |
|
2 |
26 Feb 07 |
jari |
//add graph points |
2 |
26 Feb 07 |
jari |
277 |
for (int i = 0; i < numberOfExp; i++) { |
2 |
26 Feb 07 |
jari |
278 |
if(!Float.isNaN(rowData[i])){ |
2 |
26 Feb 07 |
jari |
279 |
gp = new GraphPoint(i+1, rowData[i], Color.blue, 3); |
2 |
26 Feb 07 |
jari |
280 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
281 |
} |
2 |
26 Feb 07 |
jari |
282 |
if(!Float.isNaN(colData[i])){ |
2 |
26 Feb 07 |
jari |
283 |
gp = new GraphPoint(i+1, colData[i], Color.red, 3); |
2 |
26 Feb 07 |
jari |
284 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
285 |
} |
2 |
26 Feb 07 |
jari |
286 |
} |
2 |
26 Feb 07 |
jari |
287 |
|
2 |
26 Feb 07 |
jari |
288 |
for (int i = (int)rowMin; i <= rowMax; i++) { |
2 |
26 Feb 07 |
jari |
289 |
if (i == 0) gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "0", Color.black); |
2 |
26 Feb 07 |
jari |
//else gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "2.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
291 |
else gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "" + i, Color.black); |
2 |
26 Feb 07 |
jari |
292 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
293 |
} |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
295 |
for (int i = 1; i <= numberOfExp; i++) { |
2 |
26 Feb 07 |
jari |
296 |
gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, expData.getSampleName(i - 1), Color.black); |
2 |
26 Feb 07 |
jari |
297 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
298 |
} |
2 |
26 Feb 07 |
jari |
299 |
|
2 |
26 Feb 07 |
jari |
300 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
301 |
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); |
2 |
26 Feb 07 |
jari |
302 |
Dimension d = toolkit.getScreenSize(); |
2 |
26 Feb 07 |
jari |
303 |
graphFrame.setLocation((int)(d.getWidth()/2-250), (int)(d.getHeight()/2-250)); |
2 |
26 Feb 07 |
jari |
304 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
305 |
} |
2 |
26 Feb 07 |
jari |
306 |
|
2 |
26 Feb 07 |
jari |
307 |
private void setValues(int colIndex, int rowIndex) { |
2 |
26 Feb 07 |
jari |
308 |
int columns = experiment.getNumberOfSamples(); |
2 |
26 Feb 07 |
jari |
309 |
boolean [] rowMissingVector = new boolean[columns]; |
2 |
26 Feb 07 |
jari |
310 |
boolean [] colMissingVector = new boolean[columns]; |
2 |
26 Feb 07 |
jari |
311 |
|
2 |
26 Feb 07 |
jari |
312 |
for( int column=0; column< columns; column++) { |
2 |
26 Feb 07 |
jari |
313 |
rowMissingVector[column] = false; |
2 |
26 Feb 07 |
jari |
314 |
colMissingVector[column] = false; |
2 |
26 Feb 07 |
jari |
315 |
} |
2 |
26 Feb 07 |
jari |
316 |
|
2 |
26 Feb 07 |
jari |
317 |
for (int column = 0; column < columns; column++) { |
2 |
26 Feb 07 |
jari |
318 |
float value = experiment.get(rowIndex, column); |
2 |
26 Feb 07 |
jari |
319 |
if (Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
320 |
rowMissingVector[column] = true; |
2 |
26 Feb 07 |
jari |
321 |
this.rowMissingValues ++; |
2 |
26 Feb 07 |
jari |
322 |
} |
2 |
26 Feb 07 |
jari |
323 |
} |
2 |
26 Feb 07 |
jari |
324 |
|
2 |
26 Feb 07 |
jari |
325 |
for (int column = 0; column < columns; column++) { |
2 |
26 Feb 07 |
jari |
326 |
float value = experiment.get(colIndex, column); |
2 |
26 Feb 07 |
jari |
327 |
if (Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
328 |
colMissingVector[column] = true; |
2 |
26 Feb 07 |
jari |
329 |
this.colMissingValues ++; |
2 |
26 Feb 07 |
jari |
330 |
} |
2 |
26 Feb 07 |
jari |
331 |
} |
2 |
26 Feb 07 |
jari |
332 |
|
2 |
26 Feb 07 |
jari |
333 |
for(int column =0; column<columns; column++) { |
2 |
26 Feb 07 |
jari |
334 |
if ((rowMissingVector[column] == false) && (colMissingVector[column] == false) && (rowIndex != colIndex)) { |
2 |
26 Feb 07 |
jari |
335 |
this.distanceBasedOn++; |
2 |
26 Feb 07 |
jari |
336 |
} |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
|
2 |
26 Feb 07 |
jari |
340 |
private void drawGeneColor() { |
2 |
26 Feb 07 |
jari |
341 |
|
2 |
26 Feb 07 |
jari |
342 |
Graphics g = getGraphics(); |
2 |
26 Feb 07 |
jari |
343 |
|
2 |
26 Feb 07 |
jari |
344 |
if (g != null ){ |
2 |
26 Feb 07 |
jari |
345 |
g.setColor(rowGeneColor); |
2 |
26 Feb 07 |
jari |
346 |
g.fillRect(0, 0, 10, 10); |
2 |
26 Feb 07 |
jari |
347 |
|
2 |
26 Feb 07 |
jari |
348 |
g.setColor(columnGeneColor); |
2 |
26 Feb 07 |
jari |
349 |
g.fillRect(20, 0, 10, 10); |
2 |
26 Feb 07 |
jari |
350 |
} |
2 |
26 Feb 07 |
jari |
351 |
} |
2 |
26 Feb 07 |
jari |
352 |
|
2 |
26 Feb 07 |
jari |
353 |
class EventListener implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
354 |
|
2 |
26 Feb 07 |
jari |
355 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
356 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
357 |
if (command.equals("close")) { |
2 |
26 Feb 07 |
jari |
358 |
dispose(); |
2 |
26 Feb 07 |
jari |
359 |
} else if (command.equals("show-graph-command")){ |
2 |
26 Feb 07 |
jari |
360 |
createGeneGraph(); |
2 |
26 Feb 07 |
jari |
361 |
} |
2 |
26 Feb 07 |
jari |
362 |
} |
2 |
26 Feb 07 |
jari |
363 |
|
2 |
26 Feb 07 |
jari |
364 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
365 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
366 |
dispose(); |
2 |
26 Feb 07 |
jari |
367 |
} |
2 |
26 Feb 07 |
jari |
368 |
} |
2 |
26 Feb 07 |
jari |
369 |
|
2 |
26 Feb 07 |
jari |
370 |
public void keyReleased(KeyEvent event) {} |
2 |
26 Feb 07 |
jari |
371 |
public void keyTyped(KeyEvent event) {} |
2 |
26 Feb 07 |
jari |
372 |
} |
2 |
26 Feb 07 |
jari |
373 |
} |