$darkmode
DENOPTIM
FSParametersForm.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2020 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.gui;
20
21import java.awt.BorderLayout;
22import java.awt.Dimension;
23import java.awt.FlowLayout;
24import java.awt.GridLayout;
25import java.awt.event.ActionEvent;
26import java.awt.event.ActionListener;
27import java.util.ArrayList;
28import java.util.Arrays;
29import java.util.HashMap;
30import java.util.List;
31import java.util.Map;
32
33import javax.swing.BoxLayout;
34import javax.swing.GroupLayout;
35import javax.swing.JButton;
36import javax.swing.JComboBox;
37import javax.swing.JLabel;
38import javax.swing.JOptionPane;
39import javax.swing.JPanel;
40import javax.swing.JRadioButton;
41import javax.swing.JScrollPane;
42import javax.swing.JTable;
43import javax.swing.JTextField;
44import javax.swing.SwingConstants;
45import javax.swing.UIManager;
46import javax.swing.table.DefaultTableModel;
47
48import denoptim.fragspace.FragmentSpace;
49import denoptim.graph.rings.RingClosureParameters;
50
58public class FSParametersForm extends ParametersForm
59{
60
64 private static final long serialVersionUID = -821783042250597956L;
65
70 private Map<String,Object> mapKeyFieldToValueField;
71
72 JPanel block;
78
80 JRadioButton rdbSrcOrNew;
81
84 JTextField txtFSSource;
85 JButton btnFSSource;
87
88 String keyPar1 = "FS-ScaffoldLibFile";
89 JPanel linePar1;
90 JLabel lblPar1;
91 JTextField txtPar1;
92 JButton btnPar1;
93
94 String keyPar2 = "FS-FragmentLibFile";
95 JPanel linePar2;
96 JLabel lblPar2;
97 JTextField txtPar2;
98 JButton btnPar2;
99
100 String keyPar3 = "FS-CappingFragmentLibFile";
101 JPanel linePar3;
102 JLabel lblPar3;
103 JTextField txtPar3;
104 JButton btnPar3;
105
106 String keyCPMat = "FS-CompMatrixFile";
107 JPanel lineCPMat;
108 JLabel lblCPMat;
109 JTextField txtCPMat;
110 JButton btnCPMat;
111
112 String keyPar6 = "FS-RotBondsDefFile";
113 JPanel linePar6;
114 JLabel lblPar6;
115 JTextField txtPar6;
116 JButton btnPar6;
117
118 String keyPar7 = "FS-MaxHeavyAtom";
119 JPanel linePar7;
120 JLabel lblPar7;
121 JTextField txtPar7;
122
123 String keyPar8 = "FS-MaxMW";
124 JPanel linePar8;
125 JLabel lblPar8;
126 JTextField txtPar8;
127
128 String keyPar9 = "FS-MaxRotatableBond";
129 JPanel linePar9;
130 JLabel lblPar9;
131 JTextField txtPar9;
132
133 String keyPar10 = "FS-EnforceSymmetry";
134 JPanel linePar10;
135 JRadioButton rdbPar10;
136
137 String keyPar11 = "FS-ConstrainSymmetry";
138 JPanel linePar11;
141 JLabel lblPar11;
142 JTable tabPar11;
143 DefaultTableModel tabModPar11;
144
145 String keyPar12 = "RC-CloseRings";
146 JPanel linePar12;
147 JRadioButton rdbPar12;
148
149 String keyPar5 = "FS-RCCompMatrixFile";
150 JPanel linePar5;
151 JLabel lblPar5;
152 JTextField txtPar5;
153 JButton btnPar5;
154
155 String keyPar15 = "RC-MinNumberOfRingClosures";
156 JPanel linePar15;
157 JLabel lblPar15;
158 JTextField txtPar15;
159
160 String keyPar16 = "RC-MaxNumberRingClosures";
161 JPanel linePar16;
162 JLabel lblPar16;
163 JTextField txtPar16;
164
165 String keyPar17 = "RC-MinRCAPerTypePerGraph";
166 JPanel linePar17;
167 JLabel lblPar17;
168 JTextField txtPar17;
169
170 String keyPar18 = "RC-MaxRCAPerTypePerGraph";
171 JPanel linePar18;
172 JLabel lblPar18;
173 JTextField txtPar18;
174
175 String keyPar22 = "RC-RingSizeBias";
176 JPanel linePar22;
177 JLabel lblPar22;
180 JTable tabPar22;
181 DefaultTableModel tabModPar22;
182
183 String keyPar23 = "RC-MaxSizeNewRings";
184 JPanel linePar23;
185 JLabel lblPar23;
186 JTextField txtPar23;
187
188 String keyPar19 = "RC-EvaluationClosabilityMode";
189 JPanel linePar19;
190 JLabel lblPar19;
191 JComboBox<String> cmbPar19;
192
193 String keyPar21 = "RC-ClosableRingSMARTS";
194 JPanel linePar21;
195 JLabel lblPar21;
198 JTable tabPar21;
199 DefaultTableModel tabModPar21;
200
201 String keyPar24 = "RC-CheckInterdependentChains";
202 JPanel linePar24;
203 JRadioButton rdbPar24;
204
205 String keyPar25 = "RC-MaxRotBonds";
206 JPanel linePar25;
207 JLabel lblPar25;
208 JTextField txtPar25;
209
210 String keyPar26 = "RC-ConfSearchStep";
211 JPanel linePar26;
212 JLabel lblPar26;
213 JTextField txtPar26;
214
215 String keyPar27 = "RC-LinearityLimit";
216 JPanel linePar27;
217 JLabel lblPar27;
218 JTextField txtPar27;
219
220 String keyPar28 = "RC-ExhaustiveConfSearch";
221 JPanel linePar28;
222 JRadioButton rdbPar28;
223
224 String keyPar30 = "RC-RCCIndex";
225 JPanel linePar30;
226 JLabel lblPar30;
227 JTextField txtPar30;
228 JButton btnPar30;
229
230 String keyPar31 = "RC-RCCFolder";
231 JPanel linePar31;
232 JLabel lblPar31;
233 JTextField txtPar31;
234 JButton btnPar31;
235
236 String keyPar32 = "RC-MaxDotProd";
237 JPanel linePar32;
238 JLabel lblPar32;
239 JTextField txtPar32;
240
241 String keyPar33 = "RC-DistanceToleranceFactor";
242 JPanel linePar33;
243 JLabel lblPar33;
244 JTextField txtPar33;
245
246 String keyPar34 = "RC-ExtraDistanceToleranceFactor";
247 JPanel linePar34;
248 JLabel lblPar34;
249 JTextField txtPar34;
250
251 //HEREGOFIELDS this is only to facilitate automated insertion of code
252
253 String NL = System.getProperty("line.separator");
254
255//------------------------------------------------------------------------------
256
257 public FSParametersForm(Dimension d)
258 {
259 mapKeyFieldToValueField = new HashMap<String,Object>();
260
261 this.setLayout(new BorderLayout()); //Needed to allow dynamic resizing!
262
263 JPanel block = new JPanel();
264 JScrollPane scrollablePane = new JScrollPane(block);
265 block.setLayout(new BoxLayout(block, SwingConstants.VERTICAL));
266
267 localBlock1 = new JPanel();
268 localBlock1.setVisible(false);
269 localBlock1.setLayout(new BoxLayout(localBlock1, SwingConstants.VERTICAL));
270
271 localBlock2 = new JPanel();
272 localBlock2.setVisible(true);
273 localBlock2.setLayout(new BoxLayout(localBlock2, SwingConstants.VERTICAL));
274
275 localBlock3 = new JPanel();
276 localBlock3.setVisible(false);
277 localBlock3.setLayout(new BoxLayout(localBlock3, SwingConstants.VERTICAL));
278
279 localBlock4 = new JPanel();
280 localBlock4.setVisible(true);
281 localBlock4.setLayout(new BoxLayout(localBlock4, SwingConstants.VERTICAL));
282
283 localBlock5 = new JPanel();
284 localBlock5.setVisible(false);
285 localBlock5.setLayout(new BoxLayout(localBlock5, SwingConstants.VERTICAL));
286
287 String toolTipSrcOrNew = "Tick here to use parameters from a previously "
288 + "defined space of building blocks.";
289 lineSrcOrNew = new JPanel(new FlowLayout(FlowLayout.LEFT));
290 rdbSrcOrNew = new JRadioButton("Use parameters from existing file");
291 rdbSrcOrNew.setToolTipText(toolTipSrcOrNew);
292 rdbSrcOrNew.addActionListener(new ActionListener(){
293 public void actionPerformed(ActionEvent e){
294 if (rdbSrcOrNew.isSelected())
295 {
296 localBlock1.setVisible(true);
297 localBlock2.setVisible(false);
298 }
299 else
300 {
301 localBlock1.setVisible(false);
302 localBlock2.setVisible(true);
303 }
304 }
305 });
307 block.add(lineSrcOrNew);
308 block.add(localBlock1);
309 block.add(localBlock2);
310
311 //HEREGOESIMPLEMENTATION this is only to facilitate automated insertion of code
312
313 // From here is all stuff that will become visible once some previously defined options have been selected
314
315 String toolTipFSSource = "<html>Pathname of a DENOPTIM's parameter file with GA settings.</html>";
316 lineFSSource = new JPanel(new FlowLayout(FlowLayout.LEFT));
317 lblFSSource = new JLabel("Previous parameters file:", SwingConstants.LEFT);
318 lblFSSource.setToolTipText(toolTipFSSource);
319 txtFSSource = new JTextField();
320 txtFSSource.setToolTipText(toolTipFSSource);
321 txtFSSource.setPreferredSize(fileFieldSize);
322 btnFSSource = new JButton("Browse");
323 btnFSSource.addActionListener(new ActionListener() {
324 public void actionPerformed(ActionEvent e) {
326 }
327 });
328 btnLoadFSSource = new JButton("Load...");
329 txtFSSource.setToolTipText("<html>Specify a file with parameters to "
330 + "be loaded in this form.</html>");
331 btnLoadFSSource.addActionListener(new ActionListener() {
332 public void actionPerformed(ActionEvent e) {
333 try
334 {
336 }
337 catch (Exception e1)
338 {
339 if (e1.getMessage().equals("") || e1.getMessage() == null)
340 {
341 e1.printStackTrace();
342 JOptionPane.showMessageDialog(btnLoadFSSource,
343 "<html>Exception occurred while importing parameters.<br>Please, report this to the DENOPTIM team.</html>",
344 "Error",
345 JOptionPane.ERROR_MESSAGE,
346 UIManager.getIcon("OptionPane.errorIcon"));
347 }
348 else
349 {
350 JOptionPane.showMessageDialog(btnLoadFSSource,
351 e1.getMessage(),
352 "Error",
353 JOptionPane.ERROR_MESSAGE,
354 UIManager.getIcon("OptionPane.errorIcon"));
355 }
356 return;
357 }
358 }
359 });
365
366 String toolTipPar1 = "Pathname of the file containing the list of scaffolds.";
367 linePar1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
368 lblPar1 = new JLabel("Library of Scaffolds:", SwingConstants.LEFT);
369 lblPar1.setPreferredSize(fileLabelSize);
370 lblPar1.setToolTipText(toolTipPar1);
371 txtPar1 = new JTextField();
372 txtPar1.setToolTipText(toolTipPar1);
373 txtPar1.setPreferredSize(fileFieldSize);
374 txtPar1.getDocument().addDocumentListener(fieldListener);
375 mapKeyFieldToValueField.put(keyPar1.toUpperCase(),txtPar1);
376 btnPar1 = new JButton("Browse");
377 btnPar1.addActionListener(new ActionListener() {
378 public void actionPerformed(ActionEvent e) {
380 }
381 });
382 linePar1.add(lblPar1);
383 linePar1.add(txtPar1);
384 linePar1.add(btnPar1);
386
387 String toolTipPar2 = "Pathname of the file containing the list of fragments.";
388 linePar2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
389 lblPar2 = new JLabel("Library of vertices:", SwingConstants.LEFT);
390 lblPar2.setPreferredSize(fileLabelSize);
391 lblPar2.setToolTipText(toolTipPar2);
392 txtPar2 = new JTextField();
393 txtPar2.setToolTipText(toolTipPar2);
394 txtPar2.setPreferredSize(fileFieldSize);
395 txtPar2.getDocument().addDocumentListener(fieldListener);
396 mapKeyFieldToValueField.put(keyPar2.toUpperCase(),txtPar2);
397 btnPar2 = new JButton("Browse");
398 btnPar2.addActionListener(new ActionListener() {
399 public void actionPerformed(ActionEvent e) {
401 }
402 });
403 linePar2.add(lblPar2);
404 linePar2.add(txtPar2);
405 linePar2.add(btnPar2);
407
408 String toolTipPar3 = "Pathname of the file containing the list of capping groups.";
409 linePar3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
410 lblPar3 = new JLabel("Capping groups library:", SwingConstants.LEFT);
411 lblPar3.setPreferredSize(fileLabelSize);
412 lblPar3.setToolTipText(toolTipPar3);
413 txtPar3 = new JTextField();
414 txtPar3.setToolTipText(toolTipPar3);
415 txtPar3.setPreferredSize(fileFieldSize);
416 txtPar3.getDocument().addDocumentListener(fieldListener);
417 mapKeyFieldToValueField.put(keyPar3.toUpperCase(),txtPar3);
418 btnPar3 = new JButton("Browse");
419 btnPar3.addActionListener(new ActionListener() {
420 public void actionPerformed(ActionEvent e) {
422 }
423 });
424 linePar3.add(lblPar3);
425 linePar3.add(txtPar3);
426 linePar3.add(btnPar3);
428
429 String toolTipCPMat = "<html>Pathname of the compatibility matrix file.<br>Note that this file contains the compatibility matrix, map of AP-Class to bond order, the capping rules, and the list of forbidden ends.</html>";
430 lineCPMat = new JPanel(new FlowLayout(FlowLayout.LEFT));
431 lblCPMat = new JLabel("Compatibility matrix file:", SwingConstants.LEFT);
432 lblCPMat.setPreferredSize(fileLabelSize);
433 lblCPMat.setToolTipText(toolTipCPMat);
434 txtCPMat = new JTextField();
435 txtCPMat.setToolTipText(toolTipCPMat);
436 txtCPMat.setPreferredSize(fileFieldSize);
437 txtCPMat.getDocument().addDocumentListener(fieldListener);
438 mapKeyFieldToValueField.put(keyCPMat.toUpperCase(),txtCPMat);
439 btnCPMat = new JButton("Browse");
440 btnCPMat.addActionListener(new ActionListener() {
441 public void actionPerformed(ActionEvent e) {
443 }
444 });
445 lineCPMat.add(lblCPMat);
446 lineCPMat.add(txtCPMat);
447 lineCPMat.add(btnCPMat);
449
450 String toolTipPar6 = "<html>Pathname of the file containing the definition of the rotatable bonds.<br>Must be a list of SMARTS.</html>";
451 linePar6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
452 lblPar6 = new JLabel("Rotatable bonds list:", SwingConstants.LEFT);
453 lblPar6.setPreferredSize(fileLabelSize);
454 lblPar6.setToolTipText(toolTipPar6);
455 txtPar6 = new JTextField();
456 txtPar6.setToolTipText(toolTipPar6);
457 txtPar6.setPreferredSize(fileFieldSize);
458 txtPar6.getDocument().addDocumentListener(fieldListener);
459 mapKeyFieldToValueField.put(keyPar6.toUpperCase(),txtPar6);
460 btnPar6 = new JButton("Browse");
461 btnPar6.addActionListener(new ActionListener() {
462 public void actionPerformed(ActionEvent e) {
464 }
465 });
466 linePar6.add(lblPar6);
467 linePar6.add(txtPar6);
468 linePar6.add(btnPar6);
470
471 String toolTipPar7 = "Maximum number of heavy (non-hydrogen) atoms for a candidate.";
472 linePar7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
473 lblPar7 = new JLabel("Max non-H atoms:", SwingConstants.LEFT);
474 lblPar7.setPreferredSize(fileLabelSize);
475 lblPar7.setToolTipText(toolTipPar7);
476 txtPar7 = new JTextField();
477 txtPar7.setToolTipText(toolTipPar7);
478 txtPar7.setPreferredSize(strFieldSize);
479 txtPar7.getDocument().addDocumentListener(fieldListener);
480 mapKeyFieldToValueField.put(keyPar7.toUpperCase(),txtPar7);
481 linePar7.add(lblPar7);
482 linePar7.add(txtPar7);
484
485 String toolTipPar8 = "Maximum molecular weight accepted for a candidate";
486 linePar8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
487 lblPar8 = new JLabel("Max molecular weight: ", SwingConstants.LEFT);
488 lblPar8.setPreferredSize(fileLabelSize);
489 lblPar8.setToolTipText(toolTipPar8);
490 txtPar8 = new JTextField();
491 txtPar8.setToolTipText(toolTipPar8);
492 txtPar8.setPreferredSize(strFieldSize);
493 txtPar8.getDocument().addDocumentListener(fieldListener);
494 mapKeyFieldToValueField.put(keyPar8.toUpperCase(),txtPar8);
495 linePar8.add(lblPar8);
496 linePar8.add(txtPar8);
498
499 String toolTipPar9 = "Maximum number of rotatable bonds accepted for a candidate";
500 linePar9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
501 lblPar9 = new JLabel("Max rotatable bonds:", SwingConstants.LEFT);
502 lblPar9.setPreferredSize(fileLabelSize);
503 lblPar9.setToolTipText(toolTipPar9);
504 txtPar9 = new JTextField();
505 txtPar9.setToolTipText(toolTipPar9);
506 txtPar9.setPreferredSize(strFieldSize);
507 txtPar9.getDocument().addDocumentListener(fieldListener);
508 mapKeyFieldToValueField.put(keyPar9.toUpperCase(),txtPar9);
509 linePar9.add(lblPar9);
510 linePar9.add(txtPar9);
512
513 String toolTipPar10 = "<html>Forces constitutional symmetry whenever possible.<br>Corresponds to setting the symmetric substitution probability to 100%.</html>";
514 linePar10 = new JPanel(new FlowLayout(FlowLayout.LEFT));
515 rdbPar10 = new JRadioButton("Enforce symmetry:");
516 rdbPar10.setToolTipText(toolTipPar10);
517 rdbPar10.addChangeListener(rdbFieldChange);
518 mapKeyFieldToValueField.put(keyPar10.toUpperCase(),rdbPar10);
519 linePar10.add(rdbPar10);
521
522 String toolTipPar11 = "<html>List of constraints in the symmetric substitution probability.<br>These constraints overwrite the any other settings only for the specific AP-classes.</html>";
523 linePar11 = new JPanel(new GridLayout(2, 2));
524 lblPar11 = new JLabel("Symmetry constraints:", SwingConstants.LEFT);
525 lblPar11.setPreferredSize(fileLabelSize);
526 lblPar11.setToolTipText(toolTipPar11);
527 tabModPar11 = new DefaultTableModel();
528 tabModPar11.setColumnCount(2);
529 tabModPar11.addTableModelListener(tabFieldChange);
531 tabPar11 = new JTable(tabModPar11);
532 tabPar11.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
533 btnPar11Insert = new JButton("Add Constraint");
534 btnPar11Insert.setToolTipText("Click to choose an AP-Class from the "
535 + "compatibility matrix specified above.");
536 btnPar11Insert.addActionListener(new ActionListener(){
537 public void actionPerformed(ActionEvent e){
538
539 // WARNING: here we use the compatibility matrix file to get all the APClasses
540 // This assumes that the libraries of fragments (scaffolds, frags, and capping groups)
541 // are consistent with the compatibility matrix file.
542
543 boolean apClassesFromCPMap = false;
544 Object[] allAPClasses = new Object[]{};
545 try
546 {
547 FragmentSpace fs = new FragmentSpace();
549 allAPClasses = new Object[fs.getAllAPClassesFromCPMap().size()];
550 fs.getAllAPClassesFromCPMap().toArray(allAPClasses);
551 apClassesFromCPMap=true;
552 }
553 catch (Throwable t)
554 {
555 JOptionPane.showMessageDialog(btnPar11Insert,
556 "<html>The current parameters do not create a valid "
557 + "space of building blocks.<br>"
558 + "It looks like you want to manually insert APClasses.<br>"
559 + "If this is not true, you must adjust the parameters defining the "
560 + "space of building blocks.</html>",
561 "No valid FragmentSpace",
562 JOptionPane.WARNING_MESSAGE);
563 }
564
565 if (apClassesFromCPMap)
566 {
567 boolean done = false;
568 while (!done)
569 {
570 String apClass = (String)JOptionPane.showInputDialog(
572 "Choose attachment point class:",
573 "apClass",
574 JOptionPane.PLAIN_MESSAGE,
575 null,
576 allAPClasses,
577 null);
578
579 if ((apClass != null) && (apClass.length() > 0))
580 {
581 boolean goodChoice = true;
582 if (tabPar11.getRowCount() > 0)
583 {
584 for (int i=0; i<tabPar11.getRowCount(); i++)
585 {
586 if (apClass.equals(tabPar11.getValueAt(i, 0)))
587 {
588 JOptionPane.showMessageDialog(
590 "<html>apClass already in the "
591 + "table.<br>Choose another "
592 + "class.",
593 "Duplicate apClass",
594 JOptionPane.ERROR_MESSAGE);
595 goodChoice = false;
596 break;
597 }
598 }
599 }
600 if (goodChoice)
601 {
602 tabModPar11.addRow(new Object[]{apClass, 1.00});
603 done = true;
604 }
605 }
606 if (apClass == null)
607 {
608 done =true;
609 }
610 }
611 }
612 else
613 {
614 boolean done = false;
615 while (!done)
616 {
617 String apClass = (String)JOptionPane.showInputDialog(
619 "<html>No fragment library found.<br>Type an attachment point class:</html>",
620 "apClass",
621 JOptionPane.PLAIN_MESSAGE);
622
623 if ((apClass != null) && (apClass.length() > 0))
624 {
625 boolean goodChoice = true;
626 if (tabPar11.getRowCount() > 0)
627 {
628 for (int i=0; i<tabPar11.getRowCount(); i++)
629 {
630 if (apClass.equals(tabPar11.getValueAt(i, 0)))
631 {
632 JOptionPane.showMessageDialog(
634 "<html>apClass already in the table.<br>Choose another class.",
635 "Duplicate apClass",
636 JOptionPane.ERROR_MESSAGE);
637 goodChoice = false;
638 break;
639 }
640 }
641 }
642 if (goodChoice)
643 {
644 tabModPar11.addRow(new Object[]{apClass, 1.00});
645 }
646 }
647 if (apClass == null)
648 {
649 done =true;
650 }
651 }
652 }
653 }
654 });
655 btnPar11Cleanup = new JButton("Remove Selected");
656 btnPar11Cleanup.setToolTipText("Remove all selected entries from list.");
657 btnPar11Cleanup.addActionListener(new ActionListener(){
658 public void actionPerformed(ActionEvent e){
659 if (tabPar11.getRowCount() > 0)
660 {
661 if (tabPar11.getSelectedRowCount() > 0)
662 {
663 int selectedRowIds[] = tabPar11.getSelectedRows();
664 Arrays.sort(selectedRowIds);
665 for (int i=(selectedRowIds.length-1); i>-1; i--)
666 {
667 tabModPar11.removeRow(selectedRowIds[i]);
668 }
669 }
670 }
671 }
672 });
673 GroupLayout grpLyoPar11 = new GroupLayout(linePar11);
674 linePar11.setLayout(grpLyoPar11);
675 grpLyoPar11.setAutoCreateGaps(true);
676 grpLyoPar11.setAutoCreateContainerGaps(true);
677 grpLyoPar11.setHorizontalGroup(grpLyoPar11.createSequentialGroup()
678 .addComponent(lblPar11)
679 .addGroup(grpLyoPar11.createParallelGroup()
680 .addGroup(grpLyoPar11.createSequentialGroup()
681 .addComponent(btnPar11Insert)
682 .addComponent(btnPar11Cleanup))
683 .addComponent(tabPar11))
684 );
685 grpLyoPar11.setVerticalGroup(grpLyoPar11.createParallelGroup(GroupLayout.Alignment.LEADING)
686 .addComponent(lblPar11)
687 .addGroup(grpLyoPar11.createSequentialGroup()
688 .addGroup(grpLyoPar11.createParallelGroup()
689 .addComponent(btnPar11Insert)
690 .addComponent(btnPar11Cleanup))
691 .addComponent(tabPar11))
692 );
694
695 String toolTipPar12 = "<html>Activates search and handling of rings of fragments.</html>";
696 linePar12 = new JPanel(new FlowLayout(FlowLayout.LEFT));
697 rdbPar12 = new JRadioButton("Enable cyclic graphs (create rings of fragments)");
698 rdbPar12.setToolTipText(toolTipPar12);
699 rdbPar12.addChangeListener(rdbFieldChange);
700 mapKeyFieldToValueField.put(keyPar12.toUpperCase(),rdbPar12);
701 rdbPar12.addActionListener(new ActionListener(){
702 public void actionPerformed(ActionEvent e){
703 if (rdbPar12.isSelected())
704 {
705 localBlock3.setVisible(true);
706 scrollablePane.validate();
707 scrollablePane.repaint();
708 scrollablePane.getVerticalScrollBar().setValue(
709 scrollablePane.getVerticalScrollBar().getValue() + (int) preferredHeight*2/3);
710 }
711 else
712 {
713 localBlock3.setVisible(false);
714 }
715 }
716 });
717 linePar12.add(rdbPar12);
720
721 String toolTipPar5 = "Pathname of the file containing the compatibility matrix for ring closures";
722 linePar5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
723 lblPar5 = new JLabel("Compatibility matrix for ring closures:", SwingConstants.LEFT);
724 lblPar5.setPreferredSize(fileLabelSize);
725 lblPar5.setToolTipText(toolTipPar5);
726 txtPar5 = new JTextField();
727 txtPar5.setToolTipText(toolTipPar5);
728 txtPar5.setPreferredSize(fileFieldSize);
729 txtPar5.getDocument().addDocumentListener(fieldListener);
730 mapKeyFieldToValueField.put(keyPar5.toUpperCase(),txtPar5);
731 btnPar5 = new JButton("Browse");
732 btnPar5.addActionListener(new ActionListener() {
733 public void actionPerformed(ActionEvent e) {
735 }
736 });
737 linePar5.add(lblPar5);
738 linePar5.add(txtPar5);
739 linePar5.add(btnPar5);
741
742 String toolTipPar15 = "Specifies the minimum number of rings to be closed in order to accept a candidate graph.";
743 linePar15 = new JPanel(new FlowLayout(FlowLayout.LEFT));
744 lblPar15 = new JLabel("Min. number of ring closures:", SwingConstants.LEFT);
745 lblPar15.setPreferredSize(fileLabelSize);
746 lblPar15.setToolTipText(toolTipPar15);
747 txtPar15 = new JTextField();
748 txtPar15.setToolTipText(toolTipPar15);
749 txtPar15.setPreferredSize(strFieldSize);
750 txtPar15.getDocument().addDocumentListener(fieldListener);
751 mapKeyFieldToValueField.put(keyPar15.toUpperCase(),txtPar15);
752 linePar15.add(lblPar15);
753 linePar15.add(txtPar15);
755
756 String toolTipPar16 = "Maximum number of ring closures per graph.";
757 linePar16 = new JPanel(new FlowLayout(FlowLayout.LEFT));
758 lblPar16 = new JLabel("Max. number of ring closures:", SwingConstants.LEFT);
759 lblPar16.setPreferredSize(fileLabelSize);
760 lblPar16.setToolTipText(toolTipPar16);
761 txtPar16 = new JTextField();
762 txtPar16.setToolTipText(toolTipPar16);
763 txtPar16.setPreferredSize(strFieldSize);
764 txtPar16.getDocument().addDocumentListener(fieldListener);
765 mapKeyFieldToValueField.put(keyPar16.toUpperCase(),txtPar16);
766 linePar16.add(lblPar16);
767 linePar16.add(txtPar16);
769
770 String toolTipPar17 = "Minimum number of ring closing attractors (RCA) of the same type per graph.";
771 linePar17 = new JPanel(new FlowLayout(FlowLayout.LEFT));
772 lblPar17 = new JLabel("<html>Min. num. RCA<sub>type</sub> per graph:</html>", SwingConstants.LEFT);
773 lblPar17.setPreferredSize(fileLabelSize);
774 lblPar17.setToolTipText(toolTipPar17);
775 txtPar17 = new JTextField();
776 txtPar17.setToolTipText(toolTipPar17);
777 txtPar17.setPreferredSize(strFieldSize);
778 txtPar17.getDocument().addDocumentListener(fieldListener);
779 mapKeyFieldToValueField.put(keyPar17.toUpperCase(),txtPar17);
780 linePar17.add(lblPar17);
781 linePar17.add(txtPar17);
783
784 String toolTipPar18 = "Maximum number of ring closing attractors (RCA) of the same type that are accepted for a single graph.";
785 linePar18 = new JPanel(new FlowLayout(FlowLayout.LEFT));
786 lblPar18 = new JLabel("<html>Max. num. RCA<sub>type</sub> per graph:</html>", SwingConstants.LEFT);
787 lblPar18.setPreferredSize(fileLabelSize);
788 lblPar18.setToolTipText(toolTipPar18);
789 txtPar18 = new JTextField();
790 txtPar18.setToolTipText(toolTipPar18);
791 txtPar18.setPreferredSize(strFieldSize);
792 txtPar18.getDocument().addDocumentListener(fieldListener);
793 mapKeyFieldToValueField.put(keyPar18.toUpperCase(),txtPar18);
794 linePar18.add(lblPar18);
795 linePar18.add(txtPar18);
797
798 String toolTipPar22 = "<html>Specifies the bias associated to a given ring size.<br> The bias is an integer used as a weight when chosing among<br>combination of rings (i.e., RCAs) for a given graph.</html>";
799 linePar22 = new JPanel(new FlowLayout(FlowLayout.LEFT));
800 lblPar22 = new JLabel("Ring size preference biases:", SwingConstants.LEFT);
801 lblPar22.setPreferredSize(fileLabelSize);
802 lblPar22.setToolTipText(toolTipPar22);
803 tabModPar22 = new DefaultTableModel();
804 tabModPar22.setColumnCount(2);
805 tabModPar22.addRow(new Object[]{"<html><b>Ring Size</b></html>",
806 "<html><b>Bias (int)</b></html>"});
807 RingClosureParameters rcParamsDefault = new RingClosureParameters();
808 List<Integer> ringSizeBias = rcParamsDefault.getRingSizeBias();
809 for (int ib=0; ib<ringSizeBias.size(); ib++)
810 {
811 int w = ringSizeBias.get(ib);
812 if (w > 0)
813 {
814 tabModPar22.addRow(new Object[] {ib,w});
815 }
816 }
817 tabModPar22.addTableModelListener(tabFieldChange);
819 tabPar22 = new JTable(tabModPar22);
820 tabPar22.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
821 tabPar22.setToolTipText("Ring size (1st column) and bias (2nd column) must be positive integers.");
822 btnPar22Insert = new JButton("Add Bias");
823 btnPar22Insert.setToolTipText("Click to set a new ring size bias.");
824 btnPar22Insert.addActionListener(new ActionListener(){
825 public void actionPerformed(ActionEvent e){
826 boolean done = false;
827 while (!done)
828 {
829 String rsBias = (String)JOptionPane.showInputDialog(
831 "Specify ring size:",
832 "Ring Size",
833 JOptionPane.PLAIN_MESSAGE);
834
835 if ((rsBias != null) && (rsBias.length() > 0))
836 {
837 boolean goodChoice = true;
838 if (tabPar22.getRowCount() > 0)
839 {
840 for (int i=0; i<tabPar22.getRowCount(); i++)
841 {
842 if (rsBias.equals(tabPar22.getValueAt(i, 0)))
843 {
844 JOptionPane.showMessageDialog(
846 "<html>Rins size already in the table.<br>Choose another size or modify the value of the bias in the table.</html>", "Duplicate Entry", JOptionPane.ERROR_MESSAGE);
847 goodChoice = false;
848 break;
849 }
850 }
851 }
852 if (goodChoice)
853 {
854 if (tabPar22.getRowCount() == 0)
855 {
856 tabModPar22.addRow(new Object[]{"<html><b>Ring Size</b></html>", "<html><b>Bias (int)</b></html>"});
857 }
858 tabModPar22.addRow(new Object[]{rsBias, 1});
859 done = true;
860 }
861 }
862 if (rsBias == null)
863 {
864 done =true;
865 }
866 }
867 }
868 });
869 btnPar22Cleanup = new JButton("Remove Selected");
870 btnPar22Cleanup.setToolTipText("Remove all selected entries from list.");
871 btnPar22Cleanup.addActionListener(new ActionListener(){
872 public void actionPerformed(ActionEvent e){
873 if (tabPar22.getRowCount() > 1)
874 {
875 if (tabPar22.getSelectedRowCount() > 0)
876 {
877 int selectedRowIds[] = tabPar22.getSelectedRows();
878 Arrays.sort(selectedRowIds);
879 for (int i=(selectedRowIds.length-1); i>-1; i--)
880 {
881 if (selectedRowIds[i] != 0)
882 {
883 tabModPar22.removeRow(selectedRowIds[i]);
884 }
885 }
886 if (tabPar22.getRowCount() == 1)
887 {
888 tabModPar22.removeRow(0);
889 }
890 }
891 }
892 }
893 });
894
895 GroupLayout grpLyoPar22 = new GroupLayout(linePar22);
896 linePar22.setLayout(grpLyoPar22);
897 grpLyoPar22.setAutoCreateGaps(true);
898 grpLyoPar22.setAutoCreateContainerGaps(true);
899 grpLyoPar22.setHorizontalGroup(grpLyoPar22.createSequentialGroup()
900 .addComponent(lblPar22)
901 .addGroup(grpLyoPar22.createParallelGroup()
902 .addGroup(grpLyoPar22.createSequentialGroup()
903 .addComponent(btnPar22Insert)
904 .addComponent(btnPar22Cleanup))
905 .addComponent(tabPar22))
906 );
907 grpLyoPar22.setVerticalGroup(grpLyoPar22.createParallelGroup(GroupLayout.Alignment.LEADING)
908 .addComponent(lblPar22)
909 .addGroup(grpLyoPar22.createSequentialGroup()
910 .addGroup(grpLyoPar22.createParallelGroup()
911 .addComponent(btnPar22Insert)
912 .addComponent(btnPar22Cleanup))
913 .addComponent(tabPar22))
914 );
915
917
918 String toolTipPar23 = "Specifies the maximum number of ring members for rings created from scratch";
919 linePar23 = new JPanel(new FlowLayout(FlowLayout.LEFT));
920 lblPar23 = new JLabel("Max. size of new rings:", SwingConstants.LEFT);
921 lblPar23.setPreferredSize(fileLabelSize);
922 lblPar23.setToolTipText(toolTipPar23);
923 txtPar23 = new JTextField();
924 txtPar23.setToolTipText(toolTipPar23);
925 txtPar23.setPreferredSize(strFieldSize);
926 txtPar23.getDocument().addDocumentListener(fieldListener);
927 mapKeyFieldToValueField.put(keyPar23.toUpperCase(),txtPar23);
928 linePar23.add(lblPar23);
929 linePar23.add(txtPar23);
931
932 String toolTipPar19 = "Defined the closability condition's evaluation mode.";
933 linePar19 = new JPanel(new FlowLayout(FlowLayout.LEFT));
934 lblPar19 = new JLabel("Type of ring-closability conditions", SwingConstants.LEFT);
935 lblPar19.setPreferredSize(fileLabelSize);
936 lblPar19.setToolTipText(toolTipPar19);
937 cmbPar19 = new JComboBox<String>(new String[] {"Ring_size", "Constitution", "3D-Conformation", "Constitution_and_3D-Conformation"});
938 cmbPar19.setToolTipText(toolTipPar19);
939 cmbPar19.addActionListener(cmbFieldChange);
940 mapKeyFieldToValueField.put(keyPar19.toUpperCase(),cmbPar19);
941 cmbPar19.addActionListener(new ActionListener(){
942 public void actionPerformed(ActionEvent e){
943 switch (cmbPar19.getSelectedItem().toString())
944 {
945 case "Constitution":
946 localBlock4.setVisible(true);
947 localBlock5.setVisible(false);
948 break;
949
950 case "3D-Conformation":
951 localBlock4.setVisible(false);
952 localBlock5.setVisible(true);
953 break;
954
955 case "Constitution_and_3D-Conformation":
956 localBlock4.setVisible(true);
957 localBlock5.setVisible(true);
958 break;
959 }
960 }
961 });
962 linePar19.add(lblPar19);
963 linePar19.add(cmbPar19);
967
968 String toolTipPar21 = "Specifies the constitutional ring closability conditions by SMARTS string.";
969 linePar21 = new JPanel(new FlowLayout(FlowLayout.LEFT));
970 lblPar21 = new JLabel("Constitutional ring-closability rules:", SwingConstants.LEFT);
971 lblPar21.setPreferredSize(fileLabelSize);
972 lblPar21.setToolTipText(toolTipPar21);
973 tabModPar21 = new DefaultTableModel();
974 tabModPar21.setColumnCount(1);
975 tabModPar21.addTableModelListener(tabFieldChange);
977 tabPar21 = new JTable(tabModPar21);
978 tabPar21.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
979 btnPar21Insert = new JButton("Add SMARTS");
980 btnPar21Insert.setToolTipText("Click to set a new ring size bias.");
981 btnPar21Insert.addActionListener(new ActionListener(){
982 public void actionPerformed(ActionEvent e){
983 boolean done = false;
984 while (!done)
985 {
986 String rcRule = (String)JOptionPane.showInputDialog(
988 "Specify ring-closability rules:",
989 "Add Constitutional Closability Rule",
990 JOptionPane.PLAIN_MESSAGE);
991
992 if ((rcRule != null) && (rcRule.length() > 0))
993 {
994 boolean goodChoice = true;
995 if (tabPar21.getRowCount() > 0)
996 {
997 for (int i=0; i<tabPar21.getRowCount(); i++)
998 {
999 if (rcRule.equals(tabPar21.getValueAt(i, 0)))
1000 {
1001 JOptionPane.showMessageDialog(
1003 "<html>Rule already in the table.</html>",
1004 "Duplicate Entry",
1005 JOptionPane.ERROR_MESSAGE);
1006 goodChoice = false;
1007 break;
1008 }
1009 }
1010 }
1011 if (goodChoice)
1012 {
1013 tabModPar21.addRow(new Object[]{rcRule});
1014 done = true;
1015 }
1016 }
1017 if (rcRule == null)
1018 {
1019 done =true;
1020 }
1021 }
1022 }
1023 });
1024 btnPar21Cleanup = new JButton("Remove Selected");
1025 btnPar21Cleanup.setToolTipText("Remove all selected entries from list.");
1026 btnPar21Cleanup.addActionListener(new ActionListener(){
1027 public void actionPerformed(ActionEvent e){
1028 if (tabPar21.getRowCount() > 0)
1029 {
1030 if (tabPar21.getSelectedRowCount() > 0)
1031 {
1032 int selectedRowIds[] = tabPar21.getSelectedRows();
1033 Arrays.sort(selectedRowIds);
1034 for (int i=(selectedRowIds.length-1); i>-1; i--)
1035 {
1036 tabModPar21.removeRow(selectedRowIds[i]);
1037 }
1038 }
1039 }
1040 }
1041 });
1042 GroupLayout grpLyoPar21 = new GroupLayout(linePar21);
1043 linePar21.setLayout(grpLyoPar21);
1044 grpLyoPar21.setAutoCreateGaps(true);
1045 grpLyoPar21.setAutoCreateContainerGaps(true);
1046 grpLyoPar21.setHorizontalGroup(grpLyoPar21.createSequentialGroup()
1047 .addComponent(lblPar21)
1048 .addGroup(grpLyoPar21.createParallelGroup()
1049 .addGroup(grpLyoPar21.createSequentialGroup()
1050 .addComponent(btnPar21Insert)
1051 .addComponent(btnPar21Cleanup))
1052 .addComponent(tabPar21))
1053 );
1054 grpLyoPar21.setVerticalGroup(grpLyoPar21.createParallelGroup(
1055 GroupLayout.Alignment.LEADING)
1056 .addComponent(lblPar21)
1057 .addGroup(grpLyoPar21.createSequentialGroup()
1058 .addGroup(grpLyoPar21.createParallelGroup()
1059 .addComponent(btnPar21Insert)
1060 .addComponent(btnPar21Cleanup))
1061 .addComponent(tabPar21))
1062 );
1064
1065 String toolTipPar25 = "<html>Specifies the maximum number of rotatable bonds for which 3D chain closability is evaluated. <br>Chains with a number of rotatable bonds higher than this value are assumed closable.</html>";
1066 linePar25 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1067 lblPar25 = new JLabel("Max. rotatable bonds:", SwingConstants.LEFT);
1068 lblPar25.setPreferredSize(fileLabelSize);
1069 lblPar25.setToolTipText(toolTipPar25);
1070 txtPar25 = new JTextField();
1071 txtPar25.setToolTipText(toolTipPar25);
1072 txtPar25.setPreferredSize(strFieldSize);
1073 txtPar25.getDocument().addDocumentListener(fieldListener);
1074 mapKeyFieldToValueField.put(keyPar25.toUpperCase(),txtPar25);
1075 linePar25.add(lblPar25);
1076 linePar25.add(txtPar25);
1078
1079 String toolTipPar26 = "<html>Specifies the torsion angle step (degrees) to be used for the evaluation of 3D chain closability by scanning the torsional space.</html>";
1080 linePar26 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1081 lblPar26 = new JLabel("Dihedral angle step:", SwingConstants.LEFT);
1082 lblPar26.setPreferredSize(fileLabelSize);
1083 lblPar26.setToolTipText(toolTipPar26);
1084 txtPar26 = new JTextField();
1085 txtPar26.setToolTipText(toolTipPar26);
1086 txtPar26.setPreferredSize(strFieldSize);
1087 txtPar26.getDocument().addDocumentListener(fieldListener);
1088 mapKeyFieldToValueField.put(keyPar26.toUpperCase(),txtPar26);
1089 linePar26.add(lblPar26);
1090 linePar26.add(txtPar26);
1092
1093 String toolTipPar27 = "Specifies the bond angle above which three atoms are considered to be in a linear arragement.";
1094 linePar27 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1095 lblPar27 = new JLabel("Bond angle - linearity threshold:", SwingConstants.LEFT);
1096 lblPar27.setPreferredSize(fileLabelSize);
1097 lblPar27.setToolTipText(toolTipPar27);
1098 txtPar27 = new JTextField();
1099 txtPar27.setToolTipText(toolTipPar27);
1100 txtPar27.setPreferredSize(strFieldSize);
1101 txtPar27.getDocument().addDocumentListener(fieldListener);
1102 mapKeyFieldToValueField.put(keyPar27.toUpperCase(),txtPar27);
1103 linePar27.add(lblPar27);
1104 linePar27.add(txtPar27);
1106
1107 String toolTipPar24 = "<html>Requires evaluation of interdependent closability condition.<br><b>WARNING:</b> this function require exhaustive conformational search, which is very time consuming.</html>";
1108 linePar24 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1109 rdbPar24 = new JRadioButton("Check interdependent chain closability.");
1110 rdbPar24.setToolTipText(toolTipPar24);
1111 rdbPar24.addChangeListener(rdbFieldChange);
1112 mapKeyFieldToValueField.put(keyPar24.toUpperCase(),rdbPar24);
1113 linePar24.add(rdbPar24);
1115
1116 String toolTipPar28 = "<html>Requires the search for closable conformations to explore the complete rotational space.<br><b>WARNING:</b> this is very time consuming, but is currently needed to evaluate closability of interdependent chains.</html>";
1117 linePar28 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1118 rdbPar28 = new JRadioButton("Extensive chain conformational search:");
1119 rdbPar28.setToolTipText(toolTipPar28);
1120 rdbPar28.addChangeListener(rdbFieldChange);
1121 mapKeyFieldToValueField.put(keyPar28.toUpperCase(),rdbPar28);
1122 linePar28.add(rdbPar28);
1124
1125 String toolTipPar30 = "Pathname of the text file containing the previously encountered candidate closable chains. This file constitutes the index of the archive of ring closing conformations.";
1126 linePar30 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1127 lblPar30 = new JLabel("Index of closable chain archive:", SwingConstants.LEFT);
1128 lblPar30.setPreferredSize(fileLabelSize);
1129 lblPar30.setToolTipText(toolTipPar30);
1130 txtPar30 = new JTextField();
1131 txtPar30.setToolTipText(toolTipPar30);
1132 txtPar30.setPreferredSize(fileFieldSize);
1133 txtPar30.getDocument().addDocumentListener(fieldListener);
1134 mapKeyFieldToValueField.put(keyPar30.toUpperCase(),txtPar30);
1135 btnPar30 = new JButton("Browse");
1136 btnPar30.addActionListener(new ActionListener() {
1137 public void actionPerformed(ActionEvent e) {
1139 }
1140 });
1141 linePar30.add(lblPar30);
1142 linePar30.add(txtPar30);
1143 linePar30.add(btnPar30);
1145
1146 String toolTipPar31 = "Pathname of the folder containing the archive of ring closing conformations.";
1147 linePar31 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1148 lblPar31 = new JLabel("Root folder of chains archive:", SwingConstants.LEFT);
1149 lblPar31.setPreferredSize(fileLabelSize);
1150 lblPar31.setToolTipText(toolTipPar31);
1151 txtPar31 = new JTextField();
1152 txtPar31.setToolTipText(toolTipPar31);
1153 txtPar31.setPreferredSize(fileFieldSize);
1154 txtPar31.getDocument().addDocumentListener(fieldListener);
1155 mapKeyFieldToValueField.put(keyPar31.toUpperCase(),txtPar31);
1156 btnPar31 = new JButton("Browse");
1157 btnPar31.addActionListener(new ActionListener() {
1158 public void actionPerformed(ActionEvent e) {
1160 }
1161 });
1162 linePar31.add(lblPar31);
1163 linePar31.add(txtPar31);
1164 linePar31.add(btnPar31);
1166
1167 String toolTipPar32 = "Specifies the maximum value of the dot product of the two AP-vectors.";
1168 linePar32 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1169 lblPar32 = new JLabel("Closability – Dot product threshold:", SwingConstants.LEFT);
1170 lblPar32.setPreferredSize(fileLabelSize);
1171 lblPar32.setToolTipText(toolTipPar32);
1172 txtPar32 = new JTextField();
1173 txtPar32.setToolTipText(toolTipPar32);
1174 txtPar32.setPreferredSize(strFieldSize);
1175 txtPar32.getDocument().addDocumentListener(fieldListener);
1176 mapKeyFieldToValueField.put(keyPar32.toUpperCase(),txtPar32);
1177 linePar32.add(lblPar32);
1178 linePar32.add(txtPar32);
1180
1181 String toolTipPar33 = "Specifies the absolute normal deviation of the ideal value (a value between 0.0 and 1.0) that is considered acceptable for distances when evaluating the 3D ring closability of a conformation";
1182 linePar33 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1183 lblPar33 = new JLabel("Closability – Distance deviation:", SwingConstants.LEFT);
1184 lblPar33.setPreferredSize(fileLabelSize);
1185 lblPar33.setToolTipText(toolTipPar33);
1186 txtPar33 = new JTextField();
1187 txtPar33.setToolTipText(toolTipPar33);
1188 txtPar33.setPreferredSize(strFieldSize);
1189 txtPar33.getDocument().addDocumentListener(fieldListener);
1190 mapKeyFieldToValueField.put(keyPar33.toUpperCase(),txtPar33);
1191 linePar33.add(lblPar33);
1192 linePar33.add(txtPar33);
1194
1195 String toolTipPar34 = "Specifies the factor multiplying the tolerance for interatomic distances when evaluating the closability of a chain by a discrete (vs. continuous) exploration of torsional space.";
1196 linePar34 = new JPanel(new FlowLayout(FlowLayout.LEFT));
1197 lblPar34 = new JLabel("Closability – Additional tolerance:", SwingConstants.LEFT);
1198 lblPar34.setPreferredSize(fileLabelSize);
1199 lblPar34.setToolTipText(toolTipPar34);
1200 txtPar34 = new JTextField();
1201 txtPar34.setToolTipText(toolTipPar34);
1202 txtPar34.setPreferredSize(strFieldSize);
1203 txtPar34.getDocument().addDocumentListener(fieldListener);
1204 mapKeyFieldToValueField.put(keyPar34.toUpperCase(),txtPar34);
1205 linePar34.add(lblPar34);
1206 linePar34.add(txtPar34);
1208
1209 //HEREGOESADVIMPLEMENTATION this is only to facilitate automated insertion of code
1210
1211 block.add(super.getPanelForUnformattedInput());
1212
1213 this.add(scrollablePane);
1214 }
1215
1216//-----------------------------------------------------------------------------
1217
1225 @Override
1226 public void importParametersFromDenoptimParamsFile(String fileName) throws Exception
1227 {
1231
1232 rdbSrcOrNew.setSelected(false);
1233 localBlock1.setVisible(false);
1234 localBlock2.setVisible(true);
1235 if (rdbPar12.isSelected())
1236 {
1237 localBlock3.setVisible(true);
1238 }
1239 switch (cmbPar19.getSelectedItem().toString())
1240 {
1241 case "Constitution":
1242 localBlock4.setVisible(true);
1243 localBlock5.setVisible(false);
1244 break;
1245
1246 case "3D-Conformation":
1247 localBlock4.setVisible(false);
1248 localBlock5.setVisible(true);
1249 break;
1250
1251 case "Constitution_and_3D-Conformation":
1252 localBlock4.setVisible(true);
1253 localBlock5.setVisible(true);
1254 break;
1255 }
1256 showUnknownKeyWarning(this, "Fragment Space");
1257 }
1258
1259//-----------------------------------------------------------------------------
1260
1261 @SuppressWarnings("unchecked")
1262 @Override
1263 public void importSingleParameter(String key, String value) throws Exception
1264 {
1265 Object valueField;
1266 String valueFieldClass;
1267 if (mapKeyFieldToValueField.containsKey(key.toUpperCase()))
1268 {
1269 valueField = mapKeyFieldToValueField.get(key.toUpperCase());
1270 valueFieldClass = valueField.getClass().toString();
1271 }
1272 else
1273 {
1274 addToUnformattedTxt(key, value);
1275 return;
1276 }
1277
1278 switch (valueFieldClass)
1279 {
1280 case "class javax.swing.JTextField":
1281 ((JTextField) valueField).setText(value);
1282 break;
1283
1284 case "class javax.swing.JRadioButton":
1285 ((JRadioButton) valueField).setSelected(true);
1286 break;
1287
1288 case "class javax.swing.JComboBox":
1289 ((JComboBox<String>) valueField).setSelectedItem(value);
1290 break;
1291
1292 case "class javax.swing.table.DefaultTableModel":
1293
1294 //WARNING: there might be cases where we do not take all the records
1295
1296 if (key.equals(keyPar22)
1297 &&
1298 (((DefaultTableModel) valueField).getRowCount() == 0))
1299 {
1300 ((DefaultTableModel) valueField).addRow(new Object[]{
1301 "<html><b>Ring Size</b></html>",
1302 "<html><b>Bias</b></html>"});
1303 }
1304
1305 ((DefaultTableModel) valueField).addRow(value.split(" "));
1306 break;
1307
1308 default:
1309 throw new Exception("<html>Unexpected type for parameter: "
1310 + key + " (" + valueFieldClass
1311 + ").<br>Please report this to"
1312 + "the DEMOPTIM team.</html>");
1313 }
1314
1315 }
1316
1317//-----------------------------------------------------------------------------
1318
1319 public void possiblyReadParamsFromFSParFile() throws Exception
1320 {
1321 if (rdbSrcOrNew.isSelected())
1322 {
1323 if (txtFSSource.getText().equals("")
1324 || txtFSSource.getText() == null)
1325 {
1326 throw new Exception("<html>No source specified for the "
1327 + "parameters defining the space of building blocks."
1328 + "<br>Please, specify the file name.</html>");
1329 }
1331 }
1332 }
1333
1334//-----------------------------------------------------------------------------
1335
1336 @Override
1337 public void putParametersToString(StringBuilder sb) throws Exception
1338 {
1340
1341 sb.append("# Building Blocks Space - parameters").append(NL);
1351 sb.append(getStringFromTable(keyPar11,tabPar11, new int[]{0,1},false));
1352 if (rdbPar12.isSelected())
1353 {
1360 sb.append(getStringFromTable(keyPar22,tabPar22, new int[]{0,1},true));
1362 sb.append(keyPar19).append("=").append(cmbPar19.getSelectedItem()).append(NL);
1363 switch (cmbPar19.getSelectedItem().toString())
1364 {
1365 case "Constitution":
1366 sb.append(getStringFromTable(keyPar21,tabPar21, new int[]{0},false));
1368 break;
1369
1370 case "3D-Conformation":
1381 break;
1382
1383 case "Constitution_and_3D-Conformation":
1384 sb.append(getStringFromTable(keyPar21,tabPar21, new int[]{0},false));
1395 break;
1396 }
1397 }
1398
1399 sb.append(getTextForUnformattedSettings()).append(NL);
1400
1401 //HEREGOESPRINT this is only to facilitate automated insertion of code
1402 }
1403}
Class defining a space of building blocks.
void importCompatibilityMatrixFromFile(String inFile)
Load info from a compatibility matrix file.
Set< APClass > getAllAPClassesFromCPMap()
Return the set of APClasses that used in the compatibility matrix for the growing graph APs.
Parameters and setting related to handling ring closures.
Form collecting input parameters for defining the fragment space.
void putParametersToString(StringBuilder sb)
void importParametersFromDenoptimParamsFile(String fileName)
Imports parameters from a properly formatted parameters file.
Map< String, Object > mapKeyFieldToValueField
Map connecting the parameter keyword and the field containing the parameter value.
static final long serialVersionUID
Version.
void importSingleParameter(String key, String value)
File opener for DENOPTIM GUI.
static File pickFolderForTxtField(JTextField txtField, Component parent)
static File pickFileForTxtField(JTextField txtField, Component parent)
General structure of a form for collecting input parameters of various nature.
CmbFieldChange cmbFieldChange
Listener for changes in combo box-bound parameters.
final Dimension strFieldSize
Default sizes for short pathname fields (i.e., string or number)
FieldListener fieldListener
Listener for changes in parameters of this form.
TabFieldChange tabFieldChange
Listener for changes in table-bound parameters.
final Dimension fileLabelSize
Default sizes for file pathname labels.
final int preferredHeight
Default text field height.
String getStringFromTable(String key, JTable tab)
Produced an overall string including one or more KEY:VALUE strings taken from a table.
String getStringIfSelected(String key, JRadioButton btn)
Produced the KEY:VALUE string for a on/off button.
void addToUnformattedTxt(String key, String value)
void showUnknownKeyWarning(Component parent, String paramType)
Shown a warning dialog that informs the user about having found text that is not present in the Param...
final Dimension fileFieldSize
Default sizes for file pathname fields.
String getStringIfNotEmpty(String key, JTextField field, String prefix, String suffix)
Produced the KEY:VALUE string for a general text field.
RdbFieldChange rdbFieldChange
Listener for changes in radio button-bound parameters.