2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, 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: GDMExpViewer.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.11 $ |
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.impl.gdm; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.BorderLayout; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.GradientPaint; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.Rectangle; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.RenderingHints; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
26 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
27 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
28 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
29 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
30 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
31 |
import java.awt.event.MouseMotionListener; |
2 |
26 Feb 07 |
jari |
32 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
33 |
import java.awt.event.WindowListener; |
2 |
26 Feb 07 |
jari |
34 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
35 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
36 |
import java.util.Arrays; |
2 |
26 Feb 07 |
jari |
37 |
import java.util.Enumeration; |
2 |
26 Feb 07 |
jari |
38 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
44 |
import javax.swing.JMenu; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
46 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
47 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
48 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
49 |
import javax.swing.JRadioButtonMenuItem; |
2 |
26 Feb 07 |
jari |
50 |
import javax.swing.JScrollBar; |
2 |
26 Feb 07 |
jari |
51 |
import javax.swing.SwingUtilities; |
2 |
26 Feb 07 |
jari |
52 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmData; |
2 |
26 Feb 07 |
jari |
55 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmParameters; |
2 |
26 Feb 07 |
jari |
56 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
57 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
58 |
import org.tigr.microarray.mev.cluster.gui.IDisplayMenu; |
2 |
26 Feb 07 |
jari |
59 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
60 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
61 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
62 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentUtil; |
2 |
26 Feb 07 |
jari |
63 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
64 |
import org.tigr.util.QSort; |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
public class GDMExpViewer extends JPanel implements IViewer { |
2 |
26 Feb 07 |
jari |
67 |
|
2 |
26 Feb 07 |
jari |
68 |
private JPanel content; |
2 |
26 Feb 07 |
jari |
69 |
private GDMExpHeader expColumnHeaderSP; |
2 |
26 Feb 07 |
jari |
70 |
private GDMExpHeader expRowHeaderSP; |
2 |
26 Feb 07 |
jari |
71 |
private JScrollBar upperRightCornerSB; |
2 |
26 Feb 07 |
jari |
72 |
private JScrollBar lowerLeftCornerSB; |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
private FloatMatrix expDistMatrix; |
2 |
26 Feb 07 |
jari |
75 |
private FloatMatrix rawMatrix; |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
private IData expData; |
2 |
26 Feb 07 |
jari |
78 |
private IData arrayData; |
2 |
26 Feb 07 |
jari |
79 |
private IFramework framework; |
2 |
26 Feb 07 |
jari |
80 |
private JFrame mainframe; |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
82 |
private static final int TRACE_SPACE = 50; |
2 |
26 Feb 07 |
jari |
83 |
private static final int MAX_MATRIX_WIDTH = 400; |
2 |
26 Feb 07 |
jari |
84 |
private static final int MAX_COL_WIDTH = MAX_MATRIX_WIDTH; |
2 |
26 Feb 07 |
jari |
85 |
private static final int MAX_COL_HEIGHT = 500; |
2 |
26 Feb 07 |
jari |
86 |
private static final int MAX_ROW_WIDTH = MAX_COL_HEIGHT; |
2 |
26 Feb 07 |
jari |
87 |
private static final int MAX_ROW_HEIGHT = MAX_COL_WIDTH; |
2 |
26 Feb 07 |
jari |
88 |
private static final int NOT_UPDATE_ANNOTATION_SIZE = -1; |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
private int num_experiments; |
2 |
26 Feb 07 |
jari |
91 |
private int maxExpNameLength; |
2 |
26 Feb 07 |
jari |
92 |
private int probes; |
2 |
26 Feb 07 |
jari |
93 |
private int featuresCount; |
2 |
26 Feb 07 |
jari |
94 |
private int label; |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
private int displayEvery = 1; |
2 |
26 Feb 07 |
jari |
97 |
private Insets insets; |
2 |
26 Feb 07 |
jari |
98 |
private Color clusterBorderColor; |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
private int elementWidth; |
2 |
26 Feb 07 |
jari |
101 |
private int paletteStyle; |
2 |
26 Feb 07 |
jari |
102 |
private int labelIndex = -1; |
2 |
26 Feb 07 |
jari |
103 |
private int maxLabelWidth = 0; |
2 |
26 Feb 07 |
jari |
104 |
private boolean isGRScale; |
2 |
26 Feb 07 |
jari |
105 |
private boolean isDrawBorders; |
2 |
26 Feb 07 |
jari |
106 |
private boolean isAntiAliasing = true; |
2 |
26 Feb 07 |
jari |
107 |
private boolean isTracing = false; |
2 |
26 Feb 07 |
jari |
108 |
private int tracespace; |
2 |
26 Feb 07 |
jari |
109 |
private int xWidth; |
2 |
26 Feb 07 |
jari |
110 |
private int xHeight; |
2 |
26 Feb 07 |
jari |
111 |
private Dimension elementSize = new Dimension(15,15); |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
public static Color zeroColor = Color.black; |
2 |
26 Feb 07 |
jari |
114 |
public static Color NaNColor = Color.gray; |
2 |
26 Feb 07 |
jari |
115 |
public static Color diagColor = Color.white; |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
private float maxValue; |
2 |
26 Feb 07 |
jari |
118 |
private float minValue; |
2 |
26 Feb 07 |
jari |
119 |
private float origMaxValue; |
2 |
26 Feb 07 |
jari |
120 |
private float origMinValue; |
2 |
26 Feb 07 |
jari |
121 |
|
2 |
26 Feb 07 |
jari |
122 |
private int colorScheme = IDisplayMenu.GREEN_RED_SCHEME; |
2 |
26 Feb 07 |
jari |
123 |
private BufferedImage negGreenColorImage = createGradientImage(Color.green, Color.black); |
2 |
26 Feb 07 |
jari |
124 |
private BufferedImage posRedColorImage = createGradientImage(Color.black, Color.red); |
2 |
26 Feb 07 |
jari |
125 |
private BufferedImage negBlueColorImage = createGradientImage(Color.blue, Color.black); |
2 |
26 Feb 07 |
jari |
126 |
private BufferedImage posYellowColorImage = createGradientImage(Color.black, Color.yellow); |
2 |
26 Feb 07 |
jari |
127 |
private BufferedImage negCustomColorImage; |
2 |
26 Feb 07 |
jari |
128 |
private BufferedImage posCustomColorImage; |
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
private BufferedImage posColorImage = posRedColorImage; |
2 |
26 Feb 07 |
jari |
131 |
private BufferedImage negColorImage = negGreenColorImage; |
2 |
26 Feb 07 |
jari |
132 |
private Color borderColor; |
2 |
26 Feb 07 |
jari |
133 |
private boolean isDrawClusterBorders=true; |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
private String distanceMetric; |
2 |
26 Feb 07 |
jari |
136 |
private JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
139 |
private int [][] clusters; |
2 |
26 Feb 07 |
jari |
140 |
private int numOfClusters; |
2 |
26 Feb 07 |
jari |
141 |
private int [] clusterlength; |
2 |
26 Feb 07 |
jari |
142 |
|
2 |
26 Feb 07 |
jari |
143 |
private int [] indices; |
2 |
26 Feb 07 |
jari |
144 |
private boolean sortByProximity = true; |
2 |
26 Feb 07 |
jari |
145 |
|
2 |
26 Feb 07 |
jari |
146 |
private boolean imposeClusterOrder = false; |
2 |
26 Feb 07 |
jari |
147 |
|
2 |
26 Feb 07 |
jari |
148 |
private static final String PARAMETER = "command-parameter"; |
2 |
26 Feb 07 |
jari |
149 |
private static final String CHANGE_ANNOTATION_WIDTH = "Change Annotation Width"; |
2 |
26 Feb 07 |
jari |
150 |
private static final String BORDER_COLOR_CMD = "select-border-color-cmd"; |
2 |
26 Feb 07 |
jari |
151 |
private static final String COLOR_SCALE_CMD = "set-color-scale-cmd"; |
2 |
26 Feb 07 |
jari |
152 |
private static final String DISPLAY_LABEL_ACTION = "display--label-action"; |
2 |
26 Feb 07 |
jari |
153 |
private static final String DISPLAY_LABEL_CMD = "display-label-cmd"; |
2 |
26 Feb 07 |
jari |
154 |
private static final String GREEN_RED_COLOR_SCHEME_CMD = "display-green-red-scheme-cmd"; |
2 |
26 Feb 07 |
jari |
155 |
private static final String BLUE_YELLOW_COLOR_SCHEME_CMD = "display-blue-yellow-scheme-cmd"; |
2 |
26 Feb 07 |
jari |
156 |
private static final String CUSTOM_COLOR_SCHEME_CMD = "display-custom-color-scheme-cmd"; |
2 |
26 Feb 07 |
jari |
157 |
private static final String DISPLAY_DRAW_BORDERS_CMD = "display-draw-borders-cmd"; |
2 |
26 Feb 07 |
jari |
158 |
private static final String DISPLAY_2X2_CMD = "display-2x2-cmd"; |
2 |
26 Feb 07 |
jari |
159 |
private static final String DISPLAY_5X5_CMD = "display-5x5-cmd"; |
2 |
26 Feb 07 |
jari |
160 |
private static final String DISPLAY_10X10_CMD = "display-10x10-cmd"; |
2 |
26 Feb 07 |
jari |
161 |
private static final String DISPLAY_15X15_CMD = "display-15x15-cmd"; |
2 |
26 Feb 07 |
jari |
162 |
private static final String DISPLAY_OTHER_CMD = "display-other-cmd"; |
2 |
26 Feb 07 |
jari |
163 |
private static final String SET_CLUSTER_BORDER_CMD = "set-cluster-border-cmd"; |
2 |
26 Feb 07 |
jari |
164 |
private static final String ANNOTATION_WIDTH_ACTION = "annotation-width-action"; |
2 |
26 Feb 07 |
jari |
165 |
private static final String ANNOTATION_WIDTH_CMD = "annotation-width-cmd"; |
2 |
26 Feb 07 |
jari |
166 |
private static final String TOGGLE_PROXIMITY_SORT_CMD = "Toggle-proximity-cmd"; |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
168 |
public static final String SORT_BY_EXP_NAME_CMD = "sort-by-experiment-cmd"; |
2 |
26 Feb 07 |
jari |
169 |
public static final String SORT_BY_ORIGINAL_ORDER_CMD = "sort-by-original-order-cmd"; |
2 |
26 Feb 07 |
jari |
170 |
public static final String SORT_BY_PROXIMITY_CMD = "sort-by-proximity-cmd"; |
2 |
26 Feb 07 |
jari |
171 |
private static final String SAVE_NEIGHBORS_CMD = "save-k-neighbors"; |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>GDMExpViewer</code> for specified results. |
2 |
26 Feb 07 |
jari |
175 |
*/ |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
public GDMExpViewer(){} |
2 |
26 Feb 07 |
jari |
178 |
|
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
public GDMExpViewer(IFramework fmwk, AlgorithmData aData, String distMetric, int displayEvery, int [][] clusters, int numOfClusters) { |
2 |
26 Feb 07 |
jari |
181 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
182 |
|
2 |
26 Feb 07 |
jari |
183 |
this.framework = fmwk; |
2 |
26 Feb 07 |
jari |
184 |
this.distanceMetric = distMetric; |
2 |
26 Feb 07 |
jari |
185 |
|
2 |
26 Feb 07 |
jari |
186 |
IDisplayMenu menu = framework.getDisplayMenu(); |
2 |
26 Feb 07 |
jari |
187 |
|
2 |
26 Feb 07 |
jari |
188 |
setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
189 |
|
2 |
26 Feb 07 |
jari |
190 |
this.expData = fmwk.getData(); |
2 |
26 Feb 07 |
jari |
191 |
this.experiment = expData.getExperiment(); |
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
193 |
this.probes = expData.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
194 |
this.featuresCount = expData.getFeaturesCount(); |
2 |
26 Feb 07 |
jari |
195 |
|
2 |
26 Feb 07 |
jari |
196 |
this.displayEvery = displayEvery; |
2 |
26 Feb 07 |
jari |
197 |
this.expDistMatrix = (aData.getMatrix("gdMatrix")).getSubMatrix(displayEvery); |
2 |
26 Feb 07 |
jari |
198 |
|
2 |
26 Feb 07 |
jari |
199 |
this.rawMatrix = (aData.getMatrix("rawMatrix")).getSubMatrix(displayEvery); |
2 |
26 Feb 07 |
jari |
200 |
|
2 |
26 Feb 07 |
jari |
201 |
AlgorithmParameters params = aData.getParams(); |
2 |
26 Feb 07 |
jari |
202 |
|
2 |
26 Feb 07 |
jari |
203 |
this.clusters = clusters; |
2 |
26 Feb 07 |
jari |
204 |
this.numOfClusters = numOfClusters; |
2 |
26 Feb 07 |
jari |
205 |
|
2 |
26 Feb 07 |
jari |
206 |
this.maxValue = params.getFloat("maxDist"); |
2 |
26 Feb 07 |
jari |
207 |
this.minValue = params.getFloat("minDist"); |
2 |
26 Feb 07 |
jari |
208 |
this.origMaxValue = maxValue; |
2 |
26 Feb 07 |
jari |
209 |
this.origMinValue = minValue; |
2 |
26 Feb 07 |
jari |
210 |
|
2 |
26 Feb 07 |
jari |
211 |
this.maxExpNameLength = params.getInt("maxExpNameLength"); |
2 |
26 Feb 07 |
jari |
212 |
|
2 |
26 Feb 07 |
jari |
213 |
this.num_experiments = this.featuresCount/displayEvery; |
2 |
26 Feb 07 |
jari |
214 |
|
2 |
26 Feb 07 |
jari |
215 |
this.borderColor = Color.black; |
2 |
26 Feb 07 |
jari |
216 |
this.clusterBorderColor = Color.white; |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
this.insets = new Insets(1, 1, 1, 1); |
2 |
26 Feb 07 |
jari |
219 |
|
2 |
26 Feb 07 |
jari |
220 |
xWidth = getXSize(); |
2 |
26 Feb 07 |
jari |
221 |
xHeight = getYSize(); |
2 |
26 Feb 07 |
jari |
222 |
|
2 |
26 Feb 07 |
jari |
223 |
if(this.displayEvery==1) { |
2 |
26 Feb 07 |
jari |
224 |
setIndices(createIndices()); |
2 |
26 Feb 07 |
jari |
225 |
} else if (this.displayEvery > 1) { |
2 |
26 Feb 07 |
jari |
226 |
setIndices(createIndices(this.displayEvery)); |
2 |
26 Feb 07 |
jari |
227 |
} |
2 |
26 Feb 07 |
jari |
228 |
|
2 |
26 Feb 07 |
jari |
229 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
230 |
addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
231 |
addMouseMotionListener(listener); |
2 |
26 Feb 07 |
jari |
232 |
addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
233 |
|
2 |
26 Feb 07 |
jari |
234 |
this.expColumnHeaderSP = createHeader(TRACE_SPACE, true, xWidth, MAX_COL_HEIGHT, elementSize); |
2 |
26 Feb 07 |
jari |
235 |
this.expRowHeaderSP = createHeader(TRACE_SPACE, false, MAX_ROW_WIDTH, xHeight, elementSize); |
2 |
26 Feb 07 |
jari |
236 |
|
2 |
26 Feb 07 |
jari |
237 |
this.expColumnHeaderSP.setMatrixListener(listener); |
2 |
26 Feb 07 |
jari |
238 |
this.expRowHeaderSP.setMatrixListener(listener); |
2 |
26 Feb 07 |
jari |
239 |
|
2 |
26 Feb 07 |
jari |
240 |
this.content = createContent(MAX_MATRIX_WIDTH, MAX_MATRIX_WIDTH, listener); |
2 |
26 Feb 07 |
jari |
241 |
|
2 |
26 Feb 07 |
jari |
242 |
this.upperRightCornerSB = createScrollBar(JScrollBar.VERTICAL); |
2 |
26 Feb 07 |
jari |
243 |
this.lowerLeftCornerSB = createScrollBar(JScrollBar.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
245 |
setMaxWidth(content, expColumnHeaderSP); |
2 |
26 Feb 07 |
jari |
246 |
setMaxHeight(content, expRowHeaderSP); |
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
expColumnHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
249 |
expRowHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
251 |
expColumnHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
252 |
expRowHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
253 |
|
2 |
26 Feb 07 |
jari |
254 |
add(content); |
2 |
26 Feb 07 |
jari |
255 |
|
2 |
26 Feb 07 |
jari |
// Create a "pop-up" context menu for GDM Viewer |
2 |
26 Feb 07 |
jari |
257 |
popup = createJPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
258 |
|
2 |
26 Feb 07 |
jari |
259 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
260 |
setOpaque(true); |
2 |
26 Feb 07 |
jari |
261 |
|
2 |
26 Feb 07 |
jari |
262 |
} |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
264 |
public Expression getExpression(){ |
2 |
26 Feb 07 |
jari |
265 |
return new Expression(this, this.getClass(), "new", |
2 |
26 Feb 07 |
jari |
266 |
new Object[]{this.experiment, expDistMatrix, rawMatrix, |
2 |
26 Feb 07 |
jari |
267 |
new Integer(probes), new Integer(featuresCount), new Float(minValue), distanceMetric, |
2 |
26 Feb 07 |
jari |
268 |
new Float(origMaxValue), new Float(origMinValue), new Float(maxValue), new Integer(maxExpNameLength), |
2 |
26 Feb 07 |
jari |
269 |
new Integer(displayEvery), clusters, new Integer(numOfClusters)}); |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
|
2 |
26 Feb 07 |
jari |
272 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a new GDMExpViewer from saved state data. |
2 |
26 Feb 07 |
jari |
274 |
* |
2 |
26 Feb 07 |
jari |
* @param exptID |
2 |
26 Feb 07 |
jari |
* @param expDistMatrix |
2 |
26 Feb 07 |
jari |
* @param rawMatrix |
2 |
26 Feb 07 |
jari |
* @param probes |
2 |
26 Feb 07 |
jari |
* @param featuresCount |
2 |
26 Feb 07 |
jari |
* @param minValue |
2 |
26 Feb 07 |
jari |
* @param distMetric |
2 |
26 Feb 07 |
jari |
* @param origMaxValue |
2 |
26 Feb 07 |
jari |
* @param origMinValue |
2 |
26 Feb 07 |
jari |
* @param maxValue |
2 |
26 Feb 07 |
jari |
* @param maxExpNameLength |
2 |
26 Feb 07 |
jari |
* @param displayEvery |
2 |
26 Feb 07 |
jari |
* @param clusters |
2 |
26 Feb 07 |
jari |
* @param numOfClusters |
2 |
26 Feb 07 |
jari |
289 |
*/ |
2 |
26 Feb 07 |
jari |
290 |
public GDMExpViewer(Experiment e, FloatMatrix expDistMatrix, FloatMatrix rawMatrix, |
2 |
26 Feb 07 |
jari |
291 |
Integer probes, Integer featuresCount, Float minValue, String distMetric, |
2 |
26 Feb 07 |
jari |
292 |
Float origMaxValue, Float origMinValue, Float maxValue, Integer maxExpNameLength, |
2 |
26 Feb 07 |
jari |
293 |
Integer displayEvery, int [][] clusters, Integer numOfClusters) { |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
295 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
296 |
|
2 |
26 Feb 07 |
jari |
297 |
this.distanceMetric = distMetric; |
2 |
26 Feb 07 |
jari |
298 |
|
2 |
26 Feb 07 |
jari |
299 |
setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
300 |
this.probes = probes.intValue(); |
2 |
26 Feb 07 |
jari |
301 |
this.featuresCount = featuresCount.intValue(); |
2 |
26 Feb 07 |
jari |
302 |
|
2 |
26 Feb 07 |
jari |
303 |
this.displayEvery = displayEvery.intValue(); |
2 |
26 Feb 07 |
jari |
304 |
this.expDistMatrix = expDistMatrix; |
2 |
26 Feb 07 |
jari |
305 |
|
2 |
26 Feb 07 |
jari |
306 |
this.rawMatrix = rawMatrix; |
2 |
26 Feb 07 |
jari |
307 |
|
2 |
26 Feb 07 |
jari |
308 |
this.clusters = clusters; |
2 |
26 Feb 07 |
jari |
309 |
this.numOfClusters = numOfClusters.intValue(); |
2 |
26 Feb 07 |
jari |
310 |
|
2 |
26 Feb 07 |
jari |
311 |
this.maxValue = maxValue.floatValue(); |
2 |
26 Feb 07 |
jari |
312 |
this.minValue = minValue.floatValue(); |
2 |
26 Feb 07 |
jari |
313 |
this.origMaxValue = origMaxValue.floatValue(); |
2 |
26 Feb 07 |
jari |
314 |
this.origMinValue = origMinValue.floatValue(); |
2 |
26 Feb 07 |
jari |
315 |
|
2 |
26 Feb 07 |
jari |
316 |
this.maxExpNameLength = maxExpNameLength.intValue(); |
2 |
26 Feb 07 |
jari |
317 |
|
2 |
26 Feb 07 |
jari |
318 |
this.num_experiments = this.featuresCount/(displayEvery.intValue()); |
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
this.borderColor = Color.black; |
2 |
26 Feb 07 |
jari |
321 |
this.clusterBorderColor = Color.white; |
2 |
26 Feb 07 |
jari |
322 |
|
2 |
26 Feb 07 |
jari |
323 |
this.insets = new Insets(1, 1, 1, 1); |
2 |
26 Feb 07 |
jari |
324 |
|
2 |
26 Feb 07 |
jari |
325 |
xWidth = getXSize(); |
2 |
26 Feb 07 |
jari |
326 |
xHeight = getYSize(); |
2 |
26 Feb 07 |
jari |
327 |
|
2 |
26 Feb 07 |
jari |
328 |
if(this.displayEvery==1) { |
2 |
26 Feb 07 |
jari |
329 |
setIndices(createIndices()); |
2 |
26 Feb 07 |
jari |
330 |
} else if (this.displayEvery > 1) { |
2 |
26 Feb 07 |
jari |
331 |
setIndices(createIndices(this.displayEvery)); |
2 |
26 Feb 07 |
jari |
332 |
} |
2 |
26 Feb 07 |
jari |
333 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
334 |
|
2 |
26 Feb 07 |
jari |
335 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
336 |
addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
337 |
addMouseMotionListener(listener); |
2 |
26 Feb 07 |
jari |
338 |
addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
339 |
|
2 |
26 Feb 07 |
jari |
340 |
this.expColumnHeaderSP = createHeader(TRACE_SPACE, true, xWidth, MAX_COL_HEIGHT, elementSize); |
2 |
26 Feb 07 |
jari |
341 |
this.expRowHeaderSP = createHeader(TRACE_SPACE, false, MAX_ROW_WIDTH, xHeight, elementSize); |
2 |
26 Feb 07 |
jari |
342 |
|
2 |
26 Feb 07 |
jari |
343 |
this.expColumnHeaderSP.setMatrixListener(listener); |
2 |
26 Feb 07 |
jari |
344 |
this.expRowHeaderSP.setMatrixListener(listener); |
2 |
26 Feb 07 |
jari |
345 |
|
2 |
26 Feb 07 |
jari |
346 |
this.content = createContent(MAX_MATRIX_WIDTH, MAX_MATRIX_WIDTH, listener); |
2 |
26 Feb 07 |
jari |
347 |
|
2 |
26 Feb 07 |
jari |
348 |
this.upperRightCornerSB = createScrollBar(JScrollBar.VERTICAL); |
2 |
26 Feb 07 |
jari |
349 |
this.lowerLeftCornerSB = createScrollBar(JScrollBar.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
350 |
|
2 |
26 Feb 07 |
jari |
351 |
setMaxWidth(content, expColumnHeaderSP); |
2 |
26 Feb 07 |
jari |
352 |
setMaxHeight(content, expRowHeaderSP); |
2 |
26 Feb 07 |
jari |
353 |
|
2 |
26 Feb 07 |
jari |
354 |
expColumnHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
355 |
expRowHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
356 |
|
2 |
26 Feb 07 |
jari |
357 |
expColumnHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
358 |
expRowHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
359 |
|
2 |
26 Feb 07 |
jari |
360 |
add(content); |
2 |
26 Feb 07 |
jari |
361 |
|
2 |
26 Feb 07 |
jari |
// Create a "pop-up" context menu for GDM Viewer |
2 |
26 Feb 07 |
jari |
363 |
popup = createJPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
364 |
|
2 |
26 Feb 07 |
jari |
365 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
366 |
setOpaque(true); |
2 |
26 Feb 07 |
jari |
367 |
} |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
369 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#setExperiment(org.tigr.microarray.mev.cluster.gui.Experiment) |
2 |
26 Feb 07 |
jari |
372 |
*/ |
2 |
26 Feb 07 |
jari |
373 |
public void setExperiment(Experiment e) { |
2 |
26 Feb 07 |
jari |
374 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
375 |
} |
2 |
26 Feb 07 |
jari |
376 |
|
2 |
26 Feb 07 |
jari |
377 |
|
2 |
26 Feb 07 |
jari |
378 |
public void setMainFrame(JFrame mframe) { |
2 |
26 Feb 07 |
jari |
379 |
this.mainframe = mframe; |
2 |
26 Feb 07 |
jari |
380 |
} |
2 |
26 Feb 07 |
jari |
381 |
|
2 |
26 Feb 07 |
jari |
382 |
private void setIndices(int [] indexes) { |
2 |
26 Feb 07 |
jari |
383 |
this.indices = indexes; |
2 |
26 Feb 07 |
jari |
384 |
} |
2 |
26 Feb 07 |
jari |
385 |
|
2 |
26 Feb 07 |
jari |
386 |
private int [] getIndices() { |
2 |
26 Feb 07 |
jari |
387 |
return this.indices; |
2 |
26 Feb 07 |
jari |
388 |
} |
2 |
26 Feb 07 |
jari |
389 |
|
2 |
26 Feb 07 |
jari |
390 |
private int [] createIndices(int displayEvery) { |
2 |
26 Feb 07 |
jari |
391 |
|
2 |
26 Feb 07 |
jari |
392 |
int indicesSize = this.num_experiments; |
2 |
26 Feb 07 |
jari |
393 |
int [] indices = new int [indicesSize]; |
2 |
26 Feb 07 |
jari |
394 |
int i=0, total=0, index=0; |
2 |
26 Feb 07 |
jari |
395 |
|
2 |
26 Feb 07 |
jari |
396 |
for (index=0; index < this.probes; index++) { |
2 |
26 Feb 07 |
jari |
397 |
if ((total % this.displayEvery == 0) && (i<indicesSize)) { |
2 |
26 Feb 07 |
jari |
398 |
indices[i] = index; |
2 |
26 Feb 07 |
jari |
399 |
i++; |
2 |
26 Feb 07 |
jari |
400 |
} |
2 |
26 Feb 07 |
jari |
401 |
total++; |
2 |
26 Feb 07 |
jari |
402 |
} |
2 |
26 Feb 07 |
jari |
403 |
|
2 |
26 Feb 07 |
jari |
404 |
total = 0; |
2 |
26 Feb 07 |
jari |
405 |
if (this.numOfClusters > 0) { |
2 |
26 Feb 07 |
jari |
406 |
clusterlength = new int [numOfClusters]; |
2 |
26 Feb 07 |
jari |
407 |
i=0; |
2 |
26 Feb 07 |
jari |
408 |
for (int j=0; j<this.numOfClusters; j++) { |
2 |
26 Feb 07 |
jari |
409 |
for(int k=0; k<clusters[j].length; k++) { |
2 |
26 Feb 07 |
jari |
410 |
if ( (total % this.displayEvery == 0) && (i < indicesSize)) { |
2 |
26 Feb 07 |
jari |
411 |
indices[i] = clusters[j][k]; |
2 |
26 Feb 07 |
jari |
412 |
i++; |
2 |
26 Feb 07 |
jari |
413 |
clusterlength[j] ++; |
2 |
26 Feb 07 |
jari |
414 |
} |
2 |
26 Feb 07 |
jari |
415 |
total++; |
2 |
26 Feb 07 |
jari |
416 |
} |
2 |
26 Feb 07 |
jari |
417 |
} |
2 |
26 Feb 07 |
jari |
418 |
} |
2 |
26 Feb 07 |
jari |
419 |
return indices; |
2 |
26 Feb 07 |
jari |
420 |
} |
2 |
26 Feb 07 |
jari |
421 |
|
2 |
26 Feb 07 |
jari |
422 |
private int [] createIndices() { |
2 |
26 Feb 07 |
jari |
423 |
int [] indices = new int [this.num_experiments]; |
2 |
26 Feb 07 |
jari |
424 |
for (int i=0; i<indices.length; i++) { |
2 |
26 Feb 07 |
jari |
425 |
indices[i] = i; |
2 |
26 Feb 07 |
jari |
426 |
} |
2 |
26 Feb 07 |
jari |
427 |
|
2 |
26 Feb 07 |
jari |
428 |
|
2 |
26 Feb 07 |
jari |
429 |
if (this.numOfClusters > 0) { |
2 |
26 Feb 07 |
jari |
430 |
clusterlength = new int [this.num_experiments]; |
2 |
26 Feb 07 |
jari |
431 |
int i=0; |
2 |
26 Feb 07 |
jari |
432 |
|
2 |
26 Feb 07 |
jari |
433 |
for (int j=0; j<this.numOfClusters; j++) { |
2 |
26 Feb 07 |
jari |
434 |
for(int k=0; k<clusters[j].length; k++) { |
2 |
26 Feb 07 |
jari |
435 |
indices[i] = clusters[j][k]; |
2 |
26 Feb 07 |
jari |
436 |
clusterlength[j] ++; |
2 |
26 Feb 07 |
jari |
437 |
i++; |
2 |
26 Feb 07 |
jari |
438 |
} |
2 |
26 Feb 07 |
jari |
439 |
} |
2 |
26 Feb 07 |
jari |
440 |
} |
2 |
26 Feb 07 |
jari |
441 |
|
2 |
26 Feb 07 |
jari |
442 |
return indices; |
2 |
26 Feb 07 |
jari |
443 |
} |
2 |
26 Feb 07 |
jari |
444 |
|
2 |
26 Feb 07 |
jari |
445 |
private void setMaxWidth(JComponent content, JComponent header) { |
2 |
26 Feb 07 |
jari |
446 |
int c_width = content.getPreferredSize().width; |
2 |
26 Feb 07 |
jari |
447 |
int h_width = header.getPreferredSize().width; |
2 |
26 Feb 07 |
jari |
448 |
if (c_width > h_width) { |
2 |
26 Feb 07 |
jari |
449 |
header.setPreferredSize(new Dimension(c_width, header.getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
450 |
} else { |
2 |
26 Feb 07 |
jari |
451 |
content.setPreferredSize(new Dimension(h_width, content.getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
452 |
} |
2 |
26 Feb 07 |
jari |
453 |
} |
2 |
26 Feb 07 |
jari |
454 |
|
2 |
26 Feb 07 |
jari |
455 |
private void setMaxHeight(JComponent content, JComponent header) { |
2 |
26 Feb 07 |
jari |
456 |
int c_height = content.getPreferredSize().height; |
2 |
26 Feb 07 |
jari |
457 |
int h_height = header.getPreferredSize().height; |
2 |
26 Feb 07 |
jari |
458 |
if (c_height > h_height) { |
2 |
26 Feb 07 |
jari |
459 |
header.setPreferredSize(new Dimension(header.getPreferredSize().width, c_height)); |
2 |
26 Feb 07 |
jari |
460 |
} else { |
2 |
26 Feb 07 |
jari |
461 |
content.setPreferredSize(new Dimension(content.getPreferredSize().width, h_height)); |
2 |
26 Feb 07 |
jari |
462 |
} |
2 |
26 Feb 07 |
jari |
463 |
} |
2 |
26 Feb 07 |
jari |
464 |
|
2 |
26 Feb 07 |
jari |
465 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a gradient image for positive values. |
2 |
26 Feb 07 |
jari |
467 |
*/ |
2 |
26 Feb 07 |
jari |
468 |
public BufferedImage getPosColorImage() { |
2 |
26 Feb 07 |
jari |
469 |
return posColorImage; |
2 |
26 Feb 07 |
jari |
470 |
} |
2 |
26 Feb 07 |
jari |
471 |
|
2 |
26 Feb 07 |
jari |
472 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a gradient image for negative values. |
2 |
26 Feb 07 |
jari |
474 |
*/ |
2 |
26 Feb 07 |
jari |
475 |
public BufferedImage getNegColorImage() { |
2 |
26 Feb 07 |
jari |
476 |
return negColorImage; |
2 |
26 Feb 07 |
jari |
477 |
} |
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
479 |
|
2 |
26 Feb 07 |
jari |
480 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a gradient image for positive values. |
2 |
26 Feb 07 |
jari |
482 |
*/ |
2 |
26 Feb 07 |
jari |
483 |
public void setPosColorImage(BufferedImage image) { |
2 |
26 Feb 07 |
jari |
484 |
this.posColorImage = image; |
2 |
26 Feb 07 |
jari |
485 |
} |
2 |
26 Feb 07 |
jari |
486 |
|
2 |
26 Feb 07 |
jari |
487 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a gradient image for negative values. |
2 |
26 Feb 07 |
jari |
489 |
*/ |
2 |
26 Feb 07 |
jari |
490 |
public void setNegColorImage(BufferedImage image) { |
2 |
26 Feb 07 |
jari |
491 |
this.negColorImage = image; |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
|
2 |
26 Feb 07 |
jari |
494 |
public void setBorderColor(Color color) { |
2 |
26 Feb 07 |
jari |
495 |
this.borderColor = color; |
2 |
26 Feb 07 |
jari |
496 |
} |
2 |
26 Feb 07 |
jari |
497 |
|
2 |
26 Feb 07 |
jari |
498 |
private GDMExpHeader createHeader(int tracespace, boolean colHdr, |
2 |
26 Feb 07 |
jari |
499 |
int width, int height, Dimension eSize) { |
2 |
26 Feb 07 |
jari |
500 |
|
2 |
26 Feb 07 |
jari |
501 |
GDMExpHeader hdr = new GDMExpHeader(insets, tracespace, colHdr, experiment, width, height, eSize, maxExpNameLength, featuresCount, indices); |
2 |
26 Feb 07 |
jari |
502 |
|
2 |
26 Feb 07 |
jari |
503 |
return hdr; |
2 |
26 Feb 07 |
jari |
504 |
} |
2 |
26 Feb 07 |
jari |
505 |
|
2 |
26 Feb 07 |
jari |
506 |
private JPanel createContent(int width, int height, Listener listener) { |
2 |
26 Feb 07 |
jari |
507 |
JPanel cPanel = new JPanel(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
508 |
cPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
509 |
xWidth = getXSize(); |
2 |
26 Feb 07 |
jari |
510 |
xHeight = getYSize(); |
2 |
26 Feb 07 |
jari |
511 |
cPanel.setSize(xWidth+5, xHeight+5); |
2 |
26 Feb 07 |
jari |
512 |
cPanel.setPreferredSize(new Dimension(xWidth+5, xHeight+5)); |
2 |
26 Feb 07 |
jari |
513 |
cPanel.setOpaque(true); |
2 |
26 Feb 07 |
jari |
514 |
cPanel.setVisible(true); |
2 |
26 Feb 07 |
jari |
515 |
return cPanel; |
2 |
26 Feb 07 |
jari |
516 |
} |
2 |
26 Feb 07 |
jari |
517 |
|
2 |
26 Feb 07 |
jari |
518 |
|
2 |
26 Feb 07 |
jari |
519 |
private JScrollBar createScrollBar(int orientation) { |
2 |
26 Feb 07 |
jari |
520 |
|
2 |
26 Feb 07 |
jari |
521 |
JScrollBar jsb = new JScrollBar(orientation); |
2 |
26 Feb 07 |
jari |
522 |
|
2 |
26 Feb 07 |
jari |
// VERTICAL Upper Right Corner ScrollBar for Column Header component |
2 |
26 Feb 07 |
jari |
524 |
if (orientation == JScrollBar.VERTICAL) { |
2 |
26 Feb 07 |
jari |
525 |
jsb.setModel(expColumnHeaderSP.getVerticalScrollBar().getModel()); |
2 |
26 Feb 07 |
jari |
526 |
} else { |
2 |
26 Feb 07 |
jari |
// HORIZONTAL Lower Left Corner ScrollBar for Row Header component |
2 |
26 Feb 07 |
jari |
528 |
jsb.setModel(expRowHeaderSP.getHorizontalScrollBar().getModel()); |
2 |
26 Feb 07 |
jari |
529 |
} |
2 |
26 Feb 07 |
jari |
530 |
return jsb; |
2 |
26 Feb 07 |
jari |
531 |
} |
2 |
26 Feb 07 |
jari |
532 |
|
2 |
26 Feb 07 |
jari |
533 |
|
2 |
26 Feb 07 |
jari |
534 |
|
2 |
26 Feb 07 |
jari |
535 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of top row. |
2 |
26 Feb 07 |
jari |
537 |
*/ |
2 |
26 Feb 07 |
jari |
538 |
private int getTopIndex(int top) { |
2 |
26 Feb 07 |
jari |
539 |
if (top<0) { |
2 |
26 Feb 07 |
jari |
540 |
return 0; |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
return (top-insets.top)/elementSize.height; |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of left column. |
2 |
26 Feb 07 |
jari |
547 |
*/ |
2 |
26 Feb 07 |
jari |
548 |
private int getLeftIndex(int left) { |
2 |
26 Feb 07 |
jari |
549 |
if (left<0) { |
2 |
26 Feb 07 |
jari |
550 |
return 0; |
2 |
26 Feb 07 |
jari |
551 |
} |
2 |
26 Feb 07 |
jari |
552 |
return (left-insets.left)/(elementSize.width+getSpacing()); |
2 |
26 Feb 07 |
jari |
553 |
} |
2 |
26 Feb 07 |
jari |
554 |
|
2 |
26 Feb 07 |
jari |
555 |
|
2 |
26 Feb 07 |
jari |
556 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of right column. |
2 |
26 Feb 07 |
jari |
558 |
*/ |
2 |
26 Feb 07 |
jari |
559 |
private int getRightIndex(int right, int limit) { |
2 |
26 Feb 07 |
jari |
560 |
if (right<0) { |
2 |
26 Feb 07 |
jari |
561 |
return 0; |
2 |
26 Feb 07 |
jari |
562 |
} |
2 |
26 Feb 07 |
jari |
563 |
int result = (right-insets.left)/(elementSize.width+getSpacing())+1; |
2 |
26 Feb 07 |
jari |
564 |
return result > limit ? limit : result; |
2 |
26 Feb 07 |
jari |
565 |
} |
2 |
26 Feb 07 |
jari |
566 |
|
2 |
26 Feb 07 |
jari |
567 |
|
2 |
26 Feb 07 |
jari |
568 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of bottom row. |
2 |
26 Feb 07 |
jari |
570 |
*/ |
2 |
26 Feb 07 |
jari |
571 |
private int getBottomIndex(int bottom, int limit) { |
2 |
26 Feb 07 |
jari |
572 |
if (bottom<0) { |
2 |
26 Feb 07 |
jari |
573 |
return 0; |
2 |
26 Feb 07 |
jari |
574 |
} |
2 |
26 Feb 07 |
jari |
575 |
int result = (bottom-insets.top)/elementSize.height+1; |
2 |
26 Feb 07 |
jari |
576 |
return result > limit ? limit : result; |
2 |
26 Feb 07 |
jari |
577 |
} |
2 |
26 Feb 07 |
jari |
578 |
|
2 |
26 Feb 07 |
jari |
579 |
public void paint(Graphics g1D) { |
2 |
26 Feb 07 |
jari |
580 |
super.paint(g1D); |
2 |
26 Feb 07 |
jari |
581 |
if (num_experiments == 0 || framework == null) { // empty data |
2 |
26 Feb 07 |
jari |
582 |
return; |
2 |
26 Feb 07 |
jari |
583 |
} |
2 |
26 Feb 07 |
jari |
584 |
|
2 |
26 Feb 07 |
jari |
585 |
Graphics2D g2D = (Graphics2D)g1D; |
2 |
26 Feb 07 |
jari |
586 |
|
2 |
26 Feb 07 |
jari |
587 |
if (isAntiAliasing) {//Anti-aliasing is on |
2 |
26 Feb 07 |
jari |
588 |
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
2 |
26 Feb 07 |
jari |
589 |
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
590 |
} |
2 |
26 Feb 07 |
jari |
591 |
|
2 |
26 Feb 07 |
jari |
592 |
drawColumns(g2D); |
2 |
26 Feb 07 |
jari |
593 |
|
2 |
26 Feb 07 |
jari |
594 |
if (isDrawClusterBorders && numOfClusters > 0 ) { |
2 |
26 Feb 07 |
jari |
595 |
drawClusterBorder(g2D); |
2 |
26 Feb 07 |
jari |
596 |
} |
2 |
26 Feb 07 |
jari |
597 |
|
2 |
26 Feb 07 |
jari |
598 |
return; |
2 |
26 Feb 07 |
jari |
599 |
} |
2 |
26 Feb 07 |
jari |
600 |
|
2 |
26 Feb 07 |
jari |
601 |
private void drawClusterBorder(Graphics2D g2d) { |
2 |
26 Feb 07 |
jari |
602 |
|
2 |
26 Feb 07 |
jari |
603 |
int xPosition = insets.left; |
2 |
26 Feb 07 |
jari |
604 |
int yPosition = insets.top; |
2 |
26 Feb 07 |
jari |
605 |
int width=0, height=0; |
2 |
26 Feb 07 |
jari |
606 |
|
2 |
26 Feb 07 |
jari |
607 |
Graphics g = (Graphics) g2d; |
2 |
26 Feb 07 |
jari |
608 |
|
2 |
26 Feb 07 |
jari |
609 |
g.setColor(clusterBorderColor); |
2 |
26 Feb 07 |
jari |
610 |
|
2 |
26 Feb 07 |
jari |
611 |
for (int i = 0; i < this.numOfClusters; i++) { |
2 |
26 Feb 07 |
jari |
612 |
height = this.clusterlength[i]* (this.elementSize.height + getSpacing()); |
2 |
26 Feb 07 |
jari |
613 |
xPosition = insets.left; |
2 |
26 Feb 07 |
jari |
614 |
|
2 |
26 Feb 07 |
jari |
615 |
for (int j = 0; j < this.numOfClusters; j++) { |
2 |
26 Feb 07 |
jari |
616 |
width = this.clusterlength[j] * (this.elementSize.width + getSpacing()); |
2 |
26 Feb 07 |
jari |
617 |
g.drawRect( xPosition, yPosition, width, height); |
2 |
26 Feb 07 |
jari |
618 |
xPosition += width; |
2 |
26 Feb 07 |
jari |
619 |
} |
2 |
26 Feb 07 |
jari |
620 |
yPosition += height; |
2 |
26 Feb 07 |
jari |
621 |
} |
2 |
26 Feb 07 |
jari |
622 |
} |
2 |
26 Feb 07 |
jari |
623 |
|
2 |
26 Feb 07 |
jari |
624 |
private void drawRowColorBar(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
625 |
Rectangle bounds = g.getClipBounds(); |
2 |
26 Feb 07 |
jari |
626 |
final int top = getTopIndex(bounds.y); |
2 |
26 Feb 07 |
jari |
627 |
int bottom =0; |
2 |
26 Feb 07 |
jari |
628 |
|
2 |
26 Feb 07 |
jari |
629 |
bottom = getBottomIndex(bounds.y+bounds.height, featuresCount); |
2 |
26 Feb 07 |
jari |
630 |
|
2 |
26 Feb 07 |
jari |
631 |
for (int row=top; row<bottom; row++) { |
2 |
26 Feb 07 |
jari |
632 |
fillRowClusterRectAt(g, row, 5); |
2 |
26 Feb 07 |
jari |
633 |
} |
2 |
26 Feb 07 |
jari |
634 |
} |
2 |
26 Feb 07 |
jari |
635 |
|
2 |
26 Feb 07 |
jari |
636 |
/** |
2 |
26 Feb 07 |
jari |
* fills cluster colors |
2 |
26 Feb 07 |
jari |
638 |
*/ |
2 |
26 Feb 07 |
jari |
639 |
private void fillRowClusterRectAt(Graphics g, int row, int xLoc) { |
2 |
26 Feb 07 |
jari |
640 |
|
2 |
26 Feb 07 |
jari |
641 |
Color expColor = null; |
2 |
26 Feb 07 |
jari |
642 |
|
2 |
26 Feb 07 |
jari |
643 |
expColor = expData.getExperimentColor(indices[row]); |
2 |
26 Feb 07 |
jari |
644 |
|
2 |
26 Feb 07 |
jari |
645 |
if(expColor == null) |
2 |
26 Feb 07 |
jari |
646 |
expColor = Color.white; |
2 |
26 Feb 07 |
jari |
647 |
|
2 |
26 Feb 07 |
jari |
648 |
g.setColor(expColor); |
2 |
26 Feb 07 |
jari |
649 |
g.fillRect(xLoc, row*elementSize.height + insets.top, elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
650 |
} |
2 |
26 Feb 07 |
jari |
651 |
|
2 |
26 Feb 07 |
jari |
652 |
private void drawColumnColorBar(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
653 |
Rectangle bounds = g.getClipBounds(); |
2 |
26 Feb 07 |
jari |
654 |
final int left = getLeftIndex(bounds.x); |
2 |
26 Feb 07 |
jari |
655 |
int right = 0; |
2 |
26 Feb 07 |
jari |
656 |
|
2 |
26 Feb 07 |
jari |
657 |
right = getRightIndex(bounds.x+bounds.width, featuresCount); |
2 |
26 Feb 07 |
jari |
658 |
|
2 |
26 Feb 07 |
jari |
659 |
for (int column = left; column < right; column++) { |
2 |
26 Feb 07 |
jari |
660 |
fillColumnClusterRectAt(g, 5, column); |
2 |
26 Feb 07 |
jari |
661 |
} |
2 |
26 Feb 07 |
jari |
662 |
} |
2 |
26 Feb 07 |
jari |
663 |
|
2 |
26 Feb 07 |
jari |
664 |
/** |
2 |
26 Feb 07 |
jari |
* fills cluster colors |
2 |
26 Feb 07 |
jari |
666 |
*/ |
2 |
26 Feb 07 |
jari |
667 |
private void fillColumnClusterRectAt(Graphics g, int yLoc, int column) { |
2 |
26 Feb 07 |
jari |
668 |
|
2 |
26 Feb 07 |
jari |
669 |
Color expColor = null; |
2 |
26 Feb 07 |
jari |
670 |
|
2 |
26 Feb 07 |
jari |
671 |
expColor = expData.getExperimentColor(indices[column]); |
2 |
26 Feb 07 |
jari |
672 |
|
2 |
26 Feb 07 |
jari |
673 |
if(expColor == null) |
2 |
26 Feb 07 |
jari |
674 |
expColor = Color.white; |
2 |
26 Feb 07 |
jari |
675 |
|
2 |
26 Feb 07 |
jari |
676 |
g.setColor(expColor); |
2 |
26 Feb 07 |
jari |
677 |
g.fillRect(column*elementSize.width + insets.top, yLoc, elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
678 |
} |
2 |
26 Feb 07 |
jari |
679 |
|
2 |
26 Feb 07 |
jari |
680 |
private void drawColumns(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
681 |
|
2 |
26 Feb 07 |
jari |
682 |
Rectangle bounds = g.getClipBounds(); |
2 |
26 Feb 07 |
jari |
683 |
final int top = getTopIndex(bounds.y); |
2 |
26 Feb 07 |
jari |
684 |
final int left = getLeftIndex(bounds.x); |
2 |
26 Feb 07 |
jari |
685 |
|
2 |
26 Feb 07 |
jari |
686 |
int bottom = 0; |
2 |
26 Feb 07 |
jari |
687 |
int right = 0; |
2 |
26 Feb 07 |
jari |
688 |
|
2 |
26 Feb 07 |
jari |
689 |
bottom = getBottomIndex(bounds.y+bounds.height, featuresCount); |
2 |
26 Feb 07 |
jari |
690 |
right = getRightIndex(bounds.x+bounds.width, featuresCount); |
2 |
26 Feb 07 |
jari |
691 |
|
2 |
26 Feb 07 |
jari |
692 |
for (int column = left; column < right; column++) { |
2 |
26 Feb 07 |
jari |
693 |
drawColumn(g, column, top, bottom); |
2 |
26 Feb 07 |
jari |
694 |
} |
2 |
26 Feb 07 |
jari |
695 |
|
2 |
26 Feb 07 |
jari |
696 |
drawPerimeter(g); |
2 |
26 Feb 07 |
jari |
697 |
} |
2 |
26 Feb 07 |
jari |
698 |
|
2 |
26 Feb 07 |
jari |
699 |
private void drawPerimeter(Graphics2D g){ |
2 |
26 Feb 07 |
jari |
700 |
Color color = g.getColor(); |
2 |
26 Feb 07 |
jari |
701 |
g.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
702 |
if(this.isDrawClusterBorders && this.numOfClusters > 0) |
2 |
26 Feb 07 |
jari |
703 |
g.drawRect(0,0, getXSize()-insets.right+1, getYSize()-insets.bottom+1); |
2 |
26 Feb 07 |
jari |
704 |
else |
2 |
26 Feb 07 |
jari |
705 |
g.drawRect(0,0, getXSize()-insets.right, getYSize()-insets.bottom); |
2 |
26 Feb 07 |
jari |
706 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
707 |
} |
2 |
26 Feb 07 |
jari |
708 |
|
2 |
26 Feb 07 |
jari |
709 |
/** |
2 |
26 Feb 07 |
jari |
* Draws a specified column. |
2 |
26 Feb 07 |
jari |
711 |
*/ |
2 |
26 Feb 07 |
jari |
712 |
private void drawColumn(Graphics2D g, int column, final int top, final int bottom) { |
2 |
26 Feb 07 |
jari |
713 |
for (int row = top; row < bottom; row++) { |
2 |
26 Feb 07 |
jari |
714 |
drawSlideDataElement(g, row, column); |
2 |
26 Feb 07 |
jari |
715 |
} |
2 |
26 Feb 07 |
jari |
716 |
} |
2 |
26 Feb 07 |
jari |
717 |
|
2 |
26 Feb 07 |
jari |
718 |
/** |
2 |
26 Feb 07 |
jari |
* Draws an element rectangle to specified row and column. |
2 |
26 Feb 07 |
jari |
720 |
*/ |
2 |
26 Feb 07 |
jari |
721 |
private void drawSlideDataElement(Graphics g, final int row, final int column) { |
2 |
26 Feb 07 |
jari |
722 |
|
2 |
26 Feb 07 |
jari |
723 |
Color holdColor; |
2 |
26 Feb 07 |
jari |
724 |
|
2 |
26 Feb 07 |
jari |
725 |
float distance = expDistMatrix.get(indices[row], indices[column]); |
2 |
26 Feb 07 |
jari |
726 |
if (Float.isNaN(distance)) { |
2 |
26 Feb 07 |
jari |
727 |
holdColor = NaNColor; |
2 |
26 Feb 07 |
jari |
728 |
} else if (distance == 0 && row == column) { |
2 |
26 Feb 07 |
jari |
729 |
holdColor = diagColor; |
2 |
26 Feb 07 |
jari |
730 |
} else if (distance == 0 && row != column) { |
2 |
26 Feb 07 |
jari |
731 |
holdColor = zeroColor; |
2 |
26 Feb 07 |
jari |
732 |
} else { |
2 |
26 Feb 07 |
jari |
733 |
holdColor = getColor(distance); |
2 |
26 Feb 07 |
jari |
734 |
} |
2 |
26 Feb 07 |
jari |
735 |
g.setColor(holdColor); |
2 |
26 Feb 07 |
jari |
736 |
g.fillRect( getXPos(column), getYPos(row), elementSize.width, elementSize.height); |
2 |
26 Feb 07 |
jari |
737 |
|
2 |
26 Feb 07 |
jari |
738 |
if (isDrawBorders && elementSize.width > 2) { |
2 |
26 Feb 07 |
jari |
739 |
g.setColor(borderColor); |
2 |
26 Feb 07 |
jari |
740 |
g.drawRect( getXPos(column), getYPos(row), elementSize.width -1, elementSize.height -1); |
2 |
26 Feb 07 |
jari |
741 |
} |
2 |
26 Feb 07 |
jari |
742 |
} |
2 |
26 Feb 07 |
jari |
743 |
|
2 |
26 Feb 07 |
jari |
744 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a gradient image with specified initial colors. |
2 |
26 Feb 07 |
jari |
746 |
*/ |
2 |
26 Feb 07 |
jari |
747 |
private BufferedImage createGradientImage(Color color1, Color color2) { |
2 |
26 Feb 07 |
jari |
748 |
BufferedImage image = new BufferedImage(256, 1, BufferedImage.TYPE_3BYTE_BGR); |
2 |
26 Feb 07 |
jari |
749 |
Graphics2D graphics = image.createGraphics(); |
2 |
26 Feb 07 |
jari |
750 |
GradientPaint gp = new GradientPaint(0, 0, color1, 255, 0, color2); |
2 |
26 Feb 07 |
jari |
751 |
graphics.setPaint(gp); |
2 |
26 Feb 07 |
jari |
752 |
graphics.drawRect(0, 0, 255, 1); |
2 |
26 Feb 07 |
jari |
753 |
return image; |
2 |
26 Feb 07 |
jari |
754 |
} |
2 |
26 Feb 07 |
jari |
755 |
|
2 |
26 Feb 07 |
jari |
756 |
private Color getColor(float value) { |
2 |
26 Feb 07 |
jari |
757 |
if (Float.isNaN(value) || posColorImage == null || negColorImage == null) { |
2 |
26 Feb 07 |
jari |
758 |
return NaNColor; |
2 |
26 Feb 07 |
jari |
759 |
} |
2 |
26 Feb 07 |
jari |
//float maximum = value < 0 ? this.minValue : this.maxValue; |
2 |
26 Feb 07 |
jari |
761 |
|
2 |
26 Feb 07 |
jari |
762 |
int colorIndex = (int)(255*(value-this.minValue)/this.maxValue); |
2 |
26 Feb 07 |
jari |
763 |
if(colorIndex > 255) |
2 |
26 Feb 07 |
jari |
764 |
colorIndex = 255; |
2 |
26 Feb 07 |
jari |
765 |
if(colorIndex < 0) |
2 |
26 Feb 07 |
jari |
766 |
colorIndex = 0; |
2 |
26 Feb 07 |
jari |
767 |
int rgb = value < 0 ? negColorImage.getRGB(255-colorIndex, 0) : posColorImage.getRGB(colorIndex, 0); |
2 |
26 Feb 07 |
jari |
768 |
|
2 |
26 Feb 07 |
jari |
769 |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
770 |
} |
2 |
26 Feb 07 |
jari |
771 |
|
2 |
26 Feb 07 |
jari |
772 |
|
2 |
26 Feb 07 |
jari |
773 |
private void setFontSize(int width) { |
2 |
26 Feb 07 |
jari |
774 |
if (width > 12) |
2 |
26 Feb 07 |
jari |
775 |
width = 12; |
2 |
26 Feb 07 |
jari |
776 |
setFont(new Font("monspaced", Font.PLAIN, width)); |
2 |
26 Feb 07 |
jari |
777 |
} |
2 |
26 Feb 07 |
jari |
778 |
|
2 |
26 Feb 07 |
jari |
779 |
public void setElementWidth(int width) { |
2 |
26 Feb 07 |
jari |
780 |
this.elementWidth = width; |
2 |
26 Feb 07 |
jari |
781 |
setFontSize(width); |
2 |
26 Feb 07 |
jari |
782 |
} |
2 |
26 Feb 07 |
jari |
783 |
|
2 |
26 Feb 07 |
jari |
784 |
public int getElementWidth() { |
2 |
26 Feb 07 |
jari |
785 |
return this.elementWidth; |
2 |
26 Feb 07 |
jari |
786 |
} |
2 |
26 Feb 07 |
jari |
787 |
|
2 |
26 Feb 07 |
jari |
788 |
void setTracing(boolean isTracing) { |
2 |
26 Feb 07 |
jari |
789 |
this.isTracing = isTracing; |
2 |
26 Feb 07 |
jari |
790 |
} |
2 |
26 Feb 07 |
jari |
791 |
|
2 |
26 Feb 07 |
jari |
792 |
private int getSpacing() { |
2 |
26 Feb 07 |
jari |
793 |
if (isTracing) |
2 |
26 Feb 07 |
jari |
794 |
return tracespace; |
2 |
26 Feb 07 |
jari |
795 |
return 0; |
2 |
26 Feb 07 |
jari |
796 |
} |
2 |
26 Feb 07 |
jari |
797 |
|
2 |
26 Feb 07 |
jari |
798 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
799 |
return this; |
2 |
26 Feb 07 |
jari |
800 |
} |
2 |
26 Feb 07 |
jari |
801 |
|
2 |
26 Feb 07 |
jari |
802 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
803 |
return expColumnHeaderSP; |
2 |
26 Feb 07 |
jari |
804 |
} |
2 |
26 Feb 07 |
jari |
805 |
|
2 |
26 Feb 07 |
jari |
806 |
public JComponent getColumnHeaderComponent() { |
2 |
26 Feb 07 |
jari |
807 |
return expColumnHeaderSP; |
2 |
26 Feb 07 |
jari |
808 |
} |
2 |
26 Feb 07 |
jari |
809 |
|
2 |
26 Feb 07 |
jari |
810 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
811 |
return expRowHeaderSP; |
2 |
26 Feb 07 |
jari |
812 |
} |
2 |
26 Feb 07 |
jari |
813 |
|
2 |
26 Feb 07 |
jari |
814 |
public JComponent getUpperRightCornerSB() { |
2 |
26 Feb 07 |
jari |
815 |
return upperRightCornerSB; |
2 |
26 Feb 07 |
jari |
816 |
} |
2 |
26 Feb 07 |
jari |
817 |
|
2 |
26 Feb 07 |
jari |
818 |
public JComponent getLowerLeftCornerSB() { |
2 |
26 Feb 07 |
jari |
819 |
return lowerLeftCornerSB; |
2 |
26 Feb 07 |
jari |
820 |
} |
2 |
26 Feb 07 |
jari |
821 |
|
2 |
26 Feb 07 |
jari |
822 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a width of the viewer. |
2 |
26 Feb 07 |
jari |
824 |
*/ |
2 |
26 Feb 07 |
jari |
825 |
private int getXSize() { |
2 |
26 Feb 07 |
jari |
826 |
int size = 0; |
2 |
26 Feb 07 |
jari |
827 |
size = (featuresCount*elementSize.width)+((featuresCount-1)*getSpacing()+insets.left+insets.right); |
2 |
26 Feb 07 |
jari |
828 |
|
2 |
26 Feb 07 |
jari |
829 |
return size; |
2 |
26 Feb 07 |
jari |
830 |
} |
2 |
26 Feb 07 |
jari |
831 |
|
2 |
26 Feb 07 |
jari |
832 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a height of the viewer. |
2 |
26 Feb 07 |
jari |
834 |
*/ |
2 |
26 Feb 07 |
jari |
835 |
private int getYSize() { |
2 |
26 Feb 07 |
jari |
836 |
int size = 0; |
2 |
26 Feb 07 |
jari |
837 |
size = (featuresCount*elementSize.height)+((featuresCount-1)*getSpacing()+insets.top+insets.bottom); |
2 |
26 Feb 07 |
jari |
838 |
|
2 |
26 Feb 07 |
jari |
839 |
return size; |
2 |
26 Feb 07 |
jari |
840 |
} |
2 |
26 Feb 07 |
jari |
841 |
|
2 |
26 Feb 07 |
jari |
842 |
/** |
2 |
26 Feb 07 |
jari |
* Returns max label width. |
2 |
26 Feb 07 |
jari |
844 |
*/ |
2 |
26 Feb 07 |
jari |
845 |
private int getMaxExpNameLength() { |
2 |
26 Feb 07 |
jari |
846 |
return maxExpNameLength; |
2 |
26 Feb 07 |
jari |
847 |
} |
2 |
26 Feb 07 |
jari |
848 |
|
2 |
26 Feb 07 |
jari |
849 |
|
2 |
26 Feb 07 |
jari |
850 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer size. |
2 |
26 Feb 07 |
jari |
852 |
*/ |
2 |
26 Feb 07 |
jari |
853 |
private void updateSize(int annotationSize) { |
2 |
26 Feb 07 |
jari |
854 |
|
2 |
26 Feb 07 |
jari |
855 |
int width = getXSize(); |
2 |
26 Feb 07 |
jari |
856 |
int height = getYSize(); |
2 |
26 Feb 07 |
jari |
857 |
|
2 |
26 Feb 07 |
jari |
858 |
setSize(width, height); |
2 |
26 Feb 07 |
jari |
859 |
setPreferredSize(new Dimension(width, height)); |
2 |
26 Feb 07 |
jari |
860 |
|
2 |
26 Feb 07 |
jari |
861 |
expColumnHeaderSP.setNumExperiments(featuresCount); |
2 |
26 Feb 07 |
jari |
862 |
expColumnHeaderSP.updateSize(annotationSize); |
2 |
26 Feb 07 |
jari |
863 |
|
2 |
26 Feb 07 |
jari |
864 |
expRowHeaderSP.setNumExperiments(featuresCount); |
2 |
26 Feb 07 |
jari |
865 |
expRowHeaderSP.updateSize(annotationSize); |
2 |
26 Feb 07 |
jari |
866 |
|
2 |
26 Feb 07 |
jari |
867 |
setMaxWidth(content, expColumnHeaderSP); |
2 |
26 Feb 07 |
jari |
868 |
setMaxHeight(content, expRowHeaderSP); |
2 |
26 Feb 07 |
jari |
869 |
|
2 |
26 Feb 07 |
jari |
870 |
expColumnHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
871 |
expRowHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
872 |
|
2 |
26 Feb 07 |
jari |
873 |
this.upperRightCornerSB.setValues(190, 10, 100, 200); |
2 |
26 Feb 07 |
jari |
874 |
this.lowerLeftCornerSB.setValues(100, 10, 100, 200); |
2 |
26 Feb 07 |
jari |
875 |
|
2 |
26 Feb 07 |
jari |
876 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
877 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
878 |
|
2 |
26 Feb 07 |
jari |
879 |
repaint(); |
2 |
26 Feb 07 |
jari |
880 |
} |
2 |
26 Feb 07 |
jari |
881 |
|
2 |
26 Feb 07 |
jari |
882 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
883 |
|
2 |
26 Feb 07 |
jari |
884 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
885 |
this.expData = framework.getData(); |
2 |
26 Feb 07 |
jari |
886 |
onDataChanged(this.expData); |
2 |
26 Feb 07 |
jari |
887 |
|
2 |
26 Feb 07 |
jari |
888 |
this.probes = expData.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
889 |
this.featuresCount = expData.getFeaturesCount(); |
2 |
26 Feb 07 |
jari |
890 |
|
2 |
26 Feb 07 |
jari |
891 |
this.num_experiments = featuresCount/displayEvery; |
2 |
26 Feb 07 |
jari |
892 |
|
2 |
26 Feb 07 |
jari |
893 |
IDisplayMenu menu = framework.getDisplayMenu(); |
2 |
26 Feb 07 |
jari |
894 |
setFontSize(elementSize.width); |
2 |
26 Feb 07 |
jari |
895 |
|
2 |
26 Feb 07 |
jari |
896 |
xWidth = getXSize(); |
2 |
26 Feb 07 |
jari |
897 |
xHeight = getYSize(); |
2 |
26 Feb 07 |
jari |
898 |
|
2 |
26 Feb 07 |
jari |
899 |
expColumnHeaderSP.setData(this.expData); |
2 |
26 Feb 07 |
jari |
900 |
expColumnHeaderSP.setContentWidth(xWidth+10); |
2 |
26 Feb 07 |
jari |
901 |
expColumnHeaderSP.setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
902 |
|
2 |
26 Feb 07 |
jari |
903 |
expRowHeaderSP.setData(this.expData); |
2 |
26 Feb 07 |
jari |
904 |
expRowHeaderSP.setContentHeight(xHeight+10); |
2 |
26 Feb 07 |
jari |
905 |
expRowHeaderSP.setElementHeight(elementSize.height); |
2 |
26 Feb 07 |
jari |
906 |
|
2 |
26 Feb 07 |
jari |
907 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
908 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
909 |
|
2 |
26 Feb 07 |
jari |
910 |
onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
911 |
onDataChanged(this.expData); |
2 |
26 Feb 07 |
jari |
912 |
} |
2 |
26 Feb 07 |
jari |
913 |
|
2 |
26 Feb 07 |
jari |
914 |
public void onMenuChanged(IDisplayMenu menu) { |
2 |
26 Feb 07 |
jari |
915 |
|
2 |
26 Feb 07 |
jari |
916 |
this.probes = expData.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
917 |
this.featuresCount = expData.getFeaturesCount(); |
2 |
26 Feb 07 |
jari |
918 |
this.num_experiments = this.featuresCount/displayEvery; |
2 |
26 Feb 07 |
jari |
919 |
|
2 |
26 Feb 07 |
jari |
920 |
|
2 |
26 Feb 07 |
jari |
921 |
paletteStyle = menu.getPaletteStyle(); |
2 |
26 Feb 07 |
jari |
922 |
isGRScale = menu.isGRScale(); |
2 |
26 Feb 07 |
jari |
923 |
if (menu.isTracing() == isTracing && |
2 |
26 Feb 07 |
jari |
924 |
labelIndex == menu.getLabelIndex() && |
2 |
26 Feb 07 |
jari |
925 |
isAntiAliasing == menu.isAntiAliasing()) { |
2 |
26 Feb 07 |
jari |
926 |
return; |
2 |
26 Feb 07 |
jari |
927 |
} |
2 |
26 Feb 07 |
jari |
928 |
|
2 |
26 Feb 07 |
jari |
929 |
isAntiAliasing = menu.isAntiAliasing(); |
2 |
26 Feb 07 |
jari |
930 |
expColumnHeaderSP.setAntiAliasing(isAntiAliasing); |
2 |
26 Feb 07 |
jari |
931 |
expRowHeaderSP.setAntiAliasing(isAntiAliasing); |
2 |
26 Feb 07 |
jari |
932 |
labelIndex = menu.getLabelIndex(); |
2 |
26 Feb 07 |
jari |
933 |
isTracing = menu.isTracing(); |
2 |
26 Feb 07 |
jari |
934 |
setFont(new Font("monospaced", Font.BOLD, elementSize.height)); |
2 |
26 Feb 07 |
jari |
935 |
|
2 |
26 Feb 07 |
jari |
936 |
xWidth = getXSize(); |
2 |
26 Feb 07 |
jari |
937 |
xHeight = getYSize(); |
2 |
26 Feb 07 |
jari |
938 |
|
2 |
26 Feb 07 |
jari |
939 |
expColumnHeaderSP.setContentWidth(xWidth); |
2 |
26 Feb 07 |
jari |
940 |
expColumnHeaderSP.setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
941 |
expColumnHeaderSP.setTracing(isTracing); |
2 |
26 Feb 07 |
jari |
942 |
|
2 |
26 Feb 07 |
jari |
943 |
expRowHeaderSP.setContentHeight(xHeight); |
2 |
26 Feb 07 |
jari |
944 |
expRowHeaderSP.setElementHeight(elementSize.height); |
2 |
26 Feb 07 |
jari |
945 |
expRowHeaderSP.setTracing(isTracing); |
2 |
26 Feb 07 |
jari |
946 |
|
2 |
26 Feb 07 |
jari |
947 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
948 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
949 |
|
2 |
26 Feb 07 |
jari |
950 |
updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
951 |
} |
2 |
26 Feb 07 |
jari |
952 |
|
2 |
26 Feb 07 |
jari |
953 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
954 |
|
2 |
26 Feb 07 |
jari |
955 |
this.expData = data; |
2 |
26 Feb 07 |
jari |
956 |
|
2 |
26 Feb 07 |
jari |
957 |
this.probes = expData.getFeaturesSize(); |
2 |
26 Feb 07 |
jari |
958 |
this.featuresCount = expData.getFeaturesCount(); |
2 |
26 Feb 07 |
jari |
959 |
|
2 |
26 Feb 07 |
jari |
960 |
this.num_experiments = this.featuresCount/displayEvery; |
2 |
26 Feb 07 |
jari |
961 |
|
2 |
26 Feb 07 |
jari |
962 |
expColumnHeaderSP.setData(data); |
2 |
26 Feb 07 |
jari |
963 |
expRowHeaderSP.setData(data); |
2 |
26 Feb 07 |
jari |
964 |
|
2 |
26 Feb 07 |
jari |
965 |
updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
966 |
} |
2 |
26 Feb 07 |
jari |
967 |
|
2 |
26 Feb 07 |
jari |
968 |
public void onDeselected() { |
2 |
26 Feb 07 |
jari |
969 |
return; |
2 |
26 Feb 07 |
jari |
970 |
} |
2 |
26 Feb 07 |
jari |
971 |
|
2 |
26 Feb 07 |
jari |
972 |
public void onClosed() { |
2 |
26 Feb 07 |
jari |
973 |
return; |
2 |
26 Feb 07 |
jari |
974 |
} |
2 |
26 Feb 07 |
jari |
975 |
|
2 |
26 Feb 07 |
jari |
976 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
977 |
return null; |
2 |
26 Feb 07 |
jari |
978 |
} |
2 |
26 Feb 07 |
jari |
979 |
|
2 |
26 Feb 07 |
jari |
980 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if specified row and column are exists. |
2 |
26 Feb 07 |
jari |
982 |
*/ |
2 |
26 Feb 07 |
jari |
983 |
private boolean isLegalPosition(int row, int column) { |
2 |
26 Feb 07 |
jari |
984 |
if (isLegalRow(row) && isLegalColumn(column)) { |
2 |
26 Feb 07 |
jari |
985 |
return true; |
2 |
26 Feb 07 |
jari |
986 |
} |
2 |
26 Feb 07 |
jari |
987 |
return false; |
2 |
26 Feb 07 |
jari |
988 |
} |
2 |
26 Feb 07 |
jari |
989 |
|
2 |
26 Feb 07 |
jari |
990 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if specified column is exists. |
2 |
26 Feb 07 |
jari |
992 |
*/ |
2 |
26 Feb 07 |
jari |
993 |
private boolean isLegalColumn(int column) { |
2 |
26 Feb 07 |
jari |
994 |
if (column < 0 || column > featuresCount -1) { |
2 |
26 Feb 07 |
jari |
995 |
return false; |
2 |
26 Feb 07 |
jari |
996 |
} |
2 |
26 Feb 07 |
jari |
997 |
return true; |
2 |
26 Feb 07 |
jari |
998 |
} |
2 |
26 Feb 07 |
jari |
999 |
|
2 |
26 Feb 07 |
jari |
1000 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if specified row is exists. |
2 |
26 Feb 07 |
jari |
1002 |
*/ |
2 |
26 Feb 07 |
jari |
1003 |
private boolean isLegalRow(int row) { |
2 |
26 Feb 07 |
jari |
1004 |
if (row < 0 || row > featuresCount -1) { |
2 |
26 Feb 07 |
jari |
1005 |
return false; |
2 |
26 Feb 07 |
jari |
1006 |
} |
2 |
26 Feb 07 |
jari |
1007 |
return true; |
2 |
26 Feb 07 |
jari |
1008 |
} |
2 |
26 Feb 07 |
jari |
1009 |
|
2 |
26 Feb 07 |
jari |
1010 |
/** |
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 |
1013 |
*/ |
2 |
26 Feb 07 |
jari |
1014 |
private int findColumn(int targetx) { |
2 |
26 Feb 07 |
jari |
1015 |
int columnSize = elementSize.width + getSpacing(); |
2 |
26 Feb 07 |
jari |
1016 |
|
2 |
26 Feb 07 |
jari |
1017 |
if (targetx > featuresCount*columnSize - getSpacing() + insets.left || targetx < insets.left) { |
2 |
26 Feb 07 |
jari |
1018 |
return -1; |
2 |
26 Feb 07 |
jari |
1019 |
} else { |
2 |
26 Feb 07 |
jari |
1020 |
return ((targetx)/columnSize); |
2 |
26 Feb 07 |
jari |
1021 |
} |
2 |
26 Feb 07 |
jari |
1022 |
} |
2 |
26 Feb 07 |
jari |
1023 |
|
2 |
26 Feb 07 |
jari |
1024 |
/** |
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 |
1027 |
*/ |
2 |
26 Feb 07 |
jari |
1028 |
private int findRow(int targety) { |
2 |
26 Feb 07 |
jari |
1029 |
int rowSize = num_experiments*elementSize.height; |
2 |
26 Feb 07 |
jari |
1030 |
if (targety > rowSize + insets.top || targety < insets.top) { |
2 |
26 Feb 07 |
jari |
1031 |
return -1; |
2 |
26 Feb 07 |
jari |
1032 |
} else { |
2 |
26 Feb 07 |
jari |
1033 |
return (targety)/elementSize.height; |
2 |
26 Feb 07 |
jari |
1034 |
} |
2 |
26 Feb 07 |
jari |
1035 |
} |
2 |
26 Feb 07 |
jari |
1036 |
|
2 |
26 Feb 07 |
jari |
1037 |
/** |
2 |
26 Feb 07 |
jari |
* Returns x coordinate of a column. |
2 |
26 Feb 07 |
jari |
1039 |
*/ |
2 |
26 Feb 07 |
jari |
1040 |
private int getXPos(int column) { |
2 |
26 Feb 07 |
jari |
1041 |
return column*(elementSize.width + getSpacing()) + insets.left; |
2 |
26 Feb 07 |
jari |
1042 |
} |
2 |
26 Feb 07 |
jari |
1043 |
|
2 |
26 Feb 07 |
jari |
1044 |
/** |
2 |
26 Feb 07 |
jari |
* Returns y coordinate of a row. |
2 |
26 Feb 07 |
jari |
1046 |
*/ |
2 |
26 Feb 07 |
jari |
1047 |
private int getYPos(int row) { |
2 |
26 Feb 07 |
jari |
1048 |
return row * elementSize.height + insets.top; |
2 |
26 Feb 07 |
jari |
1049 |
} |
2 |
26 Feb 07 |
jari |
1050 |
|
2 |
26 Feb 07 |
jari |
1051 |
/** |
2 |
26 Feb 07 |
jari |
* Draws a rectangle with specified color. |
2 |
26 Feb 07 |
jari |
1053 |
*/ |
2 |
26 Feb 07 |
jari |
1054 |
private void drawColoredBoxAt(Graphics g, int row, int column, Color color) { |
2 |
26 Feb 07 |
jari |
1055 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
1056 |
g.drawRect(insets.left + column*(elementSize.width+getSpacing()), insets.top + row*elementSize.height, elementSize.width-1, elementSize.height-1); |
2 |
26 Feb 07 |
jari |
1057 |
} |
2 |
26 Feb 07 |
jari |
1058 |
|
2 |
26 Feb 07 |
jari |
1059 |
public void displayGDMSpotInfo(int col, int row) { |
2 |
26 Feb 07 |
jari |
1060 |
new GDMExpSpotInfoDisplay(mainframe, this.expData, expDistMatrix, rawMatrix, distanceMetric, col, row); |
2 |
26 Feb 07 |
jari |
1061 |
} |
2 |
26 Feb 07 |
jari |
1062 |
|
2 |
26 Feb 07 |
jari |
1063 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a check box menu item with specified name, acton command and state. |
2 |
26 Feb 07 |
jari |
1065 |
*/ |
2 |
26 Feb 07 |
jari |
1066 |
private JCheckBoxMenuItem createJCheckBoxMenuItem(String name, String command, Listener listener, boolean isSelected) { |
2 |
26 Feb 07 |
jari |
1067 |
JCheckBoxMenuItem item = new JCheckBoxMenuItem(name); |
2 |
26 Feb 07 |
jari |
1068 |
item.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
1069 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1070 |
item.setSelected(isSelected); |
2 |
26 Feb 07 |
jari |
1071 |
return item; |
2 |
26 Feb 07 |
jari |
1072 |
} |
2 |
26 Feb 07 |
jari |
1073 |
|
2 |
26 Feb 07 |
jari |
1074 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a check box menu item with specified name and acton command. |
2 |
26 Feb 07 |
jari |
1076 |
*/ |
2 |
26 Feb 07 |
jari |
1077 |
private JCheckBoxMenuItem createJCheckBoxMenuItem(String name, String command, Listener listener) { |
2 |
26 Feb 07 |
jari |
1078 |
return createJCheckBoxMenuItem(name, command, listener, false); |
2 |
26 Feb 07 |
jari |
1079 |
} |
2 |
26 Feb 07 |
jari |
1080 |
|
2 |
26 Feb 07 |
jari |
1081 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a radio button menu item with specified name, acton command and state. |
2 |
26 Feb 07 |
jari |
1083 |
*/ |
2 |
26 Feb 07 |
jari |
1084 |
private JRadioButtonMenuItem createJRadioButtonMenuItem(String name, String command, Listener listener, ButtonGroup buttonGroup, boolean isSelected) { |
2 |
26 Feb 07 |
jari |
1085 |
JRadioButtonMenuItem item = new JRadioButtonMenuItem(name); |
2 |
26 Feb 07 |
jari |
1086 |
item.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
1087 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1088 |
item.setSelected(isSelected); |
2 |
26 Feb 07 |
jari |
1089 |
if (buttonGroup != null) { |
2 |
26 Feb 07 |
jari |
1090 |
buttonGroup.add(item); |
2 |
26 Feb 07 |
jari |
1091 |
} |
2 |
26 Feb 07 |
jari |
1092 |
return item; |
2 |
26 Feb 07 |
jari |
1093 |
} |
2 |
26 Feb 07 |
jari |
1094 |
|
2 |
26 Feb 07 |
jari |
1095 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a radio button menu item with specified name, acton command and button group. |
2 |
26 Feb 07 |
jari |
1097 |
*/ |
2 |
26 Feb 07 |
jari |
1098 |
private JRadioButtonMenuItem createJRadioButtonMenuItem(String name, String command, Listener listener, ButtonGroup buttonGroup) { |
2 |
26 Feb 07 |
jari |
1099 |
return createJRadioButtonMenuItem(name, command, listener, buttonGroup, false); |
2 |
26 Feb 07 |
jari |
1100 |
} |
2 |
26 Feb 07 |
jari |
1101 |
|
2 |
26 Feb 07 |
jari |
1102 |
|
2 |
26 Feb 07 |
jari |
1103 |
private JPopupMenu createJPopupMenu(Listener listener) { |
2 |
26 Feb 07 |
jari |
1104 |
JPopupMenu popup = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
1105 |
addMenuItems(popup, listener); |
2 |
26 Feb 07 |
jari |
1106 |
return popup; |
2 |
26 Feb 07 |
jari |
1107 |
} |
2 |
26 Feb 07 |
jari |
1108 |
|
2 |
26 Feb 07 |
jari |
1109 |
private void addMenuItems(JPopupMenu menu, Listener listener) { |
2 |
26 Feb 07 |
jari |
1110 |
JMenuItem item; |
2 |
26 Feb 07 |
jari |
1111 |
ButtonGroup buttonGroup; |
2 |
26 Feb 07 |
jari |
1112 |
|
2 |
26 Feb 07 |
jari |
1113 |
JMenu colorSchemeMenu = new JMenu("Color Scheme"); |
2 |
26 Feb 07 |
jari |
1114 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1115 |
colorSchemeMenu.add(createJRadioButtonMenuItem("Black/Red Scheme", GREEN_RED_COLOR_SCHEME_CMD, listener, buttonGroup, true)); |
2 |
26 Feb 07 |
jari |
1116 |
colorSchemeMenu.add(createJRadioButtonMenuItem("Black/Yellow Scheme", BLUE_YELLOW_COLOR_SCHEME_CMD, listener, buttonGroup)); |
2 |
26 Feb 07 |
jari |
1117 |
colorSchemeMenu.add(createJRadioButtonMenuItem("Custom Color Scheme", CUSTOM_COLOR_SCHEME_CMD, listener, buttonGroup)); |
2 |
26 Feb 07 |
jari |
1118 |
menu.add(colorSchemeMenu); |
2 |
26 Feb 07 |
jari |
1119 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1120 |
|
2 |
26 Feb 07 |
jari |
1121 |
JMenu sizeMenu = new JMenu("Element Size"); |
2 |
26 Feb 07 |
jari |
1122 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1123 |
sizeMenu.add(createJRadioButtonMenuItem("2 x 2", DISPLAY_2X2_CMD, listener, buttonGroup)); |
2 |
26 Feb 07 |
jari |
1124 |
sizeMenu.add(createJRadioButtonMenuItem("5 x 5", DISPLAY_5X5_CMD, listener, buttonGroup)); |
2 |
26 Feb 07 |
jari |
1125 |
sizeMenu.add(createJRadioButtonMenuItem("10 x 10", DISPLAY_10X10_CMD, listener, buttonGroup)); |
2 |
26 Feb 07 |
jari |
1126 |
sizeMenu.add(createJRadioButtonMenuItem("15 x 15", DISPLAY_15X15_CMD, listener, buttonGroup, true)); |
2 |
26 Feb 07 |
jari |
1127 |
sizeMenu.add(createJRadioButtonMenuItem("Other", DISPLAY_OTHER_CMD, listener, buttonGroup)); |
2 |
26 Feb 07 |
jari |
1128 |
menu.add(sizeMenu); |
2 |
26 Feb 07 |
jari |
1129 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1130 |
|
2 |
26 Feb 07 |
jari |
1131 |
menu.add(createJCheckBoxMenuItem("Draw Borders", DISPLAY_DRAW_BORDERS_CMD, listener)); |
2 |
26 Feb 07 |
jari |
1132 |
|
2 |
26 Feb 07 |
jari |
1133 |
/* |
2 |
26 Feb 07 |
jari |
if (numOfClusters > 0) { |
2 |
26 Feb 07 |
jari |
menu.add(createJCheckBoxMenuItem("Draw Cluster Borders", SET_CLUSTER_BORDER_CMD, listener, true)); |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
menu.add(createJCheckBoxMenuItem("Draw Cluster Borders", SET_CLUSTER_BORDER_CMD, listener, false)); |
2 |
26 Feb 07 |
jari |
1138 |
} |
2 |
26 Feb 07 |
jari |
1139 |
*/ |
2 |
26 Feb 07 |
jari |
1140 |
|
2 |
26 Feb 07 |
jari |
1141 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1142 |
|
2 |
26 Feb 07 |
jari |
1143 |
item = new JMenuItem("Toggle Sort on Proximity"); |
2 |
26 Feb 07 |
jari |
1144 |
item.setActionCommand(TOGGLE_PROXIMITY_SORT_CMD); |
2 |
26 Feb 07 |
jari |
1145 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1146 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1147 |
|
2 |
26 Feb 07 |
jari |
1148 |
item = new JMenuItem("Save k Neighbors"); |
2 |
26 Feb 07 |
jari |
1149 |
item.setActionCommand(SAVE_NEIGHBORS_CMD); |
2 |
26 Feb 07 |
jari |
1150 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1151 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1152 |
|
2 |
26 Feb 07 |
jari |
1153 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1154 |
|
2 |
26 Feb 07 |
jari |
1155 |
item = new JMenuItem("Impose Cluster Result"); |
2 |
26 Feb 07 |
jari |
1156 |
item.setActionCommand("impose-cluster-order"); |
2 |
26 Feb 07 |
jari |
1157 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1158 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1159 |
|
2 |
26 Feb 07 |
jari |
1160 |
item = new JMenuItem("Restore Loaded Order"); |
2 |
26 Feb 07 |
jari |
1161 |
item.setActionCommand(GDMExpViewer.SORT_BY_ORIGINAL_ORDER_CMD); |
2 |
26 Feb 07 |
jari |
1162 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1163 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1164 |
|
2 |
26 Feb 07 |
jari |
1165 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1166 |
|
2 |
26 Feb 07 |
jari |
1167 |
item = new JMenuItem("Select Border Color"); |
2 |
26 Feb 07 |
jari |
1168 |
item.setActionCommand(BORDER_COLOR_CMD); |
2 |
26 Feb 07 |
jari |
1169 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1170 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1171 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1172 |
|
2 |
26 Feb 07 |
jari |
1173 |
item = new JMenuItem("Set Color Scale"); |
2 |
26 Feb 07 |
jari |
1174 |
item.setActionCommand(COLOR_SCALE_CMD); |
2 |
26 Feb 07 |
jari |
1175 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1176 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1177 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
1178 |
|
2 |
26 Feb 07 |
jari |
1179 |
item = new JMenuItem("Change Annotation Width"); |
2 |
26 Feb 07 |
jari |
1180 |
item.setActionCommand(ANNOTATION_WIDTH_CMD); |
2 |
26 Feb 07 |
jari |
1181 |
item.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
1182 |
menu.add(item); |
2 |
26 Feb 07 |
jari |
1183 |
} |
2 |
26 Feb 07 |
jari |
1184 |
|
2 |
26 Feb 07 |
jari |
1185 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the user specified spot size. |
2 |
26 Feb 07 |
jari |
1187 |
*/ |
2 |
26 Feb 07 |
jari |
1188 |
|
2 |
26 Feb 07 |
jari |
1189 |
private void onElementSizeChanged(int width, int height) { |
2 |
26 Feb 07 |
jari |
1190 |
this.elementSize = new Dimension(width, height); |
2 |
26 Feb 07 |
jari |
1191 |
xWidth = getXSize(); |
2 |
26 Feb 07 |
jari |
1192 |
xHeight = getYSize(); |
2 |
26 Feb 07 |
jari |
1193 |
|
2 |
26 Feb 07 |
jari |
1194 |
expColumnHeaderSP.setContentWidth(xWidth); |
2 |
26 Feb 07 |
jari |
1195 |
expColumnHeaderSP.setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
1196 |
expColumnHeaderSP.setElementHeight(elementSize.height); |
2 |
26 Feb 07 |
jari |
1197 |
|
2 |
26 Feb 07 |
jari |
1198 |
expRowHeaderSP.setContentHeight(xHeight); |
2 |
26 Feb 07 |
jari |
1199 |
expRowHeaderSP.setElementWidth(elementSize.width); |
2 |
26 Feb 07 |
jari |
1200 |
expRowHeaderSP.setElementHeight(elementSize.height); |
2 |
26 Feb 07 |
jari |
1201 |
|
2 |
26 Feb 07 |
jari |
1202 |
expColumnHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
1203 |
expRowHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
1204 |
|
2 |
26 Feb 07 |
jari |
1205 |
updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
1206 |
} |
2 |
26 Feb 07 |
jari |
1207 |
|
2 |
26 Feb 07 |
jari |
1208 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the user specified spot size. |
2 |
26 Feb 07 |
jari |
1210 |
*/ |
2 |
26 Feb 07 |
jari |
1211 |
private void onElementSizeChanged() { |
2 |
26 Feb 07 |
jari |
1212 |
GDMElementSizeDialog dialog = new GDMElementSizeDialog(mainframe, elementSize); |
2 |
26 Feb 07 |
jari |
1213 |
if (dialog.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
1214 |
Dimension size = dialog.getElementSize(); |
2 |
26 Feb 07 |
jari |
1215 |
onElementSizeChanged(size.width, size.height); |
2 |
26 Feb 07 |
jari |
1216 |
} |
2 |
26 Feb 07 |
jari |
1217 |
} |
2 |
26 Feb 07 |
jari |
1218 |
|
2 |
26 Feb 07 |
jari |
1219 |
private void onDrawBordersChanged(boolean state) { |
2 |
26 Feb 07 |
jari |
1220 |
isDrawBorders = state; |
2 |
26 Feb 07 |
jari |
1221 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1222 |
repaint(); |
2 |
26 Feb 07 |
jari |
1223 |
} |
2 |
26 Feb 07 |
jari |
1224 |
|
2 |
26 Feb 07 |
jari |
1225 |
private void onDrawClusterBorderChange(boolean state) { |
2 |
26 Feb 07 |
jari |
1226 |
if (numOfClusters > 0 ) { |
2 |
26 Feb 07 |
jari |
1227 |
isDrawClusterBorders = state; |
2 |
26 Feb 07 |
jari |
1228 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1229 |
repaint(); |
2 |
26 Feb 07 |
jari |
1230 |
} |
2 |
26 Feb 07 |
jari |
1231 |
} |
2 |
26 Feb 07 |
jari |
1232 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the color pallete colors |
2 |
26 Feb 07 |
jari |
1234 |
*/ |
2 |
26 Feb 07 |
jari |
1235 |
private void onColorSchemeChange(int scheme){ |
2 |
26 Feb 07 |
jari |
1236 |
|
2 |
26 Feb 07 |
jari |
1237 |
|
2 |
26 Feb 07 |
jari |
1238 |
if (this.colorScheme == scheme && scheme != IDisplayMenu.CUSTOM_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
1239 |
return; |
2 |
26 Feb 07 |
jari |
1240 |
} else { |
2 |
26 Feb 07 |
jari |
1241 |
if (scheme == IDisplayMenu.GREEN_RED_SCHEME) { |
2 |
26 Feb 07 |
jari |
1242 |
setPosColorImage(posRedColorImage); |
2 |
26 Feb 07 |
jari |
1243 |
this.colorScheme = scheme; |
2 |
26 Feb 07 |
jari |
1244 |
} else if (scheme == IDisplayMenu.BLUE_YELLOW_SCHEME) { |
2 |
26 Feb 07 |
jari |
1245 |
setPosColorImage(posYellowColorImage); |
2 |
26 Feb 07 |
jari |
1246 |
this.colorScheme = scheme; |
2 |
26 Feb 07 |
jari |
1247 |
} else { |
2 |
26 Feb 07 |
jari |
1248 |
GDMColorSelectionDialog dialog = new GDMColorSelectionDialog((Frame)mainframe, true, getPosColorImage()); |
2 |
26 Feb 07 |
jari |
1249 |
|
2 |
26 Feb 07 |
jari |
1250 |
if(dialog.showModal() != JOptionPane.OK_OPTION) |
2 |
26 Feb 07 |
jari |
1251 |
return; |
2 |
26 Feb 07 |
jari |
1252 |
setPosColorImage(dialog.getPositiveGradient()); |
2 |
26 Feb 07 |
jari |
1253 |
this.colorScheme = scheme; |
2 |
26 Feb 07 |
jari |
1254 |
} |
2 |
26 Feb 07 |
jari |
1255 |
|
2 |
26 Feb 07 |
jari |
1256 |
} |
2 |
26 Feb 07 |
jari |
1257 |
|
2 |
26 Feb 07 |
jari |
1258 |
expColumnHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
1259 |
expRowHeaderSP.setPosColorImages(posColorImage); |
2 |
26 Feb 07 |
jari |
1260 |
|
2 |
26 Feb 07 |
jari |
1261 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1262 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1263 |
|
2 |
26 Feb 07 |
jari |
1264 |
repaint(); |
2 |
26 Feb 07 |
jari |
1265 |
} |
2 |
26 Feb 07 |
jari |
1266 |
|
2 |
26 Feb 07 |
jari |
1267 |
private void onBorderColorChanged() { |
2 |
26 Feb 07 |
jari |
1268 |
|
2 |
26 Feb 07 |
jari |
1269 |
GDMBorderColorDialog dialog = new GDMBorderColorDialog((Frame)mainframe, true, borderColor); |
2 |
26 Feb 07 |
jari |
1270 |
if (dialog.showModal() != JOptionPane.OK_OPTION) |
2 |
26 Feb 07 |
jari |
1271 |
return; |
2 |
26 Feb 07 |
jari |
1272 |
setBorderColor(dialog.getBorderColor()); |
2 |
26 Feb 07 |
jari |
1273 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1274 |
repaint(); |
2 |
26 Feb 07 |
jari |
1275 |
} |
2 |
26 Feb 07 |
jari |
1276 |
|
2 |
26 Feb 07 |
jari |
1277 |
private void onColorScaleChanged() { |
2 |
26 Feb 07 |
jari |
1278 |
BufferedImage grad = getPosColorImage(); |
2 |
26 Feb 07 |
jari |
1279 |
Color lowerColor = new Color(grad.getRGB(0,0)); |
2 |
26 Feb 07 |
jari |
1280 |
Color upperColor = new Color(grad.getRGB(grad.getWidth()-1, 0)); |
2 |
26 Feb 07 |
jari |
1281 |
GDMColorScaleDialog dialog = new GDMColorScaleDialog((Frame)mainframe, minValue, maxValue, expDistMatrix, num_experiments, lowerColor, upperColor); |
2 |
26 Feb 07 |
jari |
1282 |
dialog.setGDMScaleListener(new ScaleListener()); |
2 |
26 Feb 07 |
jari |
1283 |
int res = dialog.showModal(); |
2 |
26 Feb 07 |
jari |
1284 |
minValue = dialog.getLowerLimit(); // if reset it will return the original values. |
2 |
26 Feb 07 |
jari |
1285 |
maxValue = dialog.getUpperLimit(); |
2 |
26 Feb 07 |
jari |
1286 |
expColumnHeaderSP.setValues(minValue, maxValue); |
2 |
26 Feb 07 |
jari |
1287 |
expRowHeaderSP.setValues(minValue, maxValue); |
2 |
26 Feb 07 |
jari |
1288 |
expColumnHeaderSP.updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
1289 |
expRowHeaderSP.updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
1290 |
validate(); |
2 |
26 Feb 07 |
jari |
1291 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1292 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1293 |
repaint(); |
2 |
26 Feb 07 |
jari |
1294 |
} |
2 |
26 Feb 07 |
jari |
1295 |
|
2 |
26 Feb 07 |
jari |
1296 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the user specified spot size. |
2 |
26 Feb 07 |
jari |
1298 |
*/ |
2 |
26 Feb 07 |
jari |
1299 |
private void onAnnotationWidthChanged() { |
2 |
26 Feb 07 |
jari |
1300 |
|
2 |
26 Feb 07 |
jari |
1301 |
GDMAnnotationSizeDialog dialog = new GDMAnnotationSizeDialog(mainframe); |
2 |
26 Feb 07 |
jari |
1302 |
|
2 |
26 Feb 07 |
jari |
1303 |
if (dialog.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
1304 |
int annotationSize = dialog.getAnnotationSize(); |
2 |
26 Feb 07 |
jari |
1305 |
|
2 |
26 Feb 07 |
jari |
1306 |
expColumnHeaderSP.setAnnotationSize(annotationSize); |
2 |
26 Feb 07 |
jari |
1307 |
expRowHeaderSP.setAnnotationSize(annotationSize); |
2 |
26 Feb 07 |
jari |
1308 |
|
2 |
26 Feb 07 |
jari |
1309 |
updateSize(annotationSize); |
2 |
26 Feb 07 |
jari |
1310 |
} |
2 |
26 Feb 07 |
jari |
1311 |
} |
2 |
26 Feb 07 |
jari |
1312 |
|
2 |
26 Feb 07 |
jari |
1313 |
private void toggleSortByProximity(){ |
2 |
26 Feb 07 |
jari |
1314 |
sortByProximity = !sortByProximity; |
2 |
26 Feb 07 |
jari |
1315 |
this.expColumnHeaderSP.setSortByProximity(sortByProximity); |
2 |
26 Feb 07 |
jari |
1316 |
this.expRowHeaderSP.setSortByProximity(sortByProximity); |
2 |
26 Feb 07 |
jari |
1317 |
} |
2 |
26 Feb 07 |
jari |
1318 |
|
2 |
26 Feb 07 |
jari |
1319 |
private void onSortByProximity(int baseIndex) { |
2 |
26 Feb 07 |
jari |
1320 |
this.isDrawClusterBorders = false; |
2 |
26 Feb 07 |
jari |
1321 |
this.numOfClusters = 0; |
2 |
26 Feb 07 |
jari |
1322 |
|
2 |
26 Feb 07 |
jari |
1323 |
QSort qsort = new QSort(this.expDistMatrix.A[baseIndex]); |
2 |
26 Feb 07 |
jari |
1324 |
int [] sortedIndices = qsort.getOrigIndx(); |
2 |
26 Feb 07 |
jari |
1325 |
|
2 |
26 Feb 07 |
jari |
//to handle random placement of base if sorting on NaN or have a tie |
2 |
26 Feb 07 |
jari |
1327 |
if(sortedIndices[0] != baseIndex){ |
2 |
26 Feb 07 |
jari |
1328 |
boolean notFound = true; |
2 |
26 Feb 07 |
jari |
1329 |
for(int i=0; i<sortedIndices.length && notFound; i++){ |
2 |
26 Feb 07 |
jari |
1330 |
if(sortedIndices[i] == baseIndex){ |
2 |
26 Feb 07 |
jari |
1331 |
sortedIndices[i] = sortedIndices[0]; |
2 |
26 Feb 07 |
jari |
1332 |
sortedIndices[0] = baseIndex; |
2 |
26 Feb 07 |
jari |
1333 |
notFound = false; |
2 |
26 Feb 07 |
jari |
1334 |
} |
2 |
26 Feb 07 |
jari |
1335 |
} |
2 |
26 Feb 07 |
jari |
1336 |
} |
2 |
26 Feb 07 |
jari |
1337 |
|
2 |
26 Feb 07 |
jari |
1338 |
setIndices(sortedIndices); |
2 |
26 Feb 07 |
jari |
1339 |
|
2 |
26 Feb 07 |
jari |
1340 |
expColumnHeaderSP.setIndices(sortedIndices); |
2 |
26 Feb 07 |
jari |
1341 |
expRowHeaderSP.setIndices(sortedIndices); |
2 |
26 Feb 07 |
jari |
1342 |
|
2 |
26 Feb 07 |
jari |
1343 |
onDataChanged(this.expData); |
2 |
26 Feb 07 |
jari |
1344 |
validate(); |
2 |
26 Feb 07 |
jari |
1345 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1346 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1347 |
} |
2 |
26 Feb 07 |
jari |
1348 |
|
2 |
26 Feb 07 |
jari |
1349 |
private void onSortByExperimentName() { |
2 |
26 Feb 07 |
jari |
1350 |
String [] expNames = new String[indices.length]; |
2 |
26 Feb 07 |
jari |
1351 |
String [] sortedExpNames = new String[indices.length]; |
2 |
26 Feb 07 |
jari |
1352 |
int [] sortedIndices = new int[indices.length]; |
2 |
26 Feb 07 |
jari |
1353 |
|
2 |
26 Feb 07 |
jari |
1354 |
for(int i = 0; i < this.indices.length; i++){ |
2 |
26 Feb 07 |
jari |
1355 |
expNames[i] = this.expData.getSampleName(this.indices[i]); |
2 |
26 Feb 07 |
jari |
1356 |
sortedExpNames[i] = this.expData.getSampleName(this.indices[i]); |
2 |
26 Feb 07 |
jari |
1357 |
} |
2 |
26 Feb 07 |
jari |
1358 |
|
2 |
26 Feb 07 |
jari |
1359 |
Arrays.sort(sortedExpNames); |
2 |
26 Feb 07 |
jari |
1360 |
|
2 |
26 Feb 07 |
jari |
1361 |
for(int i = 0; i < this.indices.length; i++){ |
2 |
26 Feb 07 |
jari |
1362 |
for(int j = 0; j < this.indices.length; j++){ |
2 |
26 Feb 07 |
jari |
1363 |
if(expNames[i].equals(sortedExpNames[j])) |
2 |
26 Feb 07 |
jari |
1364 |
sortedIndices[i] = indices[j]; |
2 |
26 Feb 07 |
jari |
1365 |
} |
2 |
26 Feb 07 |
jari |
1366 |
} |
2 |
26 Feb 07 |
jari |
1367 |
|
2 |
26 Feb 07 |
jari |
1368 |
|
2 |
26 Feb 07 |
jari |
1369 |
expColumnHeaderSP.setIndices(sortedIndices); |
2 |
26 Feb 07 |
jari |
1370 |
expRowHeaderSP.setIndices(sortedIndices); |
2 |
26 Feb 07 |
jari |
1371 |
|
2 |
26 Feb 07 |
jari |
1372 |
onDataChanged(this.expData); |
2 |
26 Feb 07 |
jari |
1373 |
validate(); |
2 |
26 Feb 07 |
jari |
1374 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1375 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1376 |
} |
2 |
26 Feb 07 |
jari |
1377 |
|
2 |
26 Feb 07 |
jari |
1378 |
private void onSortByClusterChange() { |
2 |
26 Feb 07 |
jari |
1379 |
if (numOfClusters > 0) { |
2 |
26 Feb 07 |
jari |
1380 |
isDrawClusterBorders=true; |
2 |
26 Feb 07 |
jari |
// drawClusterBorderItem.setState(true); |
2 |
26 Feb 07 |
jari |
1382 |
|
2 |
26 Feb 07 |
jari |
1383 |
if(this.displayEvery==1) { |
2 |
26 Feb 07 |
jari |
1384 |
setIndices(createIndices()); |
2 |
26 Feb 07 |
jari |
1385 |
} else if (this.displayEvery > 1) { |
2 |
26 Feb 07 |
jari |
1386 |
setIndices(createIndices(this.displayEvery)); |
2 |
26 Feb 07 |
jari |
1387 |
} |
2 |
26 Feb 07 |
jari |
1388 |
|
2 |
26 Feb 07 |
jari |
1389 |
expColumnHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
1390 |
expRowHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
1391 |
|
2 |
26 Feb 07 |
jari |
1392 |
onDataChanged(this.expData); |
2 |
26 Feb 07 |
jari |
1393 |
} |
2 |
26 Feb 07 |
jari |
1394 |
} |
2 |
26 Feb 07 |
jari |
1395 |
|
2 |
26 Feb 07 |
jari |
1396 |
private void onRestoreOriginalOrder() { |
2 |
26 Feb 07 |
jari |
1397 |
|
2 |
26 Feb 07 |
jari |
1398 |
numOfClusters = 0; |
2 |
26 Feb 07 |
jari |
1399 |
|
2 |
26 Feb 07 |
jari |
1400 |
setIndices(this.createIndices(this.displayEvery)); |
2 |
26 Feb 07 |
jari |
1401 |
|
2 |
26 Feb 07 |
jari |
1402 |
isDrawClusterBorders=false; |
2 |
26 Feb 07 |
jari |
1403 |
|
2 |
26 Feb 07 |
jari |
1404 |
|
2 |
26 Feb 07 |
jari |
1405 |
expColumnHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
1406 |
expRowHeaderSP.setIndices(indices); |
2 |
26 Feb 07 |
jari |
1407 |
|
2 |
26 Feb 07 |
jari |
1408 |
onDataChanged(this.expData); |
2 |
26 Feb 07 |
jari |
1409 |
validate(); |
2 |
26 Feb 07 |
jari |
1410 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1411 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1412 |
} |
2 |
26 Feb 07 |
jari |
1413 |
|
2 |
26 Feb 07 |
jari |
1414 |
private void setLabelIndex(int style) { |
2 |
26 Feb 07 |
jari |
1415 |
label = style; |
2 |
26 Feb 07 |
jari |
1416 |
} |
2 |
26 Feb 07 |
jari |
1417 |
|
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 |
1420 |
*/ |
2 |
26 Feb 07 |
jari |
1421 |
public JComponent getCornerComponent(int cornerIndex) { |
2 |
26 Feb 07 |
jari |
1422 |
if(cornerIndex == IViewer.UPPER_RIGHT_CORNER) |
2 |
26 Feb 07 |
jari |
1423 |
return this.upperRightCornerSB; |
2 |
26 Feb 07 |
jari |
1424 |
else if(cornerIndex == IViewer.LOWER_LEFT_CORNER) |
2 |
26 Feb 07 |
jari |
1425 |
return this.lowerLeftCornerSB; |
2 |
26 Feb 07 |
jari |
1426 |
return null; |
2 |
26 Feb 07 |
jari |
1427 |
} |
2 |
26 Feb 07 |
jari |
1428 |
|
2 |
26 Feb 07 |
jari |
1429 |
|
2 |
26 Feb 07 |
jari |
1430 |
private void onSaveNeighbors(){ |
2 |
26 Feb 07 |
jari |
1431 |
GDMMemberSelectionDialog dialog = new GDMMemberSelectionDialog(new JFrame(), this.num_experiments); |
2 |
26 Feb 07 |
jari |
1432 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
1433 |
int k = dialog.getK(); |
2 |
26 Feb 07 |
jari |
1434 |
if(k <= 0) |
2 |
26 Feb 07 |
jari |
1435 |
return; |
2 |
26 Feb 07 |
jari |
1436 |
if(k > this.num_experiments) |
2 |
26 Feb 07 |
jari |
1437 |
k = this.num_experiments; |
2 |
26 Feb 07 |
jari |
1438 |
int [] rows = getRows(k); |
2 |
26 Feb 07 |
jari |
1439 |
String [][] auxData = getAuxilaryData(k); |
2 |
26 Feb 07 |
jari |
1440 |
String [] auxHeaders = new String[3]; |
2 |
26 Feb 07 |
jari |
1441 |
auxHeaders[0] = "Scaled Dist."; |
2 |
26 Feb 07 |
jari |
1442 |
auxHeaders[1] = "Actual Dist."; |
2 |
26 Feb 07 |
jari |
1443 |
auxHeaders[2] = "Value Pairs"; |
2 |
26 Feb 07 |
jari |
1444 |
try{ |
2 |
26 Feb 07 |
jari |
1445 |
ExperimentUtil.saveExperimentClusterWithAux(framework.getFrame(), this.experiment, this.expData, rows, auxHeaders, auxData); |
2 |
26 Feb 07 |
jari |
1446 |
} catch (Exception e){ |
2 |
26 Feb 07 |
jari |
1447 |
JOptionPane.showMessageDialog(this, "Error saving file: "+e.getMessage(), "Output Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1448 |
} |
2 |
26 Feb 07 |
jari |
1449 |
} |
2 |
26 Feb 07 |
jari |
1450 |
} |
2 |
26 Feb 07 |
jari |
1451 |
|
2 |
26 Feb 07 |
jari |
1452 |
|
2 |
26 Feb 07 |
jari |
1453 |
private int [] getRows(int k) { |
2 |
26 Feb 07 |
jari |
1454 |
int [] rows = new int[k]; |
2 |
26 Feb 07 |
jari |
1455 |
for(int i = 0; i < k; i++){ |
2 |
26 Feb 07 |
jari |
1456 |
rows[i] = indices[i]; |
2 |
26 Feb 07 |
jari |
1457 |
} |
2 |
26 Feb 07 |
jari |
1458 |
return rows; |
2 |
26 Feb 07 |
jari |
1459 |
} |
2 |
26 Feb 07 |
jari |
1460 |
|
2 |
26 Feb 07 |
jari |
1461 |
|
2 |
26 Feb 07 |
jari |
1462 |
private String [][] getAuxilaryData(int k){ |
2 |
26 Feb 07 |
jari |
1463 |
String [][] data = new String[k][3]; |
2 |
26 Feb 07 |
jari |
1464 |
FloatMatrix matrix = this.experiment.getMatrix().transpose(); |
2 |
26 Feb 07 |
jari |
1465 |
for(int i = 0; i < k; i++){ |
2 |
26 Feb 07 |
jari |
1466 |
data[i][0] = Float.toString(this.expDistMatrix.get(indices[0], i)); |
2 |
26 Feb 07 |
jari |
1467 |
data[i][1] = Float.toString(this.rawMatrix.get(indices[0], i)); |
2 |
26 Feb 07 |
jari |
1468 |
data[i][2] = getValuePairCount(matrix, indices[0], i); |
2 |
26 Feb 07 |
jari |
1469 |
} |
2 |
26 Feb 07 |
jari |
1470 |
return data; |
2 |
26 Feb 07 |
jari |
1471 |
} |
2 |
26 Feb 07 |
jari |
1472 |
|
2 |
26 Feb 07 |
jari |
1473 |
private String getValuePairCount(FloatMatrix matrix, int row, int col){ |
2 |
26 Feb 07 |
jari |
1474 |
int cols = matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
1475 |
int count = 0; |
2 |
26 Feb 07 |
jari |
1476 |
for(int i = 0; i < cols; i++){ |
2 |
26 Feb 07 |
jari |
1477 |
if(!Float.isNaN(matrix.get(row, i)) && !Float.isNaN(matrix.get(col, i))) |
2 |
26 Feb 07 |
jari |
1478 |
count++; |
2 |
26 Feb 07 |
jari |
1479 |
} |
2 |
26 Feb 07 |
jari |
1480 |
return Integer.toString(count); |
2 |
26 Feb 07 |
jari |
1481 |
} |
2 |
26 Feb 07 |
jari |
1482 |
|
2 |
26 Feb 07 |
jari |
1483 |
private void imposeClusterOrder() { |
2 |
26 Feb 07 |
jari |
1484 |
|
2 |
26 Feb 07 |
jari |
1485 |
Hashtable results = getResultHash(); |
2 |
26 Feb 07 |
jari |
1486 |
boolean noUseableResult = false; |
2 |
26 Feb 07 |
jari |
1487 |
|
2 |
26 Feb 07 |
jari |
1488 |
Hashtable goodResults = new Hashtable(); |
2 |
26 Feb 07 |
jari |
1489 |
|
2 |
26 Feb 07 |
jari |
1490 |
Enumeration keys = results.keys(); |
2 |
26 Feb 07 |
jari |
1491 |
Object [] result; |
2 |
26 Feb 07 |
jari |
1492 |
String key; |
2 |
26 Feb 07 |
jari |
1493 |
|
2 |
26 Feb 07 |
jari |
1494 |
|
2 |
26 Feb 07 |
jari |
1495 |
while(keys.hasMoreElements()){ |
2 |
26 Feb 07 |
jari |
1496 |
key = (String)keys.nextElement(); |
2 |
26 Feb 07 |
jari |
1497 |
result = (Object [])(results.get(key)); |
2 |
26 Feb 07 |
jari |
1498 |
|
2 |
26 Feb 07 |
jari |
//need to handle HCL differently since it can be a gene or an experiemnt order |
2 |
26 Feb 07 |
jari |
1500 |
if(key.indexOf("HCL") != -1) { |
2 |
26 Feb 07 |
jari |
1501 |
int [][] clusters = new int[1][]; |
2 |
26 Feb 07 |
jari |
1502 |
clusters[0] = ((int[][])result[1])[1]; //experiment result order |
2 |
26 Feb 07 |
jari |
1503 |
|
2 |
26 Feb 07 |
jari |
1504 |
if(clusters[0] == null) //if no exp tree then continue |
2 |
26 Feb 07 |
jari |
1505 |
continue; |
2 |
26 Feb 07 |
jari |
1506 |
|
2 |
26 Feb 07 |
jari |
1507 |
if((this.experiment == result[0]) && checkClustersSize(clusters)) { |
2 |
26 Feb 07 |
jari |
1508 |
goodResults.put(key, clusters); |
2 |
26 Feb 07 |
jari |
1509 |
} |
2 |
26 Feb 07 |
jari |
1510 |
} |
2 |
26 Feb 07 |
jari |
1511 |
|
2 |
26 Feb 07 |
jari |
//make sure it's the same experiment (same cutoffs), same number of genes (not exp. cluster) |
2 |
26 Feb 07 |
jari |
1513 |
else if((this.experiment == result[0]) && checkClustersSize((int[][])result[1]) ) { |
2 |
26 Feb 07 |
jari |
1514 |
goodResults.put(key, result[1]); |
2 |
26 Feb 07 |
jari |
1515 |
} |
2 |
26 Feb 07 |
jari |
1516 |
} |
2 |
26 Feb 07 |
jari |
1517 |
|
2 |
26 Feb 07 |
jari |
1518 |
if(goodResults.size() > 0) { |
2 |
26 Feb 07 |
jari |
1519 |
GDMResultSelectionDialog dialog = new GDMResultSelectionDialog((JFrame)framework.getFrame(), goodResults.keys()); |
2 |
26 Feb 07 |
jari |
1520 |
if( dialog.showModal() == JOptionPane.OK_OPTION ) { |
2 |
26 Feb 07 |
jari |
1521 |
int [][] clusters = ((int [][])goodResults.get(dialog.getSelectedResult())); |
2 |
26 Feb 07 |
jari |
1522 |
imposeClusterOrder(clusters); |
2 |
26 Feb 07 |
jari |
1523 |
} |
2 |
26 Feb 07 |
jari |
1524 |
} else { |
2 |
26 Feb 07 |
jari |
1525 |
JOptionPane.showMessageDialog(framework.getFrame(), "There are currently no appropriate clustering results to apply to this GDM.", "No Results Available", JOptionPane.INFORMATION_MESSAGE); |
2 |
26 Feb 07 |
jari |
1526 |
} |
2 |
26 Feb 07 |
jari |
1527 |
} |
2 |
26 Feb 07 |
jari |
1528 |
|
2 |
26 Feb 07 |
jari |
1529 |
private boolean checkClustersSize(int [][] clusters) { |
2 |
26 Feb 07 |
jari |
1530 |
int cnt = 0; |
2 |
26 Feb 07 |
jari |
1531 |
for(int i = 0; i < clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1532 |
cnt += clusters[i].length; |
2 |
26 Feb 07 |
jari |
1533 |
} |
2 |
26 Feb 07 |
jari |
1534 |
|
2 |
26 Feb 07 |
jari |
1535 |
if( ((int)(cnt/displayEvery)) == this.num_experiments) |
2 |
26 Feb 07 |
jari |
1536 |
return true; |
2 |
26 Feb 07 |
jari |
1537 |
return false; |
2 |
26 Feb 07 |
jari |
1538 |
} |
2 |
26 Feb 07 |
jari |
1539 |
|
2 |
26 Feb 07 |
jari |
1540 |
|
2 |
26 Feb 07 |
jari |
1541 |
|
2 |
26 Feb 07 |
jari |
1542 |
public Hashtable getResultHash(){ |
2 |
26 Feb 07 |
jari |
1543 |
Hashtable table = new Hashtable(); |
2 |
26 Feb 07 |
jari |
1544 |
DefaultMutableTreeNode analysisNode = framework.getResultTree().getAnalysisNode(); |
2 |
26 Feb 07 |
jari |
1545 |
DefaultMutableTreeNode analysisRoot; |
2 |
26 Feb 07 |
jari |
1546 |
DefaultMutableTreeNode currentNode; |
2 |
26 Feb 07 |
jari |
1547 |
Object object; |
2 |
26 Feb 07 |
jari |
1548 |
Object [] vals; |
2 |
26 Feb 07 |
jari |
1549 |
boolean stop = false; |
2 |
26 Feb 07 |
jari |
1550 |
|
2 |
26 Feb 07 |
jari |
1551 |
IViewer viewer; |
2 |
26 Feb 07 |
jari |
1552 |
Experiment exp; |
2 |
26 Feb 07 |
jari |
1553 |
int [][] clusters; |
2 |
26 Feb 07 |
jari |
1554 |
|
2 |
26 Feb 07 |
jari |
1555 |
int childCount = analysisNode.getChildCount(); |
2 |
26 Feb 07 |
jari |
//String algTitles = new String[analysisNode.getChildCount()]; |
2 |
26 Feb 07 |
jari |
1557 |
String algName = ""; |
2 |
26 Feb 07 |
jari |
1558 |
Enumeration _enum; |
2 |
26 Feb 07 |
jari |
1559 |
|
2 |
26 Feb 07 |
jari |
1560 |
for(int i = 0; i < childCount; i++){ |
2 |
26 Feb 07 |
jari |
1561 |
analysisRoot = ((DefaultMutableTreeNode)(analysisNode.getChildAt(i))); |
2 |
26 Feb 07 |
jari |
1562 |
object = analysisRoot.getUserObject(); |
2 |
26 Feb 07 |
jari |
1563 |
if(object != null){ |
2 |
26 Feb 07 |
jari |
1564 |
if(object instanceof LeafInfo){ |
2 |
26 Feb 07 |
jari |
1565 |
algName = ((LeafInfo)object).toString(); |
2 |
26 Feb 07 |
jari |
1566 |
} else if(object instanceof String) { |
2 |
26 Feb 07 |
jari |
1567 |
algName = (String)object; |
2 |
26 Feb 07 |
jari |
1568 |
} |
2 |
26 Feb 07 |
jari |
1569 |
|
2 |
26 Feb 07 |
jari |
1570 |
_enum = analysisRoot.depthFirstEnumeration(); |
2 |
26 Feb 07 |
jari |
1571 |
while (!stop && _enum.hasMoreElements()){ |
2 |
26 Feb 07 |
jari |
1572 |
currentNode = (DefaultMutableTreeNode)_enum.nextElement(); |
2 |
26 Feb 07 |
jari |
1573 |
if(currentNode.getUserObject() instanceof LeafInfo){ |
2 |
26 Feb 07 |
jari |
1574 |
viewer = ((LeafInfo)currentNode.getUserObject()).getViewer(); |
2 |
26 Feb 07 |
jari |
1575 |
if(viewer != null) { |
2 |
26 Feb 07 |
jari |
1576 |
exp = viewer.getExperiment(); |
2 |
26 Feb 07 |
jari |
1577 |
clusters = viewer.getClusters(); |
2 |
26 Feb 07 |
jari |
1578 |
if(exp != null && clusters != null) { |
2 |
26 Feb 07 |
jari |
1579 |
vals = new Object[2]; |
2 |
26 Feb 07 |
jari |
1580 |
vals[0] = exp; |
2 |
26 Feb 07 |
jari |
1581 |
vals[1] = clusters; |
2 |
26 Feb 07 |
jari |
1582 |
table.put(algName, vals); |
2 |
26 Feb 07 |
jari |
1583 |
stop = true; |
2 |
26 Feb 07 |
jari |
1584 |
} |
2 |
26 Feb 07 |
jari |
1585 |
} |
2 |
26 Feb 07 |
jari |
1586 |
} |
2 |
26 Feb 07 |
jari |
1587 |
} |
2 |
26 Feb 07 |
jari |
1588 |
stop = false; |
2 |
26 Feb 07 |
jari |
1589 |
} |
2 |
26 Feb 07 |
jari |
1590 |
} |
2 |
26 Feb 07 |
jari |
1591 |
return table; |
2 |
26 Feb 07 |
jari |
1592 |
} |
2 |
26 Feb 07 |
jari |
1593 |
|
2 |
26 Feb 07 |
jari |
1594 |
|
2 |
26 Feb 07 |
jari |
1595 |
private void imposeClusterOrder(int [][] newClusters) { |
2 |
26 Feb 07 |
jari |
1596 |
this.clusters = newClusters; |
2 |
26 Feb 07 |
jari |
1597 |
this.numOfClusters = clusters.length; |
2 |
26 Feb 07 |
jari |
1598 |
onSortByClusterChange(); |
2 |
26 Feb 07 |
jari |
1599 |
} |
2 |
26 Feb 07 |
jari |
1600 |
|
2 |
26 Feb 07 |
jari |
1601 |
|
2 |
26 Feb 07 |
jari |
1602 |
public int[][] getClusters() { |
2 |
26 Feb 07 |
jari |
1603 |
return null; |
2 |
26 Feb 07 |
jari |
1604 |
} |
2 |
26 Feb 07 |
jari |
1605 |
|
2 |
26 Feb 07 |
jari |
1606 |
public Experiment getExperiment() { |
2 |
26 Feb 07 |
jari |
1607 |
return this.experiment; |
2 |
26 Feb 07 |
jari |
1608 |
} |
2 |
26 Feb 07 |
jari |
1609 |
|
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 |
1612 |
*/ |
2 |
26 Feb 07 |
jari |
1613 |
public int getViewerType() { |
2 |
26 Feb 07 |
jari |
1614 |
return org.tigr.microarray.mev.cluster.clusterUtil.Cluster.EXPERIMENT_CLUSTER; |
2 |
26 Feb 07 |
jari |
1615 |
} |
2 |
26 Feb 07 |
jari |
1616 |
|
2 |
26 Feb 07 |
jari |
1617 |
|
2 |
26 Feb 07 |
jari |
1618 |
/** |
2 |
26 Feb 07 |
jari |
* The listener to listen to mouse, keyboard and window events. |
2 |
26 Feb 07 |
jari |
1620 |
*/ |
2 |
26 Feb 07 |
jari |
1621 |
|
2 |
26 Feb 07 |
jari |
1622 |
private class Listener extends MouseAdapter implements ActionListener, MouseMotionListener, KeyListener, WindowListener { |
2 |
26 Feb 07 |
jari |
1623 |
|
2 |
26 Feb 07 |
jari |
1624 |
private int oldRow = -1; |
2 |
26 Feb 07 |
jari |
1625 |
private int oldColumn = -1; |
2 |
26 Feb 07 |
jari |
1626 |
private String oldStatusText; |
2 |
26 Feb 07 |
jari |
1627 |
|
2 |
26 Feb 07 |
jari |
1628 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
1629 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
1630 |
|
2 |
26 Feb 07 |
jari |
1631 |
if (command.equals(ANNOTATION_WIDTH_CMD)) { |
2 |
26 Feb 07 |
jari |
1632 |
onAnnotationWidthChanged(); |
2 |
26 Feb 07 |
jari |
1633 |
} else if (command.equals(DISPLAY_2X2_CMD)) { |
2 |
26 Feb 07 |
jari |
1634 |
onElementSizeChanged(2, 2); |
2 |
26 Feb 07 |
jari |
1635 |
} else if (command.equals(DISPLAY_5X5_CMD)) { |
2 |
26 Feb 07 |
jari |
1636 |
onElementSizeChanged(5, 5); |
2 |
26 Feb 07 |
jari |
1637 |
} else if (command.equals(DISPLAY_10X10_CMD)) { |
2 |
26 Feb 07 |
jari |
1638 |
onElementSizeChanged(10, 10); |
2 |
26 Feb 07 |
jari |
1639 |
} else if (command.equals(DISPLAY_15X15_CMD)) { |
2 |
26 Feb 07 |
jari |
1640 |
onElementSizeChanged(15, 15); |
2 |
26 Feb 07 |
jari |
1641 |
} else if (command.equals(DISPLAY_OTHER_CMD)) { |
2 |
26 Feb 07 |
jari |
1642 |
onElementSizeChanged(); |
2 |
26 Feb 07 |
jari |
1643 |
} else if (command.equals(GREEN_RED_COLOR_SCHEME_CMD)){ |
2 |
26 Feb 07 |
jari |
1644 |
onColorSchemeChange(IDisplayMenu.GREEN_RED_SCHEME); |
2 |
26 Feb 07 |
jari |
1645 |
} else if (command.equals(BLUE_YELLOW_COLOR_SCHEME_CMD)){ |
2 |
26 Feb 07 |
jari |
1646 |
onColorSchemeChange(IDisplayMenu.BLUE_YELLOW_SCHEME); |
2 |
26 Feb 07 |
jari |
1647 |
} else if (command.equals(CUSTOM_COLOR_SCHEME_CMD)){ |
2 |
26 Feb 07 |
jari |
1648 |
onColorSchemeChange(IDisplayMenu.CUSTOM_COLOR_SCHEME); |
2 |
26 Feb 07 |
jari |
1649 |
} else if (command.equals(DISPLAY_DRAW_BORDERS_CMD)) { |
2 |
26 Feb 07 |
jari |
1650 |
onDrawBordersChanged(((javax.swing.JCheckBoxMenuItem)(event.getSource())).isSelected()); |
2 |
26 Feb 07 |
jari |
1651 |
} else if (command.equals(BORDER_COLOR_CMD)) { |
2 |
26 Feb 07 |
jari |
1652 |
onBorderColorChanged(); |
2 |
26 Feb 07 |
jari |
1653 |
} else if (command.equals(COLOR_SCALE_CMD)) { |
2 |
26 Feb 07 |
jari |
1654 |
onColorScaleChanged(); |
2 |
26 Feb 07 |
jari |
1655 |
} else if (command.equals(SET_CLUSTER_BORDER_CMD)) { |
2 |
26 Feb 07 |
jari |
1656 |
onDrawClusterBorderChange(((javax.swing.JCheckBoxMenuItem)(event.getSource())).isSelected()); |
2 |
26 Feb 07 |
jari |
1657 |
} else if (command.equals(TOGGLE_PROXIMITY_SORT_CMD)) { |
2 |
26 Feb 07 |
jari |
1658 |
toggleSortByProximity(); |
2 |
26 Feb 07 |
jari |
1659 |
} else if (command.equals(SORT_BY_PROXIMITY_CMD)) { |
2 |
26 Feb 07 |
jari |
1660 |
onSortByProximity(event.getID()); |
2 |
26 Feb 07 |
jari |
1661 |
} else if (command.equals(SAVE_NEIGHBORS_CMD)) { |
2 |
26 Feb 07 |
jari |
1662 |
onSaveNeighbors(); |
2 |
26 Feb 07 |
jari |
1663 |
} else if (command.equals(SORT_BY_EXP_NAME_CMD)) { |
2 |
26 Feb 07 |
jari |
1664 |
onSortByExperimentName(); |
2 |
26 Feb 07 |
jari |
1665 |
} else if (command.equals(SORT_BY_ORIGINAL_ORDER_CMD)) { |
2 |
26 Feb 07 |
jari |
1666 |
onRestoreOriginalOrder(); |
2 |
26 Feb 07 |
jari |
1667 |
} else if (command.equals("impose-cluster-order")) { |
2 |
26 Feb 07 |
jari |
1668 |
imposeClusterOrder(); |
2 |
26 Feb 07 |
jari |
1669 |
} |
2 |
26 Feb 07 |
jari |
1670 |
} |
2 |
26 Feb 07 |
jari |
1671 |
|
2 |
26 Feb 07 |
jari |
1672 |
public void mousePressed(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1673 |
requestFocus(); |
2 |
26 Feb 07 |
jari |
1674 |
} |
2 |
26 Feb 07 |
jari |
1675 |
|
2 |
26 Feb 07 |
jari |
1676 |
public void mouseClicked(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1677 |
if (SwingUtilities.isLeftMouseButton(event)) { |
2 |
26 Feb 07 |
jari |
1678 |
int column = findColumn(event.getX()); |
2 |
26 Feb 07 |
jari |
1679 |
int row = findRow(event.getY()); |
2 |
26 Feb 07 |
jari |
1680 |
|
2 |
26 Feb 07 |
jari |
1681 |
if (!isLegalPosition(row, column)) { |
2 |
26 Feb 07 |
jari |
1682 |
return; |
2 |
26 Feb 07 |
jari |
1683 |
} |
2 |
26 Feb 07 |
jari |
1684 |
displayGDMSpotInfo(indices[column], indices[row]); |
2 |
26 Feb 07 |
jari |
1685 |
} |
2 |
26 Feb 07 |
jari |
1686 |
else { |
2 |
26 Feb 07 |
jari |
1687 |
int column = findColumn(event.getX()); |
2 |
26 Feb 07 |
jari |
1688 |
int row = findRow(event.getY()); |
2 |
26 Feb 07 |
jari |
1689 |
popup.show(event.getComponent(), event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
1690 |
} |
2 |
26 Feb 07 |
jari |
1691 |
} |
2 |
26 Feb 07 |
jari |
1692 |
|
2 |
26 Feb 07 |
jari |
1693 |
public void mouseMoved(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1694 |
if (num_experiments == 0 || event.isShiftDown()) |
2 |
26 Feb 07 |
jari |
1695 |
return; |
2 |
26 Feb 07 |
jari |
1696 |
|
2 |
26 Feb 07 |
jari |
1697 |
int column = findColumn(event.getX()); |
2 |
26 Feb 07 |
jari |
1698 |
int row = findRow(event.getY()); |
2 |
26 Feb 07 |
jari |
1699 |
|
2 |
26 Feb 07 |
jari |
1700 |
if (isCurrentPosition(row, column)) { |
2 |
26 Feb 07 |
jari |
1701 |
return; |
2 |
26 Feb 07 |
jari |
1702 |
} |
2 |
26 Feb 07 |
jari |
1703 |
|
2 |
26 Feb 07 |
jari |
1704 |
Graphics g = null; |
2 |
26 Feb 07 |
jari |
1705 |
Graphics2D g2D = (Graphics2D) g; |
2 |
26 Feb 07 |
jari |
1706 |
|
2 |
26 Feb 07 |
jari |
1707 |
if (isLegalPosition(row, column)) { |
2 |
26 Feb 07 |
jari |
1708 |
|
2 |
26 Feb 07 |
jari |
1709 |
g = getGraphics(); |
2 |
26 Feb 07 |
jari |
1710 |
|
2 |
26 Feb 07 |
jari |
1711 |
drawColoredBoxAt(g, row, column, Color.white); |
2 |
26 Feb 07 |
jari |
1712 |
|
2 |
26 Feb 07 |
jari |
1713 |
framework.setStatusText( |
2 |
26 Feb 07 |
jari |
1714 |
" Column " + column + |
2 |
26 Feb 07 |
jari |
1715 |
" " + //some padding |
2 |
26 Feb 07 |
jari |
1716 |
" Row " + row + |
2 |
26 Feb 07 |
jari |
1717 |
" " + //some padding |
2 |
26 Feb 07 |
jari |
1718 |
" Scaled Distance: " + expDistMatrix.get(indices[column], indices[row]) + |
2 |
26 Feb 07 |
jari |
1719 |
" " + //some padding |
2 |
26 Feb 07 |
jari |
1720 |
" Actual Distance: " + rawMatrix.get(indices[column], indices[row])); |
2 |
26 Feb 07 |
jari |
1721 |
|
2 |
26 Feb 07 |
jari |
1722 |
} else { |
2 |
26 Feb 07 |
jari |
1723 |
framework.setStatusText(oldStatusText); |
2 |
26 Feb 07 |
jari |
1724 |
} |
2 |
26 Feb 07 |
jari |
1725 |
if (isLegalPosition(oldRow, oldColumn)) { |
2 |
26 Feb 07 |
jari |
1726 |
g2D = g != null ? (Graphics2D)g : (Graphics2D)getGraphics(); |
2 |
26 Feb 07 |
jari |
1727 |
drawSlideDataElement(g2D, oldRow, oldColumn); |
2 |
26 Feb 07 |
jari |
1728 |
} |
2 |
26 Feb 07 |
jari |
1729 |
setOldPosition(row, column); |
2 |
26 Feb 07 |
jari |
1730 |
|
2 |
26 Feb 07 |
jari |
1731 |
if(g != null) { |
2 |
26 Feb 07 |
jari |
1732 |
if(isDrawClusterBorders && numOfClusters > 0) |
2 |
26 Feb 07 |
jari |
1733 |
drawClusterBorder((Graphics2D)g); |
2 |
26 Feb 07 |
jari |
1734 |
} else if (g2D != null) { |
2 |
26 Feb 07 |
jari |
1735 |
if(isDrawClusterBorders && numOfClusters > 0) |
2 |
26 Feb 07 |
jari |
1736 |
drawClusterBorder(g2D); |
2 |
26 Feb 07 |
jari |
1737 |
} |
2 |
26 Feb 07 |
jari |
1738 |
|
2 |
26 Feb 07 |
jari |
1739 |
if (g != null) { |
2 |
26 Feb 07 |
jari |
1740 |
if(isDrawClusterBorders && numOfClusters > 0) |
2 |
26 Feb 07 |
jari |
1741 |
drawClusterBorder((Graphics2D)g); |
2 |
26 Feb 07 |
jari |
1742 |
g.dispose(); |
2 |
26 Feb 07 |
jari |
1743 |
} |
2 |
26 Feb 07 |
jari |
1744 |
} |
2 |
26 Feb 07 |
jari |
1745 |
|
2 |
26 Feb 07 |
jari |
1746 |
public void mouseExited(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1747 |
if (isLegalPosition(oldRow, oldColumn)) { |
2 |
26 Feb 07 |
jari |
1748 |
|
2 |
26 Feb 07 |
jari |
1749 |
Graphics g = getGraphics(); |
2 |
26 Feb 07 |
jari |
1750 |
Graphics2D g2D = (Graphics2D)g; |
2 |
26 Feb 07 |
jari |
1751 |
drawSlideDataElement(g2D, oldRow, oldColumn); |
2 |
26 Feb 07 |
jari |
1752 |
g2D.dispose(); |
2 |
26 Feb 07 |
jari |
1753 |
if(isDrawClusterBorders && numOfClusters > 0) |
2 |
26 Feb 07 |
jari |
1754 |
drawClusterBorder(g2D); |
2 |
26 Feb 07 |
jari |
1755 |
} |
2 |
26 Feb 07 |
jari |
1756 |
setOldPosition(-1, -1); |
2 |
26 Feb 07 |
jari |
1757 |
framework.setStatusText(" "); // blank Status bar |
2 |
26 Feb 07 |
jari |
1758 |
} |
2 |
26 Feb 07 |
jari |
1759 |
|
2 |
26 Feb 07 |
jari |
1760 |
public void mouseEntered(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
1761 |
oldStatusText = framework.getStatusText(); |
2 |
26 Feb 07 |
jari |
1762 |
} |
2 |
26 Feb 07 |
jari |
1763 |
|
2 |
26 Feb 07 |
jari |
1764 |
private void setOldPosition(int row, int column) { |
2 |
26 Feb 07 |
jari |
1765 |
oldColumn = column; |
2 |
26 Feb 07 |
jari |
1766 |
oldRow = row; |
2 |
26 Feb 07 |
jari |
1767 |
} |
2 |
26 Feb 07 |
jari |
1768 |
|
2 |
26 Feb 07 |
jari |
1769 |
private boolean isCurrentPosition(int row, int column) { |
2 |
26 Feb 07 |
jari |
1770 |
return(row == oldRow && column == oldColumn); |
2 |
26 Feb 07 |
jari |
1771 |
} |
2 |
26 Feb 07 |
jari |
1772 |
|
2 |
26 Feb 07 |
jari |
1773 |
public void mouseDragged(MouseEvent event) {} |
2 |
26 Feb 07 |
jari |
1774 |
public void keyReleased(KeyEvent event) {} |
2 |
26 Feb 07 |
jari |
1775 |
public void keyPressed(KeyEvent e) {} |
2 |
26 Feb 07 |
jari |
1776 |
public void keyTyped(KeyEvent e) {} |
2 |
26 Feb 07 |
jari |
1777 |
public void windowClosing(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1778 |
public void windowOpened(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1779 |
public void windowClosed(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1780 |
public void windowIconified(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1781 |
public void windowDeiconified(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1782 |
public void windowActivated(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1783 |
public void windowDeactivated(WindowEvent e) {} |
2 |
26 Feb 07 |
jari |
1784 |
} |
2 |
26 Feb 07 |
jari |
1785 |
|
2 |
26 Feb 07 |
jari |
1786 |
|
2 |
26 Feb 07 |
jari |
1787 |
private class ScaleListener extends GDMScaleListener{ |
2 |
26 Feb 07 |
jari |
1788 |
|
2 |
26 Feb 07 |
jari |
1789 |
public void scaleChanged(float lower, float upper) { |
2 |
26 Feb 07 |
jari |
1790 |
minValue = lower; |
2 |
26 Feb 07 |
jari |
1791 |
maxValue = upper; |
2 |
26 Feb 07 |
jari |
1792 |
expColumnHeaderSP.setValues(minValue, maxValue); |
2 |
26 Feb 07 |
jari |
1793 |
expRowHeaderSP.setValues(minValue, maxValue); |
2 |
26 Feb 07 |
jari |
1794 |
expColumnHeaderSP.updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
1795 |
expRowHeaderSP.updateSize(NOT_UPDATE_ANNOTATION_SIZE); |
2 |
26 Feb 07 |
jari |
1796 |
validate(); |
2 |
26 Feb 07 |
jari |
1797 |
expColumnHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1798 |
expRowHeaderSP.repaint(); |
2 |
26 Feb 07 |
jari |
1799 |
repaint(); |
2 |
26 Feb 07 |
jari |
1800 |
} |
2 |
26 Feb 07 |
jari |
1801 |
} |
2 |
26 Feb 07 |
jari |
1802 |
|
2 |
26 Feb 07 |
jari |
1803 |
|
2 |
26 Feb 07 |
jari |
1804 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
1806 |
*/ |
2 |
26 Feb 07 |
jari |
1807 |
public int getExperimentID() { |
2 |
26 Feb 07 |
jari |
1808 |
return 0; |
2 |
26 Feb 07 |
jari |
1809 |
} |
2 |
26 Feb 07 |
jari |
1810 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see org.tigr.microarray.mev.cluster.gui.IViewer#setExperimentID(int) |
2 |
26 Feb 07 |
jari |
1813 |
*/ |
2 |
26 Feb 07 |
jari |
1814 |
public void setExperimentID(int id) { |
2 |
26 Feb 07 |
jari |
1815 |
; |
2 |
26 Feb 07 |
jari |
1816 |
} |
2 |
26 Feb 07 |
jari |
1817 |
|
2 |
26 Feb 07 |
jari |
1818 |
} |