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 |
* SAMInitDialog.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on November 7, 2002, 2:06 PM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
package org.tigr.microarray.mev.cluster.gui.impl.sam; |
2 |
26 Feb 07 |
jari |
11 |
|
2 |
26 Feb 07 |
jari |
12 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.ItemEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.ItemListener; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.BufferedReader; |
2 |
26 Feb 07 |
jari |
26 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
27 |
import java.io.FileOutputStream; |
2 |
26 Feb 07 |
jari |
28 |
import java.io.FileReader; |
2 |
26 Feb 07 |
jari |
29 |
import java.io.PrintWriter; |
2 |
26 Feb 07 |
jari |
30 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.DefaultListModel; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.ImageIcon; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.JComboBox; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JFileChooser; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JList; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
44 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
46 |
import javax.swing.JSplitPane; |
2 |
26 Feb 07 |
jari |
47 |
import javax.swing.JTabbedPane; |
2 |
26 Feb 07 |
jari |
48 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
49 |
import javax.swing.ScrollPaneConstants; |
2 |
26 Feb 07 |
jari |
50 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
51 |
import javax.swing.border.BevelBorder; |
2 |
26 Feb 07 |
jari |
52 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
53 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
54 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
55 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.HCLSigOnlyPanel; |
2 |
26 Feb 07 |
jari |
56 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
57 |
import org.tigr.util.StringSplitter; |
2 |
26 Feb 07 |
jari |
58 |
/** |
2 |
26 Feb 07 |
jari |
59 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
* @version |
2 |
26 Feb 07 |
jari |
62 |
*/ |
2 |
26 Feb 07 |
jari |
63 |
public class SAMInitDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
ImageIcon forwardImage, backImage; |
2 |
26 Feb 07 |
jari |
66 |
JTabbedPane tabPane; |
2 |
26 Feb 07 |
jari |
67 |
GroupExperimentsPanel gPanel; |
2 |
26 Feb 07 |
jari |
68 |
TwoClassPairedMainPanel tcpmPanel; |
2 |
26 Feb 07 |
jari |
69 |
MultiClassPanel mPanel; |
2 |
26 Feb 07 |
jari |
70 |
CensoredSurvivalPanel csPanel; |
2 |
26 Feb 07 |
jari |
71 |
OneClassPanel oneCPanel; |
2 |
26 Feb 07 |
jari |
72 |
S0AndQValueCalcPanel sqPanel; |
2 |
26 Feb 07 |
jari |
73 |
PermutationsPanel pPanel; |
2 |
26 Feb 07 |
jari |
74 |
ImputationPanel iPanel; |
2 |
26 Feb 07 |
jari |
75 |
OKCancelPanel oPanel; |
2 |
26 Feb 07 |
jari |
76 |
final int fileLoadMin=20; |
2 |
26 Feb 07 |
jari |
77 |
boolean okPressed = false, allUniquePermsUsed = false; |
2 |
26 Feb 07 |
jari |
78 |
Vector exptNames; |
2 |
26 Feb 07 |
jari |
79 |
int numGenes, numUniquePerms; |
2 |
26 Feb 07 |
jari |
80 |
HCLSigOnlyPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
81 |
boolean lotsOfSamples = false; |
2 |
26 Feb 07 |
jari |
82 |
String lotsOfSamplesWarningText = " Note: You can assign large numbers of samples quickly by using a saved text file."; |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
|
2 |
26 Feb 07 |
jari |
85 |
public static final int GROUP_A = 1; |
2 |
26 Feb 07 |
jari |
86 |
public static final int GROUP_B = 2; |
2 |
26 Feb 07 |
jari |
87 |
public static final int NEITHER_GROUP = 3; |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
89 |
public static final int TWO_CLASS_UNPAIRED = 4; |
2 |
26 Feb 07 |
jari |
90 |
public static final int TWO_CLASS_PAIRED = 5; |
2 |
26 Feb 07 |
jari |
91 |
public static final int MULTI_CLASS = 6; |
2 |
26 Feb 07 |
jari |
92 |
public static final int CENSORED_SURVIVAL = 7; |
2 |
26 Feb 07 |
jari |
93 |
public static final int ONE_CLASS = 8; |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
/** Creates new SAMInitDialog */ |
2 |
26 Feb 07 |
jari |
96 |
public SAMInitDialog(JFrame parentFrame, boolean modality, Vector exptNames, int numGenes) { |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
super(parentFrame, "SAM Initialization", modality); |
2 |
26 Feb 07 |
jari |
//this.parentFrame = parentFrame; |
2 |
26 Feb 07 |
jari |
100 |
this.exptNames = exptNames; |
2 |
26 Feb 07 |
jari |
101 |
this.numGenes = numGenes; |
2 |
26 Feb 07 |
jari |
102 |
this.numUniquePerms = 0; |
2 |
26 Feb 07 |
jari |
103 |
setBounds(0, 0, 700, 800); |
2 |
26 Feb 07 |
jari |
104 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
105 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
106 |
|
2 |
26 Feb 07 |
jari |
107 |
if(exptNames.size()>fileLoadMin){ |
2 |
26 Feb 07 |
jari |
108 |
lotsOfSamples = true; |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
forwardImage = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("org/tigr/images/Forward24.gif"))); |
2 |
26 Feb 07 |
jari |
112 |
backImage = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("org/tigr/images/Back24.gif"))); |
2 |
26 Feb 07 |
jari |
113 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
114 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
115 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
118 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
javax.swing.UIManager.put("TabbedPane.selected", Color.white); |
2 |
26 Feb 07 |
jari |
121 |
tabPane = new JTabbedPane(); |
2 |
26 Feb 07 |
jari |
122 |
gPanel = new GroupExperimentsPanel(exptNames); |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
tabPane.add("Two-class unpaired", gPanel); |
2 |
26 Feb 07 |
jari |
125 |
tcpmPanel = new TwoClassPairedMainPanel(); |
2 |
26 Feb 07 |
jari |
126 |
tabPane.add("Two-class paired", tcpmPanel); |
2 |
26 Feb 07 |
jari |
127 |
mPanel = new MultiClassPanel(/*exptNames*/); |
2 |
26 Feb 07 |
jari |
128 |
tabPane.add("Multi-class", mPanel); |
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
csPanel = new CensoredSurvivalPanel(exptNames); |
2 |
26 Feb 07 |
jari |
131 |
tabPane.add("Censored survival", csPanel); |
2 |
26 Feb 07 |
jari |
132 |
oneCPanel = new OneClassPanel(); |
2 |
26 Feb 07 |
jari |
133 |
tabPane.add("One-Class", oneCPanel); |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 75); |
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
gridbag.setConstraints(tabPane, constraints); |
2 |
26 Feb 07 |
jari |
138 |
|
2 |
26 Feb 07 |
jari |
139 |
pane.add(tabPane); |
2 |
26 Feb 07 |
jari |
140 |
|
2 |
26 Feb 07 |
jari |
141 |
pPanel = new PermutationsPanel(); |
2 |
26 Feb 07 |
jari |
142 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
143 |
gridbag.setConstraints(pPanel, constraints); |
2 |
26 Feb 07 |
jari |
144 |
pane.add(pPanel); |
2 |
26 Feb 07 |
jari |
145 |
sqPanel = new S0AndQValueCalcPanel(); |
2 |
26 Feb 07 |
jari |
146 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 10); |
2 |
26 Feb 07 |
jari |
147 |
gridbag.setConstraints(sqPanel, constraints); |
2 |
26 Feb 07 |
jari |
148 |
pane.add(sqPanel); |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
150 |
iPanel = new ImputationPanel(); |
2 |
26 Feb 07 |
jari |
151 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
152 |
gridbag.setConstraints(iPanel, constraints); |
2 |
26 Feb 07 |
jari |
153 |
pane.add(iPanel); |
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
hclOpsPanel = new HCLSigOnlyPanel(); |
2 |
26 Feb 07 |
jari |
156 |
buildConstraints(constraints, 0, 4, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
157 |
gridbag.setConstraints(hclOpsPanel, constraints); |
2 |
26 Feb 07 |
jari |
158 |
pane.add(hclOpsPanel); |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
160 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
161 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
162 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
163 |
this.addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
164 |
} |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
167 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
168 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
171 |
|
2 |
26 Feb 07 |
jari |
172 |
if (visible) { |
2 |
26 Feb 07 |
jari |
//bPanel.okButton.requestFocus(); //UNCOMMMENT THIS LATER |
2 |
26 Feb 07 |
jari |
174 |
} |
2 |
26 Feb 07 |
jari |
175 |
} |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
178 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
181 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
182 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
183 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
184 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
185 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
186 |
} |
2 |
26 Feb 07 |
jari |
187 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
188 |
return okPressed; |
2 |
26 Feb 07 |
jari |
189 |
} |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
191 |
public boolean isSaveMatrix() { |
2 |
26 Feb 07 |
jari |
192 |
return iPanel.saveMatrixChkBox.isSelected(); |
2 |
26 Feb 07 |
jari |
193 |
} |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
class GroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
196 |
JLabel[] expLabels; |
2 |
26 Feb 07 |
jari |
197 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
198 |
JRadioButton[] groupARadioButtons, groupBRadioButtons, neitherGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
199 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
200 |
|
2 |
26 Feb 07 |
jari |
201 |
GroupExperimentsPanel(Vector exptNames) { |
2 |
26 Feb 07 |
jari |
202 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Group Assignments", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
203 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
204 |
JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
205 |
expLabels = new JLabel[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
206 |
groupARadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
207 |
groupBRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
208 |
neitherGroupRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
209 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
210 |
|
2 |
26 Feb 07 |
jari |
211 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
212 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
213 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
214 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
215 |
panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
218 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
219 |
|
2 |
26 Feb 07 |
jari |
220 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
221 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
222 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
223 |
} |
2 |
26 Feb 07 |
jari |
224 |
|
2 |
26 Feb 07 |
jari |
225 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
226 |
String s1 = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
227 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
228 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
229 |
groupARadioButtons[i] = new JRadioButton("Group A", true); |
2 |
26 Feb 07 |
jari |
230 |
chooseGroup[i].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
231 |
groupBRadioButtons[i] = new JRadioButton("Group B", false); |
2 |
26 Feb 07 |
jari |
232 |
chooseGroup[i].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
233 |
neitherGroupRadioButtons[i] = new JRadioButton("Neither group", false); |
2 |
26 Feb 07 |
jari |
234 |
chooseGroup[i].add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
235 |
|
2 |
26 Feb 07 |
jari |
// set current panel |
2 |
26 Feb 07 |
jari |
237 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
238 |
|
2 |
26 Feb 07 |
jari |
239 |
buildConstraints(constraints, 0, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
240 |
gridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
241 |
panels[currPanel].add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
buildConstraints(constraints, 1, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
244 |
gridbag.setConstraints(groupARadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
245 |
panels[currPanel].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
246 |
|
2 |
26 Feb 07 |
jari |
247 |
buildConstraints(constraints, 2, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
248 |
gridbag.setConstraints(groupBRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
249 |
panels[currPanel].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
250 |
buildConstraints(constraints, 3, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
251 |
gridbag.setConstraints(neitherGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
252 |
panels[currPanel].add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
253 |
} |
2 |
26 Feb 07 |
jari |
254 |
|
2 |
26 Feb 07 |
jari |
255 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
256 |
|
2 |
26 Feb 07 |
jari |
257 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
258 |
bigPanel.add(panels[i] ,new GridBagConstraints(0,i,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
259 |
} |
2 |
26 Feb 07 |
jari |
260 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
261 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
262 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
264 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
265 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
266 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
267 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
268 |
|
2 |
26 Feb 07 |
jari |
269 |
JLabel label1 = new JLabel("Note: Group A and Group B MUST each contain more than one sample."); |
2 |
26 Feb 07 |
jari |
270 |
label1.setHorizontalAlignment(JLabel.CENTER); |
2 |
26 Feb 07 |
jari |
271 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
272 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
273 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
274 |
gridbag2.setConstraints(label1, constraints); |
2 |
26 Feb 07 |
jari |
275 |
this.add(label1); |
2 |
26 Feb 07 |
jari |
276 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
277 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
278 |
lotsOfSamplesWarningLabel.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
279 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,2,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
280 |
} |
2 |
26 Feb 07 |
jari |
281 |
|
2 |
26 Feb 07 |
jari |
282 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
283 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
284 |
GridBagLayout gridbag3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
285 |
panel2.setLayout(gridbag3); |
2 |
26 Feb 07 |
jari |
286 |
|
2 |
26 Feb 07 |
jari |
287 |
JButton saveButton = new JButton(" Save grouping "); |
2 |
26 Feb 07 |
jari |
288 |
saveButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
289 |
saveButton.setSize(180,30); |
2 |
26 Feb 07 |
jari |
290 |
saveButton.setPreferredSize(new Dimension(180,30)); |
2 |
26 Feb 07 |
jari |
291 |
JButton loadButton = new JButton(" Load grouping "); |
2 |
26 Feb 07 |
jari |
292 |
loadButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
293 |
loadButton.setPreferredSize(new Dimension(180,30)); |
2 |
26 Feb 07 |
jari |
294 |
loadButton.setSize(180,30); |
2 |
26 Feb 07 |
jari |
295 |
JButton resetButton = new JButton(" Reset "); |
2 |
26 Feb 07 |
jari |
296 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
297 |
resetButton.setSize(180,30); |
2 |
26 Feb 07 |
jari |
298 |
resetButton.setPreferredSize(new Dimension(180,30)); |
2 |
26 Feb 07 |
jari |
299 |
final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
300 |
|
2 |
26 Feb 07 |
jari |
301 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
302 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
303 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
304 |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
305 |
} |
2 |
26 Feb 07 |
jari |
306 |
} |
2 |
26 Feb 07 |
jari |
307 |
}); |
2 |
26 Feb 07 |
jari |
308 |
|
2 |
26 Feb 07 |
jari |
309 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
310 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
311 |
|
2 |
26 Feb 07 |
jari |
312 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
313 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
314 |
int returnVal = fc.showSaveDialog(GroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
315 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
316 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
317 |
try { |
2 |
26 Feb 07 |
jari |
318 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
319 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
320 |
for (int i = 0; i < groupAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
321 |
out.print(groupAssgn[i]); |
2 |
26 Feb 07 |
jari |
322 |
if (i < groupAssgn.length - 1) { |
2 |
26 Feb 07 |
jari |
323 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
324 |
} |
2 |
26 Feb 07 |
jari |
325 |
} |
2 |
26 Feb 07 |
jari |
326 |
out.println(); |
2 |
26 Feb 07 |
jari |
327 |
out.flush(); |
2 |
26 Feb 07 |
jari |
328 |
out.close(); |
2 |
26 Feb 07 |
jari |
329 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
331 |
} |
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
334 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
336 |
} |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
}); |
2 |
26 Feb 07 |
jari |
339 |
|
2 |
26 Feb 07 |
jari |
340 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
341 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
342 |
int returnVal = fc.showOpenDialog(GroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
343 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
344 |
try { |
2 |
26 Feb 07 |
jari |
345 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
346 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
347 |
String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
349 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
350 |
st.init(line); |
2 |
26 Feb 07 |
jari |
351 |
Vector groupsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
352 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
353 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
354 |
groupsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
356 |
} |
2 |
26 Feb 07 |
jari |
357 |
buff.close(); |
2 |
26 Feb 07 |
jari |
358 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
359 |
if (groupsVector.size() != groupAssgn.length) { |
2 |
26 Feb 07 |
jari |
360 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
361 |
} else { |
2 |
26 Feb 07 |
jari |
362 |
for (int i = 0; i < groupsVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
363 |
int currentExpt = ((Integer)groupsVector.get(i)).intValue(); |
2 |
26 Feb 07 |
jari |
364 |
if (currentExpt == 1) { |
2 |
26 Feb 07 |
jari |
365 |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
366 |
} else if (currentExpt == 2) { |
2 |
26 Feb 07 |
jari |
367 |
groupBRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
368 |
} else if (currentExpt == 3) { |
2 |
26 Feb 07 |
jari |
369 |
neitherGroupRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
370 |
} else { |
2 |
26 Feb 07 |
jari |
371 |
for (int j = 0; j < finNum; j++) { |
2 |
26 Feb 07 |
jari |
372 |
groupARadioButtons[j].setSelected(true); |
2 |
26 Feb 07 |
jari |
373 |
} |
2 |
26 Feb 07 |
jari |
374 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
375 |
break; |
2 |
26 Feb 07 |
jari |
376 |
} |
2 |
26 Feb 07 |
jari |
377 |
} |
2 |
26 Feb 07 |
jari |
378 |
} |
2 |
26 Feb 07 |
jari |
379 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
380 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
382 |
} |
2 |
26 Feb 07 |
jari |
383 |
|
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
386 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
388 |
} |
2 |
26 Feb 07 |
jari |
389 |
} |
2 |
26 Feb 07 |
jari |
390 |
}); |
2 |
26 Feb 07 |
jari |
391 |
|
2 |
26 Feb 07 |
jari |
392 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
393 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
394 |
constraints.insets = new Insets(5,5,5,5); |
2 |
26 Feb 07 |
jari |
395 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 10); |
2 |
26 Feb 07 |
jari |
396 |
gridbag3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
397 |
panel2.add(saveButton); |
2 |
26 Feb 07 |
jari |
398 |
|
2 |
26 Feb 07 |
jari |
399 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 10); |
2 |
26 Feb 07 |
jari |
400 |
gridbag3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
401 |
panel2.add(loadButton); |
2 |
26 Feb 07 |
jari |
402 |
|
2 |
26 Feb 07 |
jari |
403 |
buildConstraints(constraints, 2, 0, 1, 1, 33, 10); |
2 |
26 Feb 07 |
jari |
404 |
gridbag3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
405 |
panel2.add(resetButton); |
2 |
26 Feb 07 |
jari |
406 |
|
2 |
26 Feb 07 |
jari |
407 |
constraints.insets = new Insets(0,0,0,0); |
2 |
26 Feb 07 |
jari |
408 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
409 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
411 |
gridbag2.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
412 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
413 |
} |
2 |
26 Feb 07 |
jari |
414 |
/* |
2 |
26 Feb 07 |
jari |
* Resets group selections |
2 |
26 Feb 07 |
jari |
416 |
*/ |
2 |
26 Feb 07 |
jari |
417 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
418 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
419 |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
420 |
} |
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 |
|
2 |
26 Feb 07 |
jari |
426 |
class CensoredSurvivalPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
427 |
ExptTimeField[] fields; |
2 |
26 Feb 07 |
jari |
428 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
429 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
431 |
CensoredSurvivalPanel(Vector exptNames) { |
2 |
26 Feb 07 |
jari |
432 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Time / State Assignments", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
433 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
// JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
435 |
fields = new ExptTimeField[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
436 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
437 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
438 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
439 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
440 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
// panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
442 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
443 |
|
2 |
26 Feb 07 |
jari |
444 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
445 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
446 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
447 |
} |
2 |
26 Feb 07 |
jari |
448 |
|
2 |
26 Feb 07 |
jari |
449 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
450 |
String s1 = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
451 |
fields[i] = new ExptTimeField(s1); |
2 |
26 Feb 07 |
jari |
// set current panel |
2 |
26 Feb 07 |
jari |
453 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
454 |
|
2 |
26 Feb 07 |
jari |
455 |
buildConstraints(constraints, 0, i%512, 1, 1, 20, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
457 |
gridbag.setConstraints(fields[i].inAnalysisCheckBox, constraints); |
2 |
26 Feb 07 |
jari |
458 |
|
2 |
26 Feb 07 |
jari |
459 |
panels[currPanel].add(fields[i].inAnalysisCheckBox); |
2 |
26 Feb 07 |
jari |
460 |
|
2 |
26 Feb 07 |
jari |
461 |
buildConstraints(constraints, 1, i%512, 1, 1, 20, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
463 |
gridbag.setConstraints(fields[i].expLabel, constraints); |
2 |
26 Feb 07 |
jari |
464 |
|
2 |
26 Feb 07 |
jari |
465 |
panels[currPanel].add(fields[i].expLabel); |
2 |
26 Feb 07 |
jari |
466 |
|
2 |
26 Feb 07 |
jari |
467 |
|
2 |
26 Feb 07 |
jari |
468 |
buildConstraints(constraints, 2, i%512, 1, 1, 20, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
470 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
471 |
gridbag.setConstraints(fields[i].timeLabel, constraints); |
2 |
26 Feb 07 |
jari |
472 |
|
2 |
26 Feb 07 |
jari |
473 |
panels[currPanel].add(fields[i].timeLabel); |
2 |
26 Feb 07 |
jari |
474 |
|
2 |
26 Feb 07 |
jari |
475 |
buildConstraints(constraints, 3, i%512, 1, 1, 20, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
477 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
478 |
gridbag.setConstraints(fields[i].timeInputField, constraints); |
2 |
26 Feb 07 |
jari |
479 |
|
2 |
26 Feb 07 |
jari |
480 |
panels[currPanel].add(fields[i].timeInputField); |
2 |
26 Feb 07 |
jari |
481 |
|
2 |
26 Feb 07 |
jari |
482 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
483 |
buildConstraints(constraints, 4, i%512, 1, 1, 20, 100); |
2 |
26 Feb 07 |
jari |
484 |
gridbag.setConstraints(fields[i].censoredRadioButton, constraints); |
2 |
26 Feb 07 |
jari |
485 |
panels[currPanel].add(fields[i].censoredRadioButton); |
2 |
26 Feb 07 |
jari |
486 |
|
2 |
26 Feb 07 |
jari |
487 |
buildConstraints(constraints, 5, i%512, 1, 1, 20, 100); |
2 |
26 Feb 07 |
jari |
488 |
gridbag.setConstraints(fields[i].deadRadioButton, constraints); |
2 |
26 Feb 07 |
jari |
489 |
|
2 |
26 Feb 07 |
jari |
490 |
panels[currPanel].add(fields[i].deadRadioButton); |
2 |
26 Feb 07 |
jari |
491 |
|
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
|
2 |
26 Feb 07 |
jari |
494 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
495 |
|
2 |
26 Feb 07 |
jari |
496 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
497 |
bigPanel.add(panels[i] ,new GridBagConstraints(0,i,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
498 |
} |
2 |
26 Feb 07 |
jari |
499 |
|
2 |
26 Feb 07 |
jari |
500 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
501 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
502 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
503 |
|
2 |
26 Feb 07 |
jari |
504 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
505 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
506 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
507 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
508 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
509 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
510 |
lotsOfSamplesWarningLabel.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
511 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
512 |
} |
2 |
26 Feb 07 |
jari |
513 |
|
2 |
26 Feb 07 |
jari |
514 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
515 |
GridBagLayout gridbag3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
516 |
panel2.setLayout(gridbag3); |
2 |
26 Feb 07 |
jari |
517 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
518 |
JButton saveButton = new JButton(" Save settings "); |
2 |
26 Feb 07 |
jari |
519 |
saveButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
520 |
saveButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
521 |
JButton loadButton = new JButton(" Load settings "); |
2 |
26 Feb 07 |
jari |
522 |
loadButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
523 |
loadButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
524 |
JButton resetButton = new JButton(" Reset "); |
2 |
26 Feb 07 |
jari |
525 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
526 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
527 |
|
2 |
26 Feb 07 |
jari |
528 |
final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
529 |
|
2 |
26 Feb 07 |
jari |
530 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
531 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
532 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
533 |
fields[i].inAnalysisCheckBox.setSelected(true); |
2 |
26 Feb 07 |
jari |
534 |
fields[i].timeInputField.setText("0.0"); |
2 |
26 Feb 07 |
jari |
535 |
fields[i].censoredRadioButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
536 |
} |
2 |
26 Feb 07 |
jari |
537 |
} |
2 |
26 Feb 07 |
jari |
538 |
}); |
2 |
26 Feb 07 |
jari |
539 |
|
2 |
26 Feb 07 |
jari |
540 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
541 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
542 |
|
2 |
26 Feb 07 |
jari |
543 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
544 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
545 |
int returnVal = fc.showSaveDialog(CensoredSurvivalPanel.this); |
2 |
26 Feb 07 |
jari |
546 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
547 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
548 |
try { |
2 |
26 Feb 07 |
jari |
549 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
//int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
551 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
552 |
if (fields[i].inAnalysisCheckBox.isSelected()) { |
2 |
26 Feb 07 |
jari |
553 |
out.print(1); |
2 |
26 Feb 07 |
jari |
554 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
555 |
if (fields[i].timeInputField.getText() == "") { |
2 |
26 Feb 07 |
jari |
556 |
out.print("0.0"); |
2 |
26 Feb 07 |
jari |
557 |
} else { |
2 |
26 Feb 07 |
jari |
558 |
out.print(fields[i].timeInputField.getText()); |
2 |
26 Feb 07 |
jari |
559 |
} |
2 |
26 Feb 07 |
jari |
560 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
561 |
if (fields[i].censoredRadioButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
562 |
out.print(1); |
2 |
26 Feb 07 |
jari |
563 |
} else { |
2 |
26 Feb 07 |
jari |
564 |
out.print(0); |
2 |
26 Feb 07 |
jari |
565 |
} |
2 |
26 Feb 07 |
jari |
//DONE UP TO HERE 3/20/03 |
2 |
26 Feb 07 |
jari |
567 |
} else { |
2 |
26 Feb 07 |
jari |
568 |
out.print(0); |
2 |
26 Feb 07 |
jari |
569 |
} |
2 |
26 Feb 07 |
jari |
570 |
out.println(); |
2 |
26 Feb 07 |
jari |
571 |
} |
2 |
26 Feb 07 |
jari |
//out.println(); |
2 |
26 Feb 07 |
jari |
573 |
out.flush(); |
2 |
26 Feb 07 |
jari |
574 |
out.close(); |
2 |
26 Feb 07 |
jari |
575 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
577 |
} |
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
580 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
582 |
} |
2 |
26 Feb 07 |
jari |
583 |
} |
2 |
26 Feb 07 |
jari |
584 |
}); |
2 |
26 Feb 07 |
jari |
585 |
|
2 |
26 Feb 07 |
jari |
586 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
587 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
588 |
int returnVal = fc.showOpenDialog(CensoredSurvivalPanel.this); |
2 |
26 Feb 07 |
jari |
589 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
590 |
try { |
2 |
26 Feb 07 |
jari |
591 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
592 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
593 |
String currentLine; |
2 |
26 Feb 07 |
jari |
594 |
Vector inputVector = new Vector(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
//StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
597 |
while((currentLine = buff.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
598 |
inputVector.add(currentLine); |
2 |
26 Feb 07 |
jari |
599 |
} |
2 |
26 Feb 07 |
jari |
600 |
buff.close(); |
2 |
26 Feb 07 |
jari |
601 |
for (int i = 0; i < inputVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
602 |
double[] currentSettings = getCurrentSettings((String)inputVector.get(i)); |
2 |
26 Feb 07 |
jari |
603 |
if (currentSettings[0] == 0) { |
2 |
26 Feb 07 |
jari |
604 |
fields[i].inAnalysisCheckBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
605 |
} else if (currentSettings[0] == 1) { |
2 |
26 Feb 07 |
jari |
606 |
fields[i].inAnalysisCheckBox.setSelected(true); |
2 |
26 Feb 07 |
jari |
607 |
fields[i].timeInputField.setText("" + currentSettings[1]); |
2 |
26 Feb 07 |
jari |
608 |
if (currentSettings[2] == 0) { |
2 |
26 Feb 07 |
jari |
609 |
fields[i].deadRadioButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
610 |
} else if (currentSettings[2] == 1) { |
2 |
26 Feb 07 |
jari |
611 |
fields[i].censoredRadioButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
612 |
} else { |
2 |
26 Feb 07 |
jari |
613 |
for (int k = 0; k < finNum; k++) { |
2 |
26 Feb 07 |
jari |
614 |
fields[k].inAnalysisCheckBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
615 |
} |
2 |
26 Feb 07 |
jari |
616 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
617 |
break; |
2 |
26 Feb 07 |
jari |
618 |
} |
2 |
26 Feb 07 |
jari |
619 |
} else { // if currentSettings[0] != 0 or 1 |
2 |
26 Feb 07 |
jari |
620 |
for (int k = 0; k < finNum; k++) { |
2 |
26 Feb 07 |
jari |
621 |
fields[k].inAnalysisCheckBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
622 |
} |
2 |
26 Feb 07 |
jari |
623 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
624 |
break; |
2 |
26 Feb 07 |
jari |
625 |
} |
2 |
26 Feb 07 |
jari |
626 |
} |
2 |
26 Feb 07 |
jari |
627 |
|
2 |
26 Feb 07 |
jari |
628 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
629 |
for (int k = 0; k < finNum; k++) { |
2 |
26 Feb 07 |
jari |
630 |
fields[k].inAnalysisCheckBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
631 |
} |
2 |
26 Feb 07 |
jari |
632 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
634 |
} |
2 |
26 Feb 07 |
jari |
635 |
|
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
638 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
640 |
} |
2 |
26 Feb 07 |
jari |
641 |
} |
2 |
26 Feb 07 |
jari |
642 |
}); |
2 |
26 Feb 07 |
jari |
643 |
|
2 |
26 Feb 07 |
jari |
644 |
|
2 |
26 Feb 07 |
jari |
645 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
646 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
647 |
constraints.insets = new Insets(5,5,5,5); |
2 |
26 Feb 07 |
jari |
648 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
649 |
gridbag3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
650 |
panel2.add(saveButton); |
2 |
26 Feb 07 |
jari |
651 |
|
2 |
26 Feb 07 |
jari |
652 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
653 |
gridbag3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
654 |
panel2.add(loadButton); |
2 |
26 Feb 07 |
jari |
655 |
|
2 |
26 Feb 07 |
jari |
656 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
657 |
gridbag3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
658 |
panel2.add(resetButton); |
2 |
26 Feb 07 |
jari |
659 |
constraints.insets = new Insets(0,0,0,0); |
2 |
26 Feb 07 |
jari |
660 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 10); |
2 |
26 Feb 07 |
jari |
661 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
662 |
gridbag2.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
663 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
664 |
} |
2 |
26 Feb 07 |
jari |
665 |
|
2 |
26 Feb 07 |
jari |
666 |
/* |
2 |
26 Feb 07 |
jari |
* Resets valuse to default values |
2 |
26 Feb 07 |
jari |
668 |
*/ |
2 |
26 Feb 07 |
jari |
669 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
670 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
671 |
fields[i].inAnalysisCheckBox.setSelected(true); |
2 |
26 Feb 07 |
jari |
672 |
fields[i].timeInputField.setText("0.0"); |
2 |
26 Feb 07 |
jari |
673 |
fields[i].censoredRadioButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
674 |
} |
2 |
26 Feb 07 |
jari |
675 |
} |
2 |
26 Feb 07 |
jari |
676 |
|
2 |
26 Feb 07 |
jari |
677 |
/* |
2 |
26 Feb 07 |
jari |
private void addAnalysisCheckBoxListener(JCheckBox inAnalysisCheckBox, JLabel expLabel, JTextField timeInputField, JRadioButton censoredRadioButton, JRadioButton deadRadioButton, JLabel timeLabel) { |
2 |
26 Feb 07 |
jari |
inAnalysisCheckBox.addItemListener(new ItemListener() { |
2 |
26 Feb 07 |
jari |
public void itemStateChanged(ItemEvent e) { |
2 |
26 Feb 07 |
jari |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
2 |
26 Feb 07 |
jari |
expLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
timeLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
timeInputField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
timeInputField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
censoredRadioButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
deadRadioButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
688 |
|
2 |
26 Feb 07 |
jari |
689 |
} |
2 |
26 Feb 07 |
jari |
690 |
|
2 |
26 Feb 07 |
jari |
if (e.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
expLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
timeLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
timeInputField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
timeInputField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
censoredRadioButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
deadRadioButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
698 |
} |
2 |
26 Feb 07 |
jari |
699 |
|
2 |
26 Feb 07 |
jari |
700 |
} |
2 |
26 Feb 07 |
jari |
701 |
}); |
2 |
26 Feb 07 |
jari |
702 |
} |
2 |
26 Feb 07 |
jari |
703 |
*/ |
2 |
26 Feb 07 |
jari |
704 |
|
2 |
26 Feb 07 |
jari |
705 |
private class ExptTimeField { |
2 |
26 Feb 07 |
jari |
706 |
JCheckBox inAnalysisCheckBox; |
2 |
26 Feb 07 |
jari |
707 |
JLabel expLabel, timeLabel; |
2 |
26 Feb 07 |
jari |
708 |
JTextField timeInputField; |
2 |
26 Feb 07 |
jari |
709 |
JRadioButton censoredRadioButton, deadRadioButton; |
2 |
26 Feb 07 |
jari |
710 |
public ExptTimeField(String exptName) { |
2 |
26 Feb 07 |
jari |
711 |
inAnalysisCheckBox = new JCheckBox("", true); |
2 |
26 Feb 07 |
jari |
712 |
expLabel = new JLabel(exptName); |
2 |
26 Feb 07 |
jari |
713 |
timeLabel = new JLabel("Time: "); |
2 |
26 Feb 07 |
jari |
714 |
timeInputField = new JTextField("0.0", 7); |
2 |
26 Feb 07 |
jari |
715 |
censoredRadioButton = new JRadioButton("Censored", true); |
2 |
26 Feb 07 |
jari |
716 |
deadRadioButton = new JRadioButton("Dead", false); |
2 |
26 Feb 07 |
jari |
717 |
ButtonGroup chooseGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
718 |
chooseGroup.add(censoredRadioButton); |
2 |
26 Feb 07 |
jari |
719 |
chooseGroup.add(deadRadioButton); |
2 |
26 Feb 07 |
jari |
720 |
inAnalysisCheckBox.addItemListener(new ItemListener() { |
2 |
26 Feb 07 |
jari |
721 |
public void itemStateChanged(ItemEvent e) { |
2 |
26 Feb 07 |
jari |
722 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
2 |
26 Feb 07 |
jari |
723 |
expLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
724 |
timeLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
725 |
timeInputField.setText(""); |
2 |
26 Feb 07 |
jari |
726 |
timeInputField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
727 |
timeInputField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
728 |
censoredRadioButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
729 |
deadRadioButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
730 |
|
2 |
26 Feb 07 |
jari |
731 |
} |
2 |
26 Feb 07 |
jari |
732 |
|
2 |
26 Feb 07 |
jari |
733 |
if (e.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
734 |
expLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
735 |
timeLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
736 |
timeInputField.setText("0.0"); |
2 |
26 Feb 07 |
jari |
737 |
timeInputField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
738 |
timeInputField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
739 |
censoredRadioButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
740 |
deadRadioButton.setEnabled(true); |
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 |
745 |
} |
2 |
26 Feb 07 |
jari |
746 |
|
2 |
26 Feb 07 |
jari |
747 |
} |
2 |
26 Feb 07 |
jari |
748 |
|
2 |
26 Feb 07 |
jari |
749 |
private double[] getCurrentSettings(String currentLine) { |
2 |
26 Feb 07 |
jari |
750 |
double[] currentSettings; |
2 |
26 Feb 07 |
jari |
751 |
Vector currentVector = new Vector(); |
2 |
26 Feb 07 |
jari |
752 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
753 |
st.init(currentLine); |
2 |
26 Feb 07 |
jari |
754 |
|
2 |
26 Feb 07 |
jari |
755 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
756 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
757 |
currentVector.add(new Double(current)); |
2 |
26 Feb 07 |
jari |
758 |
} |
2 |
26 Feb 07 |
jari |
759 |
|
2 |
26 Feb 07 |
jari |
760 |
currentSettings = new double[currentVector.size()]; |
2 |
26 Feb 07 |
jari |
761 |
for (int i = 0; i < currentSettings.length; i++) { |
2 |
26 Feb 07 |
jari |
762 |
currentSettings[i] = ((Double)currentVector.get(i)).doubleValue(); |
2 |
26 Feb 07 |
jari |
763 |
} |
2 |
26 Feb 07 |
jari |
764 |
|
2 |
26 Feb 07 |
jari |
765 |
return currentSettings; |
2 |
26 Feb 07 |
jari |
766 |
|
2 |
26 Feb 07 |
jari |
767 |
} |
2 |
26 Feb 07 |
jari |
768 |
|
2 |
26 Feb 07 |
jari |
769 |
|
2 |
26 Feb 07 |
jari |
770 |
} |
2 |
26 Feb 07 |
jari |
771 |
|
2 |
26 Feb 07 |
jari |
772 |
class OneClassPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
773 |
JTextField meanField; |
2 |
26 Feb 07 |
jari |
774 |
JCheckBox[] includeExpts; |
2 |
26 Feb 07 |
jari |
775 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
776 |
JButton saveButton, loadButton, resetButton; |
2 |
26 Feb 07 |
jari |
777 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
778 |
|
2 |
26 Feb 07 |
jari |
779 |
OneClassPanel() { |
2 |
26 Feb 07 |
jari |
780 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
781 |
JLabel meanLabel = new JLabel("Enter the mean value to be tested against: "); |
2 |
26 Feb 07 |
jari |
782 |
meanField = new JTextField("0", 7); |
2 |
26 Feb 07 |
jari |
783 |
includeExpts = new JCheckBox[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
784 |
|
2 |
26 Feb 07 |
jari |
785 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
786 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
787 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
788 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
789 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
790 |
|
2 |
26 Feb 07 |
jari |
791 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
792 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
793 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
794 |
} |
2 |
26 Feb 07 |
jari |
795 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
//set current panel |
2 |
26 Feb 07 |
jari |
797 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
798 |
|
2 |
26 Feb 07 |
jari |
799 |
includeExpts[i] = new JCheckBox((String)(exptNames.get(i)), true); |
2 |
26 Feb 07 |
jari |
800 |
buildConstraints(constraints, 0, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
801 |
gridbag.setConstraints(includeExpts[i], constraints); |
2 |
26 Feb 07 |
jari |
802 |
|
2 |
26 Feb 07 |
jari |
803 |
panels[currPanel].add(includeExpts[i]); |
2 |
26 Feb 07 |
jari |
804 |
} |
2 |
26 Feb 07 |
jari |
805 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
806 |
|
2 |
26 Feb 07 |
jari |
807 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
808 |
bigPanel.add(panels[i] ,new GridBagConstraints(0,i,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
809 |
} |
2 |
26 Feb 07 |
jari |
810 |
|
2 |
26 Feb 07 |
jari |
811 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
812 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
813 |
|
2 |
26 Feb 07 |
jari |
814 |
JPanel enterMeanPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
815 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
816 |
enterMeanPanel.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
817 |
|
2 |
26 Feb 07 |
jari |
818 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
819 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 100); |
2 |
26 Feb 07 |
jari |
820 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
821 |
grid2.setConstraints(meanLabel, constraints); |
2 |
26 Feb 07 |
jari |
822 |
enterMeanPanel.add(meanLabel); |
2 |
26 Feb 07 |
jari |
823 |
|
2 |
26 Feb 07 |
jari |
824 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
825 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
826 |
grid2.setConstraints(meanField, constraints); |
2 |
26 Feb 07 |
jari |
827 |
enterMeanPanel.add(meanField); |
2 |
26 Feb 07 |
jari |
828 |
|
2 |
26 Feb 07 |
jari |
829 |
JScrollPane scroll2 = new JScrollPane(enterMeanPanel); |
2 |
26 Feb 07 |
jari |
830 |
|
2 |
26 Feb 07 |
jari |
831 |
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scroll, scroll2); |
2 |
26 Feb 07 |
jari |
832 |
split.setOneTouchExpandable(true); |
2 |
26 Feb 07 |
jari |
833 |
split.setDividerLocation(150); |
2 |
26 Feb 07 |
jari |
834 |
|
2 |
26 Feb 07 |
jari |
835 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
836 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 80); |
2 |
26 Feb 07 |
jari |
837 |
gridbag.setConstraints(split, constraints); |
2 |
26 Feb 07 |
jari |
838 |
this.add(split); |
2 |
26 Feb 07 |
jari |
839 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
840 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
841 |
lotsOfSamplesWarningLabel.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
842 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
843 |
} |
2 |
26 Feb 07 |
jari |
844 |
|
2 |
26 Feb 07 |
jari |
845 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
846 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
847 |
|
2 |
26 Feb 07 |
jari |
848 |
JPanel lsrPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
849 |
loadButton = new JButton("Load settings"); |
2 |
26 Feb 07 |
jari |
850 |
saveButton = new JButton("Save settings"); |
2 |
26 Feb 07 |
jari |
851 |
resetButton = new JButton("Reset"); |
2 |
26 Feb 07 |
jari |
852 |
|
2 |
26 Feb 07 |
jari |
853 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
854 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
855 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
856 |
includeExpts[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
857 |
} |
2 |
26 Feb 07 |
jari |
858 |
} |
2 |
26 Feb 07 |
jari |
859 |
}); |
2 |
26 Feb 07 |
jari |
860 |
|
2 |
26 Feb 07 |
jari |
861 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
862 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
863 |
|
2 |
26 Feb 07 |
jari |
864 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
865 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
866 |
int returnVal = fc.showSaveDialog(OneClassPanel.this); |
2 |
26 Feb 07 |
jari |
867 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
868 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
869 |
try { |
2 |
26 Feb 07 |
jari |
870 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
871 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
872 |
if (includeExpts[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
873 |
out.print(1); |
2 |
26 Feb 07 |
jari |
874 |
} else { |
2 |
26 Feb 07 |
jari |
875 |
out.print(0); |
2 |
26 Feb 07 |
jari |
876 |
} |
2 |
26 Feb 07 |
jari |
877 |
if (i < includeExpts.length - 1) { |
2 |
26 Feb 07 |
jari |
878 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
879 |
} |
2 |
26 Feb 07 |
jari |
880 |
} |
2 |
26 Feb 07 |
jari |
881 |
out.println(); |
2 |
26 Feb 07 |
jari |
882 |
out.flush(); |
2 |
26 Feb 07 |
jari |
883 |
out.close(); |
2 |
26 Feb 07 |
jari |
884 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
885 |
} |
2 |
26 Feb 07 |
jari |
886 |
} else { |
2 |
26 Feb 07 |
jari |
887 |
} |
2 |
26 Feb 07 |
jari |
888 |
} |
2 |
26 Feb 07 |
jari |
889 |
}); |
2 |
26 Feb 07 |
jari |
890 |
|
2 |
26 Feb 07 |
jari |
891 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
892 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
893 |
int returnVal = fc.showOpenDialog(OneClassPanel.this); |
2 |
26 Feb 07 |
jari |
894 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
895 |
try { |
2 |
26 Feb 07 |
jari |
896 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
897 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
898 |
String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
900 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
901 |
st.init(line); |
2 |
26 Feb 07 |
jari |
902 |
Vector includeExptsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
903 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
904 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
905 |
includeExptsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
907 |
} |
2 |
26 Feb 07 |
jari |
908 |
buff.close(); |
2 |
26 Feb 07 |
jari |
909 |
if (includeExptsVector.size() != includeExpts.length) { |
2 |
26 Feb 07 |
jari |
910 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
911 |
} else { |
2 |
26 Feb 07 |
jari |
912 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
913 |
int currentState = ((Integer)(includeExptsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
914 |
if (currentState == 0) { |
2 |
26 Feb 07 |
jari |
915 |
includeExpts[i].setSelected(false); |
2 |
26 Feb 07 |
jari |
916 |
} else if (currentState == 1) { |
2 |
26 Feb 07 |
jari |
917 |
includeExpts[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
918 |
}else { |
2 |
26 Feb 07 |
jari |
919 |
for (int j = 0; j < includeExpts.length; j++) { |
2 |
26 Feb 07 |
jari |
920 |
includeExpts[j].setSelected(true); |
2 |
26 Feb 07 |
jari |
921 |
} |
2 |
26 Feb 07 |
jari |
922 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
923 |
break; |
2 |
26 Feb 07 |
jari |
924 |
} |
2 |
26 Feb 07 |
jari |
925 |
} |
2 |
26 Feb 07 |
jari |
926 |
} |
2 |
26 Feb 07 |
jari |
927 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
928 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
929 |
|
2 |
26 Feb 07 |
jari |
930 |
} |
2 |
26 Feb 07 |
jari |
931 |
} else { |
2 |
26 Feb 07 |
jari |
932 |
} |
2 |
26 Feb 07 |
jari |
933 |
} |
2 |
26 Feb 07 |
jari |
934 |
}); |
2 |
26 Feb 07 |
jari |
935 |
|
2 |
26 Feb 07 |
jari |
936 |
|
2 |
26 Feb 07 |
jari |
937 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
938 |
lsrPanel.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
939 |
|
2 |
26 Feb 07 |
jari |
940 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
941 |
grid3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
942 |
lsrPanel.add(saveButton); |
2 |
26 Feb 07 |
jari |
943 |
|
2 |
26 Feb 07 |
jari |
944 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
945 |
grid3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
946 |
lsrPanel.add(loadButton); |
2 |
26 Feb 07 |
jari |
947 |
|
2 |
26 Feb 07 |
jari |
948 |
buildConstraints(constraints, 2, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
949 |
grid3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
950 |
lsrPanel.add(resetButton); |
2 |
26 Feb 07 |
jari |
951 |
|
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
953 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 20); |
2 |
26 Feb 07 |
jari |
954 |
gridbag.setConstraints(lsrPanel, constraints); |
2 |
26 Feb 07 |
jari |
955 |
this.add(lsrPanel); |
2 |
26 Feb 07 |
jari |
956 |
} |
2 |
26 Feb 07 |
jari |
957 |
|
2 |
26 Feb 07 |
jari |
958 |
|
2 |
26 Feb 07 |
jari |
959 |
public void reset() { |
2 |
26 Feb 07 |
jari |
960 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
961 |
includeExpts[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
962 |
} |
2 |
26 Feb 07 |
jari |
963 |
meanField.setText("0"); |
2 |
26 Feb 07 |
jari |
964 |
} |
2 |
26 Feb 07 |
jari |
965 |
} |
2 |
26 Feb 07 |
jari |
966 |
|
2 |
26 Feb 07 |
jari |
967 |
class TwoClassPairedMainPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
968 |
TwoClassPairedPanel tcpPanel; |
2 |
26 Feb 07 |
jari |
969 |
JButton saveButton, resetButton, loadButton; |
2 |
26 Feb 07 |
jari |
970 |
GridBagConstraints constraints; |
2 |
26 Feb 07 |
jari |
971 |
GridBagLayout gridbag; |
2 |
26 Feb 07 |
jari |
972 |
int dummy=0; |
2 |
26 Feb 07 |
jari |
973 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
974 |
|
2 |
26 Feb 07 |
jari |
975 |
public TwoClassPairedMainPanel() { |
2 |
26 Feb 07 |
jari |
//if(exptNames.size()<11) |
2 |
26 Feb 07 |
jari |
977 |
tcpPanel = new TwoClassPairedPanel(); |
2 |
26 Feb 07 |
jari |
//else |
2 |
26 Feb 07 |
jari |
//tcpPanel = new TwoClassPairedPanel(dummy); |
2 |
26 Feb 07 |
jari |
980 |
JPanel bottomPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
981 |
bottomPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
982 |
constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
983 |
gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
984 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
985 |
|
2 |
26 Feb 07 |
jari |
986 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
987 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
988 |
gridbag.setConstraints(tcpPanel, constraints); |
2 |
26 Feb 07 |
jari |
989 |
this.add(tcpPanel); |
2 |
26 Feb 07 |
jari |
990 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
991 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
992 |
lotsOfSamplesWarningLabel.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
993 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
994 |
} |
2 |
26 Feb 07 |
jari |
995 |
|
2 |
26 Feb 07 |
jari |
996 |
GridBagLayout grid1 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
997 |
bottomPanel.setLayout(grid1); |
2 |
26 Feb 07 |
jari |
998 |
|
2 |
26 Feb 07 |
jari |
999 |
saveButton = new JButton("Save pairings"); |
2 |
26 Feb 07 |
jari |
1000 |
|
2 |
26 Feb 07 |
jari |
1001 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
1002 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
1003 |
|
2 |
26 Feb 07 |
jari |
1004 |
saveButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1005 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1006 |
int returnVal = fc.showSaveDialog(TwoClassPairedMainPanel.this); |
2 |
26 Feb 07 |
jari |
1007 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
1008 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
1009 |
try { |
2 |
26 Feb 07 |
jari |
1010 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
1011 |
for (int i = 0; i < tcpPanel.pairedAExpts.size(); i++) { |
2 |
26 Feb 07 |
jari |
1012 |
int currentA = ((Integer)(tcpPanel.pairedAExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
1013 |
int currentB = ((Integer)(tcpPanel.pairedBExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
1014 |
out.print(currentA); |
2 |
26 Feb 07 |
jari |
1015 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
1016 |
out.print(currentB); |
2 |
26 Feb 07 |
jari |
1017 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
1018 |
out.println(); |
2 |
26 Feb 07 |
jari |
1019 |
} |
2 |
26 Feb 07 |
jari |
1020 |
out.flush(); |
2 |
26 Feb 07 |
jari |
1021 |
out.close(); |
2 |
26 Feb 07 |
jari |
1022 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1023 |
} |
2 |
26 Feb 07 |
jari |
1024 |
} else { |
2 |
26 Feb 07 |
jari |
1025 |
} |
2 |
26 Feb 07 |
jari |
1026 |
} |
2 |
26 Feb 07 |
jari |
1027 |
}); |
2 |
26 Feb 07 |
jari |
1028 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1029 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
1030 |
grid1.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
1031 |
bottomPanel.add(saveButton); |
2 |
26 Feb 07 |
jari |
1032 |
|
2 |
26 Feb 07 |
jari |
1033 |
loadButton = new JButton("Load pairings"); |
2 |
26 Feb 07 |
jari |
1034 |
|
2 |
26 Feb 07 |
jari |
1035 |
loadButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1036 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1037 |
tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
1038 |
int returnVal = fc.showOpenDialog(TwoClassPairedMainPanel.this); |
2 |
26 Feb 07 |
jari |
1039 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
1040 |
try { |
2 |
26 Feb 07 |
jari |
1041 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
1042 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
1043 |
String currentLine; |
2 |
26 Feb 07 |
jari |
1044 |
while((currentLine = buff.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
1045 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
1046 |
st.init(currentLine); |
2 |
26 Feb 07 |
jari |
1047 |
|
2 |
26 Feb 07 |
jari |
1048 |
for (int i = 0; i < 2; i++) { |
2 |
26 Feb 07 |
jari |
1049 |
String s = st.nextToken(); |
2 |
26 Feb 07 |
jari |
1050 |
if (i == 0) { |
2 |
26 Feb 07 |
jari |
1051 |
tcpPanel.pairedAExpts.add(new Integer(s)); |
2 |
26 Feb 07 |
jari |
1052 |
} else if (i == 1) { |
2 |
26 Feb 07 |
jari |
1053 |
tcpPanel.pairedBExpts.add(new Integer(s)); |
2 |
26 Feb 07 |
jari |
1054 |
} |
2 |
26 Feb 07 |
jari |
1055 |
} |
2 |
26 Feb 07 |
jari |
1056 |
|
2 |
26 Feb 07 |
jari |
1057 |
} |
2 |
26 Feb 07 |
jari |
1058 |
buff.close(); |
2 |
26 Feb 07 |
jari |
1059 |
|
2 |
26 Feb 07 |
jari |
1060 |
for (int i = 0; i < tcpPanel.pairedAExpts.size(); i++) { |
2 |
26 Feb 07 |
jari |
1061 |
int currA = ((Integer)(tcpPanel.pairedAExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
1062 |
int currB = ((Integer)(tcpPanel.pairedBExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
1063 |
String currPair = "A: " + (String)(exptNames.get(currA)) + " - B: " + (String)(exptNames.get(currB)); |
2 |
26 Feb 07 |
jari |
// tcpPanel.exptButtons[currA].setEnabled(false); |
2 |
26 Feb 07 |
jari |
// tcpPanel.exptButtons[currB].setEnabled(false); |
2 |
26 Feb 07 |
jari |
1066 |
tcpPanel.pairedListModel.addElement(currPair); |
2 |
26 Feb 07 |
jari |
1067 |
|
2 |
26 Feb 07 |
jari |
1068 |
} |
2 |
26 Feb 07 |
jari |
1069 |
|
2 |
26 Feb 07 |
jari |
1070 |
if (tcpPanel.pairedAExpts.size() > 0) { |
2 |
26 Feb 07 |
jari |
1071 |
tcpPanel.removeABPairButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1072 |
tcpPanel.pairedExptsList.setSelectedIndex(tcpPanel.pairedListModel.size() - 1); |
2 |
26 Feb 07 |
jari |
1073 |
} |
2 |
26 Feb 07 |
jari |
1074 |
|
2 |
26 Feb 07 |
jari |
1075 |
} catch (Exception exc) { |
2 |
26 Feb 07 |
jari |
1076 |
JOptionPane.showMessageDialog(tcpPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1077 |
} |
2 |
26 Feb 07 |
jari |
1078 |
} else { |
2 |
26 Feb 07 |
jari |
1079 |
} |
2 |
26 Feb 07 |
jari |
1080 |
} |
2 |
26 Feb 07 |
jari |
1081 |
}); |
2 |
26 Feb 07 |
jari |
1082 |
|
2 |
26 Feb 07 |
jari |
1083 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
1084 |
grid1.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
1085 |
bottomPanel.add(loadButton); |
2 |
26 Feb 07 |
jari |
1086 |
|
2 |
26 Feb 07 |
jari |
1087 |
resetButton = new JButton("Reset"); |
2 |
26 Feb 07 |
jari |
1088 |
|
2 |
26 Feb 07 |
jari |
1089 |
resetButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1090 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1091 |
tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
1092 |
} |
2 |
26 Feb 07 |
jari |
1093 |
}); |
2 |
26 Feb 07 |
jari |
1094 |
|
2 |
26 Feb 07 |
jari |
1095 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 100); |
2 |
26 Feb 07 |
jari |
1096 |
grid1.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
1097 |
bottomPanel.add(resetButton); |
2 |
26 Feb 07 |
jari |
1098 |
|
2 |
26 Feb 07 |
jari |
1099 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 10); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1101 |
gridbag.setConstraints(bottomPanel, constraints); |
2 |
26 Feb 07 |
jari |
1102 |
this.add(bottomPanel); |
2 |
26 Feb 07 |
jari |
1103 |
} |
2 |
26 Feb 07 |
jari |
1104 |
} |
2 |
26 Feb 07 |
jari |
1105 |
|
2 |
26 Feb 07 |
jari |
1106 |
class TwoClassPairedPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1107 |
ExperimentButton[] exptButtons; |
2 |
26 Feb 07 |
jari |
1108 |
GridBagConstraints constraints; |
2 |
26 Feb 07 |
jari |
1109 |
GridBagLayout gridbag; |
2 |
26 Feb 07 |
jari |
1110 |
JTextField currentATextField, currentBTextField; |
2 |
26 Feb 07 |
jari |
1111 |
JButton removeCurrentAButton, removeCurrentBButton, loadABPairButton, removeABPairButton; |
2 |
26 Feb 07 |
jari |
1112 |
PairedExperimentsPanel pairPanel; |
2 |
26 Feb 07 |
jari |
1113 |
JList pairedExptsList; |
2 |
26 Feb 07 |
jari |
1114 |
DefaultListModel pairedListModel; |
2 |
26 Feb 07 |
jari |
1115 |
boolean currentAFilled, currentBFilled; |
2 |
26 Feb 07 |
jari |
1116 |
int currentAExpt, currentBExpt; |
2 |
26 Feb 07 |
jari |
1117 |
Vector pairedAExpts, pairedBExpts; |
2 |
26 Feb 07 |
jari |
1118 |
|
2 |
26 Feb 07 |
jari |
1119 |
public TwoClassPairedPanel() { |
2 |
26 Feb 07 |
jari |
1120 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
1121 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
1122 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
1123 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
1124 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
1125 |
pairedAExpts = new Vector(); |
2 |
26 Feb 07 |
jari |
1126 |
pairedBExpts = new Vector(); |
2 |
26 Feb 07 |
jari |
1127 |
constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1128 |
gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
//this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1130 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1131 |
/* |
2 |
26 Feb 07 |
jari |
currentATextField = new JTextField("", 10); |
2 |
26 Feb 07 |
jari |
currentBTextField = new JTextField("", 10); |
2 |
26 Feb 07 |
jari |
currentATextField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
currentBTextField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
currentATextField.setEditable(false); |
2 |
26 Feb 07 |
jari |
currentBTextField.setEditable(false); |
2 |
26 Feb 07 |
jari |
1138 |
*/ |
2 |
26 Feb 07 |
jari |
1139 |
|
2 |
26 Feb 07 |
jari |
1140 |
pairedListModel = new DefaultListModel(); |
2 |
26 Feb 07 |
jari |
1141 |
pairedExptsList = new JList(pairedListModel); |
2 |
26 Feb 07 |
jari |
1142 |
|
2 |
26 Feb 07 |
jari |
/*JPanel exptNamesPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
GridBagLayout grid1 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
exptNamesPanel.setLayout(grid1); |
2 |
26 Feb 07 |
jari |
1146 |
*/ |
2 |
26 Feb 07 |
jari |
1147 |
exptButtons = new ExperimentButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1148 |
|
2 |
26 Feb 07 |
jari |
//wwang add for fixing 512 problem |
2 |
26 Feb 07 |
jari |
1150 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
1151 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
1152 |
|
2 |
26 Feb 07 |
jari |
1153 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
1154 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
1155 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
1156 |
} |
2 |
26 Feb 07 |
jari |
1157 |
|
2 |
26 Feb 07 |
jari |
1158 |
int maxWidth = 0,i=0; |
2 |
26 Feb 07 |
jari |
1159 |
int maxNameLength = 0; |
2 |
26 Feb 07 |
jari |
1160 |
|
2 |
26 Feb 07 |
jari |
1161 |
for ( i = 0; i <exptNames.size() ; i++) { |
2 |
26 Feb 07 |
jari |
//String s = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
1163 |
exptButtons[i] = new ExperimentButton(i); |
2 |
26 Feb 07 |
jari |
1164 |
|
2 |
26 Feb 07 |
jari |
1165 |
if (exptButtons[i].getPreferredSize().getWidth() > maxWidth) { |
2 |
26 Feb 07 |
jari |
1166 |
maxWidth = (int)Math.ceil(exptButtons[i].getPreferredSize().getWidth()); |
2 |
26 Feb 07 |
jari |
1167 |
} |
2 |
26 Feb 07 |
jari |
1168 |
|
2 |
26 Feb 07 |
jari |
1169 |
String s = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
1170 |
int currentNameLength = s.length(); |
2 |
26 Feb 07 |
jari |
1171 |
|
2 |
26 Feb 07 |
jari |
1172 |
if (currentNameLength > maxNameLength) { |
2 |
26 Feb 07 |
jari |
1173 |
maxNameLength = currentNameLength; |
2 |
26 Feb 07 |
jari |
1174 |
} |
2 |
26 Feb 07 |
jari |
1175 |
|
2 |
26 Feb 07 |
jari |
// set current panel |
2 |
26 Feb 07 |
jari |
1177 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
1178 |
|
2 |
26 Feb 07 |
jari |
1179 |
buildConstraints(constraints, 0, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
1180 |
gridbag.setConstraints(exptButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
1181 |
panels[currPanel].add(exptButtons[i]); |
2 |
26 Feb 07 |
jari |
// if(i<maxButton) |
2 |
26 Feb 07 |
jari |
// exptNamesPanel.add(exptButtons[i]); |
2 |
26 Feb 07 |
jari |
1184 |
} |
2 |
26 Feb 07 |
jari |
1185 |
|
2 |
26 Feb 07 |
jari |
1186 |
currentATextField = new JTextField("", maxNameLength + 2); |
2 |
26 Feb 07 |
jari |
1187 |
currentBTextField = new JTextField("", maxNameLength + 2); |
2 |
26 Feb 07 |
jari |
//currentATextField.setSize(maxWidth + 5, 80); |
2 |
26 Feb 07 |
jari |
//currentBTextField.setSize(maxWidth + 5, 80); |
2 |
26 Feb 07 |
jari |
//currentATextField.setPreferredSize(new Dimension(maxWidth + 5, 80)); |
2 |
26 Feb 07 |
jari |
//currentBTextField.setPreferredSize(new Dimension(maxWidth + 5, 80)); |
2 |
26 Feb 07 |
jari |
1192 |
|
2 |
26 Feb 07 |
jari |
1193 |
currentATextField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1194 |
currentBTextField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1195 |
currentATextField.setEditable(false); |
2 |
26 Feb 07 |
jari |
1196 |
currentBTextField.setEditable(false); |
2 |
26 Feb 07 |
jari |
1197 |
|
2 |
26 Feb 07 |
jari |
1198 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
1199 |
|
2 |
26 Feb 07 |
jari |
1200 |
for(int m = 0; m < numPanels; m++) { |
2 |
26 Feb 07 |
jari |
1201 |
bigPanel.add(panels[m] ,new GridBagConstraints(0,m,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
1202 |
} |
2 |
26 Feb 07 |
jari |
1203 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
1204 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1205 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1206 |
|
2 |
26 Feb 07 |
jari |
1207 |
buildConstraints(constraints, 0, 0, 1, 1, 40, 100); |
2 |
26 Feb 07 |
jari |
1208 |
constraints.fill =GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1209 |
gridbag.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
1210 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
1211 |
|
2 |
26 Feb 07 |
jari |
1212 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1213 |
|
2 |
26 Feb 07 |
jari |
1214 |
JPanel currentSelectionPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
1215 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1216 |
currentSelectionPanel.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
1217 |
removeCurrentAButton = new JButton("< Remove A"); |
2 |
26 Feb 07 |
jari |
1218 |
removeCurrentBButton = new JButton("< Remove B"); |
2 |
26 Feb 07 |
jari |
1219 |
loadABPairButton = new JButton(" Load Pair >> "); |
2 |
26 Feb 07 |
jari |
1220 |
removeABPairButton = new JButton("<< Remove Pair"); |
2 |
26 Feb 07 |
jari |
1221 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1222 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1223 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1224 |
removeABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1225 |
removeCurrentAButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1226 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1227 |
exptButtons[currentAExpt].setEnabled(true); |
2 |
26 Feb 07 |
jari |
1228 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
1229 |
currentATextField.setText(""); |
2 |
26 Feb 07 |
jari |
1230 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
1231 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1232 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1233 |
} |
2 |
26 Feb 07 |
jari |
1234 |
}); |
2 |
26 Feb 07 |
jari |
1235 |
|
2 |
26 Feb 07 |
jari |
1236 |
removeCurrentBButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1237 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1238 |
exptButtons[currentBExpt].setEnabled(true); |
2 |
26 Feb 07 |
jari |
1239 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
1240 |
currentBTextField.setText(""); |
2 |
26 Feb 07 |
jari |
1241 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
1242 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1243 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1244 |
} |
2 |
26 Feb 07 |
jari |
1245 |
}); |
2 |
26 Feb 07 |
jari |
1246 |
|
2 |
26 Feb 07 |
jari |
1247 |
loadABPairButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1248 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1249 |
String currentPair = "A: " + (String)(exptNames.get(currentAExpt)) + " - B: " + (String)(exptNames.get(currentBExpt)); |
2 |
26 Feb 07 |
jari |
1250 |
pairedListModel.addElement(currentPair); |
2 |
26 Feb 07 |
jari |
1251 |
pairedAExpts.add(new Integer(currentAExpt)); |
2 |
26 Feb 07 |
jari |
1252 |
pairedBExpts.add(new Integer(currentBExpt)); |
2 |
26 Feb 07 |
jari |
1253 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
1254 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
1255 |
currentATextField.setText(""); |
2 |
26 Feb 07 |
jari |
1256 |
currentBTextField.setText(""); |
2 |
26 Feb 07 |
jari |
1257 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
1258 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
1259 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1260 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1261 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1262 |
removeABPairButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1263 |
pairedExptsList.setSelectedIndex(pairedListModel.size() - 1); |
2 |
26 Feb 07 |
jari |
1264 |
} |
2 |
26 Feb 07 |
jari |
1265 |
}); |
2 |
26 Feb 07 |
jari |
1266 |
|
2 |
26 Feb 07 |
jari |
1267 |
removeABPairButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1268 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1269 |
int index = pairedExptsList.getSelectedIndex(); |
2 |
26 Feb 07 |
jari |
1270 |
pairedListModel.removeElementAt(index); |
2 |
26 Feb 07 |
jari |
1271 |
int removedAIndex = ((Integer)(pairedAExpts.remove(index))).intValue(); |
2 |
26 Feb 07 |
jari |
1272 |
int removedBIndex = ((Integer)(pairedBExpts.remove(index))).intValue(); |
2 |
26 Feb 07 |
jari |
1273 |
exptButtons[removedAIndex].setEnabled(true); |
2 |
26 Feb 07 |
jari |
1274 |
exptButtons[removedBIndex].setEnabled(true); |
2 |
26 Feb 07 |
jari |
1275 |
if (pairedListModel.isEmpty()) { |
2 |
26 Feb 07 |
jari |
1276 |
removeABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1277 |
} else { |
2 |
26 Feb 07 |
jari |
1278 |
pairedExptsList.setSelectedIndex(pairedListModel.size() - 1); |
2 |
26 Feb 07 |
jari |
1279 |
} |
2 |
26 Feb 07 |
jari |
1280 |
} |
2 |
26 Feb 07 |
jari |
1281 |
}); |
2 |
26 Feb 07 |
jari |
1282 |
|
2 |
26 Feb 07 |
jari |
1283 |
JScrollPane currentAScroll = new JScrollPane(currentATextField); |
2 |
26 Feb 07 |
jari |
1284 |
currentAScroll.setMinimumSize(new Dimension(90, 50)); |
2 |
26 Feb 07 |
jari |
1285 |
JScrollPane currentBScroll = new JScrollPane(currentBTextField); |
2 |
26 Feb 07 |
jari |
1286 |
currentBScroll.setMinimumSize(new Dimension(90, 50)); |
2 |
26 Feb 07 |
jari |
1287 |
|
2 |
26 Feb 07 |
jari |
1288 |
currentAScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1289 |
currentAScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); |
2 |
26 Feb 07 |
jari |
1290 |
|
2 |
26 Feb 07 |
jari |
1291 |
currentBScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1292 |
currentBScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); |
2 |
26 Feb 07 |
jari |
1293 |
|
2 |
26 Feb 07 |
jari |
1294 |
buildConstraints(constraints, 0, 0, 1, 1, 20, 50); |
2 |
26 Feb 07 |
jari |
1295 |
grid2.setConstraints(removeCurrentAButton, constraints); |
2 |
26 Feb 07 |
jari |
1296 |
currentSelectionPanel.add(removeCurrentAButton); |
2 |
26 Feb 07 |
jari |
1297 |
|
2 |
26 Feb 07 |
jari |
1298 |
JLabel aLabel = new JLabel(" Current A: "); |
2 |
26 Feb 07 |
jari |
1299 |
buildConstraints(constraints, 1, 0, 1, 1, 20, 0); |
2 |
26 Feb 07 |
jari |
1300 |
grid2.setConstraints(aLabel, constraints); |
2 |
26 Feb 07 |
jari |
1301 |
currentSelectionPanel.add(aLabel); |
2 |
26 Feb 07 |
jari |
1302 |
|
2 |
26 Feb 07 |
jari |
1303 |
buildConstraints(constraints, 2, 0, 1, 1, 60, 0); |
2 |
26 Feb 07 |
jari |
1304 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.ipady = 100; |
2 |
26 Feb 07 |
jari |
1306 |
grid2.setConstraints(currentAScroll, constraints); |
2 |
26 Feb 07 |
jari |
1307 |
currentSelectionPanel.add(currentAScroll); |
2 |
26 Feb 07 |
jari |
1308 |
|
2 |
26 Feb 07 |
jari |
//constraints.ipady = 0; |
2 |
26 Feb 07 |
jari |
1310 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1311 |
|
2 |
26 Feb 07 |
jari |
1312 |
buildConstraints(constraints, 0, 1, 1, 1, 20, 50); |
2 |
26 Feb 07 |
jari |
1313 |
grid2.setConstraints(removeCurrentBButton, constraints); |
2 |
26 Feb 07 |
jari |
1314 |
currentSelectionPanel.add(removeCurrentBButton); |
2 |
26 Feb 07 |
jari |
1315 |
|
2 |
26 Feb 07 |
jari |
1316 |
JLabel bLabel = new JLabel("Current B: "); |
2 |
26 Feb 07 |
jari |
1317 |
buildConstraints(constraints, 1, 1, 1, 1, 20, 0); |
2 |
26 Feb 07 |
jari |
1318 |
grid2.setConstraints(bLabel, constraints); |
2 |
26 Feb 07 |
jari |
1319 |
currentSelectionPanel.add(bLabel); |
2 |
26 Feb 07 |
jari |
1320 |
|
2 |
26 Feb 07 |
jari |
1321 |
buildConstraints(constraints, 2, 1, 1, 1, 60, 0); |
2 |
26 Feb 07 |
jari |
1322 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.ipady = 100; |
2 |
26 Feb 07 |
jari |
1324 |
grid2.setConstraints(currentBScroll, constraints); |
2 |
26 Feb 07 |
jari |
1325 |
currentSelectionPanel.add(currentBScroll); |
2 |
26 Feb 07 |
jari |
1326 |
|
2 |
26 Feb 07 |
jari |
//constraints.ipady = 0; |
2 |
26 Feb 07 |
jari |
1328 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1329 |
|
2 |
26 Feb 07 |
jari |
1330 |
buildConstraints(constraints, 1, 0, 1, 1, 10, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.HORIZONTAL; |
2 |
26 Feb 07 |
jari |
//constraints.ipadx = 200; |
2 |
26 Feb 07 |
jari |
1333 |
gridbag.setConstraints(currentSelectionPanel, constraints); |
2 |
26 Feb 07 |
jari |
1334 |
this.add(currentSelectionPanel); |
2 |
26 Feb 07 |
jari |
1335 |
|
2 |
26 Feb 07 |
jari |
1336 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
//constraints.ipadx = 0; |
2 |
26 Feb 07 |
jari |
1338 |
|
2 |
26 Feb 07 |
jari |
1339 |
JPanel pairButtonsPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
1340 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1341 |
pairButtonsPanel.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
1342 |
|
2 |
26 Feb 07 |
jari |
1343 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
1344 |
grid3.setConstraints(loadABPairButton, constraints); |
2 |
26 Feb 07 |
jari |
1345 |
pairButtonsPanel.add(loadABPairButton); |
2 |
26 Feb 07 |
jari |
1346 |
|
2 |
26 Feb 07 |
jari |
1347 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
1348 |
grid3.setConstraints(removeABPairButton, constraints); |
2 |
26 Feb 07 |
jari |
1349 |
pairButtonsPanel.add(removeABPairButton); |
2 |
26 Feb 07 |
jari |
1350 |
|
2 |
26 Feb 07 |
jari |
1351 |
buildConstraints(constraints, 2, 0, 1, 1, 5, 0); |
2 |
26 Feb 07 |
jari |
1352 |
gridbag.setConstraints(pairButtonsPanel, constraints); |
2 |
26 Feb 07 |
jari |
1353 |
this.add(pairButtonsPanel); |
2 |
26 Feb 07 |
jari |
1354 |
|
2 |
26 Feb 07 |
jari |
//pairPanel = new PairedExperimentsPanel(); |
2 |
26 Feb 07 |
jari |
1356 |
buildConstraints(constraints, 3, 0, 1, 1, 45, 0); |
2 |
26 Feb 07 |
jari |
1357 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1358 |
JScrollPane pairScroll = new JScrollPane(pairedExptsList); |
2 |
26 Feb 07 |
jari |
1359 |
pairScroll.setBorder(new TitledBorder("Paired Samples")); |
2 |
26 Feb 07 |
jari |
1360 |
gridbag.setConstraints(pairScroll, constraints); |
2 |
26 Feb 07 |
jari |
1361 |
this.add(pairScroll); |
2 |
26 Feb 07 |
jari |
1362 |
|
2 |
26 Feb 07 |
jari |
1363 |
} |
2 |
26 Feb 07 |
jari |
1364 |
|
2 |
26 Feb 07 |
jari |
1365 |
|
2 |
26 Feb 07 |
jari |
1366 |
public void reset() { |
2 |
26 Feb 07 |
jari |
1367 |
|
2 |
26 Feb 07 |
jari |
1368 |
for (int i = 0; i < exptButtons.length; i++) { |
2 |
26 Feb 07 |
jari |
1369 |
exptButtons[i].setEnabled(true); |
2 |
26 Feb 07 |
jari |
1370 |
currentATextField.setText(""); |
2 |
26 Feb 07 |
jari |
1371 |
currentBTextField.setText(""); |
2 |
26 Feb 07 |
jari |
1372 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1373 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1374 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1375 |
removeABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1376 |
pairedListModel.clear(); |
2 |
26 Feb 07 |
jari |
1377 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
1378 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
1379 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
1380 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
1381 |
pairedAExpts.clear(); |
2 |
26 Feb 07 |
jari |
1382 |
pairedBExpts.clear(); |
2 |
26 Feb 07 |
jari |
1383 |
} |
2 |
26 Feb 07 |
jari |
1384 |
} |
2 |
26 Feb 07 |
jari |
1385 |
|
2 |
26 Feb 07 |
jari |
1386 |
class ExperimentButton extends JButton { |
2 |
26 Feb 07 |
jari |
1387 |
String s; |
2 |
26 Feb 07 |
jari |
1388 |
int index; |
2 |
26 Feb 07 |
jari |
1389 |
public ExperimentButton(int i) { |
2 |
26 Feb 07 |
jari |
1390 |
this.index = i; |
2 |
26 Feb 07 |
jari |
1391 |
s = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
1392 |
this.setText(s); |
2 |
26 Feb 07 |
jari |
1393 |
this.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1394 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1395 |
if ((currentAFilled)&&(currentBFilled)) { |
2 |
26 Feb 07 |
jari |
1396 |
JOptionPane.showMessageDialog(null, "Clear at least one current field first!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
1397 |
} else if (!currentAFilled) { |
2 |
26 Feb 07 |
jari |
1398 |
currentAExpt = index; |
2 |
26 Feb 07 |
jari |
1399 |
currentATextField.setText(s); |
2 |
26 Feb 07 |
jari |
1400 |
currentAFilled = true; |
2 |
26 Feb 07 |
jari |
1401 |
ExperimentButton.this.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1402 |
removeCurrentAButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1403 |
} else if (!currentBFilled) { |
2 |
26 Feb 07 |
jari |
1404 |
currentBExpt = index; |
2 |
26 Feb 07 |
jari |
1405 |
currentBTextField.setText(s); |
2 |
26 Feb 07 |
jari |
1406 |
currentBFilled = true; |
2 |
26 Feb 07 |
jari |
1407 |
ExperimentButton.this.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1408 |
removeCurrentBButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1409 |
} |
2 |
26 Feb 07 |
jari |
1410 |
|
2 |
26 Feb 07 |
jari |
1411 |
if ((currentAFilled) && (currentBFilled)) { |
2 |
26 Feb 07 |
jari |
1412 |
loadABPairButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1413 |
} else { |
2 |
26 Feb 07 |
jari |
1414 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1415 |
} |
2 |
26 Feb 07 |
jari |
1416 |
} |
2 |
26 Feb 07 |
jari |
1417 |
}); |
2 |
26 Feb 07 |
jari |
1418 |
} |
2 |
26 Feb 07 |
jari |
1419 |
} |
2 |
26 Feb 07 |
jari |
1420 |
|
2 |
26 Feb 07 |
jari |
1421 |
class PairedExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1422 |
public PairedExperimentsPanel() { |
2 |
26 Feb 07 |
jari |
//this.setBorder(new TitledBorder("Paired Experiments")); |
2 |
26 Feb 07 |
jari |
1424 |
} |
2 |
26 Feb 07 |
jari |
1425 |
} |
2 |
26 Feb 07 |
jari |
1426 |
} |
2 |
26 Feb 07 |
jari |
1427 |
|
2 |
26 Feb 07 |
jari |
1428 |
|
2 |
26 Feb 07 |
jari |
1429 |
class MultiClassPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1430 |
NumGroupsPanel ngPanel; |
2 |
26 Feb 07 |
jari |
1431 |
GridBagConstraints constraints; |
2 |
26 Feb 07 |
jari |
1432 |
GridBagLayout gridbag; |
2 |
26 Feb 07 |
jari |
1433 |
JPanel dummyPanel; |
2 |
26 Feb 07 |
jari |
1434 |
MultiGroupExperimentsPanel mulgPanel; |
2 |
26 Feb 07 |
jari |
1435 |
int numGroups; |
2 |
26 Feb 07 |
jari |
//Vector exptNames; |
2 |
26 Feb 07 |
jari |
1437 |
|
2 |
26 Feb 07 |
jari |
1438 |
public MultiClassPanel(/*Vector exptNames*/) { |
2 |
26 Feb 07 |
jari |
1439 |
constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1440 |
gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1441 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//this.exptNames = exptNames; |
2 |
26 Feb 07 |
jari |
1443 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1444 |
ngPanel = new NumGroupsPanel(); |
2 |
26 Feb 07 |
jari |
1445 |
|
2 |
26 Feb 07 |
jari |
1446 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 10); |
2 |
26 Feb 07 |
jari |
1447 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1448 |
gridbag.setConstraints(ngPanel, constraints); |
2 |
26 Feb 07 |
jari |
1449 |
ngPanel.okButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1450 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1451 |
ngPanel.okPressed = true; |
2 |
26 Feb 07 |
jari |
1452 |
try { |
2 |
26 Feb 07 |
jari |
1453 |
numGroups = Integer.parseInt(ngPanel.numGroupsField.getText()); |
2 |
26 Feb 07 |
jari |
1454 |
if (numGroups <= 2) { |
2 |
26 Feb 07 |
jari |
1455 |
JOptionPane.showMessageDialog(null, "Please enter a positive integer >= 2!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
1456 |
} else { |
2 |
26 Feb 07 |
jari |
1457 |
mulgPanel = new MultiGroupExperimentsPanel(exptNames, numGroups); |
2 |
26 Feb 07 |
jari |
1458 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 90); |
2 |
26 Feb 07 |
jari |
1459 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1460 |
gridbag.setConstraints(mulgPanel, constraints); |
2 |
26 Feb 07 |
jari |
//dummyButton.setVisible(true); |
2 |
26 Feb 07 |
jari |
1462 |
MultiClassPanel.this.remove(dummyPanel); |
2 |
26 Feb 07 |
jari |
1463 |
MultiClassPanel.this.add(mulgPanel); |
2 |
26 Feb 07 |
jari |
//MultiClassPanel.this.add(dummyButton); |
2 |
26 Feb 07 |
jari |
1465 |
MultiClassPanel.this.validate(); |
2 |
26 Feb 07 |
jari |
1466 |
ngPanel.okButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1467 |
ngPanel.numGroupsField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1468 |
} |
2 |
26 Feb 07 |
jari |
1469 |
|
2 |
26 Feb 07 |
jari |
1470 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
1471 |
JOptionPane.showMessageDialog(null, "Please enter a positive integer >= 2!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
1472 |
} |
2 |
26 Feb 07 |
jari |
1473 |
} |
2 |
26 Feb 07 |
jari |
1474 |
}); |
2 |
26 Feb 07 |
jari |
1475 |
this.add(ngPanel); |
2 |
26 Feb 07 |
jari |
1476 |
|
2 |
26 Feb 07 |
jari |
1477 |
|
2 |
26 Feb 07 |
jari |
1478 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 90); |
2 |
26 Feb 07 |
jari |
1479 |
dummyPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
1480 |
dummyPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1481 |
gridbag.setConstraints(dummyPanel, constraints); |
2 |
26 Feb 07 |
jari |
1482 |
this.add(dummyPanel); |
2 |
26 Feb 07 |
jari |
1483 |
} |
2 |
26 Feb 07 |
jari |
1484 |
|
2 |
26 Feb 07 |
jari |
1485 |
|
2 |
26 Feb 07 |
jari |
1486 |
class NumGroupsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1487 |
JTextField numGroupsField; |
2 |
26 Feb 07 |
jari |
1488 |
JButton okButton; |
2 |
26 Feb 07 |
jari |
1489 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
1490 |
|
2 |
26 Feb 07 |
jari |
1491 |
public NumGroupsPanel() { |
2 |
26 Feb 07 |
jari |
//super(parentFrame, "Multiclass design: number of groups", modality); |
2 |
26 Feb 07 |
jari |
//setBounds(0, 0, 350, 150); |
2 |
26 Feb 07 |
jari |
//setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
1495 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1496 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1497 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1498 |
|
2 |
26 Feb 07 |
jari |
//JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
1500 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1501 |
|
2 |
26 Feb 07 |
jari |
1502 |
JLabel numGroupsLabel = new JLabel("Number of groups "); |
2 |
26 Feb 07 |
jari |
1503 |
buildConstraints(constraints, 0, 0, 1, 1, 30, 100); |
2 |
26 Feb 07 |
jari |
1504 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1505 |
gridbag.setConstraints(numGroupsLabel, constraints); |
2 |
26 Feb 07 |
jari |
1506 |
this.add(numGroupsLabel); |
2 |
26 Feb 07 |
jari |
1507 |
|
2 |
26 Feb 07 |
jari |
1508 |
numGroupsField = new JTextField("", 7); |
2 |
26 Feb 07 |
jari |
1509 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1510 |
buildConstraints(constraints, 1, 0, 1, 1, 30, 0); |
2 |
26 Feb 07 |
jari |
1511 |
gridbag.setConstraints(numGroupsField, constraints); |
2 |
26 Feb 07 |
jari |
1512 |
this.add(numGroupsField); |
2 |
26 Feb 07 |
jari |
1513 |
|
2 |
26 Feb 07 |
jari |
1514 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
1515 |
buildConstraints(constraints, 2, 0, 1, 1, 40, 0); |
2 |
26 Feb 07 |
jari |
1516 |
gridbag.setConstraints(okButton, constraints); |
2 |
26 Feb 07 |
jari |
1517 |
/* |
2 |
26 Feb 07 |
jari |
okButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
okPressed = true; |
2 |
26 Feb 07 |
jari |
//dispose(); |
2 |
26 Feb 07 |
jari |
1522 |
} |
2 |
26 Feb 07 |
jari |
1523 |
}); |
2 |
26 Feb 07 |
jari |
1524 |
*/ |
2 |
26 Feb 07 |
jari |
1525 |
this.add(okButton); |
2 |
26 Feb 07 |
jari |
1526 |
/* |
2 |
26 Feb 07 |
jari |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 1, 1, 1, 1, 0, 0); |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(cancelButton, constraints); |
2 |
26 Feb 07 |
jari |
cancelButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
okPressed = false; |
2 |
26 Feb 07 |
jari |
dispose(); |
2 |
26 Feb 07 |
jari |
1534 |
} |
2 |
26 Feb 07 |
jari |
1535 |
}); |
2 |
26 Feb 07 |
jari |
pane.add(cancelButton); |
2 |
26 Feb 07 |
jari |
1537 |
*/ |
2 |
26 Feb 07 |
jari |
1538 |
|
2 |
26 Feb 07 |
jari |
//setContentPane(pane); |
2 |
26 Feb 07 |
jari |
1540 |
|
2 |
26 Feb 07 |
jari |
1541 |
} |
2 |
26 Feb 07 |
jari |
1542 |
|
2 |
26 Feb 07 |
jari |
1543 |
|
2 |
26 Feb 07 |
jari |
1544 |
|
2 |
26 Feb 07 |
jari |
1545 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
1547 |
setLocation((MultiClassPanel.this.getWidth() - getSize().width)/2, (MultiClassPanel.this.getHeight() - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
1548 |
|
2 |
26 Feb 07 |
jari |
1549 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
1550 |
|
2 |
26 Feb 07 |
jari |
1551 |
if (visible) { |
2 |
26 Feb 07 |
jari |
//bPanel.okButton.requestFocus(); //UNCOMMMENT THIS LATER |
2 |
26 Feb 07 |
jari |
1553 |
} |
2 |
26 Feb 07 |
jari |
1554 |
} |
2 |
26 Feb 07 |
jari |
1555 |
|
2 |
26 Feb 07 |
jari |
1556 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
1557 |
return okPressed; |
2 |
26 Feb 07 |
jari |
1558 |
} |
2 |
26 Feb 07 |
jari |
1559 |
|
2 |
26 Feb 07 |
jari |
1560 |
} |
2 |
26 Feb 07 |
jari |
1561 |
|
2 |
26 Feb 07 |
jari |
1562 |
class MultiGroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1563 |
JLabel[] expLabels; |
2 |
26 Feb 07 |
jari |
1564 |
JRadioButton[][] exptGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
1565 |
JRadioButton[] notInGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
1566 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
1567 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
1568 |
MultiGroupExperimentsPanel(Vector exptNames, int numGroups) { |
2 |
26 Feb 07 |
jari |
1569 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Group Assignments")); |
2 |
26 Feb 07 |
jari |
1570 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
// JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
1572 |
expLabels = new JLabel[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1573 |
|
2 |
26 Feb 07 |
jari |
1574 |
exptGroupRadioButtons = new JRadioButton[numGroups][exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1575 |
notInGroupRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1576 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1577 |
|
2 |
26 Feb 07 |
jari |
1578 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1579 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1580 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1581 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
//wwang fix 512 problem |
2 |
26 Feb 07 |
jari |
1583 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
1584 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
1585 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
1586 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
1587 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
1588 |
} |
2 |
26 Feb 07 |
jari |
1589 |
|
2 |
26 Feb 07 |
jari |
1590 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
1591 |
String s1 = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
1592 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
1593 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1594 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
1595 |
exptGroupRadioButtons[j][i] = new JRadioButton("Group " + (j + 1) + " ", j == 0? true: false); |
2 |
26 Feb 07 |
jari |
1596 |
chooseGroup[i].add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
1597 |
} |
2 |
26 Feb 07 |
jari |
//set current panel |
2 |
26 Feb 07 |
jari |
1599 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
1600 |
|
2 |
26 Feb 07 |
jari |
1601 |
notInGroupRadioButtons[i] = new JRadioButton("Not in groups", false); |
2 |
26 Feb 07 |
jari |
1602 |
chooseGroup[i].add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1603 |
|
2 |
26 Feb 07 |
jari |
1604 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
1605 |
buildConstraints(constraints, j, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1607 |
gridbag.setConstraints(exptGroupRadioButtons[j][i], constraints); |
2 |
26 Feb 07 |
jari |
1608 |
panels[currPanel].add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
1609 |
} |
2 |
26 Feb 07 |
jari |
1610 |
|
2 |
26 Feb 07 |
jari |
1611 |
buildConstraints(constraints, (numGroups + 1), i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1613 |
gridbag.setConstraints(notInGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
1614 |
panels[currPanel].add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1615 |
|
2 |
26 Feb 07 |
jari |
1616 |
} |
2 |
26 Feb 07 |
jari |
1617 |
|
2 |
26 Feb 07 |
jari |
1618 |
int maxLabelWidth = 0; |
2 |
26 Feb 07 |
jari |
1619 |
|
2 |
26 Feb 07 |
jari |
1620 |
for (int j= 0; j < expLabels.length; j++) { |
2 |
26 Feb 07 |
jari |
1621 |
if (expLabels[j].getPreferredSize().getWidth() > maxLabelWidth) { |
2 |
26 Feb 07 |
jari |
1622 |
maxLabelWidth = (int)Math.ceil(expLabels[j].getPreferredSize().getWidth()); |
2 |
26 Feb 07 |
jari |
1623 |
} |
2 |
26 Feb 07 |
jari |
1624 |
} |
2 |
26 Feb 07 |
jari |
1625 |
|
2 |
26 Feb 07 |
jari |
1626 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
1627 |
|
2 |
26 Feb 07 |
jari |
1628 |
for(int m = 0; m< numPanels; m++) { |
2 |
26 Feb 07 |
jari |
1629 |
bigPanel.add(panels[m] ,new GridBagConstraints(0,m,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
1630 |
} |
2 |
26 Feb 07 |
jari |
1631 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
1632 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1633 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1634 |
|
2 |
26 Feb 07 |
jari |
//add by wwang |
2 |
26 Feb 07 |
jari |
1636 |
JPanel [] exptNameHeaderPanels = new JPanel[this.numPanels]; |
2 |
26 Feb 07 |
jari |
1637 |
GridBagLayout exptHeaderGridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1638 |
|
2 |
26 Feb 07 |
jari |
1639 |
for(int i = 0; i< exptNameHeaderPanels.length; i++) { |
2 |
26 Feb 07 |
jari |
1640 |
exptNameHeaderPanels[i] = new JPanel(); |
2 |
26 Feb 07 |
jari |
1641 |
exptNameHeaderPanels[i].setSize(50, panels[i].getPreferredSize().height); |
2 |
26 Feb 07 |
jari |
1642 |
exptNameHeaderPanels[i].setPreferredSize(new Dimension(maxLabelWidth + 10, panels[i].getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
1643 |
exptNameHeaderPanels[i].setLayout(exptHeaderGridbag); |
2 |
26 Feb 07 |
jari |
1644 |
} |
2 |
26 Feb 07 |
jari |
1645 |
|
2 |
26 Feb 07 |
jari |
//need to possibly add to additional panels if number of exp. excedes 512 |
2 |
26 Feb 07 |
jari |
1647 |
for (int m = 0; m < expLabels.length; m++) { |
2 |
26 Feb 07 |
jari |
1648 |
currPanel = m/512; |
2 |
26 Feb 07 |
jari |
1649 |
buildConstraints(constraints, 0, m%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
1650 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1651 |
exptHeaderGridbag.setConstraints(expLabels[m], constraints); |
2 |
26 Feb 07 |
jari |
1652 |
exptNameHeaderPanels[currPanel].add(expLabels[m]); |
2 |
26 Feb 07 |
jari |
1653 |
} |
2 |
26 Feb 07 |
jari |
1654 |
|
2 |
26 Feb 07 |
jari |
1655 |
JPanel headerPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
1656 |
for(int k = 0; k < exptNameHeaderPanels.length; k++) { |
2 |
26 Feb 07 |
jari |
1657 |
headerPanel.add(exptNameHeaderPanels[k], new GridBagConstraints(0,k,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
1658 |
} |
2 |
26 Feb 07 |
jari |
1659 |
|
2 |
26 Feb 07 |
jari |
1660 |
scroll.setRowHeaderView(headerPanel); |
2 |
26 Feb 07 |
jari |
1661 |
|
2 |
26 Feb 07 |
jari |
1662 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
1663 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1664 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
1665 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
1666 |
|
2 |
26 Feb 07 |
jari |
1667 |
JLabel label1 = new JLabel("Note: Each group MUST each contain more than one sample."); |
2 |
26 Feb 07 |
jari |
1668 |
label1.setHorizontalAlignment(JLabel.CENTER); |
2 |
26 Feb 07 |
jari |
1669 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
1670 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1672 |
gridbag2.setConstraints(label1, constraints); |
2 |
26 Feb 07 |
jari |
1673 |
this.add(label1); |
2 |
26 Feb 07 |
jari |
1674 |
|
2 |
26 Feb 07 |
jari |
1675 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
1676 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
1677 |
lotsOfSamplesWarningLabel.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
1678 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,2,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
1679 |
} |
2 |
26 Feb 07 |
jari |
1680 |
|
2 |
26 Feb 07 |
jari |
1681 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
1682 |
GridBagLayout gridbag3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1683 |
panel2.setLayout(gridbag3); |
2 |
26 Feb 07 |
jari |
1684 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1685 |
JButton saveButton = new JButton(" Save settings "); |
2 |
26 Feb 07 |
jari |
1686 |
saveButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1687 |
saveButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
1688 |
JButton loadButton = new JButton(" Load settings "); |
2 |
26 Feb 07 |
jari |
1689 |
loadButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1690 |
loadButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
1691 |
JButton resetButton = new JButton(" Reset "); |
2 |
26 Feb 07 |
jari |
1692 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1693 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
1694 |
|
2 |
26 Feb 07 |
jari |
1695 |
|
2 |
26 Feb 07 |
jari |
1696 |
final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
1697 |
|
2 |
26 Feb 07 |
jari |
1698 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1699 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1700 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
1701 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1702 |
} |
2 |
26 Feb 07 |
jari |
1703 |
} |
2 |
26 Feb 07 |
jari |
1704 |
}); |
2 |
26 Feb 07 |
jari |
1705 |
|
2 |
26 Feb 07 |
jari |
1706 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
1707 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
1708 |
|
2 |
26 Feb 07 |
jari |
1709 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1710 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1711 |
int returnVal = fc.showSaveDialog(MultiGroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
1712 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
1713 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
1714 |
try { |
2 |
26 Feb 07 |
jari |
1715 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
1716 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
1717 |
for (int i = 0; i < groupAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
1718 |
out.print(groupAssgn[i]); |
2 |
26 Feb 07 |
jari |
1719 |
if (i < groupAssgn.length - 1) { |
2 |
26 Feb 07 |
jari |
1720 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
1721 |
} |
2 |
26 Feb 07 |
jari |
1722 |
} |
2 |
26 Feb 07 |
jari |
1723 |
out.println(); |
2 |
26 Feb 07 |
jari |
1724 |
out.flush(); |
2 |
26 Feb 07 |
jari |
1725 |
out.close(); |
2 |
26 Feb 07 |
jari |
1726 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1728 |
} |
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
1731 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
1733 |
} |
2 |
26 Feb 07 |
jari |
1734 |
} |
2 |
26 Feb 07 |
jari |
1735 |
}); |
2 |
26 Feb 07 |
jari |
1736 |
|
2 |
26 Feb 07 |
jari |
1737 |
|
2 |
26 Feb 07 |
jari |
//NEED TO REWORK THIS FOR MULTICLASS |
2 |
26 Feb 07 |
jari |
1739 |
|
2 |
26 Feb 07 |
jari |
1740 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1741 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1742 |
int returnVal = fc.showOpenDialog(MultiGroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
1743 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
1744 |
try { |
2 |
26 Feb 07 |
jari |
1745 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
1746 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
1747 |
String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
1749 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
1750 |
st.init(line); |
2 |
26 Feb 07 |
jari |
1751 |
Vector groupsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
1752 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
1753 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
1754 |
groupsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
1756 |
} |
2 |
26 Feb 07 |
jari |
1757 |
buff.close(); |
2 |
26 Feb 07 |
jari |
1758 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
1759 |
if (groupsVector.size() != groupAssgn.length) { |
2 |
26 Feb 07 |
jari |
1760 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1761 |
} else { |
2 |
26 Feb 07 |
jari |
1762 |
for (int i = 0; i < groupsVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
1763 |
int currentGroup = ((Integer)groupsVector.get(i)).intValue(); |
2 |
26 Feb 07 |
jari |
1764 |
if (currentGroup != 0) { |
2 |
26 Feb 07 |
jari |
1765 |
exptGroupRadioButtons[currentGroup - 1][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1766 |
} else { |
2 |
26 Feb 07 |
jari |
1767 |
notInGroupRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1768 |
} |
2 |
26 Feb 07 |
jari |
1769 |
/* |
2 |
26 Feb 07 |
jari |
if (currentExpt == 1) { |
2 |
26 Feb 07 |
jari |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
} else if (currentExpt == 2) { |
2 |
26 Feb 07 |
jari |
groupBRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
} else if (currentExpt == 3) { |
2 |
26 Feb 07 |
jari |
neitherGroupRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
for (int j = 0; j < finNum; j++) { |
2 |
26 Feb 07 |
jari |
groupARadioButtons[j].setSelected(true); |
2 |
26 Feb 07 |
jari |
1779 |
} |
2 |
26 Feb 07 |
jari |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
break; |
2 |
26 Feb 07 |
jari |
1782 |
} |
2 |
26 Feb 07 |
jari |
1783 |
*/ |
2 |
26 Feb 07 |
jari |
1784 |
} |
2 |
26 Feb 07 |
jari |
1785 |
} |
2 |
26 Feb 07 |
jari |
1786 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1787 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1788 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
1789 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1790 |
} |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1792 |
} |
2 |
26 Feb 07 |
jari |
1793 |
|
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
1796 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
1798 |
} |
2 |
26 Feb 07 |
jari |
1799 |
} |
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 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1805 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1806 |
constraints.insets = new Insets(5,5,5,5); |
2 |
26 Feb 07 |
jari |
1807 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
1808 |
gridbag3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
1809 |
panel2.add(saveButton); |
2 |
26 Feb 07 |
jari |
1810 |
|
2 |
26 Feb 07 |
jari |
1811 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
1812 |
gridbag3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
1813 |
panel2.add(loadButton); |
2 |
26 Feb 07 |
jari |
1814 |
|
2 |
26 Feb 07 |
jari |
1815 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
1816 |
gridbag3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
1817 |
panel2.add(resetButton); |
2 |
26 Feb 07 |
jari |
1818 |
constraints.insets = new Insets(0,0,0,0); |
2 |
26 Feb 07 |
jari |
1819 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
1820 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1821 |
gridbag2.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
1822 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
1823 |
|
2 |
26 Feb 07 |
jari |
1824 |
|
2 |
26 Feb 07 |
jari |
1825 |
} |
2 |
26 Feb 07 |
jari |
1826 |
|
2 |
26 Feb 07 |
jari |
1827 |
/** |
2 |
26 Feb 07 |
jari |
* resets group assignments |
2 |
26 Feb 07 |
jari |
1829 |
*/ |
2 |
26 Feb 07 |
jari |
1830 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
1831 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
1832 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1833 |
} |
2 |
26 Feb 07 |
jari |
1834 |
} |
2 |
26 Feb 07 |
jari |
1835 |
} |
2 |
26 Feb 07 |
jari |
1836 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
1837 |
mulgPanel.reset(); |
2 |
26 Feb 07 |
jari |
1838 |
} |
2 |
26 Feb 07 |
jari |
1839 |
} |
2 |
26 Feb 07 |
jari |
1840 |
|
2 |
26 Feb 07 |
jari |
1841 |
class PermutationsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
//JLabel permsInfoLabel; |
2 |
26 Feb 07 |
jari |
//JRadioButton useAllPermsButton, numPermsButton; |
2 |
26 Feb 07 |
jari |
1844 |
JLabel numPermsLabel; |
2 |
26 Feb 07 |
jari |
1845 |
JTextField numPermsInputField; |
2 |
26 Feb 07 |
jari |
1846 |
PermutationsPanel() { |
2 |
26 Feb 07 |
jari |
1847 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Number of permutations", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
1848 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1849 |
numPermsLabel = new JLabel("Enter number of permutations: "); |
2 |
26 Feb 07 |
jari |
1850 |
numPermsInputField = new JTextField("100", 7); |
2 |
26 Feb 07 |
jari |
1851 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1852 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1853 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1854 |
|
2 |
26 Feb 07 |
jari |
1855 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 100); |
2 |
26 Feb 07 |
jari |
1856 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1857 |
gridbag.setConstraints(numPermsLabel, constraints); |
2 |
26 Feb 07 |
jari |
1858 |
this.add(numPermsLabel); |
2 |
26 Feb 07 |
jari |
1859 |
|
2 |
26 Feb 07 |
jari |
1860 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
1861 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1862 |
gridbag.setConstraints(numPermsInputField, constraints); |
2 |
26 Feb 07 |
jari |
1863 |
this.add(numPermsInputField); |
2 |
26 Feb 07 |
jari |
1864 |
|
2 |
26 Feb 07 |
jari |
1865 |
} |
2 |
26 Feb 07 |
jari |
1866 |
|
2 |
26 Feb 07 |
jari |
1867 |
public void reset(){ |
2 |
26 Feb 07 |
jari |
1868 |
this.numPermsInputField.setText("100"); |
2 |
26 Feb 07 |
jari |
1869 |
} |
2 |
26 Feb 07 |
jari |
1870 |
|
2 |
26 Feb 07 |
jari |
1871 |
} |
2 |
26 Feb 07 |
jari |
1872 |
|
2 |
26 Feb 07 |
jari |
1873 |
class S0AndQValueCalcPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1874 |
JComboBox s0SelectBox; |
2 |
26 Feb 07 |
jari |
1875 |
JTextField s0EntryField; |
2 |
26 Feb 07 |
jari |
1876 |
JRadioButton s0SelectButton, s0EntryButton, qYesButton, qNoButton; |
2 |
26 Feb 07 |
jari |
1877 |
|
2 |
26 Feb 07 |
jari |
1878 |
S0AndQValueCalcPanel() { |
2 |
26 Feb 07 |
jari |
1879 |
this.setBorder(new TitledBorder(new EtchedBorder(), "S0 and Q Value parameters", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
1880 |
String[] s0SelectOptions = {"Tusher et al. method", "5th percentile", "50th percentile", "90th percentile", "Minimum S Value"}; |
2 |
26 Feb 07 |
jari |
1881 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1882 |
s0SelectBox = new JComboBox(s0SelectOptions); |
2 |
26 Feb 07 |
jari |
//s0SelectBox.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1884 |
s0SelectButton = new JRadioButton("Select S0 using", true); |
2 |
26 Feb 07 |
jari |
1885 |
s0SelectButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1886 |
s0EntryButton = new JRadioButton(" OR Enter s0 percentile (0-100)", false); |
2 |
26 Feb 07 |
jari |
1887 |
s0EntryButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1888 |
s0EntryField = new JTextField("", 7); |
2 |
26 Feb 07 |
jari |
1889 |
s0EntryField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1890 |
s0EntryField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
1891 |
ButtonGroup s0Group = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1892 |
s0SelectButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1893 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1894 |
s0SelectBox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1895 |
s0EntryField.setText(""); |
2 |
26 Feb 07 |
jari |
1896 |
s0EntryField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1897 |
s0EntryField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
1898 |
} |
2 |
26 Feb 07 |
jari |
1899 |
}); |
2 |
26 Feb 07 |
jari |
1900 |
s0EntryButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1901 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1902 |
s0EntryField.setText("10"); |
2 |
26 Feb 07 |
jari |
1903 |
s0EntryField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1904 |
s0EntryField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1905 |
s0SelectBox.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1906 |
} |
2 |
26 Feb 07 |
jari |
1907 |
}); |
2 |
26 Feb 07 |
jari |
1908 |
s0Group.add(s0SelectButton); |
2 |
26 Feb 07 |
jari |
1909 |
s0Group.add(s0EntryButton); |
2 |
26 Feb 07 |
jari |
1910 |
|
2 |
26 Feb 07 |
jari |
1911 |
qYesButton = new JRadioButton("Yes (slow!)", false); |
2 |
26 Feb 07 |
jari |
1912 |
qYesButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1913 |
qNoButton = new JRadioButton("No (quick)", true); |
2 |
26 Feb 07 |
jari |
1914 |
qNoButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1915 |
ButtonGroup qGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1916 |
qGroup.add(qYesButton); |
2 |
26 Feb 07 |
jari |
1917 |
qGroup.add(qNoButton); |
2 |
26 Feb 07 |
jari |
1918 |
|
2 |
26 Feb 07 |
jari |
1919 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1920 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1921 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1922 |
|
2 |
26 Feb 07 |
jari |
1923 |
buildConstraints(constraints, 0, 0, 1, 1, 25, 50); |
2 |
26 Feb 07 |
jari |
1924 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1925 |
gridbag.setConstraints(s0SelectButton, constraints); |
2 |
26 Feb 07 |
jari |
1926 |
this.add(s0SelectButton); |
2 |
26 Feb 07 |
jari |
1927 |
|
2 |
26 Feb 07 |
jari |
1928 |
buildConstraints(constraints, 1, 0, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
1929 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1930 |
gridbag.setConstraints(s0SelectBox, constraints); |
2 |
26 Feb 07 |
jari |
1931 |
this.add(s0SelectBox); |
2 |
26 Feb 07 |
jari |
1932 |
|
2 |
26 Feb 07 |
jari |
1933 |
buildConstraints(constraints, 2, 0, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
1934 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1935 |
gridbag.setConstraints(s0EntryButton, constraints); |
2 |
26 Feb 07 |
jari |
1936 |
this.add(s0EntryButton); |
2 |
26 Feb 07 |
jari |
1937 |
|
2 |
26 Feb 07 |
jari |
1938 |
|
2 |
26 Feb 07 |
jari |
1939 |
buildConstraints(constraints, 3, 0, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
1940 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1941 |
gridbag.setConstraints(s0EntryField, constraints); |
2 |
26 Feb 07 |
jari |
1942 |
this.add(s0EntryField); |
2 |
26 Feb 07 |
jari |
1943 |
|
2 |
26 Feb 07 |
jari |
1944 |
JLabel qLabel = new JLabel("Calculate q-values? "); |
2 |
26 Feb 07 |
jari |
1945 |
buildConstraints(constraints, 0, 1, 1, 1, 10, 50); |
2 |
26 Feb 07 |
jari |
1946 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1947 |
gridbag.setConstraints(qLabel, constraints); |
2 |
26 Feb 07 |
jari |
1948 |
this.add(qLabel); |
2 |
26 Feb 07 |
jari |
1949 |
|
2 |
26 Feb 07 |
jari |
1950 |
buildConstraints(constraints, 1, 1, 1, 1, 10, 0); |
2 |
26 Feb 07 |
jari |
1951 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1952 |
gridbag.setConstraints(qNoButton, constraints); |
2 |
26 Feb 07 |
jari |
1953 |
this.add(qNoButton); |
2 |
26 Feb 07 |
jari |
1954 |
|
2 |
26 Feb 07 |
jari |
1955 |
buildConstraints(constraints, 2, 1, 2, 1, 80, 0); |
2 |
26 Feb 07 |
jari |
1956 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1957 |
gridbag.setConstraints(qYesButton, constraints); |
2 |
26 Feb 07 |
jari |
1958 |
this.add(qYesButton); |
2 |
26 Feb 07 |
jari |
1959 |
|
2 |
26 Feb 07 |
jari |
1960 |
} |
2 |
26 Feb 07 |
jari |
1961 |
|
2 |
26 Feb 07 |
jari |
1962 |
public void reset() { |
2 |
26 Feb 07 |
jari |
1963 |
s0SelectButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1964 |
s0SelectBox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1965 |
s0SelectBox.setSelectedIndex(0); |
2 |
26 Feb 07 |
jari |
1966 |
s0EntryField.setText(""); |
2 |
26 Feb 07 |
jari |
1967 |
s0EntryField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
1968 |
s0EntryField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1969 |
qNoButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1970 |
} |
2 |
26 Feb 07 |
jari |
1971 |
} |
2 |
26 Feb 07 |
jari |
1972 |
|
2 |
26 Feb 07 |
jari |
1973 |
class ImputationPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1974 |
JRadioButton kNearestButton, rowAverageButton; |
2 |
26 Feb 07 |
jari |
1975 |
JTextField numNeighborsField; |
2 |
26 Feb 07 |
jari |
1976 |
JLabel numNeighborsLabel; |
2 |
26 Feb 07 |
jari |
1977 |
String numNeighborsText; |
2 |
26 Feb 07 |
jari |
1978 |
JCheckBox saveMatrixChkBox; |
2 |
26 Feb 07 |
jari |
1979 |
ImputationPanel() { |
2 |
26 Feb 07 |
jari |
// this.setBorder(new TitledBorder(new EtchedBorder(), "Imputation Engine")); |
2 |
26 Feb 07 |
jari |
1981 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Imputation Engine", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
1982 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1983 |
numNeighborsText = "10"; |
2 |
26 Feb 07 |
jari |
1984 |
if (numGenes < 10) { |
2 |
26 Feb 07 |
jari |
1985 |
numNeighborsText = Integer.toString(numGenes); |
2 |
26 Feb 07 |
jari |
1986 |
} |
2 |
26 Feb 07 |
jari |
1987 |
numNeighborsField = new JTextField(numNeighborsText, 7); |
2 |
26 Feb 07 |
jari |
1988 |
numNeighborsLabel = new JLabel("Number of neighbors: "); |
2 |
26 Feb 07 |
jari |
1989 |
kNearestButton = new JRadioButton("K-nearest neighbors imputer", true); |
2 |
26 Feb 07 |
jari |
1990 |
kNearestButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1991 |
kNearestButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1992 |
kNearestButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1993 |
rowAverageButton = new JRadioButton("Row average imputer ", false); |
2 |
26 Feb 07 |
jari |
1994 |
rowAverageButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1995 |
rowAverageButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1996 |
rowAverageButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1997 |
kNearestButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1998 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1999 |
numNeighborsLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2000 |
numNeighborsField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2001 |
numNeighborsField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
2002 |
numNeighborsField.setText(numNeighborsText); |
2 |
26 Feb 07 |
jari |
2003 |
} |
2 |
26 Feb 07 |
jari |
2004 |
}); |
2 |
26 Feb 07 |
jari |
2005 |
|
2 |
26 Feb 07 |
jari |
2006 |
rowAverageButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
2007 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
2008 |
numNeighborsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2009 |
numNeighborsField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2010 |
numNeighborsField.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
2011 |
numNeighborsField.setText(""); |
2 |
26 Feb 07 |
jari |
2012 |
} |
2 |
26 Feb 07 |
jari |
2013 |
}); |
2 |
26 Feb 07 |
jari |
2014 |
ButtonGroup chooseKOrRowAvg = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
2015 |
chooseKOrRowAvg.add(kNearestButton); |
2 |
26 Feb 07 |
jari |
2016 |
chooseKOrRowAvg.add(rowAverageButton); |
2 |
26 Feb 07 |
jari |
2017 |
|
2 |
26 Feb 07 |
jari |
2018 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
2019 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
2020 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
2021 |
|
2 |
26 Feb 07 |
jari |
//buildConstraints(constraints, 0, 0, 1, 1, 100, 25); |
2 |
26 Feb 07 |
jari |
2023 |
buildConstraints(constraints, 0, 0, 1, 1, 40, 50); |
2 |
26 Feb 07 |
jari |
2024 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
2025 |
gridbag.setConstraints(kNearestButton, constraints); |
2 |
26 Feb 07 |
jari |
2026 |
this.add(kNearestButton); |
2 |
26 Feb 07 |
jari |
2027 |
|
2 |
26 Feb 07 |
jari |
2028 |
|
2 |
26 Feb 07 |
jari |
2029 |
|
2 |
26 Feb 07 |
jari |
2030 |
buildConstraints(constraints, 1, 0, 1, 1, 30, 0); |
2 |
26 Feb 07 |
jari |
2031 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
2032 |
gridbag.setConstraints(numNeighborsLabel, constraints); |
2 |
26 Feb 07 |
jari |
2033 |
this.add(numNeighborsLabel); |
2 |
26 Feb 07 |
jari |
2034 |
|
2 |
26 Feb 07 |
jari |
2035 |
|
2 |
26 Feb 07 |
jari |
2036 |
buildConstraints(constraints, 2, 0, 1, 1, 30, 0); |
2 |
26 Feb 07 |
jari |
2037 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
2038 |
gridbag.setConstraints(numNeighborsField, constraints); |
2 |
26 Feb 07 |
jari |
2039 |
this.add(numNeighborsField); |
2 |
26 Feb 07 |
jari |
2040 |
|
2 |
26 Feb 07 |
jari |
2041 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
2042 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
2043 |
gridbag.setConstraints(rowAverageButton, constraints); |
2 |
26 Feb 07 |
jari |
2044 |
this.add(rowAverageButton); |
2 |
26 Feb 07 |
jari |
2045 |
|
2 |
26 Feb 07 |
jari |
2046 |
buildConstraints(constraints, 1, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
// constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
2048 |
JPanel dummy = new JPanel(); |
2 |
26 Feb 07 |
jari |
2049 |
dummy.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
2050 |
gridbag.setConstraints(dummy, constraints); |
2 |
26 Feb 07 |
jari |
2051 |
this.add(dummy); |
2 |
26 Feb 07 |
jari |
2052 |
|
2 |
26 Feb 07 |
jari |
2053 |
buildConstraints(constraints, 2, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
// constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
2055 |
gridbag.setConstraints(dummy, constraints); |
2 |
26 Feb 07 |
jari |
2056 |
this.add(dummy); |
2 |
26 Feb 07 |
jari |
2057 |
|
2 |
26 Feb 07 |
jari |
2058 |
|
2 |
26 Feb 07 |
jari |
2059 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
2060 |
buildConstraints(constraints, 0, 2, 3, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
2061 |
saveMatrixChkBox = new JCheckBox("Save Imputed Matrix", false); |
2 |
26 Feb 07 |
jari |
2062 |
saveMatrixChkBox.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
2063 |
saveMatrixChkBox.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
2064 |
saveMatrixChkBox.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
2065 |
gridbag.setConstraints(saveMatrixChkBox, constraints); |
2 |
26 Feb 07 |
jari |
2066 |
this.add(saveMatrixChkBox); |
2 |
26 Feb 07 |
jari |
2067 |
} |
2 |
26 Feb 07 |
jari |
2068 |
|
2 |
26 Feb 07 |
jari |
2069 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
2070 |
this.numNeighborsField.setText(this.numNeighborsText); |
2 |
26 Feb 07 |
jari |
2071 |
this.numNeighborsField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
2072 |
this.numNeighborsField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2073 |
this.kNearestButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
2074 |
this.saveMatrixChkBox.setSelected(false); |
2 |
26 Feb 07 |
jari |
2075 |
} |
2 |
26 Feb 07 |
jari |
2076 |
} |
2 |
26 Feb 07 |
jari |
2077 |
|
2 |
26 Feb 07 |
jari |
2078 |
|
2 |
26 Feb 07 |
jari |
2079 |
class OKCancelPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
2080 |
JButton okButton, cancelButton; |
2 |
26 Feb 07 |
jari |
2081 |
JCheckBox drawTreesBox; |
2 |
26 Feb 07 |
jari |
2082 |
|
2 |
26 Feb 07 |
jari |
2083 |
OKCancelPanel() { |
2 |
26 Feb 07 |
jari |
2084 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
2085 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
2086 |
drawTreesBox = new JCheckBox("Draw Hierarchical Trees"); |
2 |
26 Feb 07 |
jari |
2087 |
|
2 |
26 Feb 07 |
jari |
2088 |
okButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
2089 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
2090 |
if (getStudyDesign() == SAMInitDialog.TWO_CLASS_UNPAIRED) { |
2 |
26 Feb 07 |
jari |
// if (evt.getSource() == okButton) { |
2 |
26 Feb 07 |
jari |
2092 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
2093 |
int grpACounter = 0; |
2 |
26 Feb 07 |
jari |
2094 |
int grpBCounter = 0; |
2 |
26 Feb 07 |
jari |
2095 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2096 |
if (grpAssignments[i] == GROUP_A) { |
2 |
26 Feb 07 |
jari |
2097 |
grpACounter++; |
2 |
26 Feb 07 |
jari |
2098 |
} else if (grpAssignments[i] == GROUP_B) { |
2 |
26 Feb 07 |
jari |
2099 |
grpBCounter++; |
2 |
26 Feb 07 |
jari |
2100 |
} |
2 |
26 Feb 07 |
jari |
2101 |
} |
2 |
26 Feb 07 |
jari |
2102 |
if ((grpACounter < 2) || (grpBCounter < 2)) { |
2 |
26 Feb 07 |
jari |
2103 |
JOptionPane.showMessageDialog(null, "Group A and Group B must contain more than one sample", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2104 |
} /*else if ((Integer.parseInt(iPanel.numNeighborsField.getText()) > numGenes) || (Integer.parseInt(iPanel.numNeighborsField.getText()) <= 0)) { |
2 |
26 Feb 07 |
jari |
JOptionPane.showMessageDialog(null, "Number of neighbors must be > 0, and <= the total number of genes", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
} else if (Integer.parseInt(pPanel.numPermsInputField.getText()) < 0) { |
2 |
26 Feb 07 |
jari |
JOptionPane.showMessageDialog(null, "Number of permutations must be > 0", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2108 |
} */else { |
2 |
26 Feb 07 |
jari |
2109 |
try { |
2 |
26 Feb 07 |
jari |
2110 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2112 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2113 |
//} |
2 |
26 Feb 07 |
jari |
2114 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2115 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2116 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2117 |
} |
2 |
26 Feb 07 |
jari |
2118 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2119 |
dispose(); |
2 |
26 Feb 07 |
jari |
2120 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2121 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2122 |
} |
2 |
26 Feb 07 |
jari |
2123 |
|
2 |
26 Feb 07 |
jari |
//okPressed = true; |
2 |
26 Feb 07 |
jari |
//hide(); |
2 |
26 Feb 07 |
jari |
//dispose(); |
2 |
26 Feb 07 |
jari |
2127 |
} |
2 |
26 Feb 07 |
jari |
2128 |
// } |
2 |
26 Feb 07 |
jari |
2129 |
} else if (getStudyDesign() == SAMInitDialog.MULTI_CLASS) { |
2 |
26 Feb 07 |
jari |
2130 |
boolean tooFew = false; |
2 |
26 Feb 07 |
jari |
2131 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
2132 |
int numGroups = getMultiClassNumGroups(); |
2 |
26 Feb 07 |
jari |
2133 |
int[] groupSize = new int[numGroups]; |
2 |
26 Feb 07 |
jari |
2134 |
|
2 |
26 Feb 07 |
jari |
2135 |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
2136 |
groupSize[i] = 0; |
2 |
26 Feb 07 |
jari |
2137 |
} |
2 |
26 Feb 07 |
jari |
2138 |
|
2 |
26 Feb 07 |
jari |
2139 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2140 |
int currentGroup = grpAssignments[i]; |
2 |
26 Feb 07 |
jari |
2141 |
if (currentGroup != 0) { |
2 |
26 Feb 07 |
jari |
2142 |
groupSize[currentGroup - 1]++; |
2 |
26 Feb 07 |
jari |
2143 |
} |
2 |
26 Feb 07 |
jari |
2144 |
} |
2 |
26 Feb 07 |
jari |
2145 |
|
2 |
26 Feb 07 |
jari |
2146 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
System.out.println("grpAssignments[" + i + "] = " + grpAssignments[i]); |
2 |
26 Feb 07 |
jari |
2149 |
} |
2 |
26 Feb 07 |
jari |
2150 |
|
2 |
26 Feb 07 |
jari |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
System.out.println("groupSize[" + i + "] = " + groupSize[i] + " (group " + (i +1) + ")"); |
2 |
26 Feb 07 |
jari |
2153 |
} |
2 |
26 Feb 07 |
jari |
2154 |
*/ |
2 |
26 Feb 07 |
jari |
2155 |
|
2 |
26 Feb 07 |
jari |
2156 |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
2157 |
if (groupSize[i] <= 1) { |
2 |
26 Feb 07 |
jari |
2158 |
JOptionPane.showMessageDialog(null, "Each group must contain more than one sample.", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2159 |
tooFew = true; |
2 |
26 Feb 07 |
jari |
2160 |
break; |
2 |
26 Feb 07 |
jari |
2161 |
} |
2 |
26 Feb 07 |
jari |
2162 |
} |
2 |
26 Feb 07 |
jari |
2163 |
|
2 |
26 Feb 07 |
jari |
2164 |
if (!tooFew) { |
2 |
26 Feb 07 |
jari |
2165 |
try { |
2 |
26 Feb 07 |
jari |
2166 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2168 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2169 |
//} |
2 |
26 Feb 07 |
jari |
2170 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2171 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2172 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2173 |
} |
2 |
26 Feb 07 |
jari |
2174 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2175 |
dispose(); |
2 |
26 Feb 07 |
jari |
2176 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2177 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2178 |
} |
2 |
26 Feb 07 |
jari |
2179 |
} |
2 |
26 Feb 07 |
jari |
2180 |
} else if (getStudyDesign() == SAMInitDialog.CENSORED_SURVIVAL) { |
2 |
26 Feb 07 |
jari |
2181 |
try { |
2 |
26 Feb 07 |
jari |
2182 |
boolean allSame = true; |
2 |
26 Feb 07 |
jari |
2183 |
int selectedCounter = 0; |
2 |
26 Feb 07 |
jari |
2184 |
double previousTime = 0; |
2 |
26 Feb 07 |
jari |
2185 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
2186 |
if (csPanel.fields[i].inAnalysisCheckBox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2187 |
selectedCounter++; |
2 |
26 Feb 07 |
jari |
2188 |
double d = (new Double(csPanel.fields[i].timeInputField.getText())).doubleValue(); |
2 |
26 Feb 07 |
jari |
2189 |
if (i > 0) { |
2 |
26 Feb 07 |
jari |
2190 |
if (previousTime != d) { |
2 |
26 Feb 07 |
jari |
2191 |
allSame = false; |
2 |
26 Feb 07 |
jari |
2192 |
} |
2 |
26 Feb 07 |
jari |
2193 |
} |
2 |
26 Feb 07 |
jari |
2194 |
previousTime = d; |
2 |
26 Feb 07 |
jari |
2195 |
} |
2 |
26 Feb 07 |
jari |
2196 |
} |
2 |
26 Feb 07 |
jari |
2197 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2199 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2200 |
//} |
2 |
26 Feb 07 |
jari |
2201 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2202 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2203 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2204 |
} |
2 |
26 Feb 07 |
jari |
2205 |
if (selectedCounter < 2) { |
2 |
26 Feb 07 |
jari |
2206 |
JOptionPane.showMessageDialog(null, "At least 2 samples must be selected!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2207 |
} else if (allSame) { |
2 |
26 Feb 07 |
jari |
2208 |
JOptionPane.showMessageDialog(null, "At least one of the survival time values must be different from the rest!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2209 |
} else { |
2 |
26 Feb 07 |
jari |
2210 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2211 |
dispose(); |
2 |
26 Feb 07 |
jari |
2212 |
} |
2 |
26 Feb 07 |
jari |
2213 |
} catch (NumberFormatException nfe){ |
2 |
26 Feb 07 |
jari |
2214 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2215 |
} |
2 |
26 Feb 07 |
jari |
2216 |
} |
2 |
26 Feb 07 |
jari |
2217 |
} |
2 |
26 Feb 07 |
jari |
2218 |
}); |
2 |
26 Feb 07 |
jari |
2219 |
|
2 |
26 Feb 07 |
jari |
2220 |
cancelButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
2221 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
// if (evt.getSource() == cancelButton) { |
2 |
26 Feb 07 |
jari |
2223 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
//hide(); |
2 |
26 Feb 07 |
jari |
2225 |
dispose(); |
2 |
26 Feb 07 |
jari |
2226 |
// } |
2 |
26 Feb 07 |
jari |
2227 |
} |
2 |
26 Feb 07 |
jari |
2228 |
}); |
2 |
26 Feb 07 |
jari |
2229 |
|
2 |
26 Feb 07 |
jari |
2230 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
2231 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
2232 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
2234 |
buildConstraints(constraints, 0, 0, 2, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
2235 |
gridbag.setConstraints(drawTreesBox, constraints); |
2 |
26 Feb 07 |
jari |
2236 |
this.add(drawTreesBox); |
2 |
26 Feb 07 |
jari |
2237 |
|
2 |
26 Feb 07 |
jari |
2238 |
buildConstraints(constraints, 0, 1, 1, 1, 50, 50); |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
2240 |
gridbag.setConstraints(okButton, constraints); |
2 |
26 Feb 07 |
jari |
2241 |
this.add(okButton); |
2 |
26 Feb 07 |
jari |
2242 |
|
2 |
26 Feb 07 |
jari |
2243 |
buildConstraints(constraints, 1, 1, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
2245 |
gridbag.setConstraints(cancelButton, constraints); |
2 |
26 Feb 07 |
jari |
2246 |
this.add(cancelButton); |
2 |
26 Feb 07 |
jari |
2247 |
} |
2 |
26 Feb 07 |
jari |
2248 |
} |
2 |
26 Feb 07 |
jari |
2249 |
|
2 |
26 Feb 07 |
jari |
2250 |
|
2 |
26 Feb 07 |
jari |
2251 |
public int getStudyDesign() { |
2 |
26 Feb 07 |
jari |
2252 |
int studyDesign = TWO_CLASS_UNPAIRED; |
2 |
26 Feb 07 |
jari |
2253 |
if (tabPane.getSelectedIndex() == 0) { |
2 |
26 Feb 07 |
jari |
2254 |
studyDesign = TWO_CLASS_UNPAIRED; |
2 |
26 Feb 07 |
jari |
2255 |
} else if (tabPane.getSelectedIndex() == 1) { |
2 |
26 Feb 07 |
jari |
2256 |
studyDesign = SAMInitDialog.TWO_CLASS_PAIRED; |
2 |
26 Feb 07 |
jari |
2257 |
} else if (tabPane.getSelectedIndex() == 2) { |
2 |
26 Feb 07 |
jari |
2258 |
studyDesign = SAMInitDialog.MULTI_CLASS; |
2 |
26 Feb 07 |
jari |
2259 |
} else if (tabPane.getSelectedIndex() == 3) { |
2 |
26 Feb 07 |
jari |
2260 |
studyDesign = SAMInitDialog.CENSORED_SURVIVAL; |
2 |
26 Feb 07 |
jari |
2261 |
} else if (tabPane.getSelectedIndex() == 4) { |
2 |
26 Feb 07 |
jari |
2262 |
studyDesign = SAMInitDialog.ONE_CLASS; |
2 |
26 Feb 07 |
jari |
2263 |
} |
2 |
26 Feb 07 |
jari |
2264 |
return studyDesign; |
2 |
26 Feb 07 |
jari |
2265 |
} |
2 |
26 Feb 07 |
jari |
2266 |
|
2 |
26 Feb 07 |
jari |
2267 |
public int[] getGroupAssignments() { |
2 |
26 Feb 07 |
jari |
2268 |
int[] groupAssignments = new int[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
2269 |
if (getStudyDesign() == TWO_CLASS_UNPAIRED) { |
2 |
26 Feb 07 |
jari |
2270 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
2271 |
if (gPanel.groupARadioButtons[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
2272 |
groupAssignments[i] = GROUP_A; |
2 |
26 Feb 07 |
jari |
2273 |
} else if (gPanel.groupBRadioButtons[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
2274 |
groupAssignments[i] = GROUP_B; |
2 |
26 Feb 07 |
jari |
2275 |
} else { |
2 |
26 Feb 07 |
jari |
2276 |
groupAssignments[i] = NEITHER_GROUP; |
2 |
26 Feb 07 |
jari |
2277 |
} |
2 |
26 Feb 07 |
jari |
2278 |
} |
2 |
26 Feb 07 |
jari |
2279 |
} else if (getStudyDesign() == MULTI_CLASS) { // THAT "NOT IN GROUP" IS STORED AS ZERO, AND GROUP J IS STORED AS THE INTEGER J (I.E., THERE IS NO GROUP 0) |
2 |
26 Feb 07 |
jari |
2280 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
2281 |
if (mPanel.mulgPanel.notInGroupRadioButtons[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
2282 |
groupAssignments[i] = 0; |
2 |
26 Feb 07 |
jari |
2283 |
} else { |
2 |
26 Feb 07 |
jari |
2284 |
for (int j = 0; j < mPanel.mulgPanel.exptGroupRadioButtons.length; j++) { |
2 |
26 Feb 07 |
jari |
2285 |
if (mPanel.mulgPanel.exptGroupRadioButtons[j][i].isSelected()) { |
2 |
26 Feb 07 |
jari |
2286 |
groupAssignments[i] = j + 1; |
2 |
26 Feb 07 |
jari |
2287 |
break; |
2 |
26 Feb 07 |
jari |
2288 |
} |
2 |
26 Feb 07 |
jari |
2289 |
} |
2 |
26 Feb 07 |
jari |
2290 |
} |
2 |
26 Feb 07 |
jari |
2291 |
} |
2 |
26 Feb 07 |
jari |
2292 |
} else if (getStudyDesign() == ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
2293 |
return getOneClassAssignments(); |
2 |
26 Feb 07 |
jari |
2294 |
} |
2 |
26 Feb 07 |
jari |
2295 |
|
2 |
26 Feb 07 |
jari |
2296 |
return groupAssignments; |
2 |
26 Feb 07 |
jari |
2297 |
} |
2 |
26 Feb 07 |
jari |
2298 |
|
2 |
26 Feb 07 |
jari |
2299 |
public int[] getOneClassAssignments() { |
2 |
26 Feb 07 |
jari |
2300 |
int[] oneClassAssignments = new int[oneCPanel.includeExpts.length]; |
2 |
26 Feb 07 |
jari |
2301 |
|
2 |
26 Feb 07 |
jari |
2302 |
for (int i = 0; i < oneClassAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2303 |
if (oneCPanel.includeExpts[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
2304 |
oneClassAssignments[i] = 1; |
2 |
26 Feb 07 |
jari |
2305 |
} else { |
2 |
26 Feb 07 |
jari |
2306 |
oneClassAssignments[i] = 0; |
2 |
26 Feb 07 |
jari |
2307 |
} |
2 |
26 Feb 07 |
jari |
2308 |
} |
2 |
26 Feb 07 |
jari |
2309 |
|
2 |
26 Feb 07 |
jari |
2310 |
return oneClassAssignments; |
2 |
26 Feb 07 |
jari |
2311 |
} |
2 |
26 Feb 07 |
jari |
2312 |
|
2 |
26 Feb 07 |
jari |
2313 |
public double getOneClassMean() { |
2 |
26 Feb 07 |
jari |
2314 |
return Double.parseDouble(oneCPanel.meanField.getText()); |
2 |
26 Feb 07 |
jari |
2315 |
} |
2 |
26 Feb 07 |
jari |
2316 |
|
2 |
26 Feb 07 |
jari |
2317 |
public int getMultiClassNumGroups() { |
2 |
26 Feb 07 |
jari |
2318 |
return Integer.parseInt(mPanel.ngPanel.numGroupsField.getText()); |
2 |
26 Feb 07 |
jari |
2319 |
} |
2 |
26 Feb 07 |
jari |
2320 |
|
2 |
26 Feb 07 |
jari |
2321 |
public int getNumValidOneClassExpts() { |
2 |
26 Feb 07 |
jari |
2322 |
int validNum = 0; |
2 |
26 Feb 07 |
jari |
2323 |
int[] oca = getOneClassAssignments(); |
2 |
26 Feb 07 |
jari |
2324 |
|
2 |
26 Feb 07 |
jari |
2325 |
for (int i =0; i < oca.length; i++) { |
2 |
26 Feb 07 |
jari |
2326 |
if (oca[i] == 1) { |
2 |
26 Feb 07 |
jari |
2327 |
validNum++; |
2 |
26 Feb 07 |
jari |
2328 |
} |
2 |
26 Feb 07 |
jari |
2329 |
} |
2 |
26 Feb 07 |
jari |
2330 |
|
2 |
26 Feb 07 |
jari |
2331 |
return validNum; |
2 |
26 Feb 07 |
jari |
2332 |
} |
2 |
26 Feb 07 |
jari |
2333 |
|
2 |
26 Feb 07 |
jari |
2334 |
|
2 |
26 Feb 07 |
jari |
2335 |
public int[] getGroupCount() { |
2 |
26 Feb 07 |
jari |
2336 |
int[] groupAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
2337 |
int groupACount = 0; |
2 |
26 Feb 07 |
jari |
2338 |
int groupBCount = 0; |
2 |
26 Feb 07 |
jari |
2339 |
|
2 |
26 Feb 07 |
jari |
2340 |
for (int i = 0; i < groupAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2341 |
if (groupAssignments[i] == GROUP_A) { |
2 |
26 Feb 07 |
jari |
2342 |
groupACount++; |
2 |
26 Feb 07 |
jari |
2343 |
} else if (groupAssignments[i] == GROUP_B) { |
2 |
26 Feb 07 |
jari |
2344 |
groupBCount++; |
2 |
26 Feb 07 |
jari |
2345 |
} |
2 |
26 Feb 07 |
jari |
2346 |
} |
2 |
26 Feb 07 |
jari |
2347 |
|
2 |
26 Feb 07 |
jari |
2348 |
int[] groupCount = new int[2]; |
2 |
26 Feb 07 |
jari |
2349 |
groupCount[0] = groupACount; |
2 |
26 Feb 07 |
jari |
2350 |
groupCount[1] = groupBCount; |
2 |
26 Feb 07 |
jari |
2351 |
|
2 |
26 Feb 07 |
jari |
2352 |
return groupCount; |
2 |
26 Feb 07 |
jari |
2353 |
} |
2 |
26 Feb 07 |
jari |
2354 |
|
2 |
26 Feb 07 |
jari |
2355 |
public boolean[] isInSurvivalAnalysis() { |
2 |
26 Feb 07 |
jari |
2356 |
boolean[] inAnalysis = new boolean[csPanel.fields.length]; |
2 |
26 Feb 07 |
jari |
2357 |
for (int i = 0; i < inAnalysis.length; i++) { |
2 |
26 Feb 07 |
jari |
2358 |
if (csPanel.fields[i].inAnalysisCheckBox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2359 |
inAnalysis[i] = true; |
2 |
26 Feb 07 |
jari |
2360 |
} else { |
2 |
26 Feb 07 |
jari |
2361 |
inAnalysis[i] = false; |
2 |
26 Feb 07 |
jari |
2362 |
} |
2 |
26 Feb 07 |
jari |
2363 |
} |
2 |
26 Feb 07 |
jari |
2364 |
return inAnalysis; |
2 |
26 Feb 07 |
jari |
2365 |
} |
2 |
26 Feb 07 |
jari |
2366 |
|
2 |
26 Feb 07 |
jari |
2367 |
public double[] getSurvivalTimes() { |
2 |
26 Feb 07 |
jari |
2368 |
double[] survivalTimes = new double[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
2369 |
for (int i = 0; i < survivalTimes.length; i++) { |
2 |
26 Feb 07 |
jari |
2370 |
try { |
2 |
26 Feb 07 |
jari |
2371 |
String s = csPanel.fields[i].timeInputField.getText(); |
2 |
26 Feb 07 |
jari |
2372 |
double d = (new Double(s)).doubleValue(); |
2 |
26 Feb 07 |
jari |
2373 |
survivalTimes[i] = d; |
2 |
26 Feb 07 |
jari |
//System.out.println("SAMInitDialog.getSurvivalTimes(): i = " + i + ", s = " + s + ", d = " + d); |
2 |
26 Feb 07 |
jari |
2375 |
} catch (NumberFormatException nfe){ |
2 |
26 Feb 07 |
jari |
//nfe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
2377 |
survivalTimes[i] = 0; |
2 |
26 Feb 07 |
jari |
2378 |
} |
2 |
26 Feb 07 |
jari |
2379 |
} |
2 |
26 Feb 07 |
jari |
2380 |
return survivalTimes; |
2 |
26 Feb 07 |
jari |
2381 |
} |
2 |
26 Feb 07 |
jari |
2382 |
|
2 |
26 Feb 07 |
jari |
2383 |
public boolean[] isCensored() { |
2 |
26 Feb 07 |
jari |
2384 |
boolean[] censored = new boolean[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
2385 |
for (int i = 0; i < censored.length; i++) { |
2 |
26 Feb 07 |
jari |
2386 |
if (csPanel.fields[i].censoredRadioButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2387 |
censored[i] = true; |
2 |
26 Feb 07 |
jari |
2388 |
} else { |
2 |
26 Feb 07 |
jari |
2389 |
censored[i] = false; |
2 |
26 Feb 07 |
jari |
2390 |
} |
2 |
26 Feb 07 |
jari |
2391 |
} |
2 |
26 Feb 07 |
jari |
2392 |
return censored; |
2 |
26 Feb 07 |
jari |
2393 |
} |
2 |
26 Feb 07 |
jari |
2394 |
|
2 |
26 Feb 07 |
jari |
2395 |
public Vector getPairedAExpts() { |
2 |
26 Feb 07 |
jari |
2396 |
return tcpmPanel.tcpPanel.pairedAExpts; |
2 |
26 Feb 07 |
jari |
2397 |
} |
2 |
26 Feb 07 |
jari |
2398 |
|
2 |
26 Feb 07 |
jari |
2399 |
public Vector getPairedBExpts() { |
2 |
26 Feb 07 |
jari |
2400 |
return tcpmPanel.tcpPanel.pairedBExpts; |
2 |
26 Feb 07 |
jari |
2401 |
} |
2 |
26 Feb 07 |
jari |
2402 |
|
2 |
26 Feb 07 |
jari |
2403 |
private long factorial(int n) { |
2 |
26 Feb 07 |
jari |
2404 |
if ((n==1) || (n == 0)) { |
2 |
26 Feb 07 |
jari |
2405 |
return 1; |
2 |
26 Feb 07 |
jari |
2406 |
} |
2 |
26 Feb 07 |
jari |
2407 |
else { |
2 |
26 Feb 07 |
jari |
2408 |
return factorial(n-1) * n; |
2 |
26 Feb 07 |
jari |
2409 |
} |
2 |
26 Feb 07 |
jari |
2410 |
} |
2 |
26 Feb 07 |
jari |
2411 |
|
2 |
26 Feb 07 |
jari |
2412 |
private int getNumCombs(int n, int k) { // nCk |
2 |
26 Feb 07 |
jari |
2413 |
|
2 |
26 Feb 07 |
jari |
2414 |
/* |
2 |
26 Feb 07 |
jari |
System.out.println("n = " + n); |
2 |
26 Feb 07 |
jari |
System.out.println("k = " + k); |
2 |
26 Feb 07 |
jari |
System.out.println("Numerator: factorial(n) = " + factorial(n)); |
2 |
26 Feb 07 |
jari |
System.out.println("factorial(k) = " + factorial(k)); |
2 |
26 Feb 07 |
jari |
System.out.println("factorial(n-k) = " + factorial(n-k)); |
2 |
26 Feb 07 |
jari |
2420 |
*/ |
2 |
26 Feb 07 |
jari |
2421 |
return Math.round(factorial(n)/(factorial(k)*factorial(n-k))); |
2 |
26 Feb 07 |
jari |
2422 |
} |
2 |
26 Feb 07 |
jari |
2423 |
|
2 |
26 Feb 07 |
jari |
2424 |
public int getNumNeighbors() { |
2 |
26 Feb 07 |
jari |
2425 |
String s = iPanel.numNeighborsField.getText(); |
2 |
26 Feb 07 |
jari |
2426 |
return Integer.parseInt(s); |
2 |
26 Feb 07 |
jari |
2427 |
} |
2 |
26 Feb 07 |
jari |
2428 |
|
2 |
26 Feb 07 |
jari |
2429 |
public int getUserNumCombs() { |
2 |
26 Feb 07 |
jari |
2430 |
String s = pPanel.numPermsInputField.getText(); |
2 |
26 Feb 07 |
jari |
2431 |
return Integer.parseInt(s); |
2 |
26 Feb 07 |
jari |
2432 |
} |
2 |
26 Feb 07 |
jari |
2433 |
|
2 |
26 Feb 07 |
jari |
2434 |
|
2 |
26 Feb 07 |
jari |
2435 |
public boolean useKNearest() { |
2 |
26 Feb 07 |
jari |
2436 |
return iPanel.kNearestButton.isSelected(); |
2 |
26 Feb 07 |
jari |
2437 |
} |
2 |
26 Feb 07 |
jari |
2438 |
|
2 |
26 Feb 07 |
jari |
2439 |
/* |
2 |
26 Feb 07 |
jari |
public boolean useAllCombs() { |
2 |
26 Feb 07 |
jari |
return pPanel.useAllPermsButton.isSelected(); |
2 |
26 Feb 07 |
jari |
2442 |
} |
2 |
26 Feb 07 |
jari |
2443 |
*/ |
2 |
26 Feb 07 |
jari |
2444 |
|
2 |
26 Feb 07 |
jari |
2445 |
public boolean drawTrees() { |
2 |
26 Feb 07 |
jari |
2446 |
return this.hclOpsPanel.isHCLSelected(); |
2 |
26 Feb 07 |
jari |
2447 |
} |
2 |
26 Feb 07 |
jari |
2448 |
|
2 |
26 Feb 07 |
jari |
2449 |
public boolean drawSigTreesOnly() { |
2 |
26 Feb 07 |
jari |
2450 |
return hclOpsPanel.drawSigTreesOnly(); |
2 |
26 Feb 07 |
jari |
2451 |
} |
2 |
26 Feb 07 |
jari |
2452 |
|
2 |
26 Feb 07 |
jari |
2453 |
public boolean useTusherEtAlS0() { |
2 |
26 Feb 07 |
jari |
2454 |
if (sqPanel.s0SelectBox.getSelectedIndex() == 0) { |
2 |
26 Feb 07 |
jari |
2455 |
return true; |
2 |
26 Feb 07 |
jari |
2456 |
} else { |
2 |
26 Feb 07 |
jari |
2457 |
return false; |
2 |
26 Feb 07 |
jari |
2458 |
} |
2 |
26 Feb 07 |
jari |
2459 |
} |
2 |
26 Feb 07 |
jari |
2460 |
|
2 |
26 Feb 07 |
jari |
2461 |
public double getPercentile() { |
2 |
26 Feb 07 |
jari |
2462 |
if (sqPanel.s0SelectButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2463 |
int index = sqPanel.s0SelectBox.getSelectedIndex(); |
2 |
26 Feb 07 |
jari |
2464 |
if (index == 0) { |
2 |
26 Feb 07 |
jari |
2465 |
return -1d; |
2 |
26 Feb 07 |
jari |
2466 |
} else if (index == 1) { |
2 |
26 Feb 07 |
jari |
2467 |
return 5d; |
2 |
26 Feb 07 |
jari |
2468 |
} else if (index == 2) { |
2 |
26 Feb 07 |
jari |
2469 |
return 50d; |
2 |
26 Feb 07 |
jari |
2470 |
} else if (index == 3) { |
2 |
26 Feb 07 |
jari |
2471 |
return 90d; |
2 |
26 Feb 07 |
jari |
2472 |
} else if (index == 4) { |
2 |
26 Feb 07 |
jari |
2473 |
return 0d; |
2 |
26 Feb 07 |
jari |
2474 |
} |
2 |
26 Feb 07 |
jari |
2475 |
} else { |
2 |
26 Feb 07 |
jari |
2476 |
return Double.parseDouble(sqPanel.s0EntryField.getText()); |
2 |
26 Feb 07 |
jari |
2477 |
} |
2 |
26 Feb 07 |
jari |
2478 |
return 0d; |
2 |
26 Feb 07 |
jari |
2479 |
} |
2 |
26 Feb 07 |
jari |
2480 |
|
2 |
26 Feb 07 |
jari |
2481 |
public boolean calculateQLowestFDR() { |
2 |
26 Feb 07 |
jari |
2482 |
if (sqPanel.qYesButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
2483 |
return true; |
2 |
26 Feb 07 |
jari |
2484 |
} else { |
2 |
26 Feb 07 |
jari |
2485 |
return false; |
2 |
26 Feb 07 |
jari |
2486 |
} |
2 |
26 Feb 07 |
jari |
2487 |
} |
2 |
26 Feb 07 |
jari |
2488 |
|
2 |
26 Feb 07 |
jari |
2489 |
public int getNumUniquePerms() { |
2 |
26 Feb 07 |
jari |
2490 |
return this.numUniquePerms; |
2 |
26 Feb 07 |
jari |
2491 |
} |
2 |
26 Feb 07 |
jari |
2492 |
|
2 |
26 Feb 07 |
jari |
2493 |
public boolean useAllUniquePerms() { |
2 |
26 Feb 07 |
jari |
2494 |
return this.allUniquePermsUsed; |
2 |
26 Feb 07 |
jari |
2495 |
} |
2 |
26 Feb 07 |
jari |
2496 |
|
2 |
26 Feb 07 |
jari |
2497 |
private int getNumUnique2ClassUnpairedPerms(int n, int k) { // nCk |
2 |
26 Feb 07 |
jari |
2498 |
return Math.round(factorial(n)/(factorial(k)*factorial(n-k))); |
2 |
26 Feb 07 |
jari |
2499 |
} |
2 |
26 Feb 07 |
jari |
2500 |
|
2 |
26 Feb 07 |
jari |
2501 |
|
2 |
26 Feb 07 |
jari |
2502 |
public class EventListener extends WindowAdapter implements ActionListener{ |
2 |
26 Feb 07 |
jari |
2503 |
public void actionPerformed(ActionEvent ae){ |
2 |
26 Feb 07 |
jari |
2504 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
2505 |
if(command.equals("ok-command")){ |
2 |
26 Feb 07 |
jari |
2506 |
try { |
2 |
26 Feb 07 |
jari |
2507 |
if (sqPanel.s0EntryButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2508 |
double d = Double.parseDouble(sqPanel.s0EntryField.getText()); |
2 |
26 Feb 07 |
jari |
2509 |
if ((d < 0)||(d > 100)) { |
2 |
26 Feb 07 |
jari |
2510 |
JOptionPane.showMessageDialog(null, "Enter a valid percentile between 0 and 100!", "Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2511 |
return; |
2 |
26 Feb 07 |
jari |
2512 |
} |
2 |
26 Feb 07 |
jari |
2513 |
} |
2 |
26 Feb 07 |
jari |
2514 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2515 |
JOptionPane.showMessageDialog(null, "Enter a valid percentile between 0 and 100!", "Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2516 |
return; |
2 |
26 Feb 07 |
jari |
2517 |
} |
2 |
26 Feb 07 |
jari |
2518 |
|
2 |
26 Feb 07 |
jari |
2519 |
try { |
2 |
26 Feb 07 |
jari |
2520 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2522 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2523 |
//} |
2 |
26 Feb 07 |
jari |
2524 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2525 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2526 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2527 |
} |
2 |
26 Feb 07 |
jari |
2528 |
|
2 |
26 Feb 07 |
jari |
2529 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2530 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2531 |
return; |
2 |
26 Feb 07 |
jari |
2532 |
} |
2 |
26 Feb 07 |
jari |
2533 |
if (getStudyDesign() == SAMInitDialog.TWO_CLASS_UNPAIRED) { |
2 |
26 Feb 07 |
jari |
// if (evt.getSource() == okButton) { |
2 |
26 Feb 07 |
jari |
2535 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
2536 |
int grpACounter = 0; |
2 |
26 Feb 07 |
jari |
2537 |
int grpBCounter = 0; |
2 |
26 Feb 07 |
jari |
2538 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2539 |
if (grpAssignments[i] == GROUP_A) { |
2 |
26 Feb 07 |
jari |
2540 |
grpACounter++; |
2 |
26 Feb 07 |
jari |
2541 |
} else if (grpAssignments[i] == GROUP_B) { |
2 |
26 Feb 07 |
jari |
2542 |
grpBCounter++; |
2 |
26 Feb 07 |
jari |
2543 |
} |
2 |
26 Feb 07 |
jari |
2544 |
} |
2 |
26 Feb 07 |
jari |
2545 |
if ((grpACounter < 2) || (grpBCounter < 2)) { |
2 |
26 Feb 07 |
jari |
2546 |
JOptionPane.showMessageDialog(null, "Group A and Group B must contain more than one sample.", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2547 |
} /*else if ((Integer.parseInt(iPanel.numNeighborsField.getText()) > numGenes) || (Integer.parseInt(iPanel.numNeighborsField.getText()) <= 0)) { |
2 |
26 Feb 07 |
jari |
JOptionPane.showMessageDialog(null, "Number of neighbors must be > 0, and <= the total number of genes", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
} else if (Integer.parseInt(pPanel.numPermsInputField.getText()) < 0) { |
2 |
26 Feb 07 |
jari |
JOptionPane.showMessageDialog(null, "Number of permutations must be > 0", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2551 |
} */else { |
2 |
26 Feb 07 |
jari |
2552 |
try { |
2 |
26 Feb 07 |
jari |
2553 |
|
2 |
26 Feb 07 |
jari |
2554 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2556 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2557 |
//} |
2 |
26 Feb 07 |
jari |
2558 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2559 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2560 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2561 |
} |
2 |
26 Feb 07 |
jari |
2562 |
|
2 |
26 Feb 07 |
jari |
2563 |
if ((grpACounter + grpBCounter) <= 20) { |
2 |
26 Feb 07 |
jari |
2564 |
numUniquePerms = getNumUnique2ClassUnpairedPerms((grpACounter + grpBCounter), grpACounter); |
2 |
26 Feb 07 |
jari |
2565 |
SAMAllPermsDialog sapDialog = new SAMAllPermsDialog(SAMGUI.SAMFrame, true, numUniquePerms, numCombs); |
2 |
26 Feb 07 |
jari |
2566 |
sapDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
2567 |
allUniquePermsUsed = sapDialog.useAllPerms(); |
2 |
26 Feb 07 |
jari |
2568 |
} |
2 |
26 Feb 07 |
jari |
2569 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2570 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2571 |
|
2 |
26 Feb 07 |
jari |
2572 |
dispose(); |
2 |
26 Feb 07 |
jari |
2573 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2574 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2575 |
} |
2 |
26 Feb 07 |
jari |
2576 |
|
2 |
26 Feb 07 |
jari |
//okPressed = true; |
2 |
26 Feb 07 |
jari |
//hide(); |
2 |
26 Feb 07 |
jari |
//dispose(); |
2 |
26 Feb 07 |
jari |
2580 |
} |
2 |
26 Feb 07 |
jari |
2581 |
// } |
2 |
26 Feb 07 |
jari |
2582 |
} else if (getStudyDesign() == SAMInitDialog.TWO_CLASS_PAIRED) { |
2 |
26 Feb 07 |
jari |
2583 |
if (tcpmPanel.tcpPanel.pairedListModel.size() < 2) { |
2 |
26 Feb 07 |
jari |
2584 |
JOptionPane.showMessageDialog(null, "Need at least two pairs of samples!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2585 |
} else { |
2 |
26 Feb 07 |
jari |
2586 |
if (tcpmPanel.tcpPanel.pairedListModel.size() <= 29) { |
2 |
26 Feb 07 |
jari |
2587 |
int numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2588 |
numUniquePerms = (int)(Math.pow(2, tcpmPanel.tcpPanel.pairedListModel.size())); |
2 |
26 Feb 07 |
jari |
2589 |
SAMAllPermsDialog sapDialog = new SAMAllPermsDialog(SAMGUI.SAMFrame, true, numUniquePerms, numCombs); |
2 |
26 Feb 07 |
jari |
2590 |
sapDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
2591 |
allUniquePermsUsed = sapDialog.useAllPerms(); |
2 |
26 Feb 07 |
jari |
2592 |
} |
2 |
26 Feb 07 |
jari |
2593 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2594 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2595 |
dispose(); |
2 |
26 Feb 07 |
jari |
2596 |
} |
2 |
26 Feb 07 |
jari |
2597 |
|
2 |
26 Feb 07 |
jari |
2598 |
} else if (getStudyDesign() == SAMInitDialog.MULTI_CLASS) { |
2 |
26 Feb 07 |
jari |
2599 |
boolean tooFew = false; |
2 |
26 Feb 07 |
jari |
2600 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
2601 |
int numGroups = getMultiClassNumGroups(); |
2 |
26 Feb 07 |
jari |
2602 |
int[] groupSize = new int[numGroups]; |
2 |
26 Feb 07 |
jari |
2603 |
|
2 |
26 Feb 07 |
jari |
2604 |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
2605 |
groupSize[i] = 0; |
2 |
26 Feb 07 |
jari |
2606 |
} |
2 |
26 Feb 07 |
jari |
2607 |
|
2 |
26 Feb 07 |
jari |
2608 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2609 |
int currentGroup = grpAssignments[i]; |
2 |
26 Feb 07 |
jari |
2610 |
if (currentGroup != 0) { |
2 |
26 Feb 07 |
jari |
2611 |
groupSize[currentGroup - 1]++; |
2 |
26 Feb 07 |
jari |
2612 |
} |
2 |
26 Feb 07 |
jari |
2613 |
} |
2 |
26 Feb 07 |
jari |
2614 |
|
2 |
26 Feb 07 |
jari |
2615 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
System.out.println("grpAssignments[" + i + "] = " + grpAssignments[i]); |
2 |
26 Feb 07 |
jari |
2618 |
} |
2 |
26 Feb 07 |
jari |
2619 |
|
2 |
26 Feb 07 |
jari |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
System.out.println("groupSize[" + i + "] = " + groupSize[i] + " (group " + (i +1) + ")"); |
2 |
26 Feb 07 |
jari |
2622 |
} |
2 |
26 Feb 07 |
jari |
2623 |
*/ |
2 |
26 Feb 07 |
jari |
2624 |
|
2 |
26 Feb 07 |
jari |
2625 |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
2626 |
if (groupSize[i] <= 1) { |
2 |
26 Feb 07 |
jari |
2627 |
JOptionPane.showMessageDialog(null, "Each group must contain more than one sample.", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2628 |
tooFew = true; |
2 |
26 Feb 07 |
jari |
2629 |
break; |
2 |
26 Feb 07 |
jari |
2630 |
} |
2 |
26 Feb 07 |
jari |
2631 |
} |
2 |
26 Feb 07 |
jari |
2632 |
|
2 |
26 Feb 07 |
jari |
2633 |
if (!tooFew) { |
2 |
26 Feb 07 |
jari |
2634 |
try { |
2 |
26 Feb 07 |
jari |
2635 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2637 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2638 |
//} |
2 |
26 Feb 07 |
jari |
2639 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2640 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2641 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2642 |
} |
2 |
26 Feb 07 |
jari |
2643 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2644 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2645 |
|
2 |
26 Feb 07 |
jari |
2646 |
dispose(); |
2 |
26 Feb 07 |
jari |
2647 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2648 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2649 |
} |
2 |
26 Feb 07 |
jari |
2650 |
} |
2 |
26 Feb 07 |
jari |
2651 |
|
2 |
26 Feb 07 |
jari |
2652 |
} else if (getStudyDesign() == SAMInitDialog.CENSORED_SURVIVAL) { |
2 |
26 Feb 07 |
jari |
2653 |
try { |
2 |
26 Feb 07 |
jari |
2654 |
boolean allSame = true; |
2 |
26 Feb 07 |
jari |
2655 |
int selectedCounter = 0; |
2 |
26 Feb 07 |
jari |
2656 |
double previousTime = 0; |
2 |
26 Feb 07 |
jari |
2657 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
2658 |
if (csPanel.fields[i].inAnalysisCheckBox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2659 |
selectedCounter++; |
2 |
26 Feb 07 |
jari |
2660 |
double d = (new Double(csPanel.fields[i].timeInputField.getText())).doubleValue(); |
2 |
26 Feb 07 |
jari |
2661 |
if (i > 0) { |
2 |
26 Feb 07 |
jari |
2662 |
if (previousTime != d) { |
2 |
26 Feb 07 |
jari |
2663 |
allSame = false; |
2 |
26 Feb 07 |
jari |
2664 |
} |
2 |
26 Feb 07 |
jari |
2665 |
} |
2 |
26 Feb 07 |
jari |
2666 |
previousTime = d; |
2 |
26 Feb 07 |
jari |
2667 |
} |
2 |
26 Feb 07 |
jari |
2668 |
} |
2 |
26 Feb 07 |
jari |
2669 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
//if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
2671 |
numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2672 |
//} |
2 |
26 Feb 07 |
jari |
2673 |
int numNeibs = 0; |
2 |
26 Feb 07 |
jari |
2674 |
if (useKNearest()) { |
2 |
26 Feb 07 |
jari |
2675 |
numNeibs = getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
2676 |
} |
2 |
26 Feb 07 |
jari |
2677 |
if (selectedCounter < 2) { |
2 |
26 Feb 07 |
jari |
2678 |
JOptionPane.showMessageDialog(null, "At least 2 samples must be selected!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2679 |
} else if (allSame) { |
2 |
26 Feb 07 |
jari |
2680 |
JOptionPane.showMessageDialog(null, "At least one of the survival time values must be different from the rest!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2681 |
} else { |
2 |
26 Feb 07 |
jari |
2682 |
if (selectedCounter <= 10) { |
2 |
26 Feb 07 |
jari |
2683 |
numUniquePerms = (int)(factorial(selectedCounter)); |
2 |
26 Feb 07 |
jari |
2684 |
SAMAllPermsDialog sapDialog = new SAMAllPermsDialog(SAMGUI.SAMFrame, true, numUniquePerms, numCombs); |
2 |
26 Feb 07 |
jari |
2685 |
sapDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
2686 |
allUniquePermsUsed = sapDialog.useAllPerms(); |
2 |
26 Feb 07 |
jari |
2687 |
} |
2 |
26 Feb 07 |
jari |
2688 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2689 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2690 |
dispose(); |
2 |
26 Feb 07 |
jari |
2691 |
} |
2 |
26 Feb 07 |
jari |
2692 |
} catch (NumberFormatException nfe){ |
2 |
26 Feb 07 |
jari |
2693 |
JOptionPane.showMessageDialog(null, "Invalid parameter value(s)!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2694 |
} |
2 |
26 Feb 07 |
jari |
2695 |
} else if (getStudyDesign() == SAMInitDialog.ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
2696 |
try { |
2 |
26 Feb 07 |
jari |
2697 |
double ocm = getOneClassMean(); |
2 |
26 Feb 07 |
jari |
2698 |
if (getNumValidOneClassExpts() < 2) { |
2 |
26 Feb 07 |
jari |
2699 |
JOptionPane.showMessageDialog(null, "At least 2 samples must be selected for one-class test!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2700 |
} else { |
2 |
26 Feb 07 |
jari |
2701 |
if (getNumValidOneClassExpts() <= 29) { |
2 |
26 Feb 07 |
jari |
2702 |
int numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2703 |
numUniquePerms = (int)(Math.pow(2, getNumValidOneClassExpts())); |
2 |
26 Feb 07 |
jari |
2704 |
SAMAllPermsDialog sapDialog = new SAMAllPermsDialog(SAMGUI.SAMFrame, true, numUniquePerms, numCombs); |
2 |
26 Feb 07 |
jari |
2705 |
sapDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
2706 |
allUniquePermsUsed = sapDialog.useAllPerms(); |
2 |
26 Feb 07 |
jari |
2707 |
} |
2 |
26 Feb 07 |
jari |
2708 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2709 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2710 |
dispose(); |
2 |
26 Feb 07 |
jari |
2711 |
} |
2 |
26 Feb 07 |
jari |
2712 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2713 |
JOptionPane.showMessageDialog(null, "Invalid value for one-class mean!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2714 |
} |
2 |
26 Feb 07 |
jari |
2715 |
} |
2 |
26 Feb 07 |
jari |
2716 |
} // ends handling ok-command |
2 |
26 Feb 07 |
jari |
2717 |
else if(command.equals("reset-command")){ |
2 |
26 Feb 07 |
jari |
2718 |
if(getStudyDesign() == SAMInitDialog.TWO_CLASS_UNPAIRED) |
2 |
26 Feb 07 |
jari |
2719 |
gPanel.reset(); |
2 |
26 Feb 07 |
jari |
2720 |
else if(getStudyDesign() == SAMInitDialog.MULTI_CLASS && mPanel.mulgPanel != null) |
2 |
26 Feb 07 |
jari |
2721 |
mPanel.reset(); |
2 |
26 Feb 07 |
jari |
2722 |
else if(getStudyDesign() == SAMInitDialog.CENSORED_SURVIVAL) |
2 |
26 Feb 07 |
jari |
2723 |
csPanel.reset(); |
2 |
26 Feb 07 |
jari |
2724 |
sqPanel.reset(); |
2 |
26 Feb 07 |
jari |
2725 |
pPanel.reset(); |
2 |
26 Feb 07 |
jari |
2726 |
iPanel.reset(); |
2 |
26 Feb 07 |
jari |
2727 |
tcpmPanel.tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
2728 |
hclOpsPanel.setHCLSelected(false); |
2 |
26 Feb 07 |
jari |
2729 |
} |
2 |
26 Feb 07 |
jari |
2730 |
else if(command.equals("cancel-command")){ |
2 |
26 Feb 07 |
jari |
2731 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
//hide(); |
2 |
26 Feb 07 |
jari |
2733 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2734 |
dispose(); |
2 |
26 Feb 07 |
jari |
2735 |
} |
2 |
26 Feb 07 |
jari |
2736 |
else if(command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
2737 |
HelpWindow help = new HelpWindow(SAMInitDialog.this, "SAM Initialization Dialog"); |
2 |
26 Feb 07 |
jari |
2738 |
if(help.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
2739 |
help.setSize(500,650); |
2 |
26 Feb 07 |
jari |
2740 |
help.setLocation(); |
2 |
26 Feb 07 |
jari |
2741 |
help.show(); |
2 |
26 Feb 07 |
jari |
2742 |
return; |
2 |
26 Feb 07 |
jari |
2743 |
} |
2 |
26 Feb 07 |
jari |
2744 |
} |
2 |
26 Feb 07 |
jari |
2745 |
} |
2 |
26 Feb 07 |
jari |
2746 |
|
2 |
26 Feb 07 |
jari |
2747 |
public void windowClosing(WindowEvent we){ |
2 |
26 Feb 07 |
jari |
2748 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
//System.out.println("Sam is closed"); |
2 |
26 Feb 07 |
jari |
2750 |
} |
2 |
26 Feb 07 |
jari |
2751 |
|
2 |
26 Feb 07 |
jari |
2752 |
} |
2 |
26 Feb 07 |
jari |
2753 |
|
2 |
26 Feb 07 |
jari |
2754 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
2755 |
|
2 |
26 Feb 07 |
jari |
2756 |
JFrame dummyFrame = new JFrame(); |
2 |
26 Feb 07 |
jari |
2757 |
Vector dummyVect = new Vector(); |
2 |
26 Feb 07 |
jari |
2758 |
for (int i = 0; i < 100; i++) { |
2 |
26 Feb 07 |
jari |
2759 |
dummyVect.add("Expt " + i); |
2 |
26 Feb 07 |
jari |
2760 |
} |
2 |
26 Feb 07 |
jari |
2761 |
SAMInitDialog sDialog = new SAMInitDialog(dummyFrame, true, dummyVect, 5); |
2 |
26 Feb 07 |
jari |
2762 |
sDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
2763 |
System.exit(0); |
2 |
26 Feb 07 |
jari |
2764 |
|
2 |
26 Feb 07 |
jari |
2765 |
} |
2 |
26 Feb 07 |
jari |
2766 |
|
2 |
26 Feb 07 |
jari |
2767 |
} |