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: AlgorithmDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.6 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/24 16:07:53 $ |
2 |
26 Feb 07 |
jari |
* $Author: wwang67 $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
package org.tigr.microarray.mev.cluster.gui.impl.dialogs; |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.GradientPaint; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JDialog; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.border.BevelBorder; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.border.Border; |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
public class AlgorithmDialog extends JDialog { |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
protected JButton okButton; |
2 |
26 Feb 07 |
jari |
41 |
protected JButton cancelButton; |
2 |
26 Feb 07 |
jari |
42 |
protected JButton resetButton; |
2 |
26 Feb 07 |
jari |
43 |
protected JButton infoButton; |
2 |
26 Feb 07 |
jari |
44 |
protected JPanel mainPanel; |
2 |
26 Feb 07 |
jari |
45 |
protected JPanel contentPanel; |
2 |
26 Feb 07 |
jari |
46 |
protected JPanel buttonPanel; |
2 |
26 Feb 07 |
jari |
47 |
|
2 |
26 Feb 07 |
jari |
48 |
GradientPaint gp; |
2 |
26 Feb 07 |
jari |
49 |
Color backgroundColor = new Color(25,25,169); |
2 |
26 Feb 07 |
jari |
50 |
Color fadeColor = new Color(140,220,240); |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
/** Creates new AlgorithmDialog */ |
2 |
26 Feb 07 |
jari |
53 |
public AlgorithmDialog(Frame parent, String title, boolean modal) { |
2 |
26 Feb 07 |
jari |
54 |
super(parent, title, modal); |
2 |
26 Feb 07 |
jari |
55 |
|
2 |
26 Feb 07 |
jari |
56 |
mainPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
57 |
mainPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
58 |
mainPanel.setBorder(BorderFactory.createEmptyBorder(0,5,5,5)); |
2 |
26 Feb 07 |
jari |
59 |
contentPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
60 |
contentPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
61 |
buttonPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
62 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
63 |
okButton.setActionCommand("ok-command"); |
2 |
26 Feb 07 |
jari |
64 |
okButton.setSize(60,30); |
2 |
26 Feb 07 |
jari |
65 |
okButton.setPreferredSize(new Dimension(60,30)); |
2 |
26 Feb 07 |
jari |
66 |
okButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
67 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
68 |
cancelButton.setActionCommand("cancel-command"); |
2 |
26 Feb 07 |
jari |
69 |
cancelButton.setSize(60,30); |
2 |
26 Feb 07 |
jari |
70 |
cancelButton.setPreferredSize(new Dimension(60,30)); |
2 |
26 Feb 07 |
jari |
71 |
cancelButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
72 |
resetButton = new JButton("Reset"); |
2 |
26 Feb 07 |
jari |
73 |
resetButton.setActionCommand("reset-command"); |
2 |
26 Feb 07 |
jari |
74 |
resetButton.setSize(60,30); |
2 |
26 Feb 07 |
jari |
75 |
resetButton.setPreferredSize(new Dimension(60,30)); |
2 |
26 Feb 07 |
jari |
76 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
77 |
infoButton = new JButton(null, GUIFactory.getIcon("Information24.gif")); |
2 |
26 Feb 07 |
jari |
78 |
infoButton.setActionCommand("info-command"); |
2 |
26 Feb 07 |
jari |
79 |
infoButton.setSize(30,30); |
2 |
26 Feb 07 |
jari |
80 |
infoButton.setPreferredSize(new Dimension(30,30)); |
2 |
26 Feb 07 |
jari |
81 |
infoButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
82 |
Border border = BorderFactory.createBevelBorder(BevelBorder.RAISED); |
2 |
26 Feb 07 |
jari |
83 |
infoButton.setBorder(border); |
2 |
26 Feb 07 |
jari |
84 |
okButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, new Color(240,240,240), new Color(180,180,180), new Color(10,0,0), new Color(10,10,10) )); |
2 |
26 Feb 07 |
jari |
85 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); |
2 |
26 Feb 07 |
jari |
86 |
cancelButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
//layout button panel |
2 |
26 Feb 07 |
jari |
89 |
buttonPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
90 |
buttonPanel.add(infoButton, new GridBagConstraints(0,0,1,1,0.0,1.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
91 |
JLabel label = new JLabel(GUIFactory.getIcon("dialog_button_bar.gif")); |
2 |
26 Feb 07 |
jari |
92 |
buttonPanel.add(label, new GridBagConstraints(1,0,1,1,1.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,5,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
93 |
buttonPanel.add(resetButton, new GridBagConstraints(2,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,5,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
94 |
buttonPanel.add(cancelButton, new GridBagConstraints(3,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
95 |
buttonPanel.add(okButton, new GridBagConstraints(4,0,1,1,0.0,0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,30,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
96 |
|
2 |
26 Feb 07 |
jari |
97 |
mainPanel.add(new HeaderImagePanel(), new GridBagConstraints(0,0,1,1,1.0,0.0,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
98 |
mainPanel.add(contentPanel, new GridBagConstraints(0,1,1,1,1.0,1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
99 |
mainPanel.add(buttonPanel, new GridBagConstraints(0,2,1,1,1.0,0.0,GridBagConstraints.SOUTH, GridBagConstraints.BOTH, new Insets(5,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
this.getContentPane().add(mainPanel); |
2 |
26 Feb 07 |
jari |
102 |
pack(); |
2 |
26 Feb 07 |
jari |
103 |
} |
2 |
26 Feb 07 |
jari |
/** Creates new AlgorithmDialog */ |
2 |
26 Feb 07 |
jari |
105 |
public AlgorithmDialog(JFrame parent, String title, boolean modal) { |
2 |
26 Feb 07 |
jari |
106 |
super(parent, title, modal); |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
mainPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
109 |
mainPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
110 |
mainPanel.setBorder(BorderFactory.createEmptyBorder(0,5,5,5)); |
2 |
26 Feb 07 |
jari |
111 |
contentPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
112 |
contentPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
113 |
buttonPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
114 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
115 |
okButton.setActionCommand("ok-command"); |
2 |
26 Feb 07 |
jari |
116 |
okButton.setSize(60,30); |
2 |
26 Feb 07 |
jari |
117 |
okButton.setPreferredSize(new Dimension(60,30)); |
2 |
26 Feb 07 |
jari |
118 |
okButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
119 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
120 |
cancelButton.setActionCommand("cancel-command"); |
2 |
26 Feb 07 |
jari |
121 |
cancelButton.setSize(60,30); |
2 |
26 Feb 07 |
jari |
122 |
cancelButton.setPreferredSize(new Dimension(60,30)); |
2 |
26 Feb 07 |
jari |
123 |
cancelButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
124 |
resetButton = new JButton("Reset"); |
2 |
26 Feb 07 |
jari |
125 |
resetButton.setActionCommand("reset-command"); |
2 |
26 Feb 07 |
jari |
126 |
resetButton.setSize(60,30); |
2 |
26 Feb 07 |
jari |
127 |
resetButton.setPreferredSize(new Dimension(60,30)); |
2 |
26 Feb 07 |
jari |
128 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
129 |
infoButton = new JButton(null, GUIFactory.getIcon("Information24.gif")); |
2 |
26 Feb 07 |
jari |
130 |
infoButton.setActionCommand("info-command"); |
2 |
26 Feb 07 |
jari |
131 |
infoButton.setSize(30,30); |
2 |
26 Feb 07 |
jari |
132 |
infoButton.setPreferredSize(new Dimension(30,30)); |
2 |
26 Feb 07 |
jari |
133 |
infoButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
134 |
Border border = BorderFactory.createBevelBorder(BevelBorder.RAISED); |
2 |
26 Feb 07 |
jari |
135 |
infoButton.setBorder(border); |
2 |
26 Feb 07 |
jari |
136 |
okButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, new Color(240,240,240), new Color(180,180,180), new Color(10,0,0), new Color(10,10,10) )); |
2 |
26 Feb 07 |
jari |
137 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); |
2 |
26 Feb 07 |
jari |
138 |
cancelButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
//layout button panel |
2 |
26 Feb 07 |
jari |
141 |
buttonPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
142 |
buttonPanel.add(infoButton, new GridBagConstraints(0,0,1,1,0.0,1.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
143 |
JLabel label = new JLabel(GUIFactory.getIcon("dialog_button_bar.gif")); |
2 |
26 Feb 07 |
jari |
144 |
buttonPanel.add(label, new GridBagConstraints(1,0,1,1,1.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,5,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
145 |
buttonPanel.add(resetButton, new GridBagConstraints(2,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,5,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
146 |
buttonPanel.add(cancelButton, new GridBagConstraints(3,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,5), 0,0)); |
2 |
26 Feb 07 |
jari |
147 |
buttonPanel.add(okButton, new GridBagConstraints(4,0,1,1,0.0,0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,30,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
mainPanel.add(new HeaderImagePanel(), new GridBagConstraints(0,0,1,1,1.0,0.0,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
150 |
mainPanel.add(contentPanel, new GridBagConstraints(0,1,1,1,1.0,1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
151 |
mainPanel.add(buttonPanel, new GridBagConstraints(0,2,1,1,1.0,0.0,GridBagConstraints.SOUTH, GridBagConstraints.BOTH, new Insets(5,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
153 |
this.getContentPane().add(mainPanel); |
2 |
26 Feb 07 |
jari |
154 |
pack(); |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
protected void setActionListeners(ActionListener listener){ |
2 |
26 Feb 07 |
jari |
158 |
okButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
159 |
cancelButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
160 |
resetButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
161 |
infoButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
protected void addContent(Component content){ |
2 |
26 Feb 07 |
jari |
165 |
contentPanel.add(content, new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
166 |
validate(); |
2 |
26 Feb 07 |
jari |
167 |
} |
2 |
26 Feb 07 |
jari |
168 |
|
2 |
26 Feb 07 |
jari |
169 |
protected void disposeDialog(){ |
2 |
26 Feb 07 |
jari |
170 |
dispose(); |
2 |
26 Feb 07 |
jari |
171 |
}; |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
protected void supplantButtonPanel(Component buttonsSet){ |
2 |
26 Feb 07 |
jari |
174 |
mainPanel.remove(buttonPanel); |
2 |
26 Feb 07 |
jari |
175 |
this.mainPanel.add(buttonsSet, new GridBagConstraints(0,2,1,1,1.0,0.0,GridBagConstraints.SOUTH, GridBagConstraints.BOTH, new Insets(5,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
176 |
validate(); |
2 |
26 Feb 07 |
jari |
177 |
} |
2 |
26 Feb 07 |
jari |
178 |
|
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
public class HeaderImagePanel extends JPanel{ |
2 |
26 Feb 07 |
jari |
181 |
|
2 |
26 Feb 07 |
jari |
182 |
public HeaderImagePanel(){ |
2 |
26 Feb 07 |
jari |
183 |
setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
184 |
JLabel iconLabel = new JLabel(GUIFactory.getIcon("dialog_banner2.gif")); |
2 |
26 Feb 07 |
jari |
185 |
iconLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
186 |
iconLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT); |
2 |
26 Feb 07 |
jari |
187 |
FillPanel fillPanel = new FillPanel(); |
2 |
26 Feb 07 |
jari |
188 |
fillPanel.setBackground(Color.blue); |
2 |
26 Feb 07 |
jari |
189 |
add(iconLabel, new GridBagConstraints(0,0,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,5,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
190 |
add(fillPanel, new GridBagConstraints(1,0,1,1,1.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
191 |
} |
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
193 |
} |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
public void setOKButtonText(String label){ |
2 |
26 Feb 07 |
jari |
196 |
this.okButton.setText(label); |
2 |
26 Feb 07 |
jari |
197 |
} |
2 |
26 Feb 07 |
jari |
198 |
|
2 |
26 Feb 07 |
jari |
199 |
public void setResetButtonText(String label){ |
2 |
26 Feb 07 |
jari |
200 |
this.resetButton.setText(label); |
2 |
26 Feb 07 |
jari |
201 |
} |
2 |
26 Feb 07 |
jari |
202 |
public class FillPanel extends JPanel{ |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
204 |
public void paint(Graphics g){ |
2 |
26 Feb 07 |
jari |
205 |
super.paint(g); |
2 |
26 Feb 07 |
jari |
206 |
Graphics2D g2 = (Graphics2D)g; |
2 |
26 Feb 07 |
jari |
207 |
Dimension dim = this.getSize(); |
2 |
26 Feb 07 |
jari |
// gp = new GradientPaint(dim.width/2,0,backgroundColor,dim.width/2,dim.height/2,fadeColor); |
2 |
26 Feb 07 |
jari |
209 |
gp = new GradientPaint(0,dim.height/2,backgroundColor,dim.width,dim.height/2,fadeColor); |
2 |
26 Feb 07 |
jari |
210 |
g2.setPaint(gp); |
2 |
26 Feb 07 |
jari |
211 |
g2.fillRect(0,0,dim.width, dim.height); |
2 |
26 Feb 07 |
jari |
212 |
g2.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
213 |
} |
2 |
26 Feb 07 |
jari |
214 |
} |
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
216 |
public static void main(String [] args){ |
2 |
26 Feb 07 |
jari |
217 |
AlgorithmDialog dialog = new AlgorithmDialog(new JFrame(), "Test", true); |
2 |
26 Feb 07 |
jari |
218 |
dialog.show(); |
2 |
26 Feb 07 |
jari |
219 |
System.exit(0); |
2 |
26 Feb 07 |
jari |
220 |
} |
2 |
26 Feb 07 |
jari |
221 |
|
2 |
26 Feb 07 |
jari |
222 |
} |