1 import java.applet.Applet;
2 import java.awt.*;
3 import java.io.*;
4 import java.awt.event.*;
5 import javax.swing.*;
6 import javax.swing.event.*;
7 import java.lang.*;
8 
9 class nwchem_MD_common extends JPanel {
10 
11   ///////////////////////////////////////////////////////////////////////
12   //	Variables that all the panels share.
13   //////////////////////////////////////////////////////////////////////
14   Font defaultfont;
15   Font disabledfont;
16 
17   JComboBox interactbox;
18   JComboBox cutbox;
19   JComboBox fixbox;
20 
21   JLabel interactlabel;
22   JLabel setlabel;
23   JLabel maxlabel;
24   JLabel tolerlabel;
25   JLabel gridlabel;
26   JLabel alphalabel;
27   JLabel orderlabel;
28   JLabel nodeslabel;
29   JLabel fftlabel;
30   JLabel fillerlabel;
31   JLabel cutlabel;
32   JLabel shortlabel;
33   JLabel longlabel;
34   JLabel freqlabel;
35   JLabel shakelabel;
36   JLabel solventlabel;
37   JLabel solutelabel;
38   JLabel maxit1label;
39   JLabel maxit2label;
40   JLabel tol1label;
41   JLabel tol2label;
42   JLabel distlabel;
43   JLabel scale1label;
44   JLabel scale2label;
45   JLabel fixlabel;
46   JLabel printlabel;
47   JLabel steplabel;
48   JLabel statlabel;
49   JLabel expectlabel;
50   JLabel calculationlabel;
51 
52   ButtonGroup  setgroup;
53   ButtonGroup  setpgroup;
54   ButtonGroup  pickcalcgroup;
55   JRadioButton classicalradio;
56   JRadioButton qmmmradio;
57   JRadioButton quantumradio;
58   JRadioButton set1button;
59   JRadioButton set2button;
60   JRadioButton set3button;
61   JCheckBox setp1button;
62   JCheckBox setp2button;
63   JRadioButton soluteradio;
64   JRadioButton solventradio;
65   JRadioButton averageradio;
66   JRadioButton applyradio;
67   JRadioButton noneradio;
68   JRadioButton allradio;
69   JRadioButton solventrbutton;
70   JRadioButton soluterbutton;
71   JRadioButton nonHradio;
72   JRadioButton topradio;
73   JRadioButton nonbradio;
74   JRadioButton solvradio;
75   JRadioButton soluradio;
76   JRadioButton resetradio;
77   JRadioButton lnoneradio;
78   JRadioButton pairsradio;
79   JRadioButton boxsizeradio;
80   JRadioButton verifyradio;
81   JRadioButton extraradio;
82   JRadioButton energyradio;
83 
84   IntegerField maxfield;
85   DoubleField tolerfield;
86   IntegerField grid1field;
87   IntegerField grid2field;
88   IntegerField grid3field;
89   DoubleField alphafield;
90   IntegerField orderfield;
91   IntegerField nodesfield;
92   IntegerField fftfield;
93   DoubleField shortfield;
94   DoubleField longfield;
95   IntegerField freqfield;
96   IntegerField maxit1field;
97   IntegerField maxit2field;
98   DoubleField tol1field;
99   DoubleField tol2field;
100   DoubleField scale1field;
101   DoubleField scale2field;
102   IntegerField stepfield;
103   IntegerField statfield;
104 
105   private nwchem_Task parentFrame = null;
106 
107 ////////////////////////////////////////////////////////////////////////
108 //	Building constraints for panel with settings common between
109 //	all calculations
110 ///////////////////////////////////////////////////////////////////////
111 
nwchem_MD_common(nwchem_Task task)112   public nwchem_MD_common(nwchem_Task task) {
113 
114     defaultfont = new Font("Dialog", Font.BOLD,12);
115     disabledfont = new Font("Dialog", Font.PLAIN,12);
116     parentFrame = task;
117 
118     GridBagLayout commonlayout = new GridBagLayout();
119     GridBagConstraints commonconstraints = new GridBagConstraints();
120     setLayout(commonlayout);
121     setgroup = new ButtonGroup();
122 
123     interactlabel = new JLabel("Interaction:");
124     interactlabel.setFont(defaultfont);
125     interactlabel.setForeground(Color.black);
126     addComponent(this,interactlabel,0,0,4,1,20,1,
127 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
128 
129     String[] interactstring = {"effective pair","first order polarization",
130 			       "SCF polarization", "particle mesh Ewald"};
131     interactbox = new JComboBox(interactstring);
132     addComponent(this,interactbox,4,0,2,1,20,1,
133 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
134     interactbox.addActionListener(new ActionListener(){
135       public void actionPerformed(ActionEvent e){
136 	parentFrame.interaction=interactbox.getSelectedIndex();
137 	enableSelections(parentFrame);
138       }});
139 
140     JPanel setbuttons = new JPanel();
141     setbuttons.setLayout(new GridBagLayout());
142     addComponent(this,setbuttons,6,0,3,1,5,1,
143 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
144 
145     setlabel = new JLabel(" set: ");
146     setlabel.setFont(defaultfont);
147     setlabel.setForeground(Color.black);
148     addComponent(setbuttons,setlabel,1,0,1,1,5,1,
149 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
150 
151     set1button = new JRadioButton("1");
152     set2button = new JRadioButton("2");
153     set3button = new JRadioButton("3");
154     setgroup.add(set1button);
155     setgroup.add(set2button);
156     setgroup.add(set3button);
157     addComponent(setbuttons,set1button,2,0,1,1,5,1,
158 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
159     addComponent(setbuttons,set2button,3,0,1,1,5,1,
160 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
161     addComponent(setbuttons,set3button,4,0,1,1,5,1,
162 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
163     set1button.addActionListener(new ActionListener(){
164       public void actionPerformed(ActionEvent e){
165 	parentFrame.set=1;
166 	enableSelections(parentFrame);
167       }});
168     set2button.addActionListener(new ActionListener(){
169       public void actionPerformed(ActionEvent e){
170 	parentFrame.set=2;
171 	enableSelections(parentFrame);
172       }});
173     set3button.addActionListener(new ActionListener(){
174       public void actionPerformed(ActionEvent e){
175 	parentFrame.set=3;
176 	enableSelections(parentFrame);
177       }});
178 
179     setp1button = new JCheckBox("P1");
180     setp2button = new JCheckBox("P2");
181     addComponent(setbuttons,setp1button,5,0,1,1,5,1,
182 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
183     addComponent(setbuttons,setp2button,6,0,1,1,5,1,
184 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
185     setp1button.addActionListener(new ActionListener(){
186       public void actionPerformed(ActionEvent e){
187 	parentFrame.pset2=setp1button.isSelected();
188       }});
189     setp2button.addActionListener(new ActionListener(){
190       public void actionPerformed(ActionEvent e){
191 	parentFrame.pset3=setp2button.isSelected();
192       }});
193 
194     maxlabel = new JLabel("max iters:");
195     maxlabel.setFont(defaultfont);
196     maxlabel.setForeground(Color.gray);
197     addComponent(this,maxlabel,4,1,4,1,20,1,
198 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
199 
200     maxfield = new IntegerField(parentFrame.polmax,14,5);
201     addComponent(this,maxfield,5,1,1,1,10,1,
202 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
203     //    maxfield.setEnabled(false);
204     maxfield.addFocusListener(new FocusListener(){
205       public void focusLost(FocusEvent e){ parentFrame.polmax=maxfield.getValue();};
206       public void focusGained(FocusEvent e){}
207     });
208 
209     tolerlabel = new JLabel("tolerance:");
210     tolerlabel.setFont(defaultfont);
211     tolerlabel.setForeground(Color.gray);
212     addComponent(this,tolerlabel,6,1,1,1,20,1,
213 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
214 
215     tolerfield = new DoubleField(parentFrame.poltol,0.0010,10);
216     addComponent(this,tolerfield,7,1,1,1,20,1,
217 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
218     tolerfield.setEnabled(false);
219     tolerfield.addFocusListener(new FocusListener(){
220       public void focusLost(FocusEvent e){ parentFrame.poltol=tolerfield.getValue();};
221       public void focusGained(FocusEvent e){}
222     });
223 
224     gridlabel = new JLabel("grid");
225     gridlabel.setFont(defaultfont);
226     gridlabel.setForeground(Color.gray);
227     addComponent(this,gridlabel,4,2,1,1,5,1,
228 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
229 
230     grid1field = new IntegerField(parentFrame.gridx,8,5);
231     grid2field = new IntegerField(parentFrame.gridy,8,5);
232     grid3field = new IntegerField(parentFrame.gridz,8,5);
233     addComponent(this,grid1field,5,2,1,1,5,1,
234 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
235     addComponent(this,grid2field,6,2,1,1,5,1,
236 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
237     addComponent(this,grid3field,7,2,1,1,5,1,
238 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
239     grid1field.setEnabled(false);
240     grid2field.setEnabled(false);
241     grid3field.setEnabled(false);
242     grid1field.addFocusListener(new FocusListener(){
243       public void focusLost(FocusEvent e){ parentFrame.gridx=grid1field.getValue();};
244       public void focusGained(FocusEvent e){}
245     });
246     grid2field.addFocusListener(new FocusListener(){
247       public void focusLost(FocusEvent e){ parentFrame.gridy=grid2field.getValue();};
248       public void focusGained(FocusEvent e){}
249     });
250     grid3field.addFocusListener(new FocusListener(){
251       public void focusLost(FocusEvent e){ parentFrame.gridz=grid3field.getValue();};
252       public void focusGained(FocusEvent e){}
253     });
254 
255     alphalabel = new JLabel("alpha:");
256     alphalabel.setFont(defaultfont);
257     alphalabel.setForeground(Color.gray);
258     addComponent(this,alphalabel,4,3,1,1,5,1,
259 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
260 
261     alphafield = new DoubleField(parentFrame.alpha,0.0,10);
262     addComponent(this,alphafield,5,3,1,1,5,1,
263 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
264     alphafield.setEnabled(false);
265     alphafield.addFocusListener(new FocusListener(){
266       public void focusLost(FocusEvent e){ parentFrame.alpha=alphafield.getValue();};
267       public void focusGained(FocusEvent e){}
268     });
269 
270     orderlabel = new JLabel("order:");
271     orderlabel.setFont(defaultfont);
272     orderlabel.setForeground(Color.gray);
273     addComponent(this,orderlabel,6,3,1,1,5,1,
274 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
275 
276     orderfield = new IntegerField(parentFrame.order,4,5);
277     addComponent(this,orderfield,7,3,1,1,5,1,
278 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
279     orderfield.setEnabled(false);
280     orderfield.addFocusListener(new FocusListener(){
281       public void focusLost(FocusEvent e){ parentFrame.order=orderfield.getValue();};
282       public void focusGained(FocusEvent e){}
283     });
284 
285     nodeslabel = new JLabel("nodes:");
286     nodeslabel.setFont(defaultfont);
287     nodeslabel.setForeground(Color.gray);
288     addComponent(this,nodeslabel,8,2,1,1,5,1,
289 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
290 
291     nodesfield = new IntegerField(parentFrame.nodpme,0,5);
292     addComponent(this,nodesfield,9,2,1,1,5,1,
293 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
294     nodesfield.setEnabled(false);
295     nodesfield.addFocusListener(new FocusListener(){
296       public void focusLost(FocusEvent e){ parentFrame.nodpme=nodesfield.getValue();};
297       public void focusGained(FocusEvent e){}
298     });
299 
300     fftlabel = new JLabel("fft:");
301     fftlabel.setFont(defaultfont);
302     fftlabel.setForeground(Color.gray);
303     addComponent(this,fftlabel,8,3,1,1,5,1,
304 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
305 
306     fftfield = new IntegerField(parentFrame.fft,1,5);
307     addComponent(this,fftfield,9,3,1,1,5,1,
308 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
309     fftfield.setEnabled(false);
310     fftfield.addFocusListener(new FocusListener(){
311       public void focusLost(FocusEvent e){ parentFrame.fft=fftfield.getValue();};
312       public void focusGained(FocusEvent e){}
313     });
314 
315     cutlabel = new JLabel("Cut off:");
316     cutlabel.setFont(defaultfont);
317     cutlabel.setForeground(Color.black);
318     addComponent(this,cutlabel,0,3,4,1,20,1,
319 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
320 
321     String[] cutstrings = {"single range", "twin range"};
322     cutbox = new JComboBox(cutstrings);
323     addComponent(this,cutbox,4,4,1,1,10,1,
324 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
325     cutbox.addActionListener(new ActionListener(){
326       public void actionPerformed(ActionEvent e){
327 	parentFrame.twin=cutbox.getSelectedIndex()==1;
328 	enableSelections(parentFrame);
329       }});
330 
331     shortlabel = new JLabel("short:");
332     shortlabel.setFont(defaultfont);
333     shortlabel.setForeground(Color.gray);
334     addComponent(this,shortlabel,5,4,1,1,5,1,
335 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
336 
337     shortfield = new DoubleField(parentFrame.r_short,0.9,5);
338     addComponent(this,shortfield,6,4,1,1,5,1,
339 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
340     shortfield.addFocusListener(new FocusListener(){
341       public void focusLost(FocusEvent e){ parentFrame.r_short=shortfield.getValue();};
342       public void focusGained(FocusEvent e){}
343     });
344 
345     longlabel = new JLabel("long:");
346     longlabel.setFont(defaultfont);
347     longlabel.setForeground(Color.gray);
348     addComponent(this,longlabel,5,5,1,1,5,1,
349 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
350 
351     longfield = new DoubleField(parentFrame.r_long,1.2,5);
352     addComponent(this,longfield,6,5,1,1,5,1,
353 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
354     longfield.setEnabled(false);
355     longfield.addFocusListener(new FocusListener(){
356       public void focusLost(FocusEvent e){ parentFrame.r_long=longfield.getValue();};
357       public void focusGained(FocusEvent e){}
358     });
359 
360     freqlabel = new JLabel("frequency:  ");
361     freqlabel.setFont(defaultfont);
362     freqlabel.setForeground(Color.gray);
363     addComponent(this,freqlabel,7,4,2,1,5,1,
364 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
365 
366     freqfield = new IntegerField(parentFrame.freq_long,5,5);
367     addComponent(this,freqfield,8,4,1,1,5,1,
368 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
369     freqfield.setEnabled(false);
370     freqfield.addFocusListener(new FocusListener(){
371       public void focusLost(FocusEvent e){ parentFrame.freq_long=freqfield.getValue();};
372       public void focusGained(FocusEvent e){}
373     });
374 
375     shakelabel = new JLabel("Shake:");
376     shakelabel.setFont(defaultfont);
377     shakelabel.setForeground(Color.black);
378     addComponent(this,shakelabel,0,6,4,1,20,1,
379 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
380 
381     solventradio = new JRadioButton("solvent");
382     addComponent(this,solventradio,4,6,1,1,10,1,
383 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
384     solventradio.addActionListener(new ActionListener(){
385       public void actionPerformed(ActionEvent e){
386 	parentFrame.shake_w=solventradio.isSelected();
387 	enableSelections(parentFrame);
388       }});
389 
390     maxit1label = new JLabel("max iters:");
391     maxit1label.setFont(defaultfont);
392     maxit1label.setForeground(Color.gray);
393     addComponent(this,maxit1label,5,6,1,1,10,1,
394 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
395 
396     maxit1field = new IntegerField(parentFrame.shake_w_iter,100, 5);
397     addComponent(this,maxit1field,6,6,1,1,5,1,
398 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
399     maxit1field.setEnabled(false);
400     maxit1field.addFocusListener(new FocusListener(){
401       public void focusLost(FocusEvent e){ parentFrame.shake_w_iter=maxit1field.getValue();};
402       public void focusGained(FocusEvent e){}
403     });
404 
405     tol1label = new JLabel("tolerance:");
406     tol1label.setFont(defaultfont);
407     tol1label.setForeground(Color.gray);
408     addComponent(this,tol1label,7,6,1,1,5,1,
409 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
410 
411     tol1field = new DoubleField(parentFrame.shake_w_toler,0.0010, 5);
412     addComponent(this,tol1field,8,6,1,1,5,1,
413 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
414     tol1field.setEnabled(false);
415     tol1field.addFocusListener(new FocusListener(){
416       public void focusLost(FocusEvent e){ parentFrame.shake_w_toler=tol1field.getValue();};
417       public void focusGained(FocusEvent e){}
418     });
419 
420     soluteradio = new JRadioButton("solute");
421     addComponent(this,soluteradio,4,7,1,1,10,1,
422 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
423     soluteradio.addActionListener(new ActionListener(){
424       public void actionPerformed(ActionEvent e){
425 	parentFrame.shake_s=soluteradio.isSelected();
426 	enableSelections(parentFrame);
427       }});
428 
429     maxit2label = new JLabel("max iters:");
430     maxit2label.setFont(defaultfont);
431     maxit2label.setForeground(Color.gray);
432     addComponent(this,maxit2label,5,7,1,1,10,1,
433 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
434 
435     maxit2field = new IntegerField(parentFrame.shake_s_iter,100,5);
436     addComponent(this,maxit2field,6,7,1,1,5,1,
437 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
438     maxit2field.setEnabled(false);
439     maxit2field.addFocusListener(new FocusListener(){
440       public void focusLost(FocusEvent e){ parentFrame.shake_s_iter=maxit2field.getValue();};
441       public void focusGained(FocusEvent e){}
442     });
443 
444     tol2label = new JLabel("tolerance:");
445     tol2label.setFont(defaultfont);
446     tol2label.setForeground(Color.gray);
447     addComponent(this,tol2label,7,7,1,1,5,1,
448 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
449 
450     tol2field = new DoubleField(parentFrame.shake_s_toler,0.0010,5);
451     addComponent(this,tol2field,8,7,1,1,5,1,
452 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
453     tol2field.setEnabled(false);
454     tol2field.addFocusListener(new FocusListener(){
455       public void focusLost(FocusEvent e){parentFrame.shake_s_toler=tol2field.getValue();};
456       public void focusGained(FocusEvent e){}
457     });
458 
459     distlabel = new JLabel("dist. rest.:");
460     distlabel.setFont(defaultfont);
461     distlabel.setForeground(Color.black);
462     addComponent(this,distlabel,0,8,4,1,20,1,
463 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
464 
465     applyradio = new JRadioButton("apply");
466     addComponent(this,applyradio,4,8,1,1,5,1,
467 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
468     applyradio.addActionListener(new ActionListener(){
469       public void actionPerformed(ActionEvent e){
470 	parentFrame.distar=applyradio.isSelected();
471 	enableSelections(parentFrame);
472       }});
473 
474     averageradio = new JRadioButton("average");
475     addComponent(this,averageradio,5,8,1,1,5,1,
476 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
477     averageradio.setEnabled(false);
478 
479     scale1label = new JLabel("scale:");
480     scale1label.setFont(defaultfont);
481     scale1label.setForeground(Color.gray);
482     addComponent(this,scale1label,6,8,1,1,5,1,
483 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
484 
485     scale1field = new DoubleField(parentFrame.drsscl,1.0,5);
486     addComponent(this,scale1field,7,8,1,1,5,1,
487 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
488     scale1field.setEnabled(false);
489     scale1field.addFocusListener(new FocusListener(){
490       public void focusLost(FocusEvent e){parentFrame.drsscl=scale1field.getValue();};
491       public void focusGained(FocusEvent e){}
492     });
493 
494     scale2label = new JLabel("scale:");
495     scale2label.setFont(defaultfont);
496     scale2label.setForeground(Color.gray);
497     addComponent(this,scale2label,8,8,1,1,5,1,
498 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
499 
500     scale2field = new DoubleField(parentFrame.drsscl,1.0,5);
501     addComponent(this,scale2field,9,8,1,1,5,1,
502 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
503     scale2field.setEnabled(false);
504     scale2field.addFocusListener(new FocusListener(){
505       public void focusLost(FocusEvent e){parentFrame.drsscl=scale2field.getValue();};
506       public void focusGained(FocusEvent e){}
507     });
508 
509     fixlabel = new JLabel("fix:");
510     fixlabel.setFont(defaultfont);
511     fixlabel.setForeground(Color.black);
512     addComponent(this,fixlabel,0,9,4,1,20,1,
513 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
514 
515     String[] fixstrings = {"fix", "unfix"};
516     fixbox = new JComboBox(fixstrings);
517     addComponent(this,fixbox,4,9,1,1,5,1,
518 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
519 
520     noneradio = new JRadioButton("none");
521     addComponent(this,noneradio,5,9,1,1,5,1,
522 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
523 
524     allradio = new JRadioButton("all");
525     addComponent(this,allradio,6,9,1,1,5,1,
526 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
527 
528     solventrbutton = new JRadioButton("solvent");
529     addComponent(this,solventrbutton,7,9,1,1,5,1,
530 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
531 
532     soluterbutton = new JRadioButton("solute");
533     addComponent(this,soluterbutton,8,9,1,1,5,1,
534 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
535 
536     nonHradio = new JRadioButton("non hydrogen");
537     addComponent(this,nonHradio,9,9,2,1,10,1,
538 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
539 
540     printlabel = new JLabel("Print:");
541     printlabel.setFont(defaultfont);
542     printlabel.setForeground(Color.black);
543     addComponent(this,printlabel,0,10,4,1,20,1,
544 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
545 
546     topradio = new JRadioButton("topology");
547     addComponent(this,topradio,4,10,2,1,10,1,
548 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
549     topradio.addActionListener(new ActionListener(){
550       public void actionPerformed(ActionEvent e){
551 	parentFrame.prt_top=topradio.isSelected();
552 	enableSelections(parentFrame);
553       }});
554 
555     nonbradio = new JRadioButton("nonb");
556     addComponent(this,nonbradio,6,10,1,1,10,1,
557 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
558     nonbradio.setEnabled(false);
559 
560     solvradio = new JRadioButton("solvent");
561     addComponent(this,solvradio,7,10,1,1,5,1,
562 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
563     solvradio.setEnabled(false);
564 
565     soluradio = new JRadioButton("solute");
566     addComponent(this,soluradio,8,10,1,1,5,1,
567 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
568     soluradio.setEnabled(false);
569 
570     steplabel = new JLabel("step:");
571     steplabel.setFont(defaultfont);
572     steplabel.setForeground(Color.black);
573     addComponent(this,steplabel,4,11,1,1,5,1,
574 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
575 
576     stepfield = new IntegerField(parentFrame.prt_step,0,5);
577     addComponent(this,stepfield,5,11,1,1,5,1,
578 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
579     stepfield.addFocusListener(new FocusListener(){
580       public void focusLost(FocusEvent e){parentFrame.prt_step=stepfield.getValue();};
581       public void focusGained(FocusEvent e){}
582     });
583 
584     extraradio = new JRadioButton("extra");
585     addComponent(this,extraradio,6,11,1,1,5,1,
586 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
587 
588     energyradio = new JRadioButton("energy");
589     addComponent(this,energyradio,7,11,1,1,5,1,
590 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
591 
592     statlabel = new JLabel("stat:");
593     statlabel.setFont(defaultfont);
594     statlabel.setForeground(Color.black);
595     addComponent(this,statlabel,4,12,1,1,5,1,
596 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
597 
598     statfield = new IntegerField(parentFrame.prt_stat,0,5);
599     addComponent(this,statfield,5,12,1,1,5,1,
600 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
601     statfield.addFocusListener(new FocusListener(){
602       public void focusLost(FocusEvent e){parentFrame.prt_stat=statfield.getValue();};
603       public void focusGained(FocusEvent e){}
604     });
605 
606     fillerlabel = new JLabel("                 ");
607     addComponent(this,fillerlabel,10,18,3,3,35,35,
608 		 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER);
609 
610     setVisible(true);
611 
612 	enableSelections(parentFrame);
613   }
614 
enableSelections(nwchem_Task tsk)615   void enableSelections(nwchem_Task tsk){
616 
617     interactbox.setSelectedIndex(tsk.interaction);
618     if(tsk.set == 1){
619       set1button.setSelected(true);
620       setp1button.setEnabled(true);
621       setp2button.setEnabled(true);
622     } else {
623       if(tsk.set == 2){ set2button.setSelected(true); };
624       if(tsk.set == 3){ set3button.setSelected(true); };
625       setp1button.setEnabled(false);
626       setp2button.setEnabled(false);
627     };
628     setp1button.setSelected(tsk.pset2);
629     setp2button.setSelected(tsk.pset3);
630     if(tsk.interaction == 0 || tsk.interaction == 1){
631       maxlabel.setForeground(Color.gray);
632       maxfield.setEnabled(false);
633       tolerlabel.setForeground(Color.gray);
634       tolerfield.setEnabled(false);
635       gridlabel.setForeground(Color.gray);
636       grid1field.setEnabled(false);
637       grid2field.setEnabled(false);
638       grid3field.setEnabled(false);
639       alphalabel.setForeground(Color.gray);
640       alphafield.setEnabled(false);
641       orderlabel.setForeground(Color.gray);
642       orderlabel.setEnabled(false);
643       nodeslabel.setForeground(Color.gray);
644       nodesfield.setEnabled(false);
645       fftlabel.setForeground(Color.gray);
646       fftfield.setEnabled(false);
647     };
648     if(tsk.interaction == 2){
649       maxlabel.setForeground(Color.black);
650       maxfield.setEnabled(true);
651       tolerlabel.setForeground(Color.black);
652       tolerfield.setEnabled(true);
653       gridlabel.setForeground(Color.gray);
654       grid1field.setEnabled(false);
655       grid2field.setEnabled(false);
656       grid3field.setEnabled(false);
657       alphalabel.setForeground(Color.gray);
658       alphafield.setEnabled(false);
659       orderlabel.setForeground(Color.gray);
660       orderlabel.setEnabled(false);
661       nodeslabel.setForeground(Color.gray);
662       nodesfield.setEnabled(false);
663       fftlabel.setForeground(Color.gray);
664       fftfield.setEnabled(false);
665     };
666     if(tsk.interaction == 3){
667       maxlabel.setForeground(Color.gray);
668       maxfield.setEnabled(false);
669       tolerlabel.setForeground(Color.gray);
670       tolerfield.setEnabled(false);
671       gridlabel.setForeground(Color.black);
672       grid1field.setEnabled(true);
673       grid2field.setEnabled(true);
674       grid3field.setEnabled(true);
675       alphalabel.setForeground(Color.black);
676       alphafield.setEnabled(true);
677       orderlabel.setForeground(Color.black);
678       orderlabel.setEnabled(true);
679       nodeslabel.setForeground(Color.black);
680       nodesfield.setEnabled(true);
681       fftlabel.setForeground(Color.black);
682       fftfield.setEnabled(true);
683     };
684     if(tsk.prt_top){
685       nonbradio.setEnabled(true);
686       solvradio.setEnabled(true);
687       soluradio.setEnabled(true);
688     } else {
689       nonbradio.setSelected(false);
690       solvradio.setSelected(false);
691       soluradio.setSelected(false);
692       nonbradio.setEnabled(false);
693       solvradio.setEnabled(false);
694       soluradio.setEnabled(false);
695     };
696     if(tsk.distar){
697       averageradio.setEnabled(true);
698       scale1label.setForeground(Color.black);
699       scale1field.setEnabled(true);
700       scale2label.setForeground(Color.black);
701       scale2field.setEnabled(true);
702     } else {
703       averageradio.setEnabled(false);
704       scale1label.setForeground(Color.gray);
705       scale1field.setEnabled(false);
706       scale2label.setForeground(Color.gray);
707       scale2field.setEnabled(false);
708     };
709     solventradio.setSelected(tsk.shake_w);
710     if(tsk.shake_w){
711       maxit1label.setForeground(Color.black);
712       maxit1field.setEnabled(true);
713       tol1label.setForeground(Color.black);
714       tol1field.setEnabled(true);
715     } else {
716       maxit1label.setForeground(Color.gray);
717       maxit1field.setEnabled(false);
718       tol1label.setForeground(Color.gray);
719       tol1field.setEnabled(false);
720     };
721     soluteradio.setSelected(tsk.shake_s);
722     if(tsk.shake_s){
723       maxit2label.setForeground(Color.black);
724       maxit2field.setEnabled(true);
725       tol2label.setForeground(Color.black);
726       tol2field.setEnabled(true);
727     } else {
728       maxit2label.setForeground(Color.gray);
729       maxit2field.setEnabled(false);
730       tol2label.setForeground(Color.gray);
731       tol2field.setEnabled(false);
732     };
733     if(tsk.twin){
734       cutbox.setSelectedIndex(1);
735       shortlabel.setForeground(Color.black);
736       longlabel.setForeground(Color.black);
737       longfield.setEnabled(true);
738       freqlabel.setForeground(Color.black);
739       freqfield.setEnabled(true);
740     } else {
741       cutbox.setSelectedIndex(0);
742       shortlabel.setForeground(Color.gray);
743       longlabel.setForeground(Color.gray);
744       longfield.setEnabled(false);
745       freqlabel.setForeground(Color.gray);
746       freqfield.setEnabled(false);
747     };
748   }
749 
750 ///////////////////////////////////////////////////////////////////////////
751 //	Helper method for setting GridBagLayout
752 //////////////////////////////////////////////////////////////////////////
753 
addComponent(Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, int anchor)754   static void addComponent(Container container, Component component,
755 			   int gridx, int gridy, int gridwidth,
756 			   int gridheight, double weightx,
757 			   double weighty, int fill, int anchor) {
758     LayoutManager lm = container.getLayout();
759     if(!(lm instanceof GridBagLayout)){
760       System.out.println("Illegal layout"); System.exit(1);
761     } else {
762       GridBagConstraints gbc = new GridBagConstraints();
763       gbc.gridx=gridx;
764       gbc.gridy=gridy;
765       gbc.gridwidth=gridwidth;
766       gbc.gridheight=gridheight;
767       gbc.weightx=weightx;
768       gbc.weighty=weighty;
769       gbc.fill=fill;
770       gbc.anchor=anchor;
771       container.add(component,gbc);
772     }
773   }
774 
setInitialVariables()775   public void setInitialVariables() {
776 
777     grid1field.setText(new Integer(parentFrame.gridx).toString());
778     grid2field.setText(new Integer(parentFrame.gridy).toString());
779     grid3field.setText(new Integer(parentFrame.gridz).toString());
780     alphafield.setText(new Double(parentFrame.alpha).toString());
781     orderfield.setText(new Integer(parentFrame.order).toString());
782     nodesfield.setText(new Integer(parentFrame.nodpme).toString());
783     fftfield.setText(new Integer(parentFrame.fft).toString());
784     if (parentFrame.twin) cutbox.setSelectedIndex(0);
785     else cutbox.setSelectedIndex(1);
786     shortfield.setText(new Double(parentFrame.r_short).toString());
787     longfield.setText(new Double(parentFrame.r_long).toString());
788     if (parentFrame.shake_w) solventradio.setSelected(true);
789     if (parentFrame.shake_s) soluteradio.setSelected(true);
790     maxit1field.setText(new Integer(parentFrame.shake_w_iter).toString());
791     maxit2field.setText(new Integer(parentFrame.shake_s_iter).toString());
792     tol1field.setText(new Double(parentFrame.shake_w_toler).toString());
793     tol2field.setText(new Double(parentFrame.shake_s_toler).toString());
794     if (parentFrame.distar) applyradio.setSelected(true);
795     if (parentFrame.draver) averageradio.setSelected(true);
796     scale1field.setText(new Double(parentFrame.drsscl).toString());
797     scale2field.setText(new Double(parentFrame.nfdrss).toString());
798     if (parentFrame.fix) fixbox.setSelectedIndex(0);
799     if (parentFrame.unfix) fixbox.setSelectedIndex(1);
800     if (parentFrame.fix_none) noneradio.setSelected(true);
801     if (parentFrame.fix_all) allradio.setSelected(true);
802     if (parentFrame.fix_w) solventrbutton.setSelected(true);
803     if (parentFrame.fix_s) soluterbutton.setSelected(true);
804     if (parentFrame.fix_X) nonHradio.setSelected(true);
805     if (parentFrame.prt_top) topradio.setSelected(true);
806     if (parentFrame.prt_topn) nonbradio.setSelected(true);
807     if (parentFrame.prt_topw) solvradio.setSelected(true);
808     if (parentFrame.prt_tops) soluradio.setSelected(true);
809     stepfield.setText(new Integer(parentFrame.prt_step).toString());
810     statfield.setText(new Integer(parentFrame.prt_stat).toString());
811     if (parentFrame.prt_extra) extraradio.setSelected(true);
812     if (parentFrame.prt_energy) energyradio.setSelected(true);
813     expectfield.setText(new Integer(parentFrame.prt_expect).toString());
814     if (parentFrame.load_pair) pairsradio.setSelected(true);
815     maxupfield.setText(new Integer(parentFrame.load_num_pair).toString());
816     if (parentFrame.load_reset) resetradio.setSelected(true);
817     if (parentFrame.load_size) boxsizeradio.setSelected(true);
818 
819   }
820 
821 }
822