2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2005, 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 |
* KNNCSecondDialog.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on September 24, 2003, 2:38 PM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
package org.tigr.microarray.mev.cluster.gui.impl.knnc; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Dimension; |
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.Toolkit; |
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 |
|
2 |
26 Feb 07 |
jari |
22 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
23 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
27 |
|
2 |
26 Feb 07 |
jari |
28 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
29 |
|
2 |
26 Feb 07 |
jari |
30 |
/** |
2 |
26 Feb 07 |
jari |
31 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
33 |
*/ |
2 |
26 Feb 07 |
jari |
34 |
public class KNNCSecondDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
37 |
JRadioButton stopButton, continueButton; |
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of KNNCSecondDialog */ |
2 |
26 Feb 07 |
jari |
40 |
public KNNCSecondDialog(JFrame parentFrame, boolean modality) { |
2 |
26 Feb 07 |
jari |
41 |
super(parentFrame, "KNN classify - continue with analysis?", modality); |
2 |
26 Feb 07 |
jari |
//okButton.setText("Next >"); |
2 |
26 Feb 07 |
jari |
43 |
setBounds(0, 0, 500, 200); |
2 |
26 Feb 07 |
jari |
44 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
45 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
48 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
49 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
52 |
pane.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
53 |
pane.setBorder(new EtchedBorder()); |
2 |
26 Feb 07 |
jari |
54 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
55 |
|
2 |
26 Feb 07 |
jari |
56 |
stopButton = new JRadioButton("Stop here, don't classify", true); |
2 |
26 Feb 07 |
jari |
57 |
stopButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
58 |
continueButton = new JRadioButton("Proceed with classification", false); |
2 |
26 Feb 07 |
jari |
59 |
continueButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
ButtonGroup stopOrContinue =new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
62 |
stopOrContinue.add(stopButton); |
2 |
26 Feb 07 |
jari |
63 |
stopOrContinue.add(continueButton); |
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
66 |
gridbag.setConstraints(stopButton, constraints); |
2 |
26 Feb 07 |
jari |
67 |
pane.add(stopButton); |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
70 |
gridbag.setConstraints(continueButton, constraints); |
2 |
26 Feb 07 |
jari |
71 |
pane.add(continueButton); |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
74 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
75 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
76 |
this.addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
77 |
} |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
|
2 |
26 Feb 07 |
jari |
80 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
81 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
82 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
85 |
} |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
87 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
88 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
91 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
92 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
93 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
94 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
95 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
96 |
} |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
99 |
return okPressed; |
2 |
26 Feb 07 |
jari |
100 |
} |
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
public boolean proceed() { |
2 |
26 Feb 07 |
jari |
103 |
return continueButton.isSelected(); |
2 |
26 Feb 07 |
jari |
104 |
} |
2 |
26 Feb 07 |
jari |
105 |
|
2 |
26 Feb 07 |
jari |
106 |
public class EventListener extends WindowAdapter implements ActionListener{ |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
public void actionPerformed(ActionEvent ae) { |
2 |
26 Feb 07 |
jari |
109 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
110 |
if(command.equals("ok-command")){ |
2 |
26 Feb 07 |
jari |
111 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
112 |
dispose(); |
2 |
26 Feb 07 |
jari |
113 |
} else if (command.equals("reset-command")) { |
2 |
26 Feb 07 |
jari |
114 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
115 |
stopButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
116 |
continueButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
117 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
118 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
119 |
dispose(); |
2 |
26 Feb 07 |
jari |
120 |
} else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
/* HelpWindow hw = new HelpWindow(KNNCSecondDialog.this, "KNNC Parameter Selections"); |
2 |
26 Feb 07 |
jari |
okPressed = false; |
2 |
26 Feb 07 |
jari |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
hw.show(); |
2 |
26 Feb 07 |
jari |
return; |
2 |
26 Feb 07 |
jari |
128 |
} |
2 |
26 Feb 07 |
jari |
else { |
2 |
26 Feb 07 |
jari |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
return; |
2 |
26 Feb 07 |
jari |
133 |
} |
2 |
26 Feb 07 |
jari |
134 |
*/ |
2 |
26 Feb 07 |
jari |
135 |
} |
2 |
26 Feb 07 |
jari |
136 |
} |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
} |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
140 |
} |