$darkmode
DENOPTIM
FitnessParametersForm.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.Color;
23import java.awt.Component;
24import java.awt.Dimension;
25import java.awt.FlowLayout;
26import java.awt.event.ActionEvent;
27import java.awt.event.ActionListener;
28import java.util.ArrayList;
29import java.util.Arrays;
30import java.util.HashMap;
31import java.util.List;
32import java.util.Map;
33import java.util.concurrent.atomic.AtomicInteger;
34
35import javax.swing.BoxLayout;
36import javax.swing.GroupLayout;
37import javax.swing.JButton;
38import javax.swing.JComboBox;
39import javax.swing.JEditorPane;
40import javax.swing.JLabel;
41import javax.swing.JOptionPane;
42import javax.swing.JPanel;
43import javax.swing.JRadioButton;
44import javax.swing.JScrollPane;
45import javax.swing.JSplitPane;
46import javax.swing.JTable;
47import javax.swing.JTextField;
48import javax.swing.JTree;
49import javax.swing.SwingConstants;
50import javax.swing.UIManager;
51import javax.swing.event.TreeSelectionEvent;
52import javax.swing.event.TreeSelectionListener;
53import javax.swing.table.DefaultTableModel;
54import javax.swing.table.JTableHeader;
55import javax.swing.tree.DefaultMutableTreeNode;
56import javax.swing.tree.DefaultTreeCellRenderer;
57import javax.swing.tree.DefaultTreeModel;
58import javax.swing.tree.TreePath;
59
60import org.openscience.cdk.fingerprint.IBitFingerprint;
61import org.openscience.cdk.fingerprint.IFingerprinter;
62import org.openscience.cdk.qsar.IDescriptor;
63
64import denoptim.exception.DENOPTIMException;
65import denoptim.fitness.DescriptorForFitness;
66import denoptim.fitness.DescriptorUtils;
67import denoptim.programs.RunTimeParameters;
68
74{
75
79 private static final long serialVersionUID = -282726238111247056L;
80
84 public static AtomicInteger fitFormUID = new AtomicInteger(1);
85
90 private Map<String,Object> mapKeyFieldToValueField;
91
92 JPanel block;
97
99 JRadioButton rdbSrcOrNew;
100
101 String key3dTrees = "FP-No3dTreeModel";
103 JRadioButton rdb3dTrees;
104
105 String keyPreFitnessUIDCheck = "FP-CheckUidBeforeFitness";
108
111 JTextField txtFPSource;
112 JButton btnFPSource;
114
116 JRadioButton rdbIntOrExt;
117
118 String keyFitProviderSource = "FP-Source";
123
124 String keyFitProviderInterpreter = "FP-Interpreter";
128
129 String keyEq = "FP-Equation";
130 JPanel lineEq;
131 JLabel lblEq;
132 JTextField txtEq;
133
134 String keyCustomVars = "FP-DescriptorSpecs";
138 DefaultTableModel tabCustomVarsMod;
139
141 JScrollPane descDefScrollPane;
150 private String descNameToTune = "";
151 private String[] paramsToTune;
153
154 //HEREGOFIELDS this is only to facilitate automated insertion of code
155
156 private static Map<Class<?>,String> additionalDocForParameters;
157 static {
158 additionalDocForParameters = new HashMap<Class<?>,String>();
159 Class<?> key = IBitFingerprint.class;
161 "<p>The <code>" + key.getSimpleName() + "</code> parameter can "
162 + "be generated "
163 + "when importing the descriptor into the fitness provider. "
164 + "To this end, use the prefix '<code>FILE:</code>' to "
165 + "provide a pathname to an SDF file from which the "
166 + "reference molecule can be fetched, and its fingerprint "
167 + "calculated and finally used as parameter to configure "
168 + "this descriptor.</p>");
169 key = IFingerprinter.class;
171 "<p>The <code>" + key.getSimpleName()
172 + "</code> parameter should be specified "
173 + "as the simple name of the desired implementation. For "
174 + "example <code>PubchemFingerprinter</code>. See "
175 + "CDK documentation on IFingerprinter for available "
176 + "implementations.</p>");
177 }
178
179 String NL = System.getProperty("line.separator");
180
181//------------------------------------------------------------------------------
182
183 public FitnessParametersForm(Dimension d)
184 {
185 mapKeyFieldToValueField = new HashMap<String,Object>();
186
187 this.setLayout(new BorderLayout()); //Needed to allow dynamic resizing!
188
189 block = new JPanel();
190 JScrollPane scrollablePane = new JScrollPane(block);
191 block.setLayout(new BoxLayout(block, SwingConstants.VERTICAL));
192
193 localBlock1 = new JPanel();
194 localBlock1.setVisible(false);
195 localBlock1.setLayout(new BoxLayout(localBlock1,
196 SwingConstants.VERTICAL));
197
198 localBlock2 = new JPanel();
199 localBlock2.setVisible(true);
200 localBlock2.setLayout(new BoxLayout(localBlock2,
201 SwingConstants.VERTICAL));
202
203 localBlock3 = new JPanel();
204 localBlock3.setVisible(false);
205 localBlock3.setLayout(new BoxLayout(localBlock3,
206 SwingConstants.VERTICAL));
207
208 localBlock4 = new JPanel();
209 localBlock4.setVisible(true);
210 localBlock4.setLayout(new BoxLayout(localBlock4,
211 SwingConstants.VERTICAL));
212
213 String toolTipSrcOrNew = "Tick here to use settings from file.";
214 lineSrcOrNew = new JPanel(new FlowLayout(FlowLayout.LEFT));
215 rdbSrcOrNew = new JRadioButton("Use parameters from existing file");
216 rdbSrcOrNew.setToolTipText(toolTipSrcOrNew);
217 rdbSrcOrNew.addActionListener(new ActionListener(){
218 public void actionPerformed(ActionEvent e){
219 if (rdbSrcOrNew.isSelected())
220 {
221 localBlock1.setVisible(true);
222 localBlock2.setVisible(false);
223 }
224 else
225 {
226 localBlock1.setVisible(false);
227 localBlock2.setVisible(true);
228 }
229 }
230 });
232 block.add(lineSrcOrNew);
233 block.add(localBlock1);
234 block.add(localBlock2);
235
236 String toolTipFPSource = "<html>Pathname of a DENOPTIM's parameter "
237 + "file with fitness-provider settings.</html>";
238 lineFPSource = new JPanel(new FlowLayout(FlowLayout.LEFT));
239 lblFPSource = new JLabel("Use parameters from file:",
240 SwingConstants.LEFT);
241 lblFPSource.setToolTipText(toolTipFPSource);
242 txtFPSource = new JTextField();
243 txtFPSource.setToolTipText(toolTipFPSource);
244 txtFPSource.setPreferredSize(fileFieldSize);
245 btnFPSource = new JButton("Browse");
246 btnFPSource.addActionListener(new ActionListener() {
247 public void actionPerformed(ActionEvent e) {
250 }
251 });
252 btnLoadFPSource = new JButton("Load...");
253 txtFPSource.setToolTipText("<html>Specify the file containing the "
254 + "parameters to be loaded in this form.</html>");
255 btnLoadFPSource.addActionListener(new ActionListener() {
256 public void actionPerformed(ActionEvent e) {
257 try
258 {
260 txtFPSource.getText());
261 }
262 catch (Exception e1)
263 {
264 if (e1.getMessage().equals("") || e1.getMessage() == null)
265 {
266 e1.printStackTrace();
267 JOptionPane.showMessageDialog(btnLoadFPSource,
268 "<html>Exception occurred while importing "
269 + "parameters.<br>Please, report this to the "
270 + "DENOPTIM team.</html>",
271 "Error",
272 JOptionPane.ERROR_MESSAGE,
273 UIManager.getIcon("OptionPane.errorIcon"));
274 }
275 else
276 {
277 JOptionPane.showMessageDialog(btnLoadFPSource,
278 e1.getMessage(),
279 "Error",
280 JOptionPane.ERROR_MESSAGE,
281 UIManager.getIcon("OptionPane.errorIcon"));
282 }
283 return;
284 }
285 }
286 });
292
293
294 String toolTip3dTrees = "<html>Tick here to enable/disable preliminary "
295 + "generation of a unrefined<br>3D geometry prior to fitness "
296 + "evaluation.<br>These models are build by aligning the given "
297 + "3D fragments<br> to the attachment point vectors. "
298 + "These models are <br>not energy-refined.</html>";
299 line3dTrees = new JPanel(new FlowLayout(FlowLayout.LEFT));
300 rdb3dTrees = new JRadioButton("Make unrefined 3d model.");
301 rdb3dTrees.setToolTipText(toolTip3dTrees);
302 rdb3dTrees.setSelected(true);
306
307 String toolTipPreFitnessUIDCheck = "<html>Tick here to enable/disable evaluation "
308 + "of candidate uniqueness prior to submission of the fitness "
309 + "evaluation.</html>";
310 linePreFitnessUIDCheck = new JPanel(new FlowLayout(FlowLayout.LEFT));
311 rdbPreFitnessUIDCheck = new JRadioButton("Check candidate uniqueness "
312 + "before sending to fitness evaluation.");
313 rdbPreFitnessUIDCheck.setToolTipText(toolTipPreFitnessUIDCheck);
314 rdbPreFitnessUIDCheck.setSelected(true);
318
319
320 String toolTipIntOrExt = "<html>A fitness provider is an existing "
321 + "tool or script.<br> The fitness provider must produce an "
322 + "output SDF file with the <code>&lt;FITNESS&gt;</code> or "
323 + "<code>&lt;MOL_ERROR&gt;</code> tags.</html>";
324 lineIntOrExt = new JPanel(new FlowLayout(FlowLayout.LEFT));
325 rdbIntOrExt = new JRadioButton("Use external fitness provider");
326 rdbIntOrExt.setToolTipText(toolTipIntOrExt);
327
328 rdbIntOrExt.setSelected(false);
329 rdbIntOrExt.setEnabled(true);
330
331 rdbIntOrExt.addActionListener(new ActionListener(){
332 public void actionPerformed(ActionEvent e){
334 }
335 });
340
341 //HEREGOESIMPLEMENTATION this is only to facilitate automated insertion of code
342
343 String toolTipFitProviderSource = "Pathname of the executable file.";
344 lineFitProviderSource = new JPanel(new FlowLayout(FlowLayout.LEFT));
345 lblFitProviderSource = new JLabel("Fitness provider executable:",
346 SwingConstants.LEFT);
347 lblFitProviderSource.setPreferredSize(fileLabelSize);
348 lblFitProviderSource.setToolTipText(toolTipFitProviderSource);
349 txtFitProviderSource = new JTextField();
350 txtFitProviderSource.setToolTipText(toolTipFitProviderSource);
351 txtFitProviderSource.setPreferredSize(fileFieldSize);
352 txtFitProviderSource.getDocument().addDocumentListener(fieldListener);
355 btnFitProviderSource = new JButton("Browse");
356 btnFitProviderSource.addActionListener(new ActionListener() {
357 public void actionPerformed(ActionEvent e) {
360 }
361 });
366
367 String toolTipFitProviderInterpreter = "Interpreter to be used for the "
368 + "fitness provider executable";
369 lineFitProviderInterpreter = new JPanel(
370 new FlowLayout(FlowLayout.LEFT));
371 lblFitProviderInterpreter = new JLabel("Interpreter for fitnes "
372 + "provider", SwingConstants.LEFT);
374 lblFitProviderInterpreter.setToolTipText(toolTipFitProviderInterpreter);
375 txtFitProviderInterpreter = new JTextField("/bin/bash");
376 txtFitProviderInterpreter.setToolTipText(toolTipFitProviderInterpreter);
377 txtFitProviderInterpreter.setEnabled(true);
379
385
386 String toolTipEq = "Define integrated fitness provider expression.";
387 lineEq = new JPanel(new FlowLayout(FlowLayout.LEFT));
388 lblEq = new JLabel("<html><i>Fitness = </i>${</html>",
389 SwingConstants.LEFT);
390 JLabel lblEqEnd = new JLabel("<html>}</html>", SwingConstants.LEFT);
391 //lblEq.setPreferredSize(fileLabelSize);
392 lblEq.setToolTipText(toolTipEq);
393 txtEq = new JTextField();
394 txtEq.setToolTipText("<html>Type here the expression for computing the fitness value out of predefined<br>"
395 + "descriptors and custom variables.<ul>"
396 + "<li>Descriptors can be selected from the 'Available descriptors' section (below).</li>"
397 + "<li>Custom variables, including atom-specific descriptors, can be defined in <br>"
398 + "the 'Custom variables' section.</li></ul></html>");
399 Dimension fitEqSize = new Dimension(700, 2*preferredHeight);
400 txtEq.setPreferredSize(fitEqSize);
401 txtEq.getDocument().addDocumentListener(fieldListener);
402 mapKeyFieldToValueField.put(keyEq.toUpperCase(),txtEq);
403 lineEq.add(lblEq);
404 lineEq.add(txtEq);
405 lineEq.add(lblEqEnd);
406 localBlock4.add(lineEq);
407
408 JLabel lblDescTreeTitle = new JLabel("Available descriptors:");
409 JPanel lineDescTreeTitle = new JPanel(new FlowLayout(FlowLayout.LEFT));
410 lineDescTreeTitle.add(lblDescTreeTitle);
411 localBlock4.add(lineDescTreeTitle);
412
413 String toolTipDescs = "<html>To select descriptor names:"
414 + "<ol><li>Browse the list of descriptors (double click to expand/reduce a node),"
415 + "</li><li>Click on the name of the descriptor you want to select,"
416 + "</li><li>Copy the selected name (<code>ctrl+C</code>/<code>command+C</code>), click in the fitness<br>"
417 + "expression field, and paste (<code>ctrl+V</code><code>command+V</code>).</li>"
418 + "</ol></html>";
419
420 DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(
421 "Descriptors");
422 DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
423 JTree descTree = new JTree(treeModel);
424 DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
425 renderer.setLeafIcon(null);
426 descTree.setCellRenderer(renderer);
427 descTree.setRootVisible(true);
428 descTree.setShowsRootHandles(true);
429 //NB: appearance depends on lookAndfeel. On Mac no lines, even if asked
430 descTree.putClientProperty("JTree.lineStyle", "Angled");
431 descTree.setToolTipText(toolTipDescs);
432 int dValLength = 350;
433 descTree.addTreeSelectionListener(new TreeSelectionListener() {
434 @Override
435 public void valueChanged(TreeSelectionEvent e) {
436 TreePath selPath = e.getPath();
437 DefaultMutableTreeNode selTreeNode = (DefaultMutableTreeNode)
438 selPath.getLastPathComponent();
439 if (!(selTreeNode instanceof DescriptorTreeNode)
440 || !selTreeNode.isLeaf())
441 {
442 return;
443 }
444 DescriptorTreeNode selNode = (DescriptorTreeNode) selTreeNode;
445 DescriptorForFitness dff = selNode.dff;
446
447 String titStr = dff.getDictTitle();
448 titStr = "<html><body width='%1s'>" + titStr + "</body></html>";
449 lblDDValueTitle.setText(String.format(titStr, dValLength));
450 lblDDValueName.setText(dff.getShortName());
451
452 String defStr = dff.getDictDefinition();
453 defStr = "<html><body width='%1s'>" + defStr + "</body></html>";
454 lblDDValueDefinition.setText(String.format(defStr, dValLength));
455
456 lblDDValueDescripton.setText("No additional descripton available");
457
458 String clsStr = Arrays.toString(dff.getDictClasses());
459 clsStr = "<html><body width='%1s'>" + clsStr + "</body></html>";
460 lblDDValueClasses.setText(String.format(clsStr, dValLength));
461
462 String parStr ="";
463 IDescriptor iDesc = dff.getImplementation();
464 String[] parNames = iDesc.getParameterNames();
465 Object[] params = iDesc.getParameters();
466 //NB: some classes return null to avoid adding a way to alter
467 // the default parameters.
468 ArrayList<Object> paramsTypes = new ArrayList<Object>();
469 if (params == null)
470 {
471 parStr = "Undeclared parameters. See source code.";
472 } else {
473 for (int ip=0; ip<parNames.length; ip++)
474 {
475 if (ip>0)
476 {
477 parStr = parStr + "<br>";
478 }
479 Object parTyp = iDesc.getParameterType(parNames[ip]);
480
481 String parTypStr = parTyp.getClass().getSimpleName();
482 if (parTyp instanceof Class<?>)
483 {
484 parTypStr = ((Class<?>) iDesc.getParameterType(
485 parNames[ip])).getSimpleName();
486 }
487 parStr = parStr + parNames[ip] + " = ("
488 + parTypStr + ") " + params[ip];
489 paramsTypes.add(parTyp);
490 }
491 }
493 if (paramsTypes.size() == 0)
494 {
495 btnDDValueParams.setEnabled(false);
496 btnDDValueParams.setVisible(false);
497 paramsToTune = new String[0];
498 } else {
499 btnDDValueParams.setEnabled(true);
500 btnDDValueParams.setVisible(true);
501 paramsToTune = parNames;
502 }
503 for (Object parTypeExample : paramsTypes)
504 {
505 String s = additionalDocForParameters.get(parTypeExample);
506 if (s != null)
507 {
508 parStr = parStr + "<p> </p>" + s;
509 }
510 }
511 parStr = "<html><body width='%1s'>" + parStr + "</body></html>";
512 lblDDValueParams.setText(String.format(parStr, dValLength));
513
514 String srcStr = dff.getClassName();
515 srcStr = "<html><body width='%1s'>" + srcStr + "</body></html>";
516 lblDDValueSource.setText(String.format(srcStr, dValLength));
517
518 }
519 });
520 JScrollPane descTreeScrollPane = new JScrollPane(descTree);
521
522 String[] sources = new String[] {"CDK", "DENOPTIM"};
523 for (String source : sources)
524 {
525 DescriptorTreeNode sourceNode = new DescriptorTreeNode(source);
526 rootNode.add(sourceNode);
527
528 List<DescriptorForFitness> allDescs = null;
529 try {
530 switch (source)
531 {
532 case "CDK":
534 null);
535 break;
536 case "DENOPTIM":
538 null);
539 break;
540 }
541 } catch (DENOPTIMException e1) {
542 System.out.println("No descriptor implementation found in "
543 + "source '" + source + "'!");
544 e1.printStackTrace();
545 continue;
546 }
547
548 // First identify the main klasses (first layer)
549 Map<String,DescriptorTreeNode> mainClassificationNodes =
550 new HashMap<String,DescriptorTreeNode>();
551 for (DescriptorForFitness dff : allDescs)
552 {
553 String[] klasses = new String[]{"Unclassified"};
554 if (dff.getDictClasses()!=null)
555 {
556 klasses = dff.getDictClasses();
557 }
558 for (String kls : klasses)
559 {
560 if (!mainClassificationNodes.containsKey(kls))
561 {
563 kls);
564 sourceNode.add(klassNode);
565 mainClassificationNodes.put(kls, klassNode);
566 }
567 }
568 }
569
570 // Then populate each class
571 for (String klass : mainClassificationNodes.keySet())
572 {
573 DescriptorTreeNode klassNode = mainClassificationNodes.get(
574 klass);
575 Map<String,DescriptorTreeNode> descriptorNodes =
576 new HashMap<String,DescriptorTreeNode>();
577 for (DescriptorForFitness dff : allDescs)
578 {
579 //TODO: check if getting the dictionary from
580 // DictionaryDatabase allows to get also the description in
581 // addition to definition
582
583 // Decide if this descriptor goes under the present klass
584 List<String> klasses = new ArrayList<String>();
585 if (dff.getDictClasses() == null)
586 {
587 if (!klass.equals("Unclassified"))
588 {
589 continue;
590 } else {
591 klasses.add(klass);
592 }
593 } else {
594 klasses = new ArrayList<String>(
595 Arrays.asList(dff.getDictClasses()));
596 }
597 if (!klasses.contains(klass))
598 {
599 continue;
600 }
601
602 // Identify parent node: either a klassNode or a descriptorNode
603 DescriptorTreeNode parentNode = klassNode;
604 if (dff.getImplementation().getDescriptorNames().length > 1)
605 {
606 String descriptorName = dff.getImplementation().getClass()
607 .getSimpleName();
608 if (!descriptorNodes.containsKey(descriptorName))
609 {
610 DescriptorTreeNode descNode =
611 new DescriptorTreeNode(descriptorName,dff);
612 parentNode.add(descNode);
613 descriptorNodes.put(descriptorName, descNode);
614 }
615 parentNode = descriptorNodes.get(descriptorName);
616 }
617
618 // Finally make the node for the present desc-to-fitness
620 parentNode.add(dtn);
621 }
622 }
623 }
624
625 Dimension ddLabelsSize = new Dimension(100,30);
626 JLabel lblDDTitle = new JLabel("<html><b>Title:</b></html>");
627 lblDDTitle.setPreferredSize(ddLabelsSize);
628 JLabel lblDDName = new JLabel("<html><b>Name:</b></html>");
629 lblDDName.setPreferredSize(ddLabelsSize);
630 JLabel lblDDDefinition = new JLabel("<html><b>Definition:</b></html>");
631 lblDDDefinition.setPreferredSize(ddLabelsSize);
632 JLabel lblDDDescription = new JLabel("<html><b>Description:</b></html>");
633 lblDDDescription.setPreferredSize(ddLabelsSize);
634 JLabel lblDDClasses = new JLabel("<html><b>Classification:</b></html>");
635 lblDDClasses.setPreferredSize(ddLabelsSize);
636 JLabel lblDDParams = new JLabel("<html><b>Parameters:</b></html>");
637 lblDDParams.setPreferredSize(ddLabelsSize);
638 JLabel lblDDSource = new JLabel("<html><b>Implementation:</b></html>");
639 lblDDSource.setPreferredSize(ddLabelsSize);
640
641 lblDDValueTitle = new JLabel();
642 lblDDValueName = new JLabel();
643 lblDDValueDefinition = new JLabel();
644 lblDDValueDescripton = new JLabel();
645 lblDDValueClasses = new JLabel();
646 pnlDDValueParams = new JPanel();
647 lblDDValueParams = new JLabel();
648 btnDDValueParams = new JButton("Set parameters");
649 btnDDValueParams.setEnabled(false);
650 btnDDValueParams.setVisible(false);
651 lblDDValueSource = new JLabel();
652
653 btnDDValueParams.addActionListener(new ActionListener() {
654 @Override
655 public void actionPerformed(ActionEvent e)
656 {
660 if (dialog.result!=null)
661 {
662 tabCustomVarsMod.addRow((Object[]) dialog.result);
663 }
664 }
665 });
666
667 GroupLayout lyoDescParamsPanel = new GroupLayout(pnlDDValueParams);
668 pnlDDValueParams.setLayout(lyoDescParamsPanel);
669 lyoDescParamsPanel.setAutoCreateGaps(true);
670 lyoDescParamsPanel.setAutoCreateContainerGaps(true);
671 lyoDescParamsPanel.setHorizontalGroup(
672 lyoDescParamsPanel.createParallelGroup()
673 .addComponent(lblDDValueParams)
674 .addComponent(btnDDValueParams));
675 lyoDescParamsPanel.setVerticalGroup(
676 lyoDescParamsPanel.createSequentialGroup()
677 .addComponent(lblDDValueParams)
678 .addComponent(btnDDValueParams));
679
680 descDefinitionPane = new JPanel();
681 GroupLayout lyoDescDefPanel = new GroupLayout(descDefinitionPane);
682 descDefinitionPane.setLayout(lyoDescDefPanel);
683 lyoDescDefPanel.setAutoCreateGaps(true);
684 lyoDescDefPanel.setAutoCreateContainerGaps(true);
685 lyoDescDefPanel.setHorizontalGroup(lyoDescDefPanel.createSequentialGroup()
686 .addGroup(lyoDescDefPanel.createParallelGroup()
687 .addComponent(lblDDName)
688 .addComponent(lblDDTitle)
689 .addComponent(lblDDClasses)
690 .addComponent(lblDDDefinition)
691 //.addComponent(lblDDDescription)
692 .addComponent(lblDDParams)
693 .addComponent(lblDDSource)
694 )
695 .addGroup(lyoDescDefPanel.createParallelGroup()
696 .addComponent(lblDDValueName)
697 .addComponent(lblDDValueTitle)
698 .addComponent(lblDDValueClasses)
699 .addComponent(lblDDValueDefinition)
700 //.addComponent(lblDDValueDescripton)
701 .addComponent(pnlDDValueParams)
702 .addComponent(lblDDValueSource)
703 ));
704 lyoDescDefPanel.setVerticalGroup(lyoDescDefPanel.createSequentialGroup()
705 .addGroup(lyoDescDefPanel.createParallelGroup()
706 .addComponent(lblDDName)
707 .addComponent(lblDDValueName))
708 .addGroup(lyoDescDefPanel.createParallelGroup()
709 .addComponent(lblDDTitle)
710 .addComponent(lblDDValueTitle))
711 .addGroup(lyoDescDefPanel.createParallelGroup()
712 .addComponent(lblDDClasses)
713 .addComponent(lblDDValueClasses))
714 .addGroup(lyoDescDefPanel.createParallelGroup()
715 .addComponent(lblDDDefinition)
716 .addComponent(lblDDValueDefinition))
717 // .addGroup(lyoDescDefPanel.createParallelGroup()
718 // .addComponent(lblDDDescription)
719 // .addComponent(lblDDValueDescripton))
720 .addGroup(lyoDescDefPanel.createParallelGroup()
721 .addComponent(lblDDParams)
722 .addComponent(pnlDDValueParams))
723 .addGroup(lyoDescDefPanel.createParallelGroup()
724 .addComponent(lblDDSource)
725 .addComponent(lblDDValueSource))
726 );
727
728 descDefScrollPane = new JScrollPane(descDefinitionPane);
729
730 JSplitPane splitPaneDescs = new JSplitPane();
731 splitPaneDescs.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
732 splitPaneDescs.setOneTouchExpandable(true);
733 splitPaneDescs.setResizeWeight(0.5);
734 splitPaneDescs.setLeftComponent(descTreeScrollPane);
735 splitPaneDescs.setRightComponent(descDefScrollPane);
736 JPanel lineDescsTree = new JPanel();
737 lineDescsTree.setLayout(new BorderLayout(2,2));
738 lineDescsTree.add(splitPaneDescs);
739 localBlock4.add(lineDescsTree);
740
741 lblCustomvars = new JLabel("Definition of custom variables:");
742 JPanel lineMoreEqTitle = new JPanel(new FlowLayout(FlowLayout.LEFT));
743 lineMoreEqTitle.add(lblCustomvars);
744 localBlock4.add(lineMoreEqTitle);
745
746 String toolTipMoreEq = "<html>Define atom/bond specific descriptors.</html>";
747 lineCustomVars = new JPanel();
748
749 tabCustomVarsMod = new DefaultTableModel();
750 tabCustomVarsMod.setColumnCount(2);
751 String column_names[]= {"<html><b>Variable</b></html>",
752 "<html><b>Definition</b></html>"};
753 tabCustomVarsMod.setColumnIdentifiers(column_names);
754 tabCustomVars = new JTable(tabCustomVarsMod);
755 tabCustomVars.setToolTipText(toolTipMoreEq);
756 tabCustomVars.putClientProperty("terminateEditOnFocusLost", true);
757 tabCustomVars.getColumnModel().getColumn(0).setMinWidth(75);
758 tabCustomVars.getColumnModel().getColumn(1).setMinWidth(100);
759 tabCustomVars.setGridColor(Color.LIGHT_GRAY);
760 JTableHeader tabMoreEqHeader = tabCustomVars.getTableHeader();
761 tabMoreEqHeader.setPreferredSize(new Dimension(120, 20));
762 JScrollPane tabMoreEqScrollPane = new JScrollPane(tabCustomVars);
763 //tabMoreEqScrollPane.setMinimumSize(new Dimension(240,30));
764
765 mapKeyFieldToValueField.put(keyCustomVars.toUpperCase(),
767
768 tabMoreEqScrollPane.setAlignmentY(Component.TOP_ALIGNMENT);
769
770 JButton btAtomSpecVar = new JButton("Add atom-specific variable");
771 btAtomSpecVar.setToolTipText("Add the defintion of an atom specific variabnle.");
772 btAtomSpecVar.addActionListener(new ActionListener() {
773 @Override
774 public void actionPerformed(ActionEvent e) {
776 new AtomSpecExpressionDefinition(btAtomSpecVar);
777 Object[] res = (Object[]) dialog.showDialog();
778 if (res!=null)
779 {
780 tabCustomVarsMod.addRow(res);
781 }
782 }
783 });
784
785 btnDDValueParams.addActionListener(new ActionListener() {
786 @Override
787 public void actionPerformed(ActionEvent e)
788 {
792 Object[] res = (Object[]) dialog.showDialog();
793 if (res!=null)
794 {
795 tabCustomVarsMod.addRow(res);
796 }
797 }
798 });
799
800 /*
801 // Not active because it needs the definition of the descriptor and its parameters
802 JButton btnParametrizedVar = new JButton("Add parametrized descriptor");
803 btnParametrizedVar.setToolTipText("Defines a variable from a parametrized descriptor.");
804 btnParametrizedVar.addActionListener(new ActionListener() {
805 @Override
806 public void actionPerformed(ActionEvent e) {
807 ParametrizedDescriptorDefinition dialog =
808 new ParametrizedDescriptorDefinition(descNameToTune,
809 paramsToTune);
810 Object[] res = (Object[]) dialog.showDialog();
811 if (res!=null)
812 {
813 tabCustomVarsMod.addRow(res);
814 }
815 }
816 });
817 */
818
819 JButton btnRemoveCustomVar = new JButton("Remove selected");
820 btnRemoveCustomVar.setToolTipText("Remove the selected definitions.");
821 btnRemoveCustomVar.addActionListener(new ActionListener() {
822 @Override
823 public void actionPerformed(ActionEvent e) {
824 if (tabCustomVars.getRowCount() > 0)
825 {
826 if (tabCustomVars.getSelectedRowCount() > 0)
827 {
828 int selectedRowIds[] = tabCustomVars.getSelectedRows();
829 Arrays.sort(selectedRowIds);
830 for (int i=(selectedRowIds.length-1); i>-1; i--)
831 {
832 tabCustomVarsMod.removeRow(selectedRowIds[i]);
833 }
834 }
835 }
836 }
837 });
838
839 GroupLayout lyoCustomvarPanel = new GroupLayout(lineCustomVars);
840 lineCustomVars.setLayout(lyoCustomvarPanel);
841 lyoCustomvarPanel.setAutoCreateGaps(true);
842 lyoCustomvarPanel.setAutoCreateContainerGaps(true);
843 lyoCustomvarPanel.setHorizontalGroup(
844 lyoCustomvarPanel.createSequentialGroup()
845 .addComponent(tabMoreEqScrollPane)
846 .addGroup(lyoCustomvarPanel.createParallelGroup(
847 GroupLayout.Alignment.CENTER)
848 .addComponent(btAtomSpecVar)
849 // .addComponent(btnParametrizedVar)
850 .addComponent(btnRemoveCustomVar)));
851 lyoCustomvarPanel.setVerticalGroup(
852 lyoCustomvarPanel.createParallelGroup()
853 .addComponent(tabMoreEqScrollPane)
854 .addGroup(lyoCustomvarPanel.createSequentialGroup()
855 .addComponent(btAtomSpecVar)
856 // .addComponent(btnParametrizedVar)
857 .addComponent(btnRemoveCustomVar)));
858
860
861
862 //HEREGOESADVIMPLEMENTATION this is only to facilitate automated insertion of code
863
864 // From here it's all about advanced options
865 /*
866 JPanel advOptsBlock = new JPanel();
867 advOptsBlock.setVisible(false);
868 advOptsBlock.setLayout(new BoxLayout(advOptsBlock, SwingConstants.VERTICAL));
869
870 */
871
872 /*
873 JButton advOptShow = new JButton("Advanced Settings");
874 advOptShow.addActionListener(new ActionListener(){
875 public void actionPerformed(ActionEvent e){
876 if (advOptsBlock.isVisible())
877 {
878 advOptsBlock.setVisible(false);
879 advOptShow.setText("Show Advanced Settings");
880 }
881 else
882 {
883 advOptsBlock.setVisible(true);
884 advOptShow.setText("Hide Advanced Settings");
885 scrollablePane.validate();
886 scrollablePane.repaint();
887 scrollablePane.getVerticalScrollBar().setValue(
888 scrollablePane.getVerticalScrollBar().getValue() + (int) preferredHeight*2/3);
889 }
890 }
891 });
892
893 JPanel advOptsController = new JPanel();
894 advOptsController.setPreferredSize(fileLabelSize);
895 advOptsController.add(advOptShow);
896 block.add(new JSeparator());
897 block.add(advOptsController);
898 block.add(advOptsBlock);
899 */
900
901 block.add(super.getPanelForUnformattedInput());
902
903 this.add(scrollablePane);
904 }
905
906//------------------------------------------------------------------------------
907
909 {
910 if (rdbIntOrExt.isSelected())
911 {
912 localBlock3.setVisible(true);
913 localBlock4.setVisible(false);
914 }
915 else
916 {
917 localBlock3.setVisible(false);
918 localBlock4.setVisible(true);
919 }
920 }
921
922//------------------------------------------------------------------------------
923
924 @Override
926 {
927 int initialRowCount = tabCustomVarsMod.getRowCount();
928 for (int i=0; i<initialRowCount; i++)
929 {
930 tabCustomVarsMod.removeRow(0);
931 }
932 }
933
934//------------------------------------------------------------------------------
935
936 @Override
937 protected void adaptVisibility()
938 {
940 }
941
942//------------------------------------------------------------------------------
943
944 @SuppressWarnings("serial")
945 private class DescriptorTreeNode extends DefaultMutableTreeNode
946 {
948
955 super(dff.getShortName());
956 this.dff = dff;
957 }
958
963 public DescriptorTreeNode(String descriptorName, DescriptorForFitness dff) {
964 super(descriptorName);
965 this.dff = dff;
966 }
967
972 public DescriptorTreeNode(String kls) {
973 super(kls);
974 }
975 }
976
977//-----------------------------------------------------------------------------
978
986 @Override
987 public void importParametersFromDenoptimParamsFile(String fileName) throws Exception
988 {
991
992 rdbSrcOrNew.setSelected(false);
993 localBlock1.setVisible(false);
994 localBlock2.setVisible(true);
995 if (rdbIntOrExt.isSelected())
996 {
997 localBlock3.setVisible(true);
998 localBlock4.setVisible(false);
999 }
1000 else
1001 {
1002 localBlock3.setVisible(false);
1003 localBlock4.setVisible(true);
1004 }
1005 showUnknownKeyWarning(this, "Fitness Provider");
1006 }
1007
1008//-----------------------------------------------------------------------------
1009
1010 @SuppressWarnings("unchecked")
1011 @Override
1012 public void importSingleParameter(String key, String value) throws Exception
1013 {
1014 Object valueField;
1015 String valueFieldClass;
1016 if (mapKeyFieldToValueField.containsKey(key.toUpperCase()))
1017 {
1018 valueField = mapKeyFieldToValueField.get(key.toUpperCase());
1019 valueFieldClass = valueField.getClass().toString();
1020 }
1021 else
1022 {
1023 addToUnformattedTxt(key, value);
1024 return;
1025 }
1026
1027 switch (valueFieldClass)
1028 {
1029 case "class javax.swing.JTextField":
1030 if (key.toUpperCase().equals(keyFitProviderSource.toUpperCase()))
1031 {
1032 rdbIntOrExt.setSelected(true);
1033 }
1034 if (key.toUpperCase().equals(keyEq.toUpperCase()))
1035 {
1036 value = value.trim();
1037 if (value.startsWith("${") && value.endsWith("}"));
1038 {
1039 value = value.substring(2, value.lastIndexOf("}"));
1040 }
1041 }
1042 ((JTextField) valueField).setText(value);
1043 break;
1044
1045 case "class javax.swing.JRadioButton":
1046 if (key.toUpperCase().equals(key3dTrees.toUpperCase()))
1047 {
1048 ((JRadioButton) valueField).setSelected(false);
1049 } else {
1050 ((JRadioButton) valueField).setSelected(true);
1051 }
1052
1053 if (key.toUpperCase().equals(keyPreFitnessUIDCheck.toUpperCase()))
1054 {
1055 ((JRadioButton) valueField).setSelected(
1057 }
1058 break;
1059
1060 case "class javax.swing.JComboBox":
1061 ((JComboBox<String>) valueField).setSelectedItem(value);
1062 break;
1063
1064 case "class javax.swing.table.DefaultTableModel":
1065 if (key.toUpperCase().equals(keyCustomVars.toUpperCase()))
1066 {
1067 String noHead = value.replace("${atomSpecific('", "");
1068 Object[] rowContent = new Object[2];
1069 rowContent[0] = noHead.split("'")[0];
1070 rowContent[1] = value;
1071 ((DefaultTableModel) valueField).addRow(rowContent);
1072 } else {
1073 //WARNING: there might be other cases where we do not take
1074 // all the row/columns
1075 ((DefaultTableModel) valueField).addRow(value.split(" "));
1076 }
1077 break;
1078
1079 default:
1080 throw new Exception("<html>Unexpected type for parameter: "
1081 + key + " (" + valueFieldClass
1082 + ").<br>Please report this to"
1083 + "the DEMOPTIM team.</html>");
1084 }
1085 }
1086
1087//-----------------------------------------------------------------------------
1088
1089 @Override
1090 public void putParametersToString(StringBuilder sb) throws Exception
1091 {
1092 sb.append(NL);
1093 sb.append("# Fitness Provider - parameters").append(NL);
1094 if (rdbIntOrExt.isSelected())
1095 {
1098 sb.append(keyFitProviderInterpreter).append("=").append(
1099 txtFitProviderInterpreter.getText()).append(NL);
1100 } else {
1101 sb.append(getStringIfNotEmpty(keyEq,txtEq,"${","}"));
1102 for (int i=0; i<tabCustomVarsMod.getRowCount(); i++)
1103 {
1104 sb.append(keyCustomVars).append("=").append(
1105 tabCustomVarsMod.getValueAt(i, 1)).append(NL);
1106 }
1107 }
1108 if (!rdb3dTrees.isSelected())
1109 {
1110 sb.append(key3dTrees).append(NL);
1111 }
1112 if (rdbPreFitnessUIDCheck.isSelected())
1113 {
1114 sb.append(keyPreFitnessUIDCheck).append("=YES").append(NL);
1115 } else {
1116 sb.append(keyPreFitnessUIDCheck).append("=NO").append(NL);
1117 }
1118
1119 sb.append(getTextForUnformattedSettings()).append(NL);
1120
1121 //HEREGOESPRINT this is only to facilitate automated insertion of code
1122 }
1123
1124//------------------------------------------------------------------------------
1125
1126 @SuppressWarnings("serial")
1128 {
1129 public ParametrizedDescriptorDefinition(String descName,
1130 String[] paramNames, Component refForPlacement)
1131 {
1132 super(refForPlacement, true);
1133 this.setTitle("Define parametrized descriptor variable");
1134
1135 Dimension sizeNameFields = new Dimension(200,preferredHeight);
1136 Dimension sizeNameLbls = new Dimension(120,preferredHeight);
1137
1138 JPanel rowOne = new JPanel(new FlowLayout(FlowLayout.LEFT));
1139 JLabel lblVarName = new JLabel("Variable name: ");
1140 lblVarName.setPreferredSize(sizeNameLbls);
1141 lblVarName.setToolTipText("<html>This is the string representing "
1142 + "a user-defined variable <br> in the expression of the "
1143 + "fitness.</html>");
1144 JTextField txtVarName = new JTextField();
1145 txtVarName.setPreferredSize(sizeNameFields);
1146 rowOne.add(lblVarName);
1147 rowOne.add(txtVarName);
1148
1149 JPanel rowTwo = new JPanel(new FlowLayout(FlowLayout.LEFT));
1150 JLabel lblDescName = new JLabel("Descriptor name: ");
1151 lblDescName.setPreferredSize(sizeNameLbls);
1152 lblDescName.setToolTipText("<html>This is the pre-defined short "
1153 + "name "
1154 + "reported <br>in "
1155 + "the collection of descriptors.</html>");
1156 JTextField txtDescName = new JTextField(descName);
1157 txtDescName.setPreferredSize(sizeNameFields);
1158 rowTwo.add(lblDescName);
1159 rowTwo.add(txtDescName);
1160
1161 JPanel rowThree = new JPanel();
1162 rowThree.setLayout(new BorderLayout());
1163 JLabel lblParams = new JLabel("Parameters:");
1164 String paramToolTip = "<html>The parameters provided in the "
1165 + "order defined in the description <br> "
1166 + "of the descriptor. Only the parameter value is needed, "
1167 + "not its name.</html>";
1168 lblParams.setToolTipText(paramToolTip);
1169
1170 JTable tabParams;
1171 DefaultTableModel tabParamsMod = new DefaultTableModel();
1172 tabParamsMod.setColumnCount(1);
1173 int tabSize = paramNames.length;
1174 tabParamsMod.setRowCount(tabSize);
1175 tabParams = new JTable(tabParamsMod);
1176 tabParams.setToolTipText(paramToolTip);
1177 tabParams.putClientProperty("terminateEditOnFocusLost", true);
1178 tabParams.getColumnModel().getColumn(0).setMinWidth(150);
1179 tabParams.setGridColor(Color.LIGHT_GRAY);
1180 JScrollPane txtParamScrollPane = new JScrollPane(tabParams);
1181 tabParams.setTableHeader(null);
1182
1183 rowThree.add(lblParams,BorderLayout.WEST);
1184 rowThree.add(txtParamScrollPane,BorderLayout.CENTER);
1185 JPanel firstTwo = new JPanel();
1186 firstTwo.setLayout(new BoxLayout(firstTwo,
1187 SwingConstants.VERTICAL));
1188 firstTwo.add(rowOne);
1189 firstTwo.add(rowTwo);
1190 addToNorthPane(firstTwo);
1191 addToCentralPane(rowThree);
1192 this.btnDone.addActionListener(new ActionListener() {
1193 @Override
1194 public void actionPerformed(ActionEvent e) {
1195 if (txtVarName.getText().equals("")
1196 || txtDescName.getText().equals(""))
1197 {
1198 result = null;
1199 } else {
1200 String line = "${Variable.parametrized('"
1201 + txtVarName.getText()
1202 + "','" + txtDescName.getText() + "','";
1203 // First check that all parameters were given
1204 boolean quit = false;
1205 for (int i=0; i<tabSize; i++)
1206 {
1207 if (tabParamsMod.getValueAt(i,0) == null ||
1208 tabParamsMod.getValueAt(i,0).toString().trim().equals(""))
1209 quit = true;
1210 }
1211
1212 if (!quit)
1213 {
1214 //NB: all params are collected into a single string!
1215 for (int i=0; i<tabSize; i++)
1216 {
1217 String s = tabParamsMod.getValueAt(i,0).toString()
1218 .trim();
1219 if (s.contains(paramNames[i]))
1220 {
1221 s = s.replaceFirst(paramNames[i],"");
1222 s = s.trim();
1223 if (s.startsWith("="))
1224 {
1225 s = s.replaceFirst("=","");
1226 s = s.trim();
1227 }
1228 }
1229 line = line + s;
1230 if (i<(tabSize-1))
1231 line = line + ", ";
1232 }
1233 line = line + "')}";
1234 result = new Object[] {txtVarName.getText(),line};
1235 }
1236 }
1237 close();
1238 }
1239 });
1240 this.btnExtra.setText("?");
1241 this.btnExtra.setVisible(true);
1242 this.btnExtra.addActionListener(new ActionListener() {
1243 @Override
1244 public void actionPerformed(ActionEvent e) {
1245 String txt = "<html><body width='%1s'>"
1246 + "Here you can define:<ul>"
1247 + "<li>the name of the variable, i.e., "
1248 + "the string used to represent this variable in the "
1249 + "equation defining the fitness,</li>"
1250 + "<li>the name of the descriptor this variable is "
1251 + "based on, i.e., the unique string identifying the "
1252 + "descriptor in the list of available descriptors,</li>"
1253 + "<li>the list of parameters that customize the "
1254 + "calculation of the descriptor. The values of the "
1255 + "parameters should be given in the order specified in "
1256 + "the description of the descriptor.</li>"
1257 + "</ul></html>";
1258 JOptionPane.showMessageDialog(btnExtra,
1259 String.format(txt, 350),
1260 "Tips",
1261 JOptionPane.PLAIN_MESSAGE);
1262 }
1263 });
1264
1265 this.btnCanc.addActionListener(new ActionListener() {
1266 @Override
1267 public void actionPerformed(ActionEvent e) {
1268 result = null;
1269 close();
1270 }
1271 });
1272 }
1273 }
1274
1275//------------------------------------------------------------------------------
1276
1277 @SuppressWarnings("serial")
1279 {
1280 public AtomSpecExpressionDefinition(Component refForPlacement)
1281 {
1282 super(refForPlacement);
1283 this.setTitle("Define atom-specific variable");
1284
1285 Dimension sizeNameFields = new Dimension(200,preferredHeight);
1286 Dimension sizeNameLbls = new Dimension(120,preferredHeight);
1287
1288 JPanel rowOne = new JPanel(new FlowLayout(FlowLayout.LEFT));
1289 JLabel lblVarName = new JLabel("Variable name: ");
1290 lblVarName.setPreferredSize(sizeNameLbls);
1291 lblVarName.setToolTipText("<html>This is the string representing "
1292 + "a user-defined variable <br> in the expression of the "
1293 + "fitness.</html>");
1294 JTextField txtVarName = new JTextField();
1295 txtVarName.setPreferredSize(sizeNameFields);
1296 rowOne.add(lblVarName);
1297 rowOne.add(txtVarName);
1298
1299 JPanel rowTwo = new JPanel(new FlowLayout(FlowLayout.LEFT));
1300 JLabel lblDescName = new JLabel("Descriptor name: ");
1301 lblDescName.setPreferredSize(sizeNameLbls);
1302 lblDescName.setToolTipText("<html>This is the pre-defined short "
1303 + "name "
1304 + "reported <br>in "
1305 + "the collection of descriptors.</html>");
1306 JTextField txtDescName = new JTextField();
1307 txtDescName.setPreferredSize(sizeNameFields);
1308 rowTwo.add(lblDescName);
1309 rowTwo.add(txtDescName);
1310
1311 JPanel rowThree = new JPanel();
1312 rowThree.setLayout(new BorderLayout());
1313 JLabel lblSmarts = new JLabel("SMARTS:");
1314 lblSmarts.setToolTipText("<html>The SMARTS query used to identify "
1315 + "specific atom/bonds to <br> "
1316 + "be used for the calculation of "
1317 + "the numerical value of this variable.</html>");
1318 JEditorPane txtSmarts = new JEditorPane();
1319 JScrollPane txtSmartsScrollPane = new JScrollPane(txtSmarts);
1320 rowThree.add(lblSmarts,BorderLayout.WEST);
1321 rowThree.add(txtSmartsScrollPane,BorderLayout.CENTER);
1322 JPanel firstTwo = new JPanel();
1323 firstTwo.setLayout(new BoxLayout(firstTwo,
1324 SwingConstants.VERTICAL));
1325 firstTwo.add(rowOne);
1326 firstTwo.add(rowTwo);
1327 addToNorthPane(firstTwo);
1328 addToCentralPane(rowThree);
1329 this.btnDone.addActionListener(new ActionListener() {
1330
1331 @Override
1332 public void actionPerformed(ActionEvent e) {
1333 if (txtVarName.getText().equals("")
1334 && txtDescName.getText().equals("")
1335 && txtSmarts.getText().equals(""))
1336 {
1337 result = null;
1338 } else {
1339 result = new Object[] {txtVarName.getText(),
1340 "${atomSpecific('" + txtVarName.getText()
1341 + "','" + txtDescName.getText() + "','"
1342 + txtSmarts.getText() + "')}"};
1343 }
1344 close();
1345 }
1346 });
1347 this.btnCanc.addActionListener(new ActionListener() {
1348
1349 @Override
1350 public void actionPerformed(ActionEvent e) {
1351 result = null;
1352 close();
1353 }
1354 });
1355 }
1356 }
1357}
This is a reference to a specific descriptor value.
static List< DescriptorForFitness > findAllCDKDescriptors(Set< String > requiredDescriptors)
Searches for descriptor implementations in the CDK packages.
static List< DescriptorForFitness > findAllDENOPTIMDescriptors(Set< String > requiredDescriptors)
Searches for descriptor implementations in the DENOPTIM packages.
DescriptorTreeNode(DescriptorForFitness dff)
Constructor meant for nodes representing an actual descriptor value.
DescriptorTreeNode(String descriptorName, DescriptorForFitness dff)
Constructor meant for nodes representing descriptors that return multiple values.
DescriptorTreeNode(String kls)
Constructor meant for nodes that represent only the main descriptor classes (e.g.,...
ParametrizedDescriptorDefinition(String descName, String[] paramNames, Component refForPlacement)
Form collecting input parameters for a setting-up the fitness provider.
Map< String, Object > mapKeyFieldToValueField
Map connecting the parameter keyword and the field containing the parameter value.
void importParametersFromDenoptimParamsFile(String fileName)
Imports parameters from a properly formatted parameters file.
static AtomicInteger fitFormUID
Unique identified for instances of this form.
void preliminatyTasksUponImportingParams()
Overwritten by subclasses.
void importSingleParameter(String key, String value)
static Map< Class<?>, String > additionalDocForParameters
void adaptVisibility()
Overwritten by subclasses.
static final long serialVersionUID
Version.
File opener for DENOPTIM GUI.
static File pickFileForTxtField(JTextField txtField, Component parent)
Object result
The result to be returned once the dialog is closed.
Object showDialog()
Shows the dialog and restrains the modality to it, until the dialog gets closed.
General structure of a form for collecting input parameters of various nature.
FieldListener fieldListener
Listener for changes in parameters of this form.
final Dimension fileLabelSize
Default sizes for file pathname labels.
final int preferredHeight
Default text field height.
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.
Collection of parameters controlling the behavior of the software.
static boolean readYesNoTrueFalse(String s)
Reads a string searching for any common way to say either yes/true (including shorthand t/y) or no/fa...