2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SetLowerCutoffsDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.5 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:41 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.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.KeyEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.KeyListener; |
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 |
|
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
39 |
public class SetLowerCutoffsDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
40 |
|
2 |
26 Feb 07 |
jari |
41 |
private int result; |
2 |
26 Feb 07 |
jari |
42 |
private float originalCy3, originalCy5; |
2 |
26 Feb 07 |
jari |
43 |
private JTextField cy3TextField, cy5TextField; |
2 |
26 Feb 07 |
jari |
44 |
private JCheckBox enableCheckBox; |
2 |
26 Feb 07 |
jari |
45 |
private JLabel cy3Label, cy5Label; |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
public SetLowerCutoffsDialog(JFrame parent, float cy3, float cy5) { |
2 |
26 Feb 07 |
jari |
48 |
super(parent, "Set Lower Cutoffs", true); |
2 |
26 Feb 07 |
jari |
49 |
originalCy3 = cy3; |
2 |
26 Feb 07 |
jari |
50 |
originalCy5 = cy5; |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
53 |
GBA gba = new GBA(); |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
enableCheckBox = new JCheckBox("Enable Lower Cutoff Filter", true); |
2 |
26 Feb 07 |
jari |
56 |
enableCheckBox.setActionCommand("enable-check-box-command"); |
2 |
26 Feb 07 |
jari |
57 |
enableCheckBox.setOpaque(false); |
2 |
26 Feb 07 |
jari |
58 |
enableCheckBox.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
59 |
enableCheckBox.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
cy3Label = new JLabel("Cy3 Lower Cutoff (" + cy3 + "): "); |
2 |
26 Feb 07 |
jari |
63 |
cy3Label.setHorizontalAlignment(JLabel.RIGHT); |
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
cy3TextField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
66 |
cy3TextField.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
67 |
cy3TextField.setText("" + cy3); |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
cy5Label = new JLabel("Cy5 Lower Cutoff (" + cy5 + "): "); |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
cy5TextField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
72 |
cy5TextField.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
73 |
cy5TextField.setText("" + cy5); |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
JPanel panel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
76 |
panel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
77 |
panel.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
gba.add(panel, enableCheckBox, 0, 0, 2, 1, 0, 0, GBA.B, GBA.C, new Insets(20, 0, 0, 0), 0, 0); |
2 |
26 Feb 07 |
jari |
80 |
gba.add(panel, cy3Label, 0, 1, 1, 1, 0, 0, GBA.H, GBA.E, new Insets(15, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
81 |
gba.add(panel, cy3TextField, 1, 1, 1, 1, 0, 0, GBA.NONE, GBA.W, new Insets(15, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
82 |
gba.add(panel, cy5Label, 0, 2, 1, 1, 0, 0, GBA.H, GBA.E, new Insets(5, 5, 25, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
83 |
gba.add(panel, cy5TextField, 1, 2, 2, 1, 0, 0, GBA.NONE, GBA.W, new Insets(5, 5, 25, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
84 |
|
2 |
26 Feb 07 |
jari |
85 |
addContent(panel); |
2 |
26 Feb 07 |
jari |
86 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
87 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
88 |
pack(); |
2 |
26 Feb 07 |
jari |
89 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
cy3TextField.grabFocus(); |
2 |
26 Feb 07 |
jari |
92 |
cy3TextField.setCaretPosition(0); |
2 |
26 Feb 07 |
jari |
93 |
cy3TextField.selectAll(); |
2 |
26 Feb 07 |
jari |
94 |
} |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
97 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
98 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
99 |
show(); |
2 |
26 Feb 07 |
jari |
100 |
return result; |
2 |
26 Feb 07 |
jari |
101 |
} |
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
public boolean isLowerCutoffEnabled() { |
2 |
26 Feb 07 |
jari |
104 |
return enableCheckBox.isSelected(); |
2 |
26 Feb 07 |
jari |
105 |
} |
2 |
26 Feb 07 |
jari |
106 |
|
2 |
26 Feb 07 |
jari |
107 |
public float getLowerCY3Cutoff() { |
2 |
26 Feb 07 |
jari |
108 |
return Float.parseFloat(cy3TextField.getText()); |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
public float getLowerCY5Cutoff() { |
2 |
26 Feb 07 |
jari |
112 |
return Float.parseFloat(cy5TextField.getText()); |
2 |
26 Feb 07 |
jari |
113 |
} |
2 |
26 Feb 07 |
jari |
114 |
|
2 |
26 Feb 07 |
jari |
115 |
private class Listener extends WindowAdapter implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
116 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
117 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
118 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
119 |
onOk(); |
2 |
26 Feb 07 |
jari |
120 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
121 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
122 |
dispose(); |
2 |
26 Feb 07 |
jari |
123 |
} else if (command.equals("reset-command")) { |
2 |
26 Feb 07 |
jari |
124 |
cy5TextField.setText(String.valueOf(originalCy5)); |
2 |
26 Feb 07 |
jari |
125 |
cy3TextField.setText(String.valueOf(originalCy3)); |
2 |
26 Feb 07 |
jari |
126 |
cy3TextField.grabFocus(); |
2 |
26 Feb 07 |
jari |
127 |
cy3TextField.setCaretPosition(0); |
2 |
26 Feb 07 |
jari |
128 |
cy3TextField.selectAll(); |
2 |
26 Feb 07 |
jari |
129 |
} else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
130 |
HelpWindow hw = new HelpWindow(SetLowerCutoffsDialog.this, "Set Lower Cutoffs"); |
2 |
26 Feb 07 |
jari |
131 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
132 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
133 |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
134 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
135 |
hw.show(); |
2 |
26 Feb 07 |
jari |
136 |
return; |
2 |
26 Feb 07 |
jari |
137 |
} |
2 |
26 Feb 07 |
jari |
138 |
else { |
2 |
26 Feb 07 |
jari |
139 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
140 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
141 |
return; |
2 |
26 Feb 07 |
jari |
142 |
} |
2 |
26 Feb 07 |
jari |
143 |
} else if (command.equals("enable-check-box-command")) { |
2 |
26 Feb 07 |
jari |
144 |
boolean enable = enableCheckBox.isSelected(); |
2 |
26 Feb 07 |
jari |
145 |
cy3Label.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
146 |
cy5Label.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
147 |
cy3TextField.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
148 |
cy5TextField.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
149 |
} |
2 |
26 Feb 07 |
jari |
150 |
} |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
153 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
154 |
onOk(); |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
} |
2 |
26 Feb 07 |
jari |
157 |
|
2 |
26 Feb 07 |
jari |
158 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
159 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
160 |
dispose(); |
2 |
26 Feb 07 |
jari |
161 |
} |
2 |
26 Feb 07 |
jari |
162 |
|
2 |
26 Feb 07 |
jari |
163 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
164 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
private void onOk() { |
2 |
26 Feb 07 |
jari |
167 |
try { |
2 |
26 Feb 07 |
jari |
168 |
Float.parseFloat(cy3TextField.getText()); |
2 |
26 Feb 07 |
jari |
169 |
Float.parseFloat(cy5TextField.getText()); |
2 |
26 Feb 07 |
jari |
170 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
171 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
172 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
173 |
} |
2 |
26 Feb 07 |
jari |
174 |
dispose(); |
2 |
26 Feb 07 |
jari |
175 |
} |
2 |
26 Feb 07 |
jari |
176 |
} |
2 |
26 Feb 07 |
jari |
177 |
|
2 |
26 Feb 07 |
jari |
178 |
public static void main(String [] args) { |
2 |
26 Feb 07 |
jari |
179 |
SetLowerCutoffsDialog d = new SetLowerCutoffsDialog(new javax.swing.JFrame(), 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
180 |
d.showModal(); |
2 |
26 Feb 07 |
jari |
181 |
} |
2 |
26 Feb 07 |
jari |
182 |
} |