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: MultipleArrayCanvas.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.10 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/03/24 15:49:44 $ |
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; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.AlphaComposite; |
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.FontMetrics; |
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.Insets; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.Rectangle; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.RenderingHints; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
26 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
27 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
28 |
import java.awt.event.MouseMotionListener; |
2 |
26 Feb 07 |
jari |
29 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
30 |
import java.awt.event.WindowListener; |
2 |
26 Feb 07 |
jari |
31 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
32 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.Action; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JMenu; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JRadioButtonMenuItem; |
2 |
26 Feb 07 |
jari |
43 |
|
2 |
26 Feb 07 |
jari |
44 |
import org.tigr.microarray.mev.MultipleArrayData; |
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.microarray.mev.action.DefaultAction; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.microarray.mev.cluster.gui.IDisplayMenu; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
50 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
51 |
import org.tigr.microarray.util.SlideDataSorter; |
2 |
26 Feb 07 |
jari |
52 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
public class MultipleArrayCanvas extends JPanel implements IViewer { |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
private static final int TRACE_SPACE = 50; |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
//constants to match IDisplayMenu |
2 |
26 Feb 07 |
jari |
60 |
private static final int GREENRED = 2; |
2 |
26 Feb 07 |
jari |
61 |
private static final int OVERLAY = 3; |
2 |
26 Feb 07 |
jari |
62 |
private static final int RATIOSPLIT = 4; |
2 |
26 Feb 07 |
jari |
63 |
|
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
private MultipleArrayHeader header; |
2 |
26 Feb 07 |
jari |
66 |
private Thumbnail thumbnail; |
2 |
26 Feb 07 |
jari |
67 |
private boolean isShowThumbnail = false; |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
private IFramework framework; |
2 |
26 Feb 07 |
jari |
70 |
private IData data; |
2 |
26 Feb 07 |
jari |
71 |
private Insets insets; |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
private int maxLabelWidth = 0; |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
// display options |
2 |
26 Feb 07 |
jari |
76 |
private boolean useDoubleGradient = true; |
2 |
26 Feb 07 |
jari |
77 |
private int paletteStyle = RATIOSPLIT; |
2 |
26 Feb 07 |
jari |
78 |
private boolean isGRScale = true; |
2 |
26 Feb 07 |
jari |
79 |
private boolean isDrawBorders; |
2 |
26 Feb 07 |
jari |
80 |
private boolean isTracing; |
2 |
26 Feb 07 |
jari |
81 |
private boolean isAntiAliasing = true; |
2 |
26 Feb 07 |
jari |
82 |
private Dimension elementSize = new Dimension(); |
2 |
26 Feb 07 |
jari |
83 |
private int labelIndex = -1; |
2 |
26 Feb 07 |
jari |
// chain members |
2 |
26 Feb 07 |
jari |
85 |
private boolean drawChain = false; |
2 |
26 Feb 07 |
jari |
86 |
private int[] chain; // probe indices |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
//micro array parameters |
2 |
26 Feb 07 |
jari |
89 |
private int features; |
2 |
26 Feb 07 |
jari |
90 |
private int probes; |
2 |
26 Feb 07 |
jari |
91 |
private float maxCY3; |
2 |
26 Feb 07 |
jari |
92 |
private float maxCY5; |
2 |
26 Feb 07 |
jari |
93 |
private float maxRatio; |
2 |
26 Feb 07 |
jari |
94 |
private float minRatio; |
2 |
26 Feb 07 |
jari |
95 |
private float midRatio; |
2 |
26 Feb 07 |
jari |
96 |
|
2 |
26 Feb 07 |
jari |
97 |
public static Color missingColor = Color.gray; |
2 |
26 Feb 07 |
jari |
98 |
private BufferedImage negColorImage; |
2 |
26 Feb 07 |
jari |
99 |
private BufferedImage posColorImage; |
2 |
26 Feb 07 |
jari |
100 |
private int xOffset = 10; |
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
private JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
103 |
private JMenu sortMenu; |
2 |
26 Feb 07 |
jari |
104 |
private ButtonGroup sortGroup; |
2 |
26 Feb 07 |
jari |
105 |
private Listener listener; |
2 |
26 Feb 07 |
jari |
106 |
private boolean oneValueData; |
2 |
26 Feb 07 |
jari |
107 |
private JRadioButtonMenuItem expressionBarItem; |
2 |
26 Feb 07 |
jari |
108 |
private JRadioButtonMenuItem overlayItem; |
2 |
26 Feb 07 |
jari |
109 |
private JCheckBoxMenuItem absoluteColorCheckBoxItem; |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
public MultipleArrayCanvas() { |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
} |
2 |
26 Feb 07 |
jari |
114 |
|
2 |
26 Feb 07 |
jari |
115 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>MultipleArrayCanvas</code> with specified |
2 |
26 Feb 07 |
jari |
* reference to a framework and insets. |
2 |
26 Feb 07 |
jari |
118 |
*/ |
2 |
26 Feb 07 |
jari |
119 |
public MultipleArrayCanvas(IFramework framework, Insets insets) { |
2 |
26 Feb 07 |
jari |
120 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
121 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
122 |
this.insets = insets; |
2 |
26 Feb 07 |
jari |
123 |
header = new MultipleArrayHeader(insets, TRACE_SPACE); |
2 |
26 Feb 07 |
jari |
124 |
listener = new Listener(); |
2 |
26 Feb 07 |
jari |
125 |
addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
126 |
addMouseMotionListener(listener); |
2 |
26 Feb 07 |
jari |
127 |
addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
128 |
this.thumbnail = new Thumbnail(framework, listener); |
2 |
26 Feb 07 |
jari |
129 |
this.negColorImage = framework.getDisplayMenu().getNegativeGradientImage(); |
2 |
26 Feb 07 |
jari |
130 |
this.posColorImage = framework.getDisplayMenu().getPositiveGradientImage(); |
2 |
26 Feb 07 |
jari |
131 |
this.header.setNegativeAndPositiveColorImages(this.negColorImage, this.posColorImage); |
2 |
26 Feb 07 |
jari |
132 |
popup = createPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
133 |
} |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
/** |
2 |
26 Feb 07 |
jari |
* Overriden to have focus. (deprecated as of 1.4, use isFocusable() |
2 |
26 Feb 07 |
jari |
137 |
*/ |
2 |
26 Feb 07 |
jari |
138 |
|
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
140 |
/** |
2 |
26 Feb 07 |
jari |
* Overriden to have focus. |
2 |
26 Feb 07 |
jari |
142 |
*/ |
2 |
26 Feb 07 |
jari |
143 |
public boolean isFocusable() { |
2 |
26 Feb 07 |
jari |
144 |
return true; |
2 |
26 Feb 07 |
jari |
145 |
} |
2 |
26 Feb 07 |
jari |
146 |
|
2 |
26 Feb 07 |
jari |
147 |
/** |
2 |
26 Feb 07 |
jari |
* @return this component. |
2 |
26 Feb 07 |
jari |
149 |
*/ |
2 |
26 Feb 07 |
jari |
150 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
151 |
return this; |
2 |
26 Feb 07 |
jari |
152 |
} |
2 |
26 Feb 07 |
jari |
153 |
|
2 |
26 Feb 07 |
jari |
154 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the viewer header. |
2 |
26 Feb 07 |
jari |
156 |
*/ |
2 |
26 Feb 07 |
jari |
157 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
158 |
return header; |
2 |
26 Feb 07 |
jari |
159 |
} |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer when it has been selected. |
2 |
26 Feb 07 |
jari |
163 |
*/ |
2 |
26 Feb 07 |
jari |
164 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
165 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
166 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
168 |
if (data.getDataType() == IData.DATA_TYPE_RATIO_ONLY || data.getDataType() == IData.DATA_TYPE_AFFY_ABS){ |
2 |
26 Feb 07 |
jari |
169 |
expressionBarItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
170 |
overlayItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
IDisplayMenu menu = framework.getDisplayMenu(); |
2 |
26 Feb 07 |
jari |
174 |
useDoubleGradient = menu.getUseDoubleGradient(); |
2 |
26 Feb 07 |
jari |
175 |
header.setUseDoubleGradient(useDoubleGradient); |
2 |
26 Feb 07 |
jari |
176 |
this.maxCY3 = menu.getMaxCY3Scale(); |
2 |
26 Feb 07 |
jari |
177 |
this.maxCY5 = menu.getMaxCY5Scale(); |
2 |
26 Feb 07 |
jari |
178 |
this.maxRatio = menu.getMaxRatioScale(); |
2 |
26 Feb 07 |
jari |
179 |
this.minRatio = menu.getMinRatioScale(); |
2 |
26 Feb 07 |
jari |
180 |
this.midRatio = menu.getMidRatioValue(); |
2 |
26 Feb 07 |
jari |
181 |
this.header.setMinAndMaxAndMidRatios(this.minRatio, this.midRatio, this.maxRatio); |
2 |
26 Feb 07 |
jari |
182 |
header.setData(data); |
2 |
26 Feb 07 |
jari |
183 |
onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
184 |
onDataChanged(data); |
2 |
26 Feb 07 |
jari |
185 |
if (this.isShowThumbnail) { |
2 |
26 Feb 07 |
jari |
186 |
this.thumbnail.show(); |
2 |
26 Feb 07 |
jari |
187 |
} |
2 |
26 Feb 07 |
jari |
188 |
} |
2 |
26 Feb 07 |
jari |
189 |
|
2 |
26 Feb 07 |
jari |
190 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer when data is changed. |
2 |
26 Feb 07 |
jari |
192 |
*/ |
2 |
26 Feb 07 |
jari |
193 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
194 |
this.data = data; |
2 |
26 Feb 07 |
jari |
195 |
features = data.getFeaturesCount(); |
2 |
26 Feb 07 |
jari |
196 |
probes = data.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
197 |
setDrawChain(false); |
2 |
26 Feb 07 |
jari |
198 |
updateSize(); |
2 |
26 Feb 07 |
jari |
199 |
header.setData(data); |
2 |
26 Feb 07 |
jari |
// header.updateSize(); |
2 |
26 Feb 07 |
jari |
//header.setContentWidth(getSize().width); |
2 |
26 Feb 07 |
jari |
// header.updateSize(); |
2 |
26 Feb 07 |
jari |
203 |
thumbnail.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
204 |
} |
2 |
26 Feb 07 |
jari |
205 |
|
2 |
26 Feb 07 |
jari |
206 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer when the framework display menu is changed. |
2 |
26 Feb 07 |
jari |
208 |
*/ |
2 |
26 Feb 07 |
jari |
209 |
public void onMenuChanged(IDisplayMenu menu) { |
2 |
26 Feb 07 |
jari |
// paletteStyle = menu.getPaletteStyle(); |
2 |
26 Feb 07 |
jari |
// isGRScale = menu.isGRScale(); |
2 |
26 Feb 07 |
jari |
212 |
isDrawBorders = menu.isDrawingBorder(); |
2 |
26 Feb 07 |
jari |
// isTracing = menu.isTracing(); |
2 |
26 Feb 07 |
jari |
214 |
useDoubleGradient = menu.getUseDoubleGradient(); |
2 |
26 Feb 07 |
jari |
215 |
header.setUseDoubleGradient(useDoubleGradient); |
2 |
26 Feb 07 |
jari |
216 |
Dimension newSize = menu.getElementSize(); |
2 |
26 Feb 07 |
jari |
217 |
elementSize = new Dimension(newSize); |
2 |
26 Feb 07 |
jari |
218 |
this.maxCY3 = menu.getMaxCY3Scale(); |
2 |
26 Feb 07 |
jari |
219 |
this.maxCY5 = menu.getMaxCY5Scale(); |
2 |
26 Feb 07 |
jari |
220 |
this.maxRatio = menu.getMaxRatioScale(); |
2 |
26 Feb 07 |
jari |
221 |
this.minRatio = menu.getMinRatioScale(); |
2 |
26 Feb 07 |
jari |
222 |
this.midRatio = menu.getMidRatioValue(); |
2 |
26 Feb 07 |
jari |
223 |
this.header.setMinAndMaxAndMidRatios(this.minRatio, this.midRatio, this.maxRatio); |
2 |
26 Feb 07 |
jari |
224 |
this.negColorImage = menu.getNegativeGradientImage(); |
2 |
26 Feb 07 |
jari |
225 |
this.posColorImage = menu.getPositiveGradientImage(); |
2 |
26 Feb 07 |
jari |
226 |
this.header.setNegativeAndPositiveColorImages(this.negColorImage, this.posColorImage); |
2 |
26 Feb 07 |
jari |
227 |
updateSize(); //first set size of viewer |
2 |
26 Feb 07 |
jari |
228 |
isAntiAliasing = menu.isAntiAliasing(); |
2 |
26 Feb 07 |
jari |
229 |
labelIndex = menu.getLabelIndex(); |
2 |
26 Feb 07 |
jari |
230 |
setFont(new Font("monospaced", Font.BOLD, elementSize.height)); |
2 |
26 Feb 07 |
jari |
231 |
updateSize(); |
2 |
26 Feb 07 |
jari |
232 |
header.setTracing(isTracing); |
2 |
26 Feb 07 |
jari |
233 |
header.setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
234 |
this.thumbnail.onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
235 |
} |
2 |
26 Feb 07 |
jari |
236 |
|
2 |
26 Feb 07 |
jari |
237 |
/** |
2 |
26 Feb 07 |
jari |
* Hides a thumbnail when the viewer is deselected. |
2 |
26 Feb 07 |
jari |
239 |
*/ |
2 |
26 Feb 07 |
jari |
240 |
public void onDeselected() { |
2 |
26 Feb 07 |
jari |
241 |
this.thumbnail.hide(); |
2 |
26 Feb 07 |
jari |
242 |
} |
2 |
26 Feb 07 |
jari |
243 |
|
2 |
26 Feb 07 |
jari |
244 |
/** |
2 |
26 Feb 07 |
jari |
* Disposes a thumbnail when the framework is going to be closed. |
2 |
26 Feb 07 |
jari |
246 |
*/ |
2 |
26 Feb 07 |
jari |
247 |
public void onClosed() { |
2 |
26 Feb 07 |
jari |
248 |
this.thumbnail.dispose(); |
2 |
26 Feb 07 |
jari |
249 |
} |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
251 |
/** |
2 |
26 Feb 07 |
jari |
* Shows a thumbnail. |
2 |
26 Feb 07 |
jari |
253 |
*/ |
2 |
26 Feb 07 |
jari |
254 |
public void onShowThumbnail() { |
2 |
26 Feb 07 |
jari |
255 |
this.isShowThumbnail = true; |
2 |
26 Feb 07 |
jari |
256 |
this.thumbnail.show(); |
2 |
26 Feb 07 |
jari |
257 |
} |
2 |
26 Feb 07 |
jari |
258 |
|
2 |
26 Feb 07 |
jari |
259 |
/** |
2 |
26 Feb 07 |
jari |
* @return true if it's possible to show a thumbnail. |
2 |
26 Feb 07 |
jari |
261 |
*/ |
2 |
26 Feb 07 |
jari |
262 |
public boolean isThumbnailEnabled() { |
2 |
26 Feb 07 |
jari |
263 |
return this.data.getFeaturesCount() > 0; |
2 |
26 Feb 07 |
jari |
264 |
} |
2 |
26 Feb 07 |
jari |
265 |
|
2 |
26 Feb 07 |
jari |
266 |
/** |
2 |
26 Feb 07 |
jari |
* @return null. |
2 |
26 Feb 07 |
jari |
268 |
*/ |
2 |
26 Feb 07 |
jari |
269 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
270 |
return null; |
2 |
26 Feb 07 |
jari |
271 |
} |
2 |
26 Feb 07 |
jari |
272 |
|
2 |
26 Feb 07 |
jari |
273 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer size. |
2 |
26 Feb 07 |
jari |
275 |
*/ |
2 |
26 Feb 07 |
jari |
276 |
private void updateSize() { |
2 |
26 Feb 07 |
jari |
277 |
updateMaxLabelWidth(); |
2 |
26 Feb 07 |
jari |
278 |
int width = insets.left + getXSize() + insets.right + getMaxLabelWidth() + 20; |
2 |
26 Feb 07 |
jari |
279 |
int height = insets.top + getYSize() + insets.bottom; |
2 |
26 Feb 07 |
jari |
280 |
setSize(width, height); |
2 |
26 Feb 07 |
jari |
281 |
setPreferredSize(new Dimension(width, height)); |
2 |
26 Feb 07 |
jari |
282 |
this.header.setContentWidth(this.getSize().width); |
2 |
26 Feb 07 |
jari |
283 |
} |
2 |
26 Feb 07 |
jari |
284 |
|
2 |
26 Feb 07 |
jari |
285 |
/** |
2 |
26 Feb 07 |
jari |
* Paints the viewer content into specified graphics. |
2 |
26 Feb 07 |
jari |
287 |
*/ |
2 |
26 Feb 07 |
jari |
288 |
public void paint(Graphics g1D) { |
2 |
26 Feb 07 |
jari |
289 |
g1D.setColor(Color.white); |
2 |
26 Feb 07 |
jari |
290 |
super.paint(g1D); |
2 |
26 Feb 07 |
jari |
291 |
if(this.elementSize.getHeight() < 1) |
2 |
26 Feb 07 |
jari |
292 |
return; |
2 |
26 Feb 07 |
jari |
293 |
g1D.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
294 |
if (features == 0 || framework == null) { // empty data |
2 |
26 Feb 07 |
jari |
295 |
return; |
2 |
26 Feb 07 |
jari |
296 |
} |
2 |
26 Feb 07 |
jari |
297 |
Graphics2D g2D = (Graphics2D)g1D; |
2 |
26 Feb 07 |
jari |
298 |
if (isAntiAliasing) {//Anti-aliasing is on |
2 |
26 Feb 07 |
jari |
299 |
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
2 |
26 Feb 07 |
jari |
300 |
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
301 |
} |
2 |
26 Feb 07 |
jari |
302 |
drawColumns(g2D); |
2 |
26 Feb 07 |
jari |
303 |
} |
2 |
26 Feb 07 |
jari |
304 |
|
2 |
26 Feb 07 |
jari |
305 |
/** |
2 |
26 Feb 07 |
jari |
* Draws microarrays columns into a specified graphics. |
2 |
26 Feb 07 |
jari |
307 |
*/ |
2 |
26 Feb 07 |
jari |
308 |
private void drawColumns(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
309 |
|
2 |
26 Feb 07 |
jari |
310 |
Rectangle bounds = g.getClipBounds(); |
2 |
26 Feb 07 |
jari |
311 |
final int top = getTopIndex(bounds.y); |
2 |
26 Feb 07 |
jari |
312 |
final int bottom = getBottomIndex(bounds.y+bounds.height, probes); |
2 |
26 Feb 07 |
jari |
313 |
final int left = getLeftIndex(bounds.x); |
2 |
26 Feb 07 |
jari |
314 |
final int right = getRightIndex(bounds.x+bounds.width, features); |
2 |
26 Feb 07 |
jari |
315 |
|
2 |
26 Feb 07 |
jari |
316 |
for (int column = left; column < right; column++) { |
2 |
26 Feb 07 |
jari |
317 |
drawColumn(g, column, top, bottom); |
2 |
26 Feb 07 |
jari |
318 |
} |
2 |
26 Feb 07 |
jari |
319 |
if (isDrawChain()) { |
2 |
26 Feb 07 |
jari |
320 |
drawChain(g, Color.magenta, getChain(), left, right); |
2 |
26 Feb 07 |
jari |
321 |
} |
2 |
26 Feb 07 |
jari |
322 |
if ((right >= features) && (labelIndex >= 0)) { |
2 |
26 Feb 07 |
jari |
323 |
drawLabels(g, top, bottom); |
2 |
26 Feb 07 |
jari |
324 |
} |
2 |
26 Feb 07 |
jari |
325 |
} |
2 |
26 Feb 07 |
jari |
326 |
|
2 |
26 Feb 07 |
jari |
327 |
/** |
2 |
26 Feb 07 |
jari |
* Draws a specified column. |
2 |
26 Feb 07 |
jari |
329 |
*/ |
2 |
26 Feb 07 |
jari |
330 |
private void drawColumn(Graphics2D g, int column, final int top, final int bottom) { |
2 |
26 Feb 07 |
jari |
331 |
int[] indices = data.getSortedIndices(column); |
2 |
26 Feb 07 |
jari |
332 |
for (int row = top; row < bottom; row++) { |
2 |
26 Feb 07 |
jari |
333 |
drawSlideDataElement(g, row, column, indices); |
2 |
26 Feb 07 |
jari |
334 |
} |
2 |
26 Feb 07 |
jari |
335 |
} |
2 |
26 Feb 07 |
jari |
336 |
|
2 |
26 Feb 07 |
jari |
337 |
private boolean isMissingValue(int row, int column) { |
2 |
26 Feb 07 |
jari |
338 |
boolean missing = false; |
2 |
26 Feb 07 |
jari |
339 |
FloatMatrix matrix = data.getExperiment().getMatrix(); |
2 |
26 Feb 07 |
jari |
340 |
if (Float.isNaN(matrix.get(row, column))) { |
2 |
26 Feb 07 |
jari |
341 |
missing = true; |
2 |
26 Feb 07 |
jari |
342 |
} |
2 |
26 Feb 07 |
jari |
343 |
return missing; |
2 |
26 Feb 07 |
jari |
344 |
} |
2 |
26 Feb 07 |
jari |
345 |
|
2 |
26 Feb 07 |
jari |
346 |
/** |
2 |
26 Feb 07 |
jari |
* Draws an element rectangle to specified row and column. |
2 |
26 Feb 07 |
jari |
348 |
*/ |
2 |
26 Feb 07 |
jari |
349 |
private void drawSlideDataElement(Graphics g, final int row, final int column, int[] indices) { |
2 |
26 Feb 07 |
jari |
350 |
|
2 |
26 Feb 07 |
jari |
351 |
float cy3 = data.getCY3(column, indices[row]); |
2 |
26 Feb 07 |
jari |
352 |
float cy5 = data.getCY5(column, indices[row]); |
2 |
26 Feb 07 |
jari |
353 |
|
2 |
26 Feb 07 |
jari |
354 |
int x, y, width, height; |
2 |
26 Feb 07 |
jari |
355 |
|
2 |
26 Feb 07 |
jari |
356 |
switch (paletteStyle) { |
2 |
26 Feb 07 |
jari |
357 |
case OVERLAY: |
2 |
26 Feb 07 |
jari |
358 |
x = insets.left + column*(elementSize.width + getSpacing()); |
2 |
26 Feb 07 |
jari |
359 |
y = insets.top + row*elementSize.height; |
2 |
26 Feb 07 |
jari |
360 |
Color color = getOverlayColor(cy3, cy5);//new Color(getRedValue(cy5), getGreenValue(cy3), 0); |
2 |
26 Feb 07 |
jari |
361 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
362 |
g.fillRect(x, y, elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
363 |
break; |
2 |
26 Feb 07 |
jari |
364 |
case RATIOSPLIT: |
2 |
26 Feb 07 |
jari |
365 |
float ratio = data.getRatio(column, indices[row], IData.LOG); |
2 |
26 Feb 07 |
jari |
366 |
Color holdColor; |
2 |
26 Feb 07 |
jari |
367 |
g.setColor(getColor(ratio)); |
2 |
26 Feb 07 |
jari |
368 |
g.fillRect(insets.left+column*(elementSize.width+getSpacing()), |
2 |
26 Feb 07 |
jari |
369 |
insets.top + row*elementSize.height, |
2 |
26 Feb 07 |
jari |
370 |
elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
371 |
break; |
2 |
26 Feb 07 |
jari |
372 |
case GREENRED: |
2 |
26 Feb 07 |
jari |
373 |
if (cy3 <= 0 && cy5 <= 0 ) { |
2 |
26 Feb 07 |
jari |
374 |
g.setColor(missingColor); |
2 |
26 Feb 07 |
jari |
375 |
g.fillRect(insets.left+column*(elementSize.width+getSpacing()), |
2 |
26 Feb 07 |
jari |
376 |
insets.top + row*elementSize.height, |
2 |
26 Feb 07 |
jari |
377 |
elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
378 |
} else { |
2 |
26 Feb 07 |
jari |
379 |
int adjust = (int)(elementSize.width*cy3/(cy3+cy5)); |
2 |
26 Feb 07 |
jari |
//g.setColor(new Color(0, getGreenValue(cy3), 0)); |
2 |
26 Feb 07 |
jari |
381 |
g.setColor(this.getNegativeColor(cy3)); |
2 |
26 Feb 07 |
jari |
382 |
g.fillRect(insets.left+column*(elementSize.width+getSpacing()), |
2 |
26 Feb 07 |
jari |
383 |
insets.top + row*elementSize.height, |
2 |
26 Feb 07 |
jari |
384 |
adjust, elementSize.height); |
2 |
26 Feb 07 |
jari |
385 |
g.setColor(this.getPositiveColor(cy5)); |
2 |
26 Feb 07 |
jari |
386 |
g.fillRect(insets.left+column*(elementSize.width+getSpacing())+adjust, |
2 |
26 Feb 07 |
jari |
387 |
insets.top + row*elementSize.height, |
2 |
26 Feb 07 |
jari |
388 |
elementSize.width-adjust, elementSize.height); |
2 |
26 Feb 07 |
jari |
389 |
} |
2 |
26 Feb 07 |
jari |
390 |
break; |
2 |
26 Feb 07 |
jari |
391 |
} |
2 |
26 Feb 07 |
jari |
392 |
if (isDrawBorders) { |
2 |
26 Feb 07 |
jari |
393 |
g.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
394 |
g.drawRect(getXPos(column), getYPos(row) + insets.top, elementSize.width -1, elementSize.height -1); |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
} |
2 |
26 Feb 07 |
jari |
397 |
|
2 |
26 Feb 07 |
jari |
398 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates color for passed value. |
2 |
26 Feb 07 |
jari |
400 |
*/ |
2 |
26 Feb 07 |
jari |
/*private Color getColor(float value) { |
2 |
26 Feb 07 |
jari |
if (Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
return missingColor; |
2 |
26 Feb 07 |
jari |
404 |
} |
2 |
26 Feb 07 |
jari |
float maximum = value < 0 ? this.minRatio : this.maxRatio; |
2 |
26 Feb 07 |
jari |
int colorIndex = (int)(255*value/maximum); |
2 |
26 Feb 07 |
jari |
colorIndex = colorIndex > 255 ? 255 : colorIndex; |
2 |
26 Feb 07 |
jari |
int rgb = value < 0 ? negColorImage.getRGB(255-colorIndex, 0) : posColorImage.getRGB(colorIndex, 0); |
2 |
26 Feb 07 |
jari |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
410 |
} |
2 |
26 Feb 07 |
jari |
411 |
*/ |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
|
2 |
26 Feb 07 |
jari |
414 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates color for passed value. |
2 |
26 Feb 07 |
jari |
416 |
*/ |
2 |
26 Feb 07 |
jari |
/* private Color getColor(float value) { |
2 |
26 Feb 07 |
jari |
if (Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
return missingColor; |
2 |
26 Feb 07 |
jari |
420 |
} |
2 |
26 Feb 07 |
jari |
421 |
|
2 |
26 Feb 07 |
jari |
float maximum; |
2 |
26 Feb 07 |
jari |
int colorIndex, rgb; |
2 |
26 Feb 07 |
jari |
424 |
|
2 |
26 Feb 07 |
jari |
if(useDoubleGradient) { |
2 |
26 Feb 07 |
jari |
maximum = value < 0 ? this.minRatio : this.maxRatio; |
2 |
26 Feb 07 |
jari |
colorIndex = (int) (255 * value / maximum); |
2 |
26 Feb 07 |
jari |
colorIndex = colorIndex > 255 ? 255 : colorIndex; |
2 |
26 Feb 07 |
jari |
rgb = value < 0 ? negColorImage.getRGB(255 - colorIndex, 0) |
2 |
26 Feb 07 |
jari |
: posColorImage.getRGB(colorIndex, 0); |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
float span = this.maxRatio - this.minRatio; |
2 |
26 Feb 07 |
jari |
if(value <= minRatio) |
2 |
26 Feb 07 |
jari |
colorIndex = 0; |
2 |
26 Feb 07 |
jari |
else if(value >= maxRatio) |
2 |
26 Feb 07 |
jari |
colorIndex = 255; |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
colorIndex = (int)(((value - this.minRatio)/span) * 255); |
2 |
26 Feb 07 |
jari |
439 |
|
2 |
26 Feb 07 |
jari |
rgb = posColorImage.getRGB(colorIndex,0); |
2 |
26 Feb 07 |
jari |
441 |
} |
2 |
26 Feb 07 |
jari |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
443 |
} |
2 |
26 Feb 07 |
jari |
444 |
*/ |
2 |
26 Feb 07 |
jari |
445 |
|
2 |
26 Feb 07 |
jari |
446 |
|
2 |
26 Feb 07 |
jari |
447 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates color for passed value. |
2 |
26 Feb 07 |
jari |
449 |
*/ |
2 |
26 Feb 07 |
jari |
450 |
private Color getColor(float value) { |
2 |
26 Feb 07 |
jari |
451 |
if (Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
452 |
return missingColor; |
2 |
26 Feb 07 |
jari |
453 |
} |
2 |
26 Feb 07 |
jari |
454 |
|
2 |
26 Feb 07 |
jari |
455 |
float maximum; |
2 |
26 Feb 07 |
jari |
456 |
int colorIndex, rgb; |
2 |
26 Feb 07 |
jari |
457 |
|
2 |
26 Feb 07 |
jari |
458 |
if(useDoubleGradient) { |
2 |
26 Feb 07 |
jari |
459 |
maximum = value < midRatio ? this.minRatio : this.maxRatio; |
2 |
26 Feb 07 |
jari |
460 |
colorIndex = (int) (255 * (value-midRatio) / (maximum - midRatio)); |
2 |
26 Feb 07 |
jari |
461 |
colorIndex = colorIndex > 255 ? 255 : colorIndex; |
2 |
26 Feb 07 |
jari |
462 |
rgb = value < midRatio ? negColorImage.getRGB(255 - colorIndex, 0) |
2 |
26 Feb 07 |
jari |
463 |
: posColorImage.getRGB(colorIndex, 0); |
2 |
26 Feb 07 |
jari |
464 |
} else { |
2 |
26 Feb 07 |
jari |
465 |
float span = this.maxRatio - this.minRatio; |
2 |
26 Feb 07 |
jari |
466 |
if(value <= minRatio) |
2 |
26 Feb 07 |
jari |
467 |
colorIndex = 0; |
2 |
26 Feb 07 |
jari |
468 |
else if(value >= maxRatio) |
2 |
26 Feb 07 |
jari |
469 |
colorIndex = 255; |
2 |
26 Feb 07 |
jari |
470 |
else |
2 |
26 Feb 07 |
jari |
471 |
colorIndex = (int)(((value - this.minRatio)/span) * 255); |
2 |
26 Feb 07 |
jari |
472 |
|
2 |
26 Feb 07 |
jari |
473 |
rgb = posColorImage.getRGB(colorIndex,0); |
2 |
26 Feb 07 |
jari |
474 |
} |
2 |
26 Feb 07 |
jari |
475 |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
476 |
} |
2 |
26 Feb 07 |
jari |
477 |
|
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
479 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the current negative color for given cy3 |
2 |
26 Feb 07 |
jari |
481 |
*/ |
2 |
26 Feb 07 |
jari |
482 |
private Color getNegativeColor(float cy3){ |
2 |
26 Feb 07 |
jari |
483 |
float fraction = (float)cy3/maxCY3; |
2 |
26 Feb 07 |
jari |
484 |
int rgb = 0; |
2 |
26 Feb 07 |
jari |
485 |
int colorIndex = (int)(255*cy3/this.maxCY3); |
2 |
26 Feb 07 |
jari |
486 |
colorIndex = Math.min(colorIndex, 255); |
2 |
26 Feb 07 |
jari |
487 |
if(isGRScale){ |
2 |
26 Feb 07 |
jari |
488 |
rgb = negColorImage.getRGB(255-colorIndex, 0); |
2 |
26 Feb 07 |
jari |
489 |
} |
2 |
26 Feb 07 |
jari |
490 |
else{ |
2 |
26 Feb 07 |
jari |
491 |
rgb = negColorImage.getRGB(0, 0); |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
494 |
} |
2 |
26 Feb 07 |
jari |
495 |
|
2 |
26 Feb 07 |
jari |
496 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the current negative color for given cy3 |
2 |
26 Feb 07 |
jari |
498 |
*/ |
2 |
26 Feb 07 |
jari |
499 |
private Color getPositiveColor(float cy5){ |
2 |
26 Feb 07 |
jari |
500 |
float fraction = (float)cy5/maxCY3; |
2 |
26 Feb 07 |
jari |
501 |
int rgb = 0; |
2 |
26 Feb 07 |
jari |
502 |
int colorIndex = (int)(255*cy5/this.maxCY5); |
2 |
26 Feb 07 |
jari |
503 |
colorIndex = Math.min(colorIndex, 255); |
2 |
26 Feb 07 |
jari |
504 |
if(isGRScale){ |
2 |
26 Feb 07 |
jari |
505 |
rgb = posColorImage.getRGB(colorIndex, 0); |
2 |
26 Feb 07 |
jari |
506 |
} |
2 |
26 Feb 07 |
jari |
507 |
else{ |
2 |
26 Feb 07 |
jari |
508 |
rgb = posColorImage.getRGB(255, 0); |
2 |
26 Feb 07 |
jari |
509 |
} |
2 |
26 Feb 07 |
jari |
510 |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
511 |
} |
2 |
26 Feb 07 |
jari |
512 |
|
2 |
26 Feb 07 |
jari |
513 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the current overlay color for passed cy3 and cy5 |
2 |
26 Feb 07 |
jari |
515 |
*/ |
2 |
26 Feb 07 |
jari |
516 |
private Color getOverlayColor(float cy3, float cy5){ |
2 |
26 Feb 07 |
jari |
517 |
Color negColor = getNegativeColor(cy3); |
2 |
26 Feb 07 |
jari |
518 |
Color posColor = getPositiveColor(cy5); |
2 |
26 Feb 07 |
jari |
519 |
double negFraction = cy3/(cy3 + cy5); |
2 |
26 Feb 07 |
jari |
520 |
double posFraction = cy5/(cy3 + cy5); |
2 |
26 Feb 07 |
jari |
521 |
int r, g, b; |
2 |
26 Feb 07 |
jari |
522 |
|
2 |
26 Feb 07 |
jari |
523 |
r = (int)(negColor.getRed()+ posColor.getRed()); |
2 |
26 Feb 07 |
jari |
524 |
r = r < 256 ? r : 255; |
2 |
26 Feb 07 |
jari |
525 |
g = (int)(negColor.getGreen() + posColor.getGreen()); |
2 |
26 Feb 07 |
jari |
526 |
g = g < 256 ? g : 255; |
2 |
26 Feb 07 |
jari |
527 |
b = (int)(negColor.getBlue() + posColor.getBlue()); |
2 |
26 Feb 07 |
jari |
528 |
b = b < 256 ? b : 255; |
2 |
26 Feb 07 |
jari |
529 |
|
2 |
26 Feb 07 |
jari |
530 |
return new Color(r, g, b); |
2 |
26 Feb 07 |
jari |
531 |
} |
2 |
26 Feb 07 |
jari |
532 |
|
2 |
26 Feb 07 |
jari |
533 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the current overlay color for passed cy3 and cy5 |
2 |
26 Feb 07 |
jari |
535 |
*/ |
2 |
26 Feb 07 |
jari |
536 |
private BufferedImage getOverlayImage(float cy3, float cy5){ |
2 |
26 Feb 07 |
jari |
537 |
Color negColor = getNegativeColor(cy3); |
2 |
26 Feb 07 |
jari |
538 |
Color posColor = getPositiveColor(cy5); |
2 |
26 Feb 07 |
jari |
539 |
|
2 |
26 Feb 07 |
jari |
540 |
BufferedImage bi = new BufferedImage(elementSize.width, elementSize.height, BufferedImage.TYPE_INT_ARGB); |
2 |
26 Feb 07 |
jari |
541 |
Graphics2D g2 = (Graphics2D)bi.createGraphics(); |
2 |
26 Feb 07 |
jari |
542 |
g2.setColor(Color.white); |
2 |
26 Feb 07 |
jari |
543 |
g2.fillRect(0,0, elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
// g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(cy3/(cy3+cy5)))); |
2 |
26 Feb 07 |
jari |
545 |
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(0.5))); |
2 |
26 Feb 07 |
jari |
546 |
g2.setColor(negColor); |
2 |
26 Feb 07 |
jari |
547 |
g2.fillRect(0,0, elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
// g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(cy5/(cy3+cy5)))); |
2 |
26 Feb 07 |
jari |
549 |
g2.setColor(posColor); |
2 |
26 Feb 07 |
jari |
550 |
g2.fillRect(0, 0, elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
551 |
|
2 |
26 Feb 07 |
jari |
552 |
return bi; |
2 |
26 Feb 07 |
jari |
553 |
} |
2 |
26 Feb 07 |
jari |
554 |
|
2 |
26 Feb 07 |
jari |
555 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the draw chain attribute. |
2 |
26 Feb 07 |
jari |
557 |
*/ |
2 |
26 Feb 07 |
jari |
558 |
private void setDrawChain(boolean drawChain) { |
2 |
26 Feb 07 |
jari |
559 |
this.drawChain = drawChain; |
2 |
26 Feb 07 |
jari |
560 |
repaint(); |
2 |
26 Feb 07 |
jari |
561 |
} |
2 |
26 Feb 07 |
jari |
562 |
|
2 |
26 Feb 07 |
jari |
563 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the draw chain attribute value. |
2 |
26 Feb 07 |
jari |
565 |
*/ |
2 |
26 Feb 07 |
jari |
566 |
private boolean isDrawChain() { |
2 |
26 Feb 07 |
jari |
567 |
return drawChain; |
2 |
26 Feb 07 |
jari |
568 |
} |
2 |
26 Feb 07 |
jari |
569 |
|
2 |
26 Feb 07 |
jari |
570 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a chain array. |
2 |
26 Feb 07 |
jari |
572 |
*/ |
2 |
26 Feb 07 |
jari |
573 |
private void setChain(int[] chain) { |
2 |
26 Feb 07 |
jari |
574 |
this.chain = chain; |
2 |
26 Feb 07 |
jari |
575 |
} |
2 |
26 Feb 07 |
jari |
576 |
|
2 |
26 Feb 07 |
jari |
577 |
/** |
2 |
26 Feb 07 |
jari |
* Creates and sets a chain for specified row and column. |
2 |
26 Feb 07 |
jari |
579 |
*/ |
2 |
26 Feb 07 |
jari |
580 |
private void doChain(int row, int column) { |
2 |
26 Feb 07 |
jari |
581 |
setChain(createChain(row, column)); |
2 |
26 Feb 07 |
jari |
582 |
} |
2 |
26 Feb 07 |
jari |
583 |
|
2 |
26 Feb 07 |
jari |
584 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a chain. |
2 |
26 Feb 07 |
jari |
586 |
*/ |
2 |
26 Feb 07 |
jari |
587 |
private int[] getChain() { |
2 |
26 Feb 07 |
jari |
588 |
return chain; |
2 |
26 Feb 07 |
jari |
589 |
} |
2 |
26 Feb 07 |
jari |
590 |
|
2 |
26 Feb 07 |
jari |
591 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a chain for specified row and column. |
2 |
26 Feb 07 |
jari |
593 |
*/ |
2 |
26 Feb 07 |
jari |
594 |
private int[] createChain(int row, int column) { |
2 |
26 Feb 07 |
jari |
595 |
int[] indices = data.getSortedIndices(column); |
2 |
26 Feb 07 |
jari |
596 |
int trueColumn = data.getProbeColumn(column, indices[row]); |
2 |
26 Feb 07 |
jari |
597 |
int trueRow = data.getProbeRow(column, indices[row]); |
2 |
26 Feb 07 |
jari |
598 |
int[] positions = new int[data.getFeaturesCount()]; |
2 |
26 Feb 07 |
jari |
599 |
final int size = data.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
600 |
for (int feature = 0; feature < positions.length; feature++) { |
2 |
26 Feb 07 |
jari |
601 |
if (feature == column) { |
2 |
26 Feb 07 |
jari |
602 |
positions[column] = row; |
2 |
26 Feb 07 |
jari |
603 |
} else { |
2 |
26 Feb 07 |
jari |
604 |
indices = data.getSortedIndices(feature); |
2 |
26 Feb 07 |
jari |
605 |
for (int probe = 0; probe < size; probe++) { |
2 |
26 Feb 07 |
jari |
606 |
if ((data.getProbeColumn(feature, indices[probe]) == trueColumn) && |
2 |
26 Feb 07 |
jari |
607 |
(data.getProbeRow(feature, indices[probe]) == trueRow)) { |
2 |
26 Feb 07 |
jari |
608 |
positions[feature] = probe; |
2 |
26 Feb 07 |
jari |
609 |
break; |
2 |
26 Feb 07 |
jari |
610 |
} |
2 |
26 Feb 07 |
jari |
611 |
} |
2 |
26 Feb 07 |
jari |
612 |
} |
2 |
26 Feb 07 |
jari |
613 |
} |
2 |
26 Feb 07 |
jari |
614 |
return positions; |
2 |
26 Feb 07 |
jari |
615 |
} |
2 |
26 Feb 07 |
jari |
616 |
|
2 |
26 Feb 07 |
jari |
617 |
/** |
2 |
26 Feb 07 |
jari |
* Returns width of tracing space. |
2 |
26 Feb 07 |
jari |
619 |
*/ |
2 |
26 Feb 07 |
jari |
620 |
private int getSpacing() { |
2 |
26 Feb 07 |
jari |
621 |
if (isTracing) { |
2 |
26 Feb 07 |
jari |
622 |
return TRACE_SPACE; |
2 |
26 Feb 07 |
jari |
623 |
} |
2 |
26 Feb 07 |
jari |
624 |
return 0; |
2 |
26 Feb 07 |
jari |
625 |
} |
2 |
26 Feb 07 |
jari |
626 |
|
2 |
26 Feb 07 |
jari |
627 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a width of the viewer. |
2 |
26 Feb 07 |
jari |
629 |
*/ |
2 |
26 Feb 07 |
jari |
630 |
private int getXSize() { |
2 |
26 Feb 07 |
jari |
631 |
return(features*elementSize.width)+((features-1)*getSpacing()); |
2 |
26 Feb 07 |
jari |
632 |
} |
2 |
26 Feb 07 |
jari |
633 |
|
2 |
26 Feb 07 |
jari |
634 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a height of the viewer. |
2 |
26 Feb 07 |
jari |
636 |
*/ |
2 |
26 Feb 07 |
jari |
637 |
private int getYSize() { |
2 |
26 Feb 07 |
jari |
638 |
return probes*elementSize.height; |
2 |
26 Feb 07 |
jari |
639 |
} |
2 |
26 Feb 07 |
jari |
640 |
|
2 |
26 Feb 07 |
jari |
641 |
/** |
2 |
26 Feb 07 |
jari |
* Updates max label width value. |
2 |
26 Feb 07 |
jari |
643 |
*/ |
2 |
26 Feb 07 |
jari |
644 |
private void updateMaxLabelWidth() { |
2 |
26 Feb 07 |
jari |
645 |
Graphics2D g = (Graphics2D)getGraphics(); |
2 |
26 Feb 07 |
jari |
646 |
if (g == null) { |
2 |
26 Feb 07 |
jari |
647 |
return; |
2 |
26 Feb 07 |
jari |
648 |
} |
2 |
26 Feb 07 |
jari |
649 |
if (isAntiAliasing) {//Anti-aliasing is on |
2 |
26 Feb 07 |
jari |
650 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
2 |
26 Feb 07 |
jari |
651 |
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
652 |
} |
2 |
26 Feb 07 |
jari |
653 |
FontMetrics fm = g.getFontMetrics(); |
2 |
26 Feb 07 |
jari |
654 |
if (labelIndex < 0) { |
2 |
26 Feb 07 |
jari |
655 |
maxLabelWidth = fm.stringWidth(""); |
2 |
26 Feb 07 |
jari |
656 |
return; |
2 |
26 Feb 07 |
jari |
657 |
} |
2 |
26 Feb 07 |
jari |
658 |
String label; |
2 |
26 Feb 07 |
jari |
659 |
double maxWidth = 0; |
2 |
26 Feb 07 |
jari |
660 |
final int SIZE = data.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
661 |
for (int i = 0; i < SIZE; i++) { |
2 |
26 Feb 07 |
jari |
662 |
label = data.getElementAttribute(i, labelIndex); |
2 |
26 Feb 07 |
jari |
663 |
maxWidth = Math.max(maxWidth, fm.stringWidth(label)); |
2 |
26 Feb 07 |
jari |
664 |
} |
2 |
26 Feb 07 |
jari |
665 |
maxLabelWidth = (int)maxWidth; |
2 |
26 Feb 07 |
jari |
666 |
} |
2 |
26 Feb 07 |
jari |
667 |
|
2 |
26 Feb 07 |
jari |
668 |
/** |
2 |
26 Feb 07 |
jari |
* Returns max label width. |
2 |
26 Feb 07 |
jari |
670 |
*/ |
2 |
26 Feb 07 |
jari |
671 |
private int getMaxLabelWidth() { |
2 |
26 Feb 07 |
jari |
672 |
return maxLabelWidth; |
2 |
26 Feb 07 |
jari |
673 |
} |
2 |
26 Feb 07 |
jari |
674 |
|
2 |
26 Feb 07 |
jari |
675 |
/** |
2 |
26 Feb 07 |
jari |
* Draws annotations into specified graphics. |
2 |
26 Feb 07 |
jari |
677 |
*/ |
2 |
26 Feb 07 |
jari |
678 |
private void drawLabels(Graphics2D g, final int top, final int bottom) { |
2 |
26 Feb 07 |
jari |
679 |
String label; |
2 |
26 Feb 07 |
jari |
680 |
g.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
681 |
int[] indices = data.getSortedIndices(0); |
2 |
26 Feb 07 |
jari |
682 |
for (int probe = top; probe < bottom; probe++) { |
2 |
26 Feb 07 |
jari |
683 |
label = data.getElementAttribute(indices[probe], labelIndex); |
2 |
26 Feb 07 |
jari |
684 |
if (label != null) { |
2 |
26 Feb 07 |
jari |
685 |
g.drawString(label, insets.left + getXSize() + insets.right, insets.top + ((probe +1)*elementSize.height) -1); |
2 |
26 Feb 07 |
jari |
686 |
} |
2 |
26 Feb 07 |
jari |
687 |
} |
2 |
26 Feb 07 |
jari |
688 |
} |
2 |
26 Feb 07 |
jari |
689 |
|
2 |
26 Feb 07 |
jari |
690 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of top row. |
2 |
26 Feb 07 |
jari |
692 |
*/ |
2 |
26 Feb 07 |
jari |
693 |
private int getTopIndex(int top) { |
2 |
26 Feb 07 |
jari |
694 |
if (top<0) { |
2 |
26 Feb 07 |
jari |
695 |
return 0; |
2 |
26 Feb 07 |
jari |
696 |
} |
2 |
26 Feb 07 |
jari |
697 |
return top/elementSize.height; |
2 |
26 Feb 07 |
jari |
698 |
} |
2 |
26 Feb 07 |
jari |
699 |
|
2 |
26 Feb 07 |
jari |
700 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of left column. |
2 |
26 Feb 07 |
jari |
702 |
*/ |
2 |
26 Feb 07 |
jari |
703 |
private int getLeftIndex(int left) { |
2 |
26 Feb 07 |
jari |
704 |
if (left<insets.left) { |
2 |
26 Feb 07 |
jari |
705 |
return 0; |
2 |
26 Feb 07 |
jari |
706 |
} |
2 |
26 Feb 07 |
jari |
707 |
return (left - insets.left)/(elementSize.width+getSpacing()); |
2 |
26 Feb 07 |
jari |
708 |
} |
2 |
26 Feb 07 |
jari |
709 |
|
2 |
26 Feb 07 |
jari |
710 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of right column. |
2 |
26 Feb 07 |
jari |
712 |
*/ |
2 |
26 Feb 07 |
jari |
713 |
private int getRightIndex(int right, int limit) { |
2 |
26 Feb 07 |
jari |
714 |
if (right<0) { |
2 |
26 Feb 07 |
jari |
715 |
return 0; |
2 |
26 Feb 07 |
jari |
716 |
} |
2 |
26 Feb 07 |
jari |
717 |
int result = right/(elementSize.width+getSpacing())+1; |
2 |
26 Feb 07 |
jari |
718 |
return result > limit ? limit : result; |
2 |
26 Feb 07 |
jari |
719 |
} |
2 |
26 Feb 07 |
jari |
720 |
|
2 |
26 Feb 07 |
jari |
721 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of bottom row. |
2 |
26 Feb 07 |
jari |
723 |
*/ |
2 |
26 Feb 07 |
jari |
724 |
private int getBottomIndex(int bottom, int limit) { |
2 |
26 Feb 07 |
jari |
725 |
if (bottom<0) { |
2 |
26 Feb 07 |
jari |
726 |
return 0; |
2 |
26 Feb 07 |
jari |
727 |
} |
2 |
26 Feb 07 |
jari |
728 |
int result = bottom/elementSize.height+1; |
2 |
26 Feb 07 |
jari |
729 |
return result > limit ? limit : result; |
2 |
26 Feb 07 |
jari |
730 |
} |
2 |
26 Feb 07 |
jari |
731 |
|
2 |
26 Feb 07 |
jari |
732 |
/** |
2 |
26 Feb 07 |
jari |
* Draws link for specified spots. |
2 |
26 Feb 07 |
jari |
734 |
*/ |
2 |
26 Feb 07 |
jari |
735 |
private void drawLink(Graphics2D g, int row1, int col1, int row2, int col2, Color color) { |
2 |
26 Feb 07 |
jari |
736 |
double yPos1 = row1+0.5; |
2 |
26 Feb 07 |
jari |
737 |
double yPos2 = row2+0.5; |
2 |
26 Feb 07 |
jari |
738 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
739 |
g.drawLine(insets.left + elementSize.width + col1*(elementSize.width+getSpacing()), |
2 |
26 Feb 07 |
jari |
740 |
insets.top + (int)(yPos1*elementSize.height), |
2 |
26 Feb 07 |
jari |
741 |
insets.left + col2*(elementSize.width+getSpacing())-1, |
2 |
26 Feb 07 |
jari |
742 |
insets.top + (int)(yPos2*elementSize.height)); |
2 |
26 Feb 07 |
jari |
743 |
} |
2 |
26 Feb 07 |
jari |
744 |
|
2 |
26 Feb 07 |
jari |
745 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates color for CY3 value. |
2 |
26 Feb 07 |
jari |
747 |
*/ |
2 |
26 Feb 07 |
jari |
748 |
private float getGreenValue(float cy3) { |
2 |
26 Feb 07 |
jari |
749 |
if (isGRScale) { |
2 |
26 Feb 07 |
jari |
750 |
float color = Math.abs(cy3/maxCY3); |
2 |
26 Feb 07 |
jari |
751 |
return color > 1f ? 1f : color; |
2 |
26 Feb 07 |
jari |
752 |
} else { |
2 |
26 Feb 07 |
jari |
753 |
if (cy3 == 0f) |
2 |
26 Feb 07 |
jari |
754 |
return 0f; |
2 |
26 Feb 07 |
jari |
755 |
else |
2 |
26 Feb 07 |
jari |
756 |
return 1f; |
2 |
26 Feb 07 |
jari |
757 |
} |
2 |
26 Feb 07 |
jari |
758 |
} |
2 |
26 Feb 07 |
jari |
759 |
|
2 |
26 Feb 07 |
jari |
760 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates color for CY5 value. |
2 |
26 Feb 07 |
jari |
762 |
*/ |
2 |
26 Feb 07 |
jari |
763 |
private float getRedValue(float cy5) { |
2 |
26 Feb 07 |
jari |
764 |
if (isGRScale) { |
2 |
26 Feb 07 |
jari |
765 |
float color = Math.abs(cy5/maxCY5); |
2 |
26 Feb 07 |
jari |
766 |
return color > 1f ? 1f : color; |
2 |
26 Feb 07 |
jari |
767 |
} else { |
2 |
26 Feb 07 |
jari |
768 |
if (cy5 == 0f) |
2 |
26 Feb 07 |
jari |
769 |
return 0f; |
2 |
26 Feb 07 |
jari |
770 |
else |
2 |
26 Feb 07 |
jari |
771 |
return 1f; |
2 |
26 Feb 07 |
jari |
772 |
} |
2 |
26 Feb 07 |
jari |
773 |
} |
2 |
26 Feb 07 |
jari |
774 |
|
2 |
26 Feb 07 |
jari |
775 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if specified row and column are exists. |
2 |
26 Feb 07 |
jari |
777 |
*/ |
2 |
26 Feb 07 |
jari |
778 |
private boolean isLegalPosition(int row, int column) { |
2 |
26 Feb 07 |
jari |
779 |
if (isLegalRow(row) && isLegalColumn(column)) |
2 |
26 Feb 07 |
jari |
780 |
return true; |
2 |
26 Feb 07 |
jari |
781 |
return false; |
2 |
26 Feb 07 |
jari |
782 |
} |
2 |
26 Feb 07 |
jari |
783 |
|
2 |
26 Feb 07 |
jari |
784 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if specified column is exists. |
2 |
26 Feb 07 |
jari |
786 |
*/ |
2 |
26 Feb 07 |
jari |
787 |
private boolean isLegalColumn(int column) { |
2 |
26 Feb 07 |
jari |
788 |
if (column < 0 || column > features -1) |
2 |
26 Feb 07 |
jari |
789 |
return false; |
2 |
26 Feb 07 |
jari |
790 |
return true; |
2 |
26 Feb 07 |
jari |
791 |
} |
2 |
26 Feb 07 |
jari |
792 |
|
2 |
26 Feb 07 |
jari |
793 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if specified row is exists. |
2 |
26 Feb 07 |
jari |
795 |
*/ |
2 |
26 Feb 07 |
jari |
796 |
private boolean isLegalRow(int row) { |
2 |
26 Feb 07 |
jari |
797 |
if (row < 0 || row > probes -1) |
2 |
26 Feb 07 |
jari |
798 |
return false; |
2 |
26 Feb 07 |
jari |
799 |
return true; |
2 |
26 Feb 07 |
jari |
800 |
} |
2 |
26 Feb 07 |
jari |
801 |
|
2 |
26 Feb 07 |
jari |
802 |
/** |
2 |
26 Feb 07 |
jari |
* Finds column by specified x coordinate. |
2 |
26 Feb 07 |
jari |
* @return -1 if column was not found. |
2 |
26 Feb 07 |
jari |
805 |
*/ |
2 |
26 Feb 07 |
jari |
806 |
private int findColumn(int targetx) { |
2 |
26 Feb 07 |
jari |
//targetx -= insets.left; |
2 |
26 Feb 07 |
jari |
808 |
int columnSize = elementSize.width + getSpacing(); |
2 |
26 Feb 07 |
jari |
809 |
if (targetx >= features*columnSize - getSpacing() + insets.left || targetx < insets.left) { |
2 |
26 Feb 07 |
jari |
810 |
return -1; |
2 |
26 Feb 07 |
jari |
811 |
} |
2 |
26 Feb 07 |
jari |
// if(targetx < insets.left) |
2 |
26 Feb 07 |
jari |
// return 0; |
2 |
26 Feb 07 |
jari |
814 |
else |
2 |
26 Feb 07 |
jari |
815 |
return ((targetx - insets.left)/columnSize); |
2 |
26 Feb 07 |
jari |
816 |
} |
2 |
26 Feb 07 |
jari |
817 |
|
2 |
26 Feb 07 |
jari |
818 |
/** |
2 |
26 Feb 07 |
jari |
* Finds row by specified y coordinate. |
2 |
26 Feb 07 |
jari |
* @return -1 if row was not found. |
2 |
26 Feb 07 |
jari |
821 |
*/ |
2 |
26 Feb 07 |
jari |
822 |
private int findRow(int targety) { |
2 |
26 Feb 07 |
jari |
823 |
targety -= insets.top; |
2 |
26 Feb 07 |
jari |
824 |
int ySize = probes*elementSize.height; |
2 |
26 Feb 07 |
jari |
825 |
if (targety >= ySize || targety < 0) |
2 |
26 Feb 07 |
jari |
826 |
return -1; |
2 |
26 Feb 07 |
jari |
827 |
return targety/elementSize.height; |
2 |
26 Feb 07 |
jari |
828 |
} |
2 |
26 Feb 07 |
jari |
829 |
|
2 |
26 Feb 07 |
jari |
830 |
/** |
2 |
26 Feb 07 |
jari |
* Returns x coordinate of a column. |
2 |
26 Feb 07 |
jari |
832 |
*/ |
2 |
26 Feb 07 |
jari |
833 |
private int getXPos(int column) { |
2 |
26 Feb 07 |
jari |
834 |
return column*(elementSize.width + getSpacing()) + insets.left; |
2 |
26 Feb 07 |
jari |
835 |
} |
2 |
26 Feb 07 |
jari |
836 |
|
2 |
26 Feb 07 |
jari |
837 |
/** |
2 |
26 Feb 07 |
jari |
* Returns y coordinate of a row. |
2 |
26 Feb 07 |
jari |
839 |
*/ |
2 |
26 Feb 07 |
jari |
840 |
private int getYPos(int row) { |
2 |
26 Feb 07 |
jari |
841 |
return row * elementSize.height; |
2 |
26 Feb 07 |
jari |
842 |
} |
2 |
26 Feb 07 |
jari |
843 |
|
2 |
26 Feb 07 |
jari |
844 |
/** |
2 |
26 Feb 07 |
jari |
* Draws a rectangle with specified color. |
2 |
26 Feb 07 |
jari |
846 |
*/ |
2 |
26 Feb 07 |
jari |
847 |
private void drawColoredBoxAt(Graphics g, int row, int column, Color color) { |
2 |
26 Feb 07 |
jari |
848 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
849 |
g.drawRect(insets.left + column*(elementSize.width+getSpacing()), insets.top + row*elementSize.height, elementSize.width-1, elementSize.height-1); |
2 |
26 Feb 07 |
jari |
850 |
} |
2 |
26 Feb 07 |
jari |
851 |
|
2 |
26 Feb 07 |
jari |
852 |
/** |
2 |
26 Feb 07 |
jari |
* Draws a chain. |
2 |
26 Feb 07 |
jari |
854 |
*/ |
2 |
26 Feb 07 |
jari |
855 |
private void drawChain(Graphics2D g, Color color, int[] chain, final int left, final int right) { |
2 |
26 Feb 07 |
jari |
856 |
for (int column = left; column < right; column++) { |
2 |
26 Feb 07 |
jari |
857 |
drawColoredBoxAt(g, chain[column], column, color); |
2 |
26 Feb 07 |
jari |
858 |
} |
2 |
26 Feb 07 |
jari |
859 |
final int last = right == chain.length ? right-1 : right; |
2 |
26 Feb 07 |
jari |
860 |
for (int column = left; column < last; column++) { |
2 |
26 Feb 07 |
jari |
861 |
drawLink(g, chain[column], column, chain[column+1], column+1, color); |
2 |
26 Feb 07 |
jari |
862 |
} |
2 |
26 Feb 07 |
jari |
863 |
} |
2 |
26 Feb 07 |
jari |
864 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into the scroll pane row header |
2 |
26 Feb 07 |
jari |
866 |
*/ |
2 |
26 Feb 07 |
jari |
867 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
868 |
return null; |
2 |
26 Feb 07 |
jari |
869 |
} |
2 |
26 Feb 07 |
jari |
870 |
|
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 |
873 |
*/ |
2 |
26 Feb 07 |
jari |
874 |
public JComponent getCornerComponent(int cornerIndex) { |
2 |
26 Feb 07 |
jari |
875 |
return null; |
2 |
26 Feb 07 |
jari |
876 |
} |
2 |
26 Feb 07 |
jari |
877 |
|
2 |
26 Feb 07 |
jari |
878 |
public int[][] getClusters() { |
2 |
26 Feb 07 |
jari |
879 |
return null; |
2 |
26 Feb 07 |
jari |
880 |
} |
2 |
26 Feb 07 |
jari |
881 |
|
2 |
26 Feb 07 |
jari |
882 |
/** |
2 |
26 Feb 07 |
jari |
* Implemented only to satisfy the IViewer interface. Always returns null. |
2 |
26 Feb 07 |
jari |
884 |
*/ |
2 |
26 Feb 07 |
jari |
885 |
public Experiment getExperiment() { |
2 |
26 Feb 07 |
jari |
886 |
return null; |
2 |
26 Feb 07 |
jari |
887 |
} |
2 |
26 Feb 07 |
jari |
888 |
/** |
2 |
26 Feb 07 |
jari |
* Implemented only to satisfy the IViewer interface. Does nothing. |
2 |
26 Feb 07 |
jari |
890 |
*/ |
2 |
26 Feb 07 |
jari |
891 |
public void setExperiment(Experiment e){} |
2 |
26 Feb 07 |
jari |
892 |
/** |
2 |
26 Feb 07 |
jari |
* Implemented only to satisfy the IViewer interface. Does nothing. |
2 |
26 Feb 07 |
jari |
894 |
*/ |
2 |
26 Feb 07 |
jari |
895 |
public void setExperimentID(int i){} |
2 |
26 Feb 07 |
jari |
896 |
/** |
2 |
26 Feb 07 |
jari |
* Implemented only to satisfy the IViewer interface. Does nothing. |
2 |
26 Feb 07 |
jari |
898 |
*/ |
2 |
26 Feb 07 |
jari |
899 |
public int getExperimentID(){return 0;} |
2 |
26 Feb 07 |
jari |
900 |
|
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 |
903 |
*/ |
2 |
26 Feb 07 |
jari |
904 |
public int getViewerType() { |
2 |
26 Feb 07 |
jari |
905 |
return -1; |
2 |
26 Feb 07 |
jari |
906 |
} |
2 |
26 Feb 07 |
jari |
907 |
|
2 |
26 Feb 07 |
jari |
908 |
|
2 |
26 Feb 07 |
jari |
909 |
|
2 |
26 Feb 07 |
jari |
910 |
private JPopupMenu createPopupMenu(Listener listener) { |
2 |
26 Feb 07 |
jari |
911 |
JPopupMenu menu = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
912 |
|
2 |
26 Feb 07 |
jari |
//add to main view context |
2 |
26 Feb 07 |
jari |
914 |
ButtonGroup buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
915 |
|
2 |
26 Feb 07 |
jari |
916 |
|
2 |
26 Feb 07 |
jari |
917 |
JRadioButtonMenuItem item = new JRadioButtonMenuItem("Color Gradient View", true); |
2 |
26 Feb 07 |
jari |
918 |
buttonGroup.add(item); |
2 |
26 Feb 07 |
jari |
919 |
item.setActionCommand("palette "+RATIOSPLIT); |
2 |
26 Feb 07 |
jari |
920 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
921 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
922 |
|
2 |
26 Feb 07 |
jari |
923 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
924 |
|
2 |
26 Feb 07 |
jari |
925 |
expressionBarItem = new JRadioButtonMenuItem("Expression Bar View"); |
2 |
26 Feb 07 |
jari |
926 |
buttonGroup.add(expressionBarItem); |
2 |
26 Feb 07 |
jari |
927 |
expressionBarItem.setActionCommand("palette "+GREENRED); |
2 |
26 Feb 07 |
jari |
928 |
expressionBarItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
929 |
menu.add(expressionBarItem); |
2 |
26 Feb 07 |
jari |
930 |
|
2 |
26 Feb 07 |
jari |
931 |
absoluteColorCheckBoxItem = new JCheckBoxMenuItem("Use Absolute Bar Colors", true); |
2 |
26 Feb 07 |
jari |
932 |
absoluteColorCheckBoxItem.setActionCommand("use-absolute-bar-colors"); |
2 |
26 Feb 07 |
jari |
933 |
absoluteColorCheckBoxItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
934 |
absoluteColorCheckBoxItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
935 |
menu.add(absoluteColorCheckBoxItem); |
2 |
26 Feb 07 |
jari |
936 |
|
2 |
26 Feb 07 |
jari |
937 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
938 |
|
2 |
26 Feb 07 |
jari |
939 |
overlayItem = new JRadioButtonMenuItem("Color Overlay View"); |
2 |
26 Feb 07 |
jari |
940 |
buttonGroup.add(overlayItem); |
2 |
26 Feb 07 |
jari |
941 |
overlayItem.setActionCommand("palette "+OVERLAY); |
2 |
26 Feb 07 |
jari |
942 |
overlayItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
943 |
menu.add(overlayItem); |
2 |
26 Feb 07 |
jari |
944 |
|
2 |
26 Feb 07 |
jari |
945 |
|
2 |
26 Feb 07 |
jari |
946 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
947 |
|
2 |
26 Feb 07 |
jari |
/* menu.add(createJCheckBoxMenuItem("G/R Scale", ActionManager.DISPLAY_GR_SCALE_CMD, listener, true)); |
2 |
26 Feb 07 |
jari |
menu.add(createJCheckBoxMenuItem("Tracing", ActionManager.DISPLAY_TRACING_CMD, listener)); |
2 |
26 Feb 07 |
jari |
menu.add(createJMenuItem("Set Upper Limits", ActionManager.DISPLAY_SET_UPPER_LIMITS_CMD, listener)); |
2 |
26 Feb 07 |
jari |
951 |
*/ |
2 |
26 Feb 07 |
jari |
952 |
|
2 |
26 Feb 07 |
jari |
//move to main view context |
2 |
26 Feb 07 |
jari |
954 |
sortGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
955 |
sortMenu = new JMenu("Sort Main View"); |
2 |
26 Feb 07 |
jari |
956 |
|
2 |
26 Feb 07 |
jari |
957 |
item = new JRadioButtonMenuItem("Restore Load Order"); |
2 |
26 Feb 07 |
jari |
958 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
959 |
item.setActionCommand("sort "+SlideDataSorter.SORT_BY_LOCATION); |
2 |
26 Feb 07 |
jari |
960 |
sortGroup.add(item); |
2 |
26 Feb 07 |
jari |
961 |
sortMenu.add(item); |
2 |
26 Feb 07 |
jari |
962 |
|
2 |
26 Feb 07 |
jari |
963 |
|
2 |
26 Feb 07 |
jari |
964 |
item = new JRadioButtonMenuItem("Sort by Ratio"); |
2 |
26 Feb 07 |
jari |
965 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
966 |
item.setActionCommand("sort "+SlideDataSorter.SORT_BY_RATIO); |
2 |
26 Feb 07 |
jari |
967 |
sortGroup.add(item); |
2 |
26 Feb 07 |
jari |
968 |
sortMenu.add(item); |
2 |
26 Feb 07 |
jari |
969 |
|
2 |
26 Feb 07 |
jari |
970 |
|
2 |
26 Feb 07 |
jari |
971 |
((JRadioButtonMenuItem)sortMenu.getMenuComponent(0)).setSelected(true); |
2 |
26 Feb 07 |
jari |
972 |
if(data != null && data.getFieldNames() != null) |
2 |
26 Feb 07 |
jari |
973 |
addSortMenuItems(this.data.getFieldNames()); |
2 |
26 Feb 07 |
jari |
974 |
menu.add(sortMenu); |
2 |
26 Feb 07 |
jari |
975 |
|
2 |
26 Feb 07 |
jari |
// Menu.add(manager.getAction(ActionManager.SHOW_THUMBNAIL_ACTION)); |
2 |
26 Feb 07 |
jari |
977 |
|
2 |
26 Feb 07 |
jari |
978 |
|
2 |
26 Feb 07 |
jari |
979 |
return menu; |
2 |
26 Feb 07 |
jari |
980 |
|
2 |
26 Feb 07 |
jari |
981 |
} |
2 |
26 Feb 07 |
jari |
982 |
|
2 |
26 Feb 07 |
jari |
983 |
|
2 |
26 Feb 07 |
jari |
984 |
|
2 |
26 Feb 07 |
jari |
985 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a menu item from specified action. |
2 |
26 Feb 07 |
jari |
987 |
*/ |
2 |
26 Feb 07 |
jari |
988 |
private JMenuItem createJMenuItem(Action action) { |
2 |
26 Feb 07 |
jari |
989 |
JMenuItem item = new JMenuItem(action); |
2 |
26 Feb 07 |
jari |
990 |
item.setActionCommand((String)action.getValue(Action.ACTION_COMMAND_KEY)); |
2 |
26 Feb 07 |
jari |
991 |
return item; |
2 |
26 Feb 07 |
jari |
992 |
} |
2 |
26 Feb 07 |
jari |
993 |
|
2 |
26 Feb 07 |
jari |
994 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a menu item with specified name and acton command. |
2 |
26 Feb 07 |
jari |
996 |
*/ |
2 |
26 Feb 07 |
jari |
997 |
private JMenuItem createJMenuItem(String name, String command, ActionListener listener) { |
2 |
26 Feb 07 |
jari |
998 |
JMenuItem item = new JMenuItem(name); |
2 |
26 Feb 07 |
jari |
999 |
item.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
1000 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1001 |
return item; |
2 |
26 Feb 07 |
jari |
1002 |
} |
2 |
26 Feb 07 |
jari |
1003 |
|
2 |
26 Feb 07 |
jari |
1004 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a check box menu item with specified name, acton command and state. |
2 |
26 Feb 07 |
jari |
1006 |
*/ |
2 |
26 Feb 07 |
jari |
1007 |
private JCheckBoxMenuItem createJCheckBoxMenuItem(String name, String command, ActionListener listener, boolean isSelected) { |
2 |
26 Feb 07 |
jari |
1008 |
JCheckBoxMenuItem item = new JCheckBoxMenuItem(name); |
2 |
26 Feb 07 |
jari |
1009 |
item.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
1010 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1011 |
item.setSelected(isSelected); |
2 |
26 Feb 07 |
jari |
1012 |
return item; |
2 |
26 Feb 07 |
jari |
1013 |
} |
2 |
26 Feb 07 |
jari |
1014 |
|
2 |
26 Feb 07 |
jari |
1015 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a check box menu item with specified name and acton command. |
2 |
26 Feb 07 |
jari |
1017 |
*/ |
2 |
26 Feb 07 |
jari |
1018 |
private JCheckBoxMenuItem createJCheckBoxMenuItem(String name, String command, ActionListener listener) { |
2 |
26 Feb 07 |
jari |
1019 |
return createJCheckBoxMenuItem(name, command, listener, false); |
2 |
26 Feb 07 |
jari |
1020 |
} |
2 |
26 Feb 07 |
jari |
1021 |
|
2 |
26 Feb 07 |
jari |
1022 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a radio button menu item with specified name, acton command and state. |
2 |
26 Feb 07 |
jari |
1024 |
*/ |
2 |
26 Feb 07 |
jari |
1025 |
private JRadioButtonMenuItem createJRadioButtonMenuItem(String name, String command, ActionListener listener, ButtonGroup buttonGroup, boolean isSelected) { |
2 |
26 Feb 07 |
jari |
1026 |
JRadioButtonMenuItem item = new JRadioButtonMenuItem(name); |
2 |
26 Feb 07 |
jari |
1027 |
item.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
1028 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1029 |
item.setSelected(isSelected); |
2 |
26 Feb 07 |
jari |
1030 |
if (buttonGroup != null) { |
2 |
26 Feb 07 |
jari |
1031 |
buttonGroup.add(item); |
2 |
26 Feb 07 |
jari |
1032 |
} |
2 |
26 Feb 07 |
jari |
1033 |
return item; |
2 |
26 Feb 07 |
jari |
1034 |
} |
2 |
26 Feb 07 |
jari |
1035 |
|
2 |
26 Feb 07 |
jari |
1036 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a radio button menu item with specified name, acton command and button group. |
2 |
26 Feb 07 |
jari |
1038 |
*/ |
2 |
26 Feb 07 |
jari |
1039 |
private JRadioButtonMenuItem createJRadioButtonMenuItem(String name, String command, ActionListener listener, ButtonGroup buttonGroup) { |
2 |
26 Feb 07 |
jari |
1040 |
return createJRadioButtonMenuItem(name, command, listener, buttonGroup, false); |
2 |
26 Feb 07 |
jari |
1041 |
} |
2 |
26 Feb 07 |
jari |
1042 |
|
2 |
26 Feb 07 |
jari |
1043 |
|
2 |
26 Feb 07 |
jari |
1044 |
public void addSortMenuItems(String [] fieldNames){ |
2 |
26 Feb 07 |
jari |
1045 |
JRadioButtonMenuItem item; |
2 |
26 Feb 07 |
jari |
1046 |
DefaultAction action; |
2 |
26 Feb 07 |
jari |
1047 |
for(int i = 0; i < fieldNames.length; i++){ |
2 |
26 Feb 07 |
jari |
1048 |
item = new JRadioButtonMenuItem("Sort by "+fieldNames[i]); |
2 |
26 Feb 07 |
jari |
1049 |
item.setActionCommand("sort "+Integer.toString(i)); |
2 |
26 Feb 07 |
jari |
1050 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1051 |
sortGroup.add(item); |
2 |
26 Feb 07 |
jari |
1052 |
this.sortMenu.add(item); |
2 |
26 Feb 07 |
jari |
1053 |
} |
2 |
26 Feb 07 |
jari |
1054 |
} |
2 |
26 Feb 07 |
jari |
1055 |
|
2 |
26 Feb 07 |
jari |
1056 |
|
2 |
26 Feb 07 |
jari |
1057 |
|
2 |
26 Feb 07 |
jari |
1058 |
|
2 |
26 Feb 07 |
jari |
1059 |
/** |
2 |
26 Feb 07 |
jari |
* Sorts the framework data. |
2 |
26 Feb 07 |
jari |
1061 |
*/ |
2 |
26 Feb 07 |
jari |
1062 |
private void onSort(int style) { |
2 |
26 Feb 07 |
jari |
1063 |
if(data instanceof MultipleArrayData) { |
2 |
26 Feb 07 |
jari |
1064 |
((MultipleArrayData)data).sort(style); |
2 |
26 Feb 07 |
jari |
1065 |
} |
2 |
26 Feb 07 |
jari |
1066 |
this.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
1067 |
} |
2 |
26 Feb 07 |
jari |
1068 |
|
2 |
26 Feb 07 |
jari |
1069 |
|
2 |
26 Feb 07 |
jari |
1070 |
/** |
2 |
26 Feb 07 |
jari |
* The listener to listen to mouse, keyboard and window events. |
2 |
26 Feb 07 |
jari |
1072 |
*/ |
2 |
26 Feb 07 |
jari |
1073 |
private class Listener extends MouseAdapter implements MouseMotionListener, KeyListener, WindowListener, ActionListener { |
2 |
26 Feb 07 |
jari |
1074 |
|
2 |
26 Feb 07 |
jari |
1075 |
public Listener() { } |
2 |
26 Feb 07 |
jari |
1076 |
|
2 |
26 Feb 07 |
jari |
1077 |
private int oldRow = -1; |
2 |
26 Feb 07 |
jari |
1078 |
private int oldColumn = -1; |
2 |
26 Feb 07 |
jari |
1079 |
|
2 |
26 Feb 07 |
jari |
1080 |
public void mousePressed(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1081 |
requestFocus(); |
2 |
26 Feb 07 |
jari |
1082 |
if(event.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1083 |
popup.show(MultipleArrayCanvas.this, event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
1084 |
return; |
2 |
26 Feb 07 |
jari |
1085 |
} |
2 |
26 Feb 07 |
jari |
1086 |
} |
2 |
26 Feb 07 |
jari |
1087 |
|
2 |
26 Feb 07 |
jari |
1088 |
public void mouseClicked(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1089 |
int column = findColumn(event.getX()); |
2 |
26 Feb 07 |
jari |
1090 |
int row = findRow(event.getY()); |
2 |
26 Feb 07 |
jari |
1091 |
if(event.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1092 |
popup.show(MultipleArrayCanvas.this, event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
1093 |
return; |
2 |
26 Feb 07 |
jari |
1094 |
} |
2 |
26 Feb 07 |
jari |
1095 |
if (!isLegalPosition(row, column)) { |
2 |
26 Feb 07 |
jari |
1096 |
return; |
2 |
26 Feb 07 |
jari |
1097 |
} |
2 |
26 Feb 07 |
jari |
1098 |
if (event.isControlDown()) { // single array viewer |
2 |
26 Feb 07 |
jari |
1099 |
framework.displaySingleArrayViewer(column); |
2 |
26 Feb 07 |
jari |
1100 |
return; |
2 |
26 Feb 07 |
jari |
1101 |
} |
2 |
26 Feb 07 |
jari |
1102 |
if (!event.isShiftDown()) { // element info |
2 |
26 Feb 07 |
jari |
1103 |
int[] indices = data.getSortedIndices(column); |
2 |
26 Feb 07 |
jari |
1104 |
framework.displaySlideElementInfo(column, indices[row]); |
2 |
26 Feb 07 |
jari |
1105 |
return; |
2 |
26 Feb 07 |
jari |
1106 |
} |
2 |
26 Feb 07 |
jari |
// start chain |
2 |
26 Feb 07 |
jari |
1108 |
doChain(row, column); |
2 |
26 Feb 07 |
jari |
1109 |
setDrawChain(true); |
2 |
26 Feb 07 |
jari |
1110 |
} |
2 |
26 Feb 07 |
jari |
1111 |
|
2 |
26 Feb 07 |
jari |
1112 |
public void mouseMoved(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1113 |
if (features == 0 || event.isShiftDown()) |
2 |
26 Feb 07 |
jari |
1114 |
return; |
2 |
26 Feb 07 |
jari |
1115 |
int column = findColumn(event.getX()); |
2 |
26 Feb 07 |
jari |
1116 |
int row = findRow(event.getY()); |
2 |
26 Feb 07 |
jari |
1117 |
if (isCurrentPosition(row, column)) { |
2 |
26 Feb 07 |
jari |
1118 |
return; |
2 |
26 Feb 07 |
jari |
1119 |
} |
2 |
26 Feb 07 |
jari |
1120 |
Graphics g = null; |
2 |
26 Feb 07 |
jari |
1121 |
if (isLegalPosition(row, column)) { |
2 |
26 Feb 07 |
jari |
1122 |
g = getGraphics(); |
2 |
26 Feb 07 |
jari |
1123 |
drawColoredBoxAt(g, row, column, Color.white); |
2 |
26 Feb 07 |
jari |
1124 |
} |
2 |
26 Feb 07 |
jari |
1125 |
if (isLegalPosition(oldRow, oldColumn)) { |
2 |
26 Feb 07 |
jari |
1126 |
g = g != null ? g : getGraphics(); |
2 |
26 Feb 07 |
jari |
1127 |
drawSlideDataElement(g, oldRow, oldColumn, data.getSortedIndices(oldColumn)); |
2 |
26 Feb 07 |
jari |
1128 |
} |
2 |
26 Feb 07 |
jari |
1129 |
setOldPosition(row, column); |
2 |
26 Feb 07 |
jari |
1130 |
if (g != null) { |
2 |
26 Feb 07 |
jari |
1131 |
g.dispose(); |
2 |
26 Feb 07 |
jari |
1132 |
} |
2 |
26 Feb 07 |
jari |
1133 |
} |
2 |
26 Feb 07 |
jari |
1134 |
|
2 |
26 Feb 07 |
jari |
1135 |
|
2 |
26 Feb 07 |
jari |
1136 |
public void mouseReleased(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1137 |
if(event.isPopupTrigger()) { |
2 |
26 Feb 07 |
jari |
1138 |
popup.show(MultipleArrayCanvas.this, event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
1139 |
return; |
2 |
26 Feb 07 |
jari |
1140 |
} |
2 |
26 Feb 07 |
jari |
1141 |
} |
2 |
26 Feb 07 |
jari |
1142 |
|
2 |
26 Feb 07 |
jari |
1143 |
public void mouseExited(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1144 |
if (isLegalPosition(oldRow, oldColumn)) { |
2 |
26 Feb 07 |
jari |
1145 |
Graphics g = getGraphics(); |
2 |
26 Feb 07 |
jari |
1146 |
drawSlideDataElement(g, oldRow, oldColumn, data.getSortedIndices(oldColumn)); |
2 |
26 Feb 07 |
jari |
1147 |
g.dispose(); |
2 |
26 Feb 07 |
jari |
1148 |
} |
2 |
26 Feb 07 |
jari |
1149 |
setOldPosition(-1, -1); |
2 |
26 Feb 07 |
jari |
1150 |
} |
2 |
26 Feb 07 |
jari |
1151 |
|
2 |
26 Feb 07 |
jari |
1152 |
public void mouseDragged(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1153 |
} |
2 |
26 Feb 07 |
jari |
1154 |
|
2 |
26 Feb 07 |
jari |
1155 |
public void keyReleased(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
1156 |
if ((event.getKeyCode() == KeyEvent.VK_SHIFT) && (isDrawChain() == true)) { |
2 |
26 Feb 07 |
jari |
1157 |
setDrawChain(false); |
2 |
26 Feb 07 |
jari |
1158 |
} |
2 |
26 Feb 07 |
jari |
1159 |
} |
2 |
26 Feb 07 |
jari |
1160 |
|
2 |
26 Feb 07 |
jari |
1161 |
public void keyPressed(KeyEvent e) {} |
2 |
26 Feb 07 |
jari |
1162 |
public void keyTyped(KeyEvent e) {} |
2 |
26 Feb 07 |
jari |
1163 |
|
2 |
26 Feb 07 |
jari |
1164 |
private void setOldPosition(int row, int column) { |
2 |
26 Feb 07 |
jari |
1165 |
oldColumn = column; |
2 |
26 Feb 07 |
jari |
1166 |
oldRow = row; |
2 |
26 Feb 07 |
jari |
1167 |
} |
2 |
26 Feb 07 |
jari |
1168 |
|
2 |
26 Feb 07 |
jari |
1169 |
private boolean isCurrentPosition(int row, int column) { |
2 |
26 Feb 07 |
jari |
1170 |
return(row == oldRow && column == oldColumn); |
2 |
26 Feb 07 |
jari |
1171 |
} |
2 |
26 Feb 07 |
jari |
1172 |
|
2 |
26 Feb 07 |
jari |
1173 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
1174 |
MultipleArrayCanvas.this.isShowThumbnail = false; |
2 |
26 Feb 07 |
jari |
1175 |
MultipleArrayCanvas.this.thumbnail.hide(); |
2 |
26 Feb 07 |
jari |
1176 |
} |
2 |
26 Feb 07 |
jari |
1177 |
|
2 |
26 Feb 07 |
jari |
1178 |
public void windowOpened(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1179 |
public void windowClosed(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1180 |
public void windowIconified(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1181 |
public void windowDeiconified(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1182 |
public void windowActivated(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1183 |
public void windowDeactivated(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1184 |
|
2 |
26 Feb 07 |
jari |
1185 |
public void actionPerformed(java.awt.event.ActionEvent actionEvent) { |
2 |
26 Feb 07 |
jari |
1186 |
String command = actionEvent.getActionCommand(); |
2 |
26 Feb 07 |
jari |
1187 |
if(command.indexOf("sort") != -1) { |
2 |
26 Feb 07 |
jari |
1188 |
String indexString = command.substring(5); |
2 |
26 Feb 07 |
jari |
1189 |
onSort(Integer.parseInt(indexString)); |
2 |
26 Feb 07 |
jari |
1190 |
} else if(command.indexOf("palette") != -1) { |
2 |
26 Feb 07 |
jari |
1191 |
paletteStyle = Integer.parseInt(command.substring(8)); |
2 |
26 Feb 07 |
jari |
1192 |
if(paletteStyle == GREENRED) {//bar view |
2 |
26 Feb 07 |
jari |
1193 |
absoluteColorCheckBoxItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1194 |
isGRScale = !absoluteColorCheckBoxItem.isSelected(); |
2 |
26 Feb 07 |
jari |
1195 |
} else { |
2 |
26 Feb 07 |
jari |
1196 |
isGRScale = true; |
2 |
26 Feb 07 |
jari |
1197 |
absoluteColorCheckBoxItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1198 |
} |
2 |
26 Feb 07 |
jari |
1199 |
repaint(); |
2 |
26 Feb 07 |
jari |
1200 |
} else if(command.equals("use-absolute-bar-colors")) { |
2 |
26 Feb 07 |
jari |
1201 |
isGRScale = !absoluteColorCheckBoxItem.isSelected(); |
2 |
26 Feb 07 |
jari |
1202 |
repaint(); |
2 |
26 Feb 07 |
jari |
1203 |
System.out.println("isGRScale ="+isGRScale); |
2 |
26 Feb 07 |
jari |
1204 |
} |
2 |
26 Feb 07 |
jari |
1205 |
} |
2 |
26 Feb 07 |
jari |
1206 |
|
2 |
26 Feb 07 |
jari |
1207 |
} |
2 |
26 Feb 07 |
jari |
1208 |
|
2 |
26 Feb 07 |
jari |
1209 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#getExpression() |
2 |
26 Feb 07 |
jari |
1212 |
*/ |
2 |
26 Feb 07 |
jari |
1213 |
public Expression getExpression() { |
2 |
26 Feb 07 |
jari |
// TODO Auto-generated method stub |
2 |
26 Feb 07 |
jari |
1215 |
return null; |
2 |
26 Feb 07 |
jari |
1216 |
} |
2 |
26 Feb 07 |
jari |
1217 |
|
2 |
26 Feb 07 |
jari |
1218 |
} |