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 |
* $RCSfile: ExperimentClusterHeader.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.7 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/05/02 16:56:57 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
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.helpers; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.FontMetrics; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.RenderingHints; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
23 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
24 |
import java.io.ObjectInputStream; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.ObjectOutputStream; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
29 |
|
2 |
26 Feb 07 |
jari |
30 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
public class ExperimentClusterHeader extends JPanel implements IExperimentHeader{ |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
private static final int RECT_HEIGHT = 15; |
2 |
26 Feb 07 |
jari |
37 |
private static final int COLOR_BAR_HEIGHT = 10; |
2 |
26 Feb 07 |
jari |
38 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
39 |
private IData data; |
2 |
26 Feb 07 |
jari |
40 |
private int[][] samplesOrder; |
2 |
26 Feb 07 |
jari |
41 |
private int elementWidth; |
2 |
26 Feb 07 |
jari |
42 |
private boolean isAntiAliasing = true; |
2 |
26 Feb 07 |
jari |
43 |
private float maxValue = 3f; |
2 |
26 Feb 07 |
jari |
44 |
private float minValue = -3f; |
2 |
26 Feb 07 |
jari |
45 |
private float midValue = 0.0f; |
2 |
26 Feb 07 |
jari |
46 |
int clusterIndex = 0; |
2 |
26 Feb 07 |
jari |
47 |
private String centroidName; |
2 |
26 Feb 07 |
jari |
48 |
private boolean hasCentroid; |
2 |
26 Feb 07 |
jari |
49 |
|
2 |
26 Feb 07 |
jari |
50 |
private BufferedImage negColorImage; |
2 |
26 Feb 07 |
jari |
51 |
private BufferedImage posColorImage; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
private Insets insets = new Insets(0, 10, 0, 0); |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
private boolean useDoubleGradient = true; |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
public static String[] getPersistenceDelegateArgs(){ |
2 |
26 Feb 07 |
jari |
// return new String[]{"samplesOrder", "centroidName", "elementWidth", "hasCentroid", "insets"}; |
2 |
26 Feb 07 |
jari |
59 |
return new String[]{"experiment", "samplesOrder"}; |
2 |
26 Feb 07 |
jari |
60 |
} |
2 |
26 Feb 07 |
jari |
61 |
public String getCentroidName() {return centroidName;} |
2 |
26 Feb 07 |
jari |
62 |
public int[][] getSamplesOrder() {return samplesOrder;} |
2 |
26 Feb 07 |
jari |
63 |
public int getElementWidth() {return elementWidth;} |
2 |
26 Feb 07 |
jari |
64 |
public boolean getHasCentroid() {return hasCentroid;} |
2 |
26 Feb 07 |
jari |
65 |
public Insets getInsets() {return insets;} |
2 |
26 Feb 07 |
jari |
66 |
public void setExperiment(Experiment e) { |
2 |
26 Feb 07 |
jari |
67 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
68 |
} |
2 |
26 Feb 07 |
jari |
69 |
public ExperimentClusterHeader(int[][] samplesOrder, String centroidName, int elementWidth, boolean hasCentroid, Insets insets){ |
2 |
26 Feb 07 |
jari |
70 |
this(null, samplesOrder, centroidName); |
2 |
26 Feb 07 |
jari |
71 |
this.elementWidth = elementWidth; |
2 |
26 Feb 07 |
jari |
72 |
this.hasCentroid = hasCentroid; |
2 |
26 Feb 07 |
jari |
73 |
this.insets = insets; |
2 |
26 Feb 07 |
jari |
74 |
} |
2 |
26 Feb 07 |
jari |
75 |
/** |
2 |
26 Feb 07 |
jari |
* Construct an <code>ExperimentClusterHeader</code> with specified experiment |
2 |
26 Feb 07 |
jari |
* and samples order. |
2 |
26 Feb 07 |
jari |
78 |
*/ |
2 |
26 Feb 07 |
jari |
79 |
public ExperimentClusterHeader(Experiment experiment, int[] samplesOrder) { |
2 |
26 Feb 07 |
jari |
80 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
81 |
this.samplesOrder = new int[1][]; |
2 |
26 Feb 07 |
jari |
82 |
this.samplesOrder[0] = samplesOrder; |
2 |
26 Feb 07 |
jari |
83 |
this.hasCentroid = false; |
2 |
26 Feb 07 |
jari |
84 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
85 |
} |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
87 |
/** |
2 |
26 Feb 07 |
jari |
* Construct an <code>ExperimentClusterHeader</code> with specified experiment |
2 |
26 Feb 07 |
jari |
* and samples order. |
2 |
26 Feb 07 |
jari |
90 |
*/ |
2 |
26 Feb 07 |
jari |
91 |
public ExperimentClusterHeader(Experiment experiment, int[][] samplesOrder) { |
2 |
26 Feb 07 |
jari |
92 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
93 |
this.samplesOrder = samplesOrder; |
2 |
26 Feb 07 |
jari |
94 |
this.hasCentroid = false; |
2 |
26 Feb 07 |
jari |
95 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
96 |
} |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
/** |
2 |
26 Feb 07 |
jari |
* Construct an <code>ExperimentClusterHeader</code> with specified experiment |
2 |
26 Feb 07 |
jari |
* and samples order. |
2 |
26 Feb 07 |
jari |
102 |
*/ |
2 |
26 Feb 07 |
jari |
103 |
public ExperimentClusterHeader(Experiment experiment, int[][] samplesOrder, String centroidName) { |
2 |
26 Feb 07 |
jari |
104 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
105 |
this.samplesOrder = samplesOrder; |
2 |
26 Feb 07 |
jari |
106 |
this.centroidName = centroidName; |
2 |
26 Feb 07 |
jari |
107 |
this.hasCentroid = true; |
2 |
26 Feb 07 |
jari |
108 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a component to be inserted into scroll pane view port. |
2 |
26 Feb 07 |
jari |
112 |
*/ |
2 |
26 Feb 07 |
jari |
113 |
public JComponent getContentComponent(){ |
2 |
26 Feb 07 |
jari |
114 |
return this; |
2 |
26 Feb 07 |
jari |
115 |
} |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
/** |
2 |
26 Feb 07 |
jari |
* Sets data. |
2 |
26 Feb 07 |
jari |
119 |
*/ |
2 |
26 Feb 07 |
jari |
120 |
public void setData(IData data) { |
2 |
26 Feb 07 |
jari |
121 |
this.data = data; |
2 |
26 Feb 07 |
jari |
122 |
} |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
public void setClusterIndex(int index){ |
2 |
26 Feb 07 |
jari |
125 |
this.clusterIndex = index; |
2 |
26 Feb 07 |
jari |
126 |
} |
2 |
26 Feb 07 |
jari |
127 |
|
2 |
26 Feb 07 |
jari |
128 |
public void setUseDoubleGradient(boolean useDouble) { |
2 |
26 Feb 07 |
jari |
129 |
useDoubleGradient = useDouble; |
2 |
26 Feb 07 |
jari |
130 |
} |
2 |
26 Feb 07 |
jari |
131 |
|
2 |
26 Feb 07 |
jari |
132 |
/** |
2 |
26 Feb 07 |
jari |
* Sets max and min experiment values. |
2 |
26 Feb 07 |
jari |
134 |
*/ |
2 |
26 Feb 07 |
jari |
135 |
public void setValues(float minValue, float midValue, float maxValue) { |
2 |
26 Feb 07 |
jari |
136 |
this.maxValue = maxValue; |
2 |
26 Feb 07 |
jari |
137 |
this.minValue = minValue; |
2 |
26 Feb 07 |
jari |
138 |
this.midValue = midValue; |
2 |
26 Feb 07 |
jari |
139 |
} |
2 |
26 Feb 07 |
jari |
140 |
|
2 |
26 Feb 07 |
jari |
141 |
/** |
2 |
26 Feb 07 |
jari |
* Sets max and min experiment values. |
2 |
26 Feb 07 |
jari |
143 |
*/ |
2 |
26 Feb 07 |
jari |
144 |
public void setValues(float minValue, float maxValue) { |
2 |
26 Feb 07 |
jari |
145 |
this.maxValue = maxValue; |
2 |
26 Feb 07 |
jari |
146 |
this.minValue = minValue; |
2 |
26 Feb 07 |
jari |
147 |
} |
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
/** |
2 |
26 Feb 07 |
jari |
* Sets positive and negative images |
2 |
26 Feb 07 |
jari |
151 |
*/ |
2 |
26 Feb 07 |
jari |
152 |
public void setNegAndPosColorImages(BufferedImage neg, BufferedImage pos){ |
2 |
26 Feb 07 |
jari |
153 |
this.negColorImage = neg; |
2 |
26 Feb 07 |
jari |
154 |
this.posColorImage = pos; |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
/** |
2 |
26 Feb 07 |
jari |
* Sets anti-aliasing property. |
2 |
26 Feb 07 |
jari |
159 |
*/ |
2 |
26 Feb 07 |
jari |
160 |
public void setAntiAliasing(boolean isAntiAliasing) { |
2 |
26 Feb 07 |
jari |
161 |
this.isAntiAliasing = isAntiAliasing; |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
/** |
2 |
26 Feb 07 |
jari |
* Sets an element width. |
2 |
26 Feb 07 |
jari |
166 |
*/ |
2 |
26 Feb 07 |
jari |
167 |
private void setElementWidth(int width) { |
2 |
26 Feb 07 |
jari |
168 |
this.elementWidth = width; |
2 |
26 Feb 07 |
jari |
169 |
if (width > 12) { |
2 |
26 Feb 07 |
jari |
170 |
width = 12; |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
setFont(new Font("monospaced", Font.PLAIN, width)); |
2 |
26 Feb 07 |
jari |
173 |
} |
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the left margin for the header |
2 |
26 Feb 07 |
jari |
177 |
*/ |
2 |
26 Feb 07 |
jari |
178 |
public void setLeftInset(int leftMargin){ |
2 |
26 Feb 07 |
jari |
179 |
insets.left = leftMargin; |
2 |
26 Feb 07 |
jari |
180 |
} |
2 |
26 Feb 07 |
jari |
181 |
|
2 |
26 Feb 07 |
jari |
182 |
/** |
2 |
26 Feb 07 |
jari |
* Updates size of this header. |
2 |
26 Feb 07 |
jari |
184 |
*/ |
2 |
26 Feb 07 |
jari |
185 |
public void updateSizes(int contentWidth, int elementWidth) { |
2 |
26 Feb 07 |
jari |
186 |
setElementWidth(elementWidth); |
2 |
26 Feb 07 |
jari |
187 |
Graphics2D g = (Graphics2D)getGraphics(); |
2 |
26 Feb 07 |
jari |
188 |
if (g == null) { |
2 |
26 Feb 07 |
jari |
189 |
return; |
2 |
26 Feb 07 |
jari |
190 |
} |
2 |
26 Feb 07 |
jari |
191 |
if (isAntiAliasing) { |
2 |
26 Feb 07 |
jari |
192 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF); |
2 |
26 Feb 07 |
jari |
193 |
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
194 |
} |
2 |
26 Feb 07 |
jari |
195 |
FontMetrics hfm = g.getFontMetrics(); |
2 |
26 Feb 07 |
jari |
196 |
int maxHeight = 0; |
2 |
26 Feb 07 |
jari |
197 |
String name; |
2 |
26 Feb 07 |
jari |
198 |
|
2 |
26 Feb 07 |
jari |
199 |
final int size = this.samplesOrder[clusterIndex].length; |
2 |
26 Feb 07 |
jari |
200 |
|
2 |
26 Feb 07 |
jari |
201 |
for (int feature = 0; feature < size; feature++) { |
2 |
26 Feb 07 |
jari |
202 |
name = data.getSampleName(experiment.getSampleIndex(samplesOrder[clusterIndex][feature])); |
2 |
26 Feb 07 |
jari |
203 |
maxHeight = Math.max(maxHeight, hfm.stringWidth(name)); |
2 |
26 Feb 07 |
jari |
204 |
} |
2 |
26 Feb 07 |
jari |
205 |
if(hasCentroid) |
2 |
26 Feb 07 |
jari |
206 |
maxHeight = Math.max(maxHeight, hfm.stringWidth(this.centroidName)); |
2 |
26 Feb 07 |
jari |
207 |
|
2 |
26 Feb 07 |
jari |
208 |
maxHeight += RECT_HEIGHT + hfm.getHeight() + 10; |
2 |
26 Feb 07 |
jari |
209 |
maxHeight += getColorBarHeight(); |
2 |
26 Feb 07 |
jari |
210 |
if(!hasCentroid){ |
2 |
26 Feb 07 |
jari |
211 |
setSize(contentWidth, maxHeight); |
2 |
26 Feb 07 |
jari |
212 |
setPreferredSize(new Dimension(contentWidth, maxHeight)); |
2 |
26 Feb 07 |
jari |
213 |
} |
2 |
26 Feb 07 |
jari |
214 |
else{ |
2 |
26 Feb 07 |
jari |
215 |
setSize(contentWidth, maxHeight); |
2 |
26 Feb 07 |
jari |
216 |
setPreferredSize(new Dimension(contentWidth, maxHeight)); |
2 |
26 Feb 07 |
jari |
217 |
} |
2 |
26 Feb 07 |
jari |
218 |
|
2 |
26 Feb 07 |
jari |
219 |
} |
2 |
26 Feb 07 |
jari |
220 |
|
2 |
26 Feb 07 |
jari |
221 |
/** |
2 |
26 Feb 07 |
jari |
* Returns height of color bar for experiment clustering |
2 |
26 Feb 07 |
jari |
223 |
*/ |
2 |
26 Feb 07 |
jari |
224 |
private int getColorBarHeight(){ |
2 |
26 Feb 07 |
jari |
225 |
for( int sample = 0; sample < samplesOrder[clusterIndex].length ; sample++){ |
2 |
26 Feb 07 |
jari |
226 |
if(data.getExperimentColor(experiment.getSampleIndex(this.samplesOrder[clusterIndex][sample])) != null) |
2 |
26 Feb 07 |
jari |
227 |
return COLOR_BAR_HEIGHT; |
2 |
26 Feb 07 |
jari |
228 |
} |
2 |
26 Feb 07 |
jari |
229 |
return 0; |
2 |
26 Feb 07 |
jari |
230 |
} |
2 |
26 Feb 07 |
jari |
231 |
|
2 |
26 Feb 07 |
jari |
232 |
/** |
2 |
26 Feb 07 |
jari |
* Paints the header into specified graphics. |
2 |
26 Feb 07 |
jari |
234 |
*/ |
2 |
26 Feb 07 |
jari |
235 |
public void paint(Graphics g1D) { |
2 |
26 Feb 07 |
jari |
236 |
super.paint(g1D); |
2 |
26 Feb 07 |
jari |
237 |
if (data == null) { |
2 |
26 Feb 07 |
jari |
238 |
return; |
2 |
26 Feb 07 |
jari |
239 |
} |
2 |
26 Feb 07 |
jari |
240 |
Graphics2D g = (Graphics2D)g1D; |
2 |
26 Feb 07 |
jari |
241 |
if (isAntiAliasing) { |
2 |
26 Feb 07 |
jari |
242 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF); |
2 |
26 Feb 07 |
jari |
243 |
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
drawHeader(g); |
2 |
26 Feb 07 |
jari |
246 |
} |
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
/** |
2 |
26 Feb 07 |
jari |
* Draws the header into specified graphics. |
2 |
26 Feb 07 |
jari |
250 |
*/ |
2 |
26 Feb 07 |
jari |
251 |
private void drawHeader(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
252 |
final int samples = this.samplesOrder[clusterIndex].length; |
2 |
26 Feb 07 |
jari |
253 |
if (samples == 0) { |
2 |
26 Feb 07 |
jari |
254 |
return; |
2 |
26 Feb 07 |
jari |
255 |
} |
2 |
26 Feb 07 |
jari |
256 |
|
2 |
26 Feb 07 |
jari |
257 |
int width = samples*elementWidth; |
2 |
26 Feb 07 |
jari |
258 |
if(this.hasCentroid) |
2 |
26 Feb 07 |
jari |
259 |
width += this.elementWidth + 5; |
2 |
26 Feb 07 |
jari |
260 |
if(useDoubleGradient) { |
2 |
26 Feb 07 |
jari |
261 |
g.drawImage(this.negColorImage, insets.left, 0, (int)(width/2f), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
262 |
g.drawImage(this.posColorImage, (int)((width/2f)+insets.left), 0, (int)(width/2f), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
263 |
} else { |
2 |
26 Feb 07 |
jari |
264 |
g.drawImage(this.posColorImage, insets.left, 0, width, RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
265 |
} |
2 |
26 Feb 07 |
jari |
266 |
|
2 |
26 Feb 07 |
jari |
267 |
FontMetrics hfm = g.getFontMetrics(); |
2 |
26 Feb 07 |
jari |
268 |
int descent = hfm.getDescent(); |
2 |
26 Feb 07 |
jari |
269 |
int fHeight = hfm.getHeight(); |
2 |
26 Feb 07 |
jari |
270 |
g.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
271 |
|
2 |
26 Feb 07 |
jari |
272 |
int textWidth; |
2 |
26 Feb 07 |
jari |
273 |
g.drawString(String.valueOf(this.minValue), insets.left, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
274 |
textWidth = hfm.stringWidth(String.valueOf(midValue)); |
2 |
26 Feb 07 |
jari |
275 |
if(useDoubleGradient) |
2 |
26 Feb 07 |
jari |
276 |
g.drawString(String.valueOf(midValue), (int)((width+insets.left)/2f)-textWidth/2, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
277 |
textWidth = hfm.stringWidth(String.valueOf(this.maxValue)); |
2 |
26 Feb 07 |
jari |
278 |
g.drawString(String.valueOf(this.maxValue), (width-textWidth)+insets.left, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
279 |
|
2 |
26 Feb 07 |
jari |
// draw feature names |
2 |
26 Feb 07 |
jari |
281 |
g.rotate(-Math.PI/2); |
2 |
26 Feb 07 |
jari |
282 |
String name; |
2 |
26 Feb 07 |
jari |
283 |
int h = -getSize().height + 5; |
2 |
26 Feb 07 |
jari |
284 |
boolean hasColorBar = false; |
2 |
26 Feb 07 |
jari |
285 |
int centroidNameOffset = 0; |
2 |
26 Feb 07 |
jari |
286 |
|
2 |
26 Feb 07 |
jari |
287 |
if(this.getColorBarHeight() > 0){ |
2 |
26 Feb 07 |
jari |
288 |
h += COLOR_BAR_HEIGHT; |
2 |
26 Feb 07 |
jari |
289 |
hasColorBar = true; |
2 |
26 Feb 07 |
jari |
290 |
} |
2 |
26 Feb 07 |
jari |
291 |
|
2 |
26 Feb 07 |
jari |
292 |
if(this.hasCentroid){ |
2 |
26 Feb 07 |
jari |
293 |
centroidNameOffset = elementWidth + 5; |
2 |
26 Feb 07 |
jari |
294 |
g.drawString(this.centroidName, h, descent + elementWidth/2 + insets.left); |
2 |
26 Feb 07 |
jari |
295 |
} |
2 |
26 Feb 07 |
jari |
296 |
|
2 |
26 Feb 07 |
jari |
297 |
for (int sample = 0; sample < samples; sample++) { |
2 |
26 Feb 07 |
jari |
298 |
name = data.getSampleName(experiment.getSampleIndex(this.samplesOrder[clusterIndex][sample])); |
2 |
26 Feb 07 |
jari |
299 |
g.drawString(name, h, descent + elementWidth*sample + elementWidth/2 + insets.left + centroidNameOffset); |
2 |
26 Feb 07 |
jari |
300 |
} |
2 |
26 Feb 07 |
jari |
301 |
g.rotate(Math.PI/2); |
2 |
26 Feb 07 |
jari |
302 |
if(hasColorBar){ |
2 |
26 Feb 07 |
jari |
303 |
Color color; |
2 |
26 Feb 07 |
jari |
304 |
for(int sample = 0; sample < samples; sample++){ |
2 |
26 Feb 07 |
jari |
305 |
color = data.getExperimentColor(experiment.getSampleIndex(this.samplesOrder[clusterIndex][sample])); |
2 |
26 Feb 07 |
jari |
306 |
if(color != null) |
2 |
26 Feb 07 |
jari |
307 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
308 |
else |
2 |
26 Feb 07 |
jari |
309 |
g.setColor(Color.white); |
2 |
26 Feb 07 |
jari |
310 |
g.fillRect(sample*elementWidth + insets.left + centroidNameOffset, getSize().height - COLOR_BAR_HEIGHT - 2, elementWidth, COLOR_BAR_HEIGHT); |
2 |
26 Feb 07 |
jari |
311 |
} |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
} |
2 |
26 Feb 07 |
jari |
314 |
/* |
2 |
26 Feb 07 |
jari |
private void writeObject(ObjectOutputStream oos) throws IOException { |
2 |
26 Feb 07 |
jari |
oos.writeObject(experiment); |
2 |
26 Feb 07 |
jari |
oos.writeObject(samplesOrder); |
2 |
26 Feb 07 |
jari |
oos.writeInt(elementWidth); |
2 |
26 Feb 07 |
jari |
oos.writeObject(insets); |
2 |
26 Feb 07 |
jari |
oos.writeBoolean(this.hasCentroid); |
2 |
26 Feb 07 |
jari |
if(this.hasCentroid){ |
2 |
26 Feb 07 |
jari |
oos.writeObject(this.centroidName); |
2 |
26 Feb 07 |
jari |
323 |
} |
2 |
26 Feb 07 |
jari |
324 |
} |
2 |
26 Feb 07 |
jari |
325 |
|
2 |
26 Feb 07 |
jari |
326 |
|
2 |
26 Feb 07 |
jari |
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { |
2 |
26 Feb 07 |
jari |
experiment = (Experiment)ois.readObject(); |
2 |
26 Feb 07 |
jari |
samplesOrder = (int[][])ois.readObject(); |
2 |
26 Feb 07 |
jari |
elementWidth = ois.readInt(); |
2 |
26 Feb 07 |
jari |
insets = (Insets)ois.readObject(); |
2 |
26 Feb 07 |
jari |
if(ois.readBoolean()){ |
2 |
26 Feb 07 |
jari |
this.hasCentroid = true; |
2 |
26 Feb 07 |
jari |
this.centroidName = (String)ois.readObject(); |
2 |
26 Feb 07 |
jari |
335 |
} |
2 |
26 Feb 07 |
jari |
336 |
} |
2 |
26 Feb 07 |
jari |
337 |
*/ |
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
|