21import java.awt.BorderLayout;
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;
33import java.util.concurrent.atomic.AtomicInteger;
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;
60import org.openscience.cdk.fingerprint.IBitFingerprint;
61import org.openscience.cdk.fingerprint.IFingerprinter;
62import org.openscience.cdk.qsar.IDescriptor;
64import denoptim.exception.DENOPTIMException;
65import denoptim.fitness.DescriptorForFitness;
66import denoptim.fitness.DescriptorUtils;
67import denoptim.programs.RunTimeParameters;
84 public static AtomicInteger
fitFormUID =
new AtomicInteger(1);
159 Class<?> key = IBitFingerprint.class;
161 "<p>The <code>" + key.getSimpleName() +
"</code> parameter can "
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>");
179 String
NL = System.getProperty(
"line.separator");
187 this.setLayout(
new BorderLayout());
189 block =
new JPanel();
190 JScrollPane scrollablePane =
new JScrollPane(
block);
191 block.setLayout(
new BoxLayout(
block, SwingConstants.VERTICAL));
196 SwingConstants.VERTICAL));
201 SwingConstants.VERTICAL));
206 SwingConstants.VERTICAL));
211 SwingConstants.VERTICAL));
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");
217 rdbSrcOrNew.addActionListener(
new ActionListener(){
218 public void actionPerformed(ActionEvent e){
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);
246 btnFPSource.addActionListener(
new ActionListener() {
247 public void actionPerformed(ActionEvent e) {
253 txtFPSource.setToolTipText(
"<html>Specify the file containing the "
254 +
"parameters to be loaded in this form.</html>");
256 public void actionPerformed(ActionEvent e) {
264 if (e1.getMessage().equals(
"") || e1.getMessage() ==
null)
266 e1.printStackTrace();
268 "<html>Exception occurred while importing "
269 +
"parameters.<br>Please, report this to the "
270 +
"DENOPTIM team.</html>",
272 JOptionPane.ERROR_MESSAGE,
273 UIManager.getIcon(
"OptionPane.errorIcon"));
280 JOptionPane.ERROR_MESSAGE,
281 UIManager.getIcon(
"OptionPane.errorIcon"));
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.");
307 String toolTipPreFitnessUIDCheck =
"<html>Tick here to enable/disable evaluation "
308 +
"of candidate uniqueness prior to submission of the fitness "
309 +
"evaluation.</html>";
312 +
"before sending to fitness evaluation.");
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><FITNESS></code> or "
323 +
"<code><MOL_ERROR></code> tags.</html>";
324 lineIntOrExt =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
325 rdbIntOrExt =
new JRadioButton(
"Use external fitness provider");
331 rdbIntOrExt.addActionListener(
new ActionListener(){
332 public void actionPerformed(ActionEvent e){
343 String toolTipFitProviderSource =
"Pathname of the executable file.";
346 SwingConstants.LEFT);
357 public void actionPerformed(ActionEvent e) {
367 String toolTipFitProviderInterpreter =
"Interpreter to be used for the "
368 +
"fitness provider executable";
370 new FlowLayout(FlowLayout.LEFT));
372 +
"provider", SwingConstants.LEFT);
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);
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>");
400 txtEq.setPreferredSize(fitEqSize);
408 JLabel lblDescTreeTitle =
new JLabel(
"Available descriptors:");
409 JPanel lineDescTreeTitle =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
410 lineDescTreeTitle.add(lblDescTreeTitle);
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>"
420 DefaultMutableTreeNode rootNode =
new DefaultMutableTreeNode(
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);
430 descTree.putClientProperty(
"JTree.lineStyle",
"Angled");
431 descTree.setToolTipText(toolTipDescs);
432 int dValLength = 350;
433 descTree.addTreeSelectionListener(
new TreeSelectionListener() {
435 public void valueChanged(TreeSelectionEvent e) {
436 TreePath selPath = e.getPath();
437 DefaultMutableTreeNode selTreeNode = (DefaultMutableTreeNode)
438 selPath.getLastPathComponent();
440 || !selTreeNode.isLeaf())
448 titStr =
"<html><body width='%1s'>" + titStr +
"</body></html>";
453 defStr =
"<html><body width='%1s'>" + defStr +
"</body></html>";
459 clsStr =
"<html><body width='%1s'>" + clsStr +
"</body></html>";
464 String[] parNames = iDesc.getParameterNames();
465 Object[] params = iDesc.getParameters();
468 ArrayList<Object> paramsTypes =
new ArrayList<Object>();
471 parStr =
"Undeclared parameters. See source code.";
473 for (
int ip=0; ip<parNames.length; ip++)
477 parStr = parStr +
"<br>";
479 Object parTyp = iDesc.getParameterType(parNames[ip]);
481 String parTypStr = parTyp.getClass().getSimpleName();
482 if (parTyp instanceof Class<?>)
484 parTypStr = ((Class<?>) iDesc.getParameterType(
485 parNames[ip])).getSimpleName();
487 parStr = parStr + parNames[ip] +
" = ("
488 + parTypStr +
") " + params[ip];
489 paramsTypes.add(parTyp);
493 if (paramsTypes.size() == 0)
503 for (Object parTypeExample : paramsTypes)
508 parStr = parStr +
"<p> </p>" + s;
511 parStr =
"<html><body width='%1s'>" + parStr +
"</body></html>";
515 srcStr =
"<html><body width='%1s'>" + srcStr +
"</body></html>";
520 JScrollPane descTreeScrollPane =
new JScrollPane(descTree);
522 String[] sources =
new String[] {
"CDK",
"DENOPTIM"};
523 for (String source : sources)
526 rootNode.add(sourceNode);
528 List<DescriptorForFitness> allDescs =
null;
542 System.out.println(
"No descriptor implementation found in "
543 +
"source '" + source +
"'!");
544 e1.printStackTrace();
549 Map<String,DescriptorTreeNode> mainClassificationNodes =
550 new HashMap<String,DescriptorTreeNode>();
553 String[] klasses =
new String[]{
"Unclassified"};
554 if (dff.getDictClasses()!=
null)
556 klasses = dff.getDictClasses();
558 for (String kls : klasses)
560 if (!mainClassificationNodes.containsKey(kls))
564 sourceNode.add(klassNode);
565 mainClassificationNodes.put(kls, klassNode);
571 for (String klass : mainClassificationNodes.keySet())
575 Map<String,DescriptorTreeNode> descriptorNodes =
576 new HashMap<String,DescriptorTreeNode>();
584 List<String> klasses =
new ArrayList<String>();
585 if (dff.getDictClasses() ==
null)
587 if (!klass.equals(
"Unclassified"))
594 klasses =
new ArrayList<String>(
595 Arrays.asList(dff.getDictClasses()));
597 if (!klasses.contains(klass))
604 if (dff.getImplementation().getDescriptorNames().length > 1)
606 String descriptorName = dff.getImplementation().getClass()
608 if (!descriptorNodes.containsKey(descriptorName))
612 parentNode.add(descNode);
613 descriptorNodes.put(descriptorName, descNode);
615 parentNode = descriptorNodes.get(descriptorName);
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);
655 public void actionPerformed(ActionEvent e)
669 lyoDescParamsPanel.setAutoCreateGaps(
true);
670 lyoDescParamsPanel.setAutoCreateContainerGaps(
true);
671 lyoDescParamsPanel.setHorizontalGroup(
672 lyoDescParamsPanel.createParallelGroup()
675 lyoDescParamsPanel.setVerticalGroup(
676 lyoDescParamsPanel.createSequentialGroup()
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)
692 .addComponent(lblDDParams)
693 .addComponent(lblDDSource)
695 .addGroup(lyoDescDefPanel.createParallelGroup()
704 lyoDescDefPanel.setVerticalGroup(lyoDescDefPanel.createSequentialGroup()
705 .addGroup(lyoDescDefPanel.createParallelGroup()
706 .addComponent(lblDDName)
708 .addGroup(lyoDescDefPanel.createParallelGroup()
709 .addComponent(lblDDTitle)
711 .addGroup(lyoDescDefPanel.createParallelGroup()
712 .addComponent(lblDDClasses)
714 .addGroup(lyoDescDefPanel.createParallelGroup()
715 .addComponent(lblDDDefinition)
720 .addGroup(lyoDescDefPanel.createParallelGroup()
721 .addComponent(lblDDParams)
723 .addGroup(lyoDescDefPanel.createParallelGroup()
724 .addComponent(lblDDSource)
730 JSplitPane splitPaneDescs =
new JSplitPane();
731 splitPaneDescs.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
732 splitPaneDescs.setOneTouchExpandable(
true);
733 splitPaneDescs.setResizeWeight(0.5);
734 splitPaneDescs.setLeftComponent(descTreeScrollPane);
736 JPanel lineDescsTree =
new JPanel();
737 lineDescsTree.setLayout(
new BorderLayout(2,2));
738 lineDescsTree.add(splitPaneDescs);
741 lblCustomvars =
new JLabel(
"Definition of custom variables:");
742 JPanel lineMoreEqTitle =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
746 String toolTipMoreEq =
"<html>Define atom/bond specific descriptors.</html>";
751 String column_names[]= {
"<html><b>Variable</b></html>",
752 "<html><b>Definition</b></html>"};
756 tabCustomVars.putClientProperty(
"terminateEditOnFocusLost",
true);
758 tabCustomVars.getColumnModel().getColumn(1).setMinWidth(100);
760 JTableHeader tabMoreEqHeader =
tabCustomVars.getTableHeader();
761 tabMoreEqHeader.setPreferredSize(
new Dimension(120, 20));
762 JScrollPane tabMoreEqScrollPane =
new JScrollPane(
tabCustomVars);
768 tabMoreEqScrollPane.setAlignmentY(Component.TOP_ALIGNMENT);
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() {
774 public void actionPerformed(ActionEvent e) {
777 Object[] res = (Object[]) dialog.
showDialog();
787 public void actionPerformed(ActionEvent e)
792 Object[] res = (Object[]) dialog.
showDialog();
819 JButton btnRemoveCustomVar =
new JButton(
"Remove selected");
820 btnRemoveCustomVar.setToolTipText(
"Remove the selected definitions.");
821 btnRemoveCustomVar.addActionListener(
new ActionListener() {
823 public void actionPerformed(ActionEvent e) {
829 Arrays.sort(selectedRowIds);
830 for (
int i=(selectedRowIds.length-1); i>-1; i--)
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)
850 .addComponent(btnRemoveCustomVar)));
851 lyoCustomvarPanel.setVerticalGroup(
852 lyoCustomvarPanel.createParallelGroup()
853 .addComponent(tabMoreEqScrollPane)
854 .addGroup(lyoCustomvarPanel.createSequentialGroup()
855 .addComponent(btAtomSpecVar)
857 .addComponent(btnRemoveCustomVar)));
901 block.add(super.getPanelForUnformattedInput());
903 this.add(scrollablePane);
928 for (
int i=0; i<initialRowCount; i++)
944 @SuppressWarnings(
"serial")
964 super(descriptorName);
1010 @SuppressWarnings(
"unchecked")
1015 String valueFieldClass;
1019 valueFieldClass = valueField.getClass().toString();
1027 switch (valueFieldClass)
1029 case "class javax.swing.JTextField":
1034 if (key.toUpperCase().equals(
keyEq.toUpperCase()))
1036 value = value.trim();
1037 if (value.startsWith(
"${") && value.endsWith(
"}"));
1039 value = value.substring(2, value.lastIndexOf(
"}"));
1042 ((JTextField) valueField).setText(value);
1045 case "class javax.swing.JRadioButton":
1046 if (key.toUpperCase().equals(
key3dTrees.toUpperCase()))
1048 ((JRadioButton) valueField).setSelected(
false);
1050 ((JRadioButton) valueField).setSelected(
true);
1055 ((JRadioButton) valueField).setSelected(
1060 case "class javax.swing.JComboBox":
1061 ((JComboBox<String>) valueField).setSelectedItem(value);
1064 case "class javax.swing.table.DefaultTableModel":
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);
1075 ((DefaultTableModel) valueField).addRow(value.split(
" "));
1080 throw new Exception(
"<html>Unexpected type for parameter: "
1081 + key +
" (" + valueFieldClass
1082 +
").<br>Please report this to"
1083 +
"the DEMOPTIM team.</html>");
1093 sb.append(
"# Fitness Provider - parameters").append(
NL);
1126 @SuppressWarnings(
"serial")
1130 String[] paramNames, Component refForPlacement)
1132 super(refForPlacement,
true);
1133 this.setTitle(
"Define parametrized descriptor variable");
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);
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 "
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);
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);
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);
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() {
1194 public void actionPerformed(ActionEvent e) {
1195 if (txtVarName.getText().equals(
"")
1196 || txtDescName.getText().equals(
""))
1200 String line =
"${Variable.parametrized('"
1201 + txtVarName.getText()
1202 +
"','" + txtDescName.getText() +
"','";
1204 boolean quit =
false;
1205 for (
int i=0; i<tabSize; i++)
1207 if (tabParamsMod.getValueAt(i,0) ==
null ||
1208 tabParamsMod.getValueAt(i,0).toString().trim().equals(
""))
1215 for (
int i=0; i<tabSize; i++)
1217 String s = tabParamsMod.getValueAt(i,0).toString()
1219 if (s.contains(paramNames[i]))
1221 s = s.replaceFirst(paramNames[i],
"");
1223 if (s.startsWith(
"="))
1225 s = s.replaceFirst(
"=",
"");
1233 line = line +
"')}";
1234 result =
new Object[] {txtVarName.getText(),line};
1240 this.btnExtra.setText(
"?");
1241 this.btnExtra.setVisible(
true);
1242 this.btnExtra.addActionListener(
new ActionListener() {
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>"
1258 JOptionPane.showMessageDialog(btnExtra,
1259 String.format(txt, 350),
1261 JOptionPane.PLAIN_MESSAGE);
1265 this.btnCanc.addActionListener(
new ActionListener() {
1267 public void actionPerformed(ActionEvent e) {
1277 @SuppressWarnings(
"serial")
1282 super(refForPlacement);
1283 this.setTitle(
"Define atom-specific variable");
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);
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 "
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);
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() {
1332 public void actionPerformed(ActionEvent e) {
1333 if (txtVarName.getText().equals(
"")
1334 && txtDescName.getText().equals(
"")
1335 && txtSmarts.getText().equals(
""))
1339 result =
new Object[] {txtVarName.getText(),
1340 "${atomSpecific('" + txtVarName.getText()
1341 +
"','" + txtDescName.getText() +
"','"
1342 + txtSmarts.getText() +
"')}"};
1347 this.btnCanc.addActionListener(
new ActionListener() {
1350 public void actionPerformed(ActionEvent e) {
This is a reference to a specific descriptor value.
String[] getDictClasses()
String getDictDefinition()
IDescriptor getImplementation()
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.
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.
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...