2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: KMCSupportDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.4 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:52 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
package org.tigr.microarray.mev.cluster.gui.impl.kmcs; |
2 |
26 Feb 07 |
jari |
14 |
|
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.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.SwingConstants; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DialogListener; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DistanceMetricPanel; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.HCLSelectionPanel; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.SampleSelectionPanel; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
42 |
|
2 |
26 Feb 07 |
jari |
43 |
/** |
2 |
26 Feb 07 |
jari |
44 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
* @version |
2 |
26 Feb 07 |
jari |
47 |
*/ |
2 |
26 Feb 07 |
jari |
48 |
public class KMCSupportDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
49 |
|
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
SampleSelectionPanel sPanel; |
2 |
26 Feb 07 |
jari |
52 |
MeansOrMediansPanel mPanel; |
2 |
26 Feb 07 |
jari |
53 |
TopPanel tPanel; |
2 |
26 Feb 07 |
jari |
54 |
KMCParameterPanel kPanel; |
2 |
26 Feb 07 |
jari |
55 |
HCLSelectionPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
56 |
DistanceMetricPanel metricPanel; |
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
59 |
|
2 |
26 Feb 07 |
jari |
/** Creates new KMCSupportDialog */ |
2 |
26 Feb 07 |
jari |
61 |
public KMCSupportDialog(JFrame parentFrame, boolean modality, String globalMetricName, boolean globalAbsoluteSetting) { |
2 |
26 Feb 07 |
jari |
62 |
super(parentFrame, "KMS: K-Means/K-Medians Support", modality); |
2 |
26 Feb 07 |
jari |
63 |
setBounds(0, 0, 500, 550); |
2 |
26 Feb 07 |
jari |
64 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
65 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
66 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
67 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
68 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
69 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
sPanel = new SampleSelectionPanel(Color.white, UIManager.getColor("Label.foreground"),true,"Sample Selection"); |
2 |
26 Feb 07 |
jari |
72 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 10); |
2 |
26 Feb 07 |
jari |
73 |
gridbag.setConstraints(sPanel, constraints); |
2 |
26 Feb 07 |
jari |
74 |
pane.add(sPanel); |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
metricPanel = new DistanceMetricPanel(globalMetricName, globalAbsoluteSetting, "Euclidean Distance", "KMCS", true, true); |
2 |
26 Feb 07 |
jari |
77 |
buildConstraints(constraints, 0, 1, 1, 1, 100, 10); |
2 |
26 Feb 07 |
jari |
78 |
gridbag.setConstraints(metricPanel, constraints); |
2 |
26 Feb 07 |
jari |
79 |
pane.add(metricPanel); |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
mPanel = new MeansOrMediansPanel(); |
2 |
26 Feb 07 |
jari |
82 |
buildConstraints(constraints, 0, 2, 1, 1, 100, 10); |
2 |
26 Feb 07 |
jari |
83 |
gridbag.setConstraints(mPanel, constraints); |
2 |
26 Feb 07 |
jari |
84 |
pane.add(mPanel); |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
tPanel = new TopPanel(); |
2 |
26 Feb 07 |
jari |
87 |
buildConstraints(constraints, 0, 3, 1, 1, 100, 30); |
2 |
26 Feb 07 |
jari |
88 |
gridbag.setConstraints(tPanel, constraints); |
2 |
26 Feb 07 |
jari |
89 |
pane.add(tPanel); |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
kPanel = new KMCParameterPanel(); |
2 |
26 Feb 07 |
jari |
92 |
buildConstraints(constraints, 0, 4, 1, 1, 0, 30); |
2 |
26 Feb 07 |
jari |
93 |
gridbag.setConstraints(kPanel, constraints); |
2 |
26 Feb 07 |
jari |
94 |
pane.add(kPanel); |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
hclOpsPanel = new HCLSelectionPanel(); |
2 |
26 Feb 07 |
jari |
97 |
buildConstraints(constraints, 0, 5, 1, 1, 0, 10); |
2 |
26 Feb 07 |
jari |
98 |
gridbag.setConstraints(hclOpsPanel, constraints); |
2 |
26 Feb 07 |
jari |
99 |
pane.add(hclOpsPanel); |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
102 |
setActionListeners(new Listener()); |
2 |
26 Feb 07 |
jari |
103 |
} |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
106 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
107 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
109 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
if (visible) { |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
} |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
117 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
118 |
|
2 |
26 Feb 07 |
jari |
119 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
120 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
121 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
122 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
123 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
124 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
|
2 |
26 Feb 07 |
jari |
128 |
class MeansOrMediansPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
129 |
JRadioButton meansButton, mediansButton; |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
MeansOrMediansPanel() { |
2 |
26 Feb 07 |
jari |
132 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Means or Medians", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
133 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
134 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
135 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
136 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
meansButton = new JRadioButton("Calculate means", true); |
2 |
26 Feb 07 |
jari |
139 |
meansButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
140 |
meansButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
141 |
meansButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
142 |
meansButton.setHorizontalAlignment(SwingConstants.CENTER); |
2 |
26 Feb 07 |
jari |
143 |
|
2 |
26 Feb 07 |
jari |
144 |
mediansButton = new JRadioButton("Calculate medians", false); |
2 |
26 Feb 07 |
jari |
145 |
mediansButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
146 |
mediansButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
147 |
mediansButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
148 |
mediansButton.setHorizontalAlignment(SwingConstants.CENTER); |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
150 |
ButtonGroup chooseMeansOrMedians = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
chooseMeansOrMedians.add(meansButton); |
2 |
26 Feb 07 |
jari |
153 |
chooseMeansOrMedians.add(mediansButton); |
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 100); |
2 |
26 Feb 07 |
jari |
156 |
gridbag.setConstraints(meansButton, constraints); |
2 |
26 Feb 07 |
jari |
157 |
this.add(meansButton); |
2 |
26 Feb 07 |
jari |
158 |
|
2 |
26 Feb 07 |
jari |
159 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
160 |
gridbag.setConstraints(mediansButton, constraints); |
2 |
26 Feb 07 |
jari |
161 |
this.add(mediansButton); |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
} |
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
class TopPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
167 |
JTextField numRepsInputField, thresholdInputField; |
2 |
26 Feb 07 |
jari |
168 |
|
2 |
26 Feb 07 |
jari |
169 |
TopPanel() { |
2 |
26 Feb 07 |
jari |
170 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Parameters for K-Means / K-Medians repetitions", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
171 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
172 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
173 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
175 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
JLabel numRepsLabel = new JLabel("Number of k-means / k-medians runs "); |
2 |
26 Feb 07 |
jari |
178 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 50); |
2 |
26 Feb 07 |
jari |
179 |
gridbag.setConstraints(numRepsLabel, constraints); |
2 |
26 Feb 07 |
jari |
180 |
this.add(numRepsLabel); |
2 |
26 Feb 07 |
jari |
181 |
|
2 |
26 Feb 07 |
jari |
182 |
numRepsInputField = new JTextField("10", 7); |
2 |
26 Feb 07 |
jari |
183 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
184 |
gridbag.setConstraints(numRepsInputField, constraints); |
2 |
26 Feb 07 |
jari |
185 |
this.add(numRepsInputField); |
2 |
26 Feb 07 |
jari |
186 |
|
2 |
26 Feb 07 |
jari |
187 |
JLabel thresholdLabel = new JLabel("Threshold % of occurrence in same cluster"); |
2 |
26 Feb 07 |
jari |
188 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
189 |
gridbag.setConstraints(thresholdLabel, constraints); |
2 |
26 Feb 07 |
jari |
190 |
this.add(thresholdLabel); |
2 |
26 Feb 07 |
jari |
191 |
|
2 |
26 Feb 07 |
jari |
192 |
thresholdInputField = new JTextField("80", 7); |
2 |
26 Feb 07 |
jari |
193 |
buildConstraints(constraints, 1, 1, 1, 1, 0, 0); |
2 |
26 Feb 07 |
jari |
194 |
gridbag.setConstraints(thresholdInputField, constraints); |
2 |
26 Feb 07 |
jari |
195 |
this.add(thresholdInputField); |
2 |
26 Feb 07 |
jari |
196 |
|
2 |
26 Feb 07 |
jari |
197 |
|
2 |
26 Feb 07 |
jari |
198 |
} |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
|
2 |
26 Feb 07 |
jari |
201 |
class KMCParameterPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
202 |
|
2 |
26 Feb 07 |
jari |
203 |
JTextField numClustersInputField, numIterationsInputField; |
2 |
26 Feb 07 |
jari |
204 |
|
2 |
26 Feb 07 |
jari |
205 |
KMCParameterPanel() { |
2 |
26 Feb 07 |
jari |
206 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Parameters for each K-Means / K-Medians run", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
207 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
208 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
209 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
210 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
JLabel numClustersLabel = new JLabel("Number of clusters "); |
2 |
26 Feb 07 |
jari |
213 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 50); |
2 |
26 Feb 07 |
jari |
214 |
gridbag.setConstraints(numClustersLabel, constraints); |
2 |
26 Feb 07 |
jari |
215 |
this.add(numClustersLabel); |
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
numClustersInputField = new JTextField("10", 7); |
2 |
26 Feb 07 |
jari |
218 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
219 |
gridbag.setConstraints(numClustersInputField, constraints); |
2 |
26 Feb 07 |
jari |
220 |
this.add(numClustersInputField); |
2 |
26 Feb 07 |
jari |
221 |
|
2 |
26 Feb 07 |
jari |
222 |
JLabel iterationsLabel = new JLabel("Maximum number of iterations "); |
2 |
26 Feb 07 |
jari |
223 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
224 |
gridbag.setConstraints(iterationsLabel, constraints); |
2 |
26 Feb 07 |
jari |
225 |
this.add(iterationsLabel); |
2 |
26 Feb 07 |
jari |
226 |
|
2 |
26 Feb 07 |
jari |
227 |
numIterationsInputField = new JTextField("50", 7); |
2 |
26 Feb 07 |
jari |
228 |
buildConstraints(constraints, 1, 1, 1, 1, 0, 0); |
2 |
26 Feb 07 |
jari |
229 |
gridbag.setConstraints(numIterationsInputField, constraints); |
2 |
26 Feb 07 |
jari |
230 |
this.add(numIterationsInputField); |
2 |
26 Feb 07 |
jari |
231 |
} |
2 |
26 Feb 07 |
jari |
232 |
} |
2 |
26 Feb 07 |
jari |
233 |
|
2 |
26 Feb 07 |
jari |
234 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
235 |
return okPressed; |
2 |
26 Feb 07 |
jari |
236 |
} |
2 |
26 Feb 07 |
jari |
237 |
|
2 |
26 Feb 07 |
jari |
238 |
public int getNumReps() { |
2 |
26 Feb 07 |
jari |
239 |
int numReps; |
2 |
26 Feb 07 |
jari |
240 |
|
2 |
26 Feb 07 |
jari |
241 |
String s1 = tPanel.numRepsInputField.getText(); |
2 |
26 Feb 07 |
jari |
242 |
numReps = Integer.parseInt(s1); |
2 |
26 Feb 07 |
jari |
243 |
return numReps; |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
|
2 |
26 Feb 07 |
jari |
246 |
public double getThresholdPercent() { |
2 |
26 Feb 07 |
jari |
247 |
double thresholdPercent; |
2 |
26 Feb 07 |
jari |
248 |
|
2 |
26 Feb 07 |
jari |
249 |
String s1 = tPanel.thresholdInputField.getText(); |
2 |
26 Feb 07 |
jari |
250 |
thresholdPercent = Double.parseDouble(s1); |
2 |
26 Feb 07 |
jari |
251 |
return thresholdPercent; |
2 |
26 Feb 07 |
jari |
252 |
} |
2 |
26 Feb 07 |
jari |
253 |
|
2 |
26 Feb 07 |
jari |
254 |
public int getNumClusters() { |
2 |
26 Feb 07 |
jari |
255 |
int numClusters; |
2 |
26 Feb 07 |
jari |
256 |
|
2 |
26 Feb 07 |
jari |
257 |
String s1 = kPanel.numClustersInputField.getText(); |
2 |
26 Feb 07 |
jari |
258 |
numClusters = Integer.parseInt(s1); |
2 |
26 Feb 07 |
jari |
259 |
|
2 |
26 Feb 07 |
jari |
260 |
return numClusters; |
2 |
26 Feb 07 |
jari |
261 |
} |
2 |
26 Feb 07 |
jari |
262 |
|
2 |
26 Feb 07 |
jari |
263 |
public int getIterations() { |
2 |
26 Feb 07 |
jari |
264 |
int iterations; |
2 |
26 Feb 07 |
jari |
265 |
|
2 |
26 Feb 07 |
jari |
266 |
String s1 = kPanel.numIterationsInputField.getText(); |
2 |
26 Feb 07 |
jari |
267 |
iterations = Integer.parseInt(s1); |
2 |
26 Feb 07 |
jari |
268 |
|
2 |
26 Feb 07 |
jari |
269 |
return iterations; |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
|
2 |
26 Feb 07 |
jari |
272 |
public boolean isDrawTrees() { |
2 |
26 Feb 07 |
jari |
273 |
boolean drawTrees = hclOpsPanel.isHCLSelected(); |
2 |
26 Feb 07 |
jari |
274 |
return drawTrees; |
2 |
26 Feb 07 |
jari |
275 |
} |
2 |
26 Feb 07 |
jari |
276 |
|
2 |
26 Feb 07 |
jari |
277 |
public boolean meansChosen() { |
2 |
26 Feb 07 |
jari |
278 |
return mPanel.meansButton.isSelected(); |
2 |
26 Feb 07 |
jari |
279 |
} |
2 |
26 Feb 07 |
jari |
280 |
|
2 |
26 Feb 07 |
jari |
281 |
public boolean isClusterGenes(){ |
2 |
26 Feb 07 |
jari |
282 |
return sPanel.isClusterGenesSelected(); |
2 |
26 Feb 07 |
jari |
283 |
} |
2 |
26 Feb 07 |
jari |
284 |
|
2 |
26 Feb 07 |
jari |
285 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the currently selected metric |
2 |
26 Feb 07 |
jari |
287 |
*/ |
2 |
26 Feb 07 |
jari |
288 |
public int getDistanceMetric() { |
2 |
26 Feb 07 |
jari |
289 |
return metricPanel.getMetricIndex(); |
2 |
26 Feb 07 |
jari |
290 |
} |
2 |
26 Feb 07 |
jari |
291 |
|
2 |
26 Feb 07 |
jari |
292 |
/** |
2 |
26 Feb 07 |
jari |
* Returns true if the absolute checkbox is selected, else false |
2 |
26 Feb 07 |
jari |
294 |
*/ |
2 |
26 Feb 07 |
jari |
295 |
public boolean getAbsoluteSelection() { |
2 |
26 Feb 07 |
jari |
296 |
return metricPanel.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
297 |
} |
2 |
26 Feb 07 |
jari |
298 |
|
2 |
26 Feb 07 |
jari |
299 |
/** |
2 |
26 Feb 07 |
jari |
* Resets to initial values |
2 |
26 Feb 07 |
jari |
301 |
*/ |
2 |
26 Feb 07 |
jari |
302 |
private void resetControls(){ |
2 |
26 Feb 07 |
jari |
303 |
this.sPanel.setClusterGenesSelected(true); |
2 |
26 Feb 07 |
jari |
304 |
this.mPanel.meansButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
305 |
this.tPanel.numRepsInputField.setText("10"); |
2 |
26 Feb 07 |
jari |
306 |
this.tPanel.thresholdInputField.setText("80"); |
2 |
26 Feb 07 |
jari |
307 |
this.kPanel.numClustersInputField.setText("10"); |
2 |
26 Feb 07 |
jari |
308 |
this.kPanel.numIterationsInputField.setText("50"); |
2 |
26 Feb 07 |
jari |
309 |
this.hclOpsPanel.setHCLSelected(false); |
2 |
26 Feb 07 |
jari |
310 |
this.metricPanel.reset(); |
2 |
26 Feb 07 |
jari |
311 |
} |
2 |
26 Feb 07 |
jari |
312 |
|
2 |
26 Feb 07 |
jari |
313 |
/** |
2 |
26 Feb 07 |
jari |
* Validates the input |
2 |
26 Feb 07 |
jari |
315 |
*/ |
2 |
26 Feb 07 |
jari |
316 |
private boolean validInput(int n, double p, int k, int i){ |
2 |
26 Feb 07 |
jari |
317 |
boolean valid = true; |
2 |
26 Feb 07 |
jari |
318 |
if(n < 1){ |
2 |
26 Feb 07 |
jari |
319 |
tPanel.numRepsInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
320 |
tPanel.numRepsInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
321 |
JOptionPane.showMessageDialog(KMCSupportDialog.this, "Number of repetitions must be > 0", "Input Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
322 |
valid = false; |
2 |
26 Feb 07 |
jari |
323 |
} else if(p <= 0 || p > 100){ |
2 |
26 Feb 07 |
jari |
324 |
tPanel.thresholdInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
325 |
tPanel.thresholdInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
326 |
JOptionPane.showMessageDialog(KMCSupportDialog.this, "Threshold % must be > 0 and <= 100", "Input Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
327 |
valid = false; |
2 |
26 Feb 07 |
jari |
328 |
}else if(k < 1){ |
2 |
26 Feb 07 |
jari |
329 |
kPanel.numClustersInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
330 |
kPanel.numClustersInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
331 |
JOptionPane.showMessageDialog(KMCSupportDialog.this, "Number of clusters must be > 0", "Input Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
332 |
valid = false; |
2 |
26 Feb 07 |
jari |
333 |
} else if(i < 1){ |
2 |
26 Feb 07 |
jari |
334 |
JOptionPane.showMessageDialog(KMCSupportDialog.this, "Number of iterations must be > 0", "Input Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
335 |
kPanel.numIterationsInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
336 |
kPanel.numIterationsInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
337 |
valid = false; |
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
return valid; |
2 |
26 Feb 07 |
jari |
340 |
} |
2 |
26 Feb 07 |
jari |
341 |
|
2 |
26 Feb 07 |
jari |
342 |
/** |
2 |
26 Feb 07 |
jari |
* The class to listen to the dialog and check boxes items events. |
2 |
26 Feb 07 |
jari |
344 |
*/ |
2 |
26 Feb 07 |
jari |
345 |
private class Listener extends DialogListener { |
2 |
26 Feb 07 |
jari |
346 |
|
2 |
26 Feb 07 |
jari |
347 |
public void actionPerformed(ActionEvent e) { |
2 |
26 Feb 07 |
jari |
348 |
String command = e.getActionCommand(); |
2 |
26 Feb 07 |
jari |
349 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
350 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
351 |
int n, k, i, progress = 0; |
2 |
26 Feb 07 |
jari |
352 |
double p; |
2 |
26 Feb 07 |
jari |
353 |
try{ |
2 |
26 Feb 07 |
jari |
354 |
n = Integer.parseInt(tPanel.numRepsInputField.getText()); |
2 |
26 Feb 07 |
jari |
355 |
progress++; |
2 |
26 Feb 07 |
jari |
356 |
p = Double.parseDouble(tPanel.thresholdInputField.getText()); |
2 |
26 Feb 07 |
jari |
357 |
progress++; |
2 |
26 Feb 07 |
jari |
358 |
k = Integer.parseInt(kPanel.numClustersInputField.getText()); |
2 |
26 Feb 07 |
jari |
359 |
progress++; |
2 |
26 Feb 07 |
jari |
360 |
i = Integer.parseInt(kPanel.numIterationsInputField.getText()); |
2 |
26 Feb 07 |
jari |
361 |
progress++; |
2 |
26 Feb 07 |
jari |
362 |
} catch (NumberFormatException e1){ |
2 |
26 Feb 07 |
jari |
363 |
switch(progress){ |
2 |
26 Feb 07 |
jari |
364 |
case 0:{ |
2 |
26 Feb 07 |
jari |
365 |
tPanel.numRepsInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
366 |
tPanel.numRepsInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
367 |
break; |
2 |
26 Feb 07 |
jari |
368 |
} |
2 |
26 Feb 07 |
jari |
369 |
case 1:{ |
2 |
26 Feb 07 |
jari |
370 |
tPanel.thresholdInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
371 |
tPanel.thresholdInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
372 |
break; |
2 |
26 Feb 07 |
jari |
373 |
} |
2 |
26 Feb 07 |
jari |
374 |
case 2:{ |
2 |
26 Feb 07 |
jari |
375 |
kPanel.numClustersInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
376 |
kPanel.numClustersInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
377 |
break; |
2 |
26 Feb 07 |
jari |
378 |
} |
2 |
26 Feb 07 |
jari |
379 |
case 3:{ |
2 |
26 Feb 07 |
jari |
380 |
kPanel.numIterationsInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
381 |
kPanel.numIterationsInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
382 |
break; |
2 |
26 Feb 07 |
jari |
383 |
} |
2 |
26 Feb 07 |
jari |
384 |
} |
2 |
26 Feb 07 |
jari |
385 |
JOptionPane.showMessageDialog(KMCSupportDialog.this, "Entry format error.", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
386 |
return; |
2 |
26 Feb 07 |
jari |
387 |
} |
2 |
26 Feb 07 |
jari |
388 |
if(!validInput(n,p,k,i)){ |
2 |
26 Feb 07 |
jari |
389 |
return; |
2 |
26 Feb 07 |
jari |
390 |
} |
2 |
26 Feb 07 |
jari |
391 |
|
2 |
26 Feb 07 |
jari |
392 |
|
2 |
26 Feb 07 |
jari |
393 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
394 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
else if (command.equals("reset-command")){ |
2 |
26 Feb 07 |
jari |
397 |
resetControls(); |
2 |
26 Feb 07 |
jari |
398 |
return; |
2 |
26 Feb 07 |
jari |
399 |
} |
2 |
26 Feb 07 |
jari |
400 |
else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
401 |
HelpWindow hw = new HelpWindow(KMCSupportDialog.this, "KMS Initialization Dialog"); |
2 |
26 Feb 07 |
jari |
402 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
403 |
hw.setSize(450,650); |
2 |
26 Feb 07 |
jari |
404 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
405 |
hw.show(); |
2 |
26 Feb 07 |
jari |
406 |
return; |
2 |
26 Feb 07 |
jari |
407 |
} |
2 |
26 Feb 07 |
jari |
408 |
else { |
2 |
26 Feb 07 |
jari |
409 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
410 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
411 |
return; |
2 |
26 Feb 07 |
jari |
412 |
} |
2 |
26 Feb 07 |
jari |
413 |
} |
2 |
26 Feb 07 |
jari |
414 |
dispose(); |
2 |
26 Feb 07 |
jari |
415 |
} |
2 |
26 Feb 07 |
jari |
416 |
|
2 |
26 Feb 07 |
jari |
417 |
|
2 |
26 Feb 07 |
jari |
418 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
419 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
420 |
dispose(); |
2 |
26 Feb 07 |
jari |
421 |
} |
2 |
26 Feb 07 |
jari |
422 |
} |
2 |
26 Feb 07 |
jari |
423 |
|
2 |
26 Feb 07 |
jari |
424 |
|
2 |
26 Feb 07 |
jari |
425 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
426 |
JFrame dummyFrame = new JFrame(); |
2 |
26 Feb 07 |
jari |
427 |
KMCSupportDialog kSuppDialog = new KMCSupportDialog(dummyFrame, true, "Euclidean Distance", false); |
2 |
26 Feb 07 |
jari |
428 |
kSuppDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
429 |
System.exit(0); |
2 |
26 Feb 07 |
jari |
430 |
} |
2 |
26 Feb 07 |
jari |
431 |
|
2 |
26 Feb 07 |
jari |
432 |
} |