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