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 |
by wwang |
2 |
26 Feb 07 |
jari |
7 |
*/ |
2 |
26 Feb 07 |
jari |
8 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
9 |
|
2 |
26 Feb 07 |
jari |
10 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
11 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
12 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
15 |
|
2 |
26 Feb 07 |
jari |
16 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
public class GenePixCutoffDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
39 |
private float originalValue; |
2 |
26 Feb 07 |
jari |
40 |
private int result; |
2 |
26 Feb 07 |
jari |
41 |
private JTextField textField; |
2 |
26 Feb 07 |
jari |
42 |
private JCheckBox enableCheckBox; |
2 |
26 Feb 07 |
jari |
43 |
private JLabel percentageLabel; |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
public GenePixCutoffDialog(JFrame parent, float percentage) { |
2 |
26 Feb 07 |
jari |
46 |
super(parent, "Set GenePix Flags Filter", true); |
2 |
26 Feb 07 |
jari |
47 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
48 |
originalValue = percentage; |
2 |
26 Feb 07 |
jari |
49 |
|
2 |
26 Feb 07 |
jari |
50 |
GBA gba = new GBA(); |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
enableCheckBox = new JCheckBox("Enable GenePix Flags Filter", true); |
2 |
26 Feb 07 |
jari |
53 |
enableCheckBox.setActionCommand("enable-check-box-command"); |
2 |
26 Feb 07 |
jari |
54 |
enableCheckBox.setOpaque(false); |
2 |
26 Feb 07 |
jari |
55 |
enableCheckBox.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
56 |
enableCheckBox.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
percentageLabel = new JLabel("Above Percentage((samples with negative flags) /(total samples)) for each gene"); |
2 |
26 Feb 07 |
jari |
59 |
percentageLabel.setHorizontalTextPosition(JLabel.RIGHT); |
2 |
26 Feb 07 |
jari |
60 |
percentageLabel.setHorizontalAlignment(JLabel.RIGHT); |
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
textField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
63 |
textField.setText(String.valueOf(percentage)); |
2 |
26 Feb 07 |
jari |
64 |
textField.selectAll(); |
2 |
26 Feb 07 |
jari |
65 |
textField.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
JPanel panel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
68 |
panel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
69 |
panel.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
gba.add(panel, enableCheckBox, 0, 0, 2, 1, 0, 0, GBA.V, GBA.C, new Insets(25, 5, 0, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
72 |
gba.add(panel, percentageLabel, 0, 1, 1, 1, 1, 0, GBA.B, GBA.E, new Insets(10, 5, 35, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
73 |
gba.add(panel, textField, 1, 1, 1, 1, 1, 0, GBA.NONE, GBA.W, new Insets(10, 5, 35, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
addContent(panel); |
2 |
26 Feb 07 |
jari |
76 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
77 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
78 |
pack(); |
2 |
26 Feb 07 |
jari |
79 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
80 |
textField.grabFocus(); |
2 |
26 Feb 07 |
jari |
81 |
} |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
84 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
85 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
86 |
show(); |
2 |
26 Feb 07 |
jari |
87 |
return result; |
2 |
26 Feb 07 |
jari |
88 |
} |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
public boolean isCutoffFilterEnabled() { |
2 |
26 Feb 07 |
jari |
91 |
return enableCheckBox.isSelected(); |
2 |
26 Feb 07 |
jari |
92 |
} |
2 |
26 Feb 07 |
jari |
93 |
|
2 |
26 Feb 07 |
jari |
94 |
public float getPercentageCutoff() { |
2 |
26 Feb 07 |
jari |
95 |
return Float.parseFloat(textField.getText()); |
2 |
26 Feb 07 |
jari |
96 |
} |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
public static void main(String [] args) { |
2 |
26 Feb 07 |
jari |
99 |
GenePixCutoffDialog dialog = new GenePixCutoffDialog(new JFrame(), 0f); |
2 |
26 Feb 07 |
jari |
100 |
dialog.showModal(); |
2 |
26 Feb 07 |
jari |
101 |
} |
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
private class Listener extends WindowAdapter implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
104 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
105 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
106 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
107 |
try { |
2 |
26 Feb 07 |
jari |
108 |
Float.parseFloat(textField.getText()); |
2 |
26 Feb 07 |
jari |
109 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
110 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
111 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
112 |
} |
2 |
26 Feb 07 |
jari |
113 |
dispose(); |
2 |
26 Feb 07 |
jari |
114 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
115 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
116 |
dispose(); |
2 |
26 Feb 07 |
jari |
117 |
} else if (command.equals("reset-command")) { |
2 |
26 Feb 07 |
jari |
118 |
enableCheckBox.setSelected(true); |
2 |
26 Feb 07 |
jari |
119 |
textField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
120 |
percentageLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
121 |
textField.setText(String.valueOf(originalValue)); |
2 |
26 Feb 07 |
jari |
122 |
textField.selectAll(); |
2 |
26 Feb 07 |
jari |
123 |
textField.grabFocus(); |
2 |
26 Feb 07 |
jari |
124 |
} else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
125 |
HelpWindow hw = new HelpWindow(GenePixCutoffDialog.this, "Set Percentage Cutoff"); |
2 |
26 Feb 07 |
jari |
126 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
127 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
128 |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
129 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
130 |
hw.show(); |
2 |
26 Feb 07 |
jari |
131 |
return; |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
else { |
2 |
26 Feb 07 |
jari |
134 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
135 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
136 |
return; |
2 |
26 Feb 07 |
jari |
137 |
} |
2 |
26 Feb 07 |
jari |
138 |
} else if (command.equals("enable-check-box-command")) { |
2 |
26 Feb 07 |
jari |
139 |
boolean enabled = enableCheckBox.isSelected(); |
2 |
26 Feb 07 |
jari |
140 |
percentageLabel.setEnabled(enabled); |
2 |
26 Feb 07 |
jari |
141 |
textField.setEnabled(enabled); |
2 |
26 Feb 07 |
jari |
142 |
} |
2 |
26 Feb 07 |
jari |
143 |
} |
2 |
26 Feb 07 |
jari |
144 |
|
2 |
26 Feb 07 |
jari |
145 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
146 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
147 |
dispose(); |
2 |
26 Feb 07 |
jari |
148 |
} |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
150 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
151 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
152 |
try { |
2 |
26 Feb 07 |
jari |
153 |
Float.parseFloat(textField.getText()); |
2 |
26 Feb 07 |
jari |
154 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
155 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
156 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
157 |
} |
2 |
26 Feb 07 |
jari |
158 |
dispose(); |
2 |
26 Feb 07 |
jari |
159 |
} |
2 |
26 Feb 07 |
jari |
160 |
} |
2 |
26 Feb 07 |
jari |
161 |
|
2 |
26 Feb 07 |
jari |
162 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
163 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
164 |
} |
2 |
26 Feb 07 |
jari |
165 |
} |