2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: LOLADialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.3 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2005/03/10 15:52:21 $ |
2 |
26 Feb 07 |
jari |
* $Author: braistedj $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev.cluster.clusterUtil.submit.lola; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.BorderLayout; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
26 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
27 |
|
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.clusterUtil.Cluster; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
42 |
|
2 |
26 Feb 07 |
jari |
43 |
public class LOLADialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
44 |
private GroupExperimentsPanel gPanel; |
2 |
26 Feb 07 |
jari |
45 |
private JButton lola_it, cancel; |
2 |
26 Feb 07 |
jari |
46 |
int result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
// private Cluster cluster; |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
//jcb mod |
2 |
26 Feb 07 |
jari |
50 |
String [] sample_names; |
2 |
26 Feb 07 |
jari |
51 |
int [] sample_groupings; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
public LOLADialog(String frameTitle, String[] sample_names, Cluster cluster) { |
2 |
26 Feb 07 |
jari |
54 |
super(new JFrame(), frameTitle, true); |
2 |
26 Feb 07 |
jari |
55 |
this.sample_names = sample_names; |
2 |
26 Feb 07 |
jari |
56 |
this.sample_groupings = new int[sample_names.length]; |
2 |
26 Feb 07 |
jari |
// this.cluster = cluster; |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
setBounds(0, 0, 800, 500); |
2 |
26 Feb 07 |
jari |
60 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
63 |
pane.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
64 |
pane.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
65 |
pane.setLayout(new BorderLayout(1,2)); |
2 |
26 Feb 07 |
jari |
66 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
67 |
|
2 |
26 Feb 07 |
jari |
68 |
gPanel = new GroupExperimentsPanel(sample_names); |
2 |
26 Feb 07 |
jari |
69 |
|
2 |
26 Feb 07 |
jari |
70 |
int count; |
2 |
26 Feb 07 |
jari |
71 |
for (count = 0; count < gPanel.groupARadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
72 |
gPanel.groupARadioButtons[count].addActionListener(new GroupListener(0, count)); |
2 |
26 Feb 07 |
jari |
73 |
} |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
for (count = 0; count < gPanel.groupBRadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
76 |
gPanel.groupBRadioButtons[count].addActionListener(new GroupListener(1, count)); |
2 |
26 Feb 07 |
jari |
77 |
} |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
// should add another column of buttons for neither group |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
pane.add(gPanel, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
84 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
87 |
} |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
//jcb mod to remove group assignment information from the cluster |
2 |
26 Feb 07 |
jari |
90 |
public int [] getGroupAssignments() { |
2 |
26 Feb 07 |
jari |
91 |
return sample_groupings; |
2 |
26 Feb 07 |
jari |
92 |
} |
2 |
26 Feb 07 |
jari |
93 |
|
2 |
26 Feb 07 |
jari |
94 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
95 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
96 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
97 |
show(); |
2 |
26 Feb 07 |
jari |
98 |
return result; |
2 |
26 Feb 07 |
jari |
99 |
} |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
private class Listener extends WindowAdapter implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
102 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
103 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
104 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
105 |
onOk(); |
2 |
26 Feb 07 |
jari |
106 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
107 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
108 |
dispose(); |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
} |
2 |
26 Feb 07 |
jari |
111 |
|
2 |
26 Feb 07 |
jari |
112 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
113 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
114 |
onOk(); |
2 |
26 Feb 07 |
jari |
115 |
} |
2 |
26 Feb 07 |
jari |
116 |
} |
2 |
26 Feb 07 |
jari |
117 |
|
2 |
26 Feb 07 |
jari |
118 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
119 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
120 |
dispose(); |
2 |
26 Feb 07 |
jari |
121 |
} |
2 |
26 Feb 07 |
jari |
122 |
|
2 |
26 Feb 07 |
jari |
123 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
124 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
|
2 |
26 Feb 07 |
jari |
128 |
private void onOk() { |
2 |
26 Feb 07 |
jari |
129 |
try { |
2 |
26 Feb 07 |
jari |
//getFoldFilter();//etectionCheckbox.getState(); |
2 |
26 Feb 07 |
jari |
//String[] sn = cluster.getSampleNames(); |
2 |
26 Feb 07 |
jari |
//for (int i = 0; i < sn.length; i++){ |
2 |
26 Feb 07 |
jari |
// System.out.println("Sample: "+sn[i]+" in group: " + cluster.get_grouping(i)); |
2 |
26 Feb 07 |
jari |
134 |
//} |
2 |
26 Feb 07 |
jari |
135 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
136 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
137 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
138 |
} |
2 |
26 Feb 07 |
jari |
139 |
dispose(); |
2 |
26 Feb 07 |
jari |
140 |
} |
2 |
26 Feb 07 |
jari |
141 |
} |
2 |
26 Feb 07 |
jari |
142 |
|
2 |
26 Feb 07 |
jari |
143 |
class GroupListener implements ActionListener { |
2 |
26 Feb 07 |
jari |
144 |
int file_index; |
2 |
26 Feb 07 |
jari |
145 |
int group; |
2 |
26 Feb 07 |
jari |
146 |
GroupListener(int group, int file_index){ |
2 |
26 Feb 07 |
jari |
147 |
this.group = group; |
2 |
26 Feb 07 |
jari |
148 |
this.file_index = file_index; |
2 |
26 Feb 07 |
jari |
149 |
} |
2 |
26 Feb 07 |
jari |
150 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
// original |
2 |
26 Feb 07 |
jari |
// if (!(cluster.get_grouping(file_index) == group) ){ |
2 |
26 Feb 07 |
jari |
// cluster.set_grouping(file_index, group); |
2 |
26 Feb 07 |
jari |
154 |
// } |
2 |
26 Feb 07 |
jari |
155 |
sample_groupings[file_index] = group; |
2 |
26 Feb 07 |
jari |
156 |
} |
2 |
26 Feb 07 |
jari |
157 |
} |
2 |
26 Feb 07 |
jari |
158 |
|
2 |
26 Feb 07 |
jari |
159 |
class GroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
JRadioButton[] groupARadioButtons, groupBRadioButtons, neitherGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
162 |
GroupExperimentsPanel(String[] exptNames) { |
2 |
26 Feb 07 |
jari |
163 |
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 |
164 |
JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
165 |
JLabel[] expLabels = new JLabel[exptNames.length]; |
2 |
26 Feb 07 |
jari |
166 |
groupARadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
167 |
groupBRadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
168 |
neitherGroupRadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.length]; |
2 |
26 Feb 07 |
jari |
171 |
|
2 |
26 Feb 07 |
jari |
172 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
173 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
174 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
175 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
176 |
panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
177 |
|
2 |
26 Feb 07 |
jari |
178 |
for (int i = 0; i < exptNames.length; i++) { |
2 |
26 Feb 07 |
jari |
179 |
String s1 = (String)(exptNames[i]); |
2 |
26 Feb 07 |
jari |
180 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
181 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
182 |
groupARadioButtons[i] = new JRadioButton("Group A", true); |
2 |
26 Feb 07 |
jari |
183 |
chooseGroup[i].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
184 |
groupBRadioButtons[i] = new JRadioButton("Group B", false); |
2 |
26 Feb 07 |
jari |
185 |
chooseGroup[i].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
186 |
|
2 |
26 Feb 07 |
jari |
187 |
neitherGroupRadioButtons[i] = new JRadioButton("Neither", false); |
2 |
26 Feb 07 |
jari |
188 |
chooseGroup[i].add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
189 |
|
2 |
26 Feb 07 |
jari |
190 |
buildConstraints(constraints, 0, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
192 |
gridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
193 |
panel1.add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
buildConstraints(constraints, 1, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
197 |
gridbag.setConstraints(groupARadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
198 |
panel1.add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
buildConstraints(constraints, 2, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
202 |
gridbag.setConstraints(groupBRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
203 |
panel1.add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
204 |
|
2 |
26 Feb 07 |
jari |
205 |
buildConstraints(constraints, 3, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
207 |
gridbag.setConstraints(neitherGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
208 |
panel1.add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
209 |
|
2 |
26 Feb 07 |
jari |
210 |
} |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
JScrollPane scroll = new JScrollPane(panel1); |
2 |
26 Feb 07 |
jari |
// scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
//scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
215 |
scroll.setPreferredSize(new Dimension(400, 450)); |
2 |
26 Feb 07 |
jari |
216 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
217 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
218 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
219 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
220 |
|
2 |
26 Feb 07 |
jari |
221 |
} |
2 |
26 Feb 07 |
jari |
222 |
|
2 |
26 Feb 07 |
jari |
223 |
|
2 |
26 Feb 07 |
jari |
224 |
|
2 |
26 Feb 07 |
jari |
225 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
226 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
227 |
|
2 |
26 Feb 07 |
jari |
228 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
229 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
230 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
231 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
232 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
233 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
234 |
} |
2 |
26 Feb 07 |
jari |
235 |
|
2 |
26 Feb 07 |
jari |
236 |
} |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
|
2 |
26 Feb 07 |
jari |
239 |
|
2 |
26 Feb 07 |
jari |
240 |
|
2 |
26 Feb 07 |
jari |
241 |
|
2 |
26 Feb 07 |
jari |
242 |
|