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