21import java.awt.BorderLayout;
23import java.awt.Component;
24import java.awt.Cursor;
25import java.awt.Dimension;
26import java.awt.event.ActionEvent;
27import java.awt.event.ActionListener;
28import java.beans.PropertyChangeEvent;
29import java.beans.PropertyChangeListener;
30import java.io.BufferedReader;
32import java.io.InputStreamReader;
33import java.util.ArrayList;
36import java.util.concurrent.atomic.AtomicInteger;
38import javax.swing.BoxLayout;
39import javax.swing.DefaultListModel;
40import javax.swing.GroupLayout;
41import javax.swing.JButton;
42import javax.swing.JComponent;
43import javax.swing.JLabel;
44import javax.swing.JList;
45import javax.swing.JOptionPane;
46import javax.swing.JPanel;
47import javax.swing.JScrollPane;
48import javax.swing.JSeparator;
49import javax.swing.JSpinner;
50import javax.swing.JSpinner.DefaultEditor;
51import javax.swing.ListSelectionModel;
52import javax.swing.SpinnerNumberModel;
53import javax.swing.SwingConstants;
54import javax.swing.UIManager;
55import javax.swing.event.ChangeEvent;
56import javax.swing.event.ChangeListener;
57import javax.swing.table.DefaultTableModel;
58import javax.vecmath.Point3d;
60import org.openscience.cdk.interfaces.IAtom;
61import org.openscience.cdk.interfaces.IAtomContainer;
62import org.openscience.cdk.interfaces.IBond;
64import denoptim.constants.DENOPTIMConstants;
65import denoptim.exception.DENOPTIMException;
66import denoptim.files.FileAndFormat;
67import denoptim.files.FileUtils;
68import denoptim.fragmenter.FragmenterTools;
69import denoptim.graph.APClass;
70import denoptim.graph.AttachmentPoint;
71import denoptim.graph.DGraph;
72import denoptim.graph.Edge.BondType;
73import denoptim.graph.EmptyVertex;
74import denoptim.graph.Fragment;
75import denoptim.graph.Vertex;
76import denoptim.graph.Vertex.BBType;
77import denoptim.io.DenoptimIO;
78import denoptim.programs.fragmenter.CuttingRule;
79import denoptim.programs.fragmenter.FragmenterParameters;
80import denoptim.utils.DummyAtomHandler;
81import denoptim.utils.MoleculeUtils;
168 super.setLayout(
new BorderLayout());
180 this.setLayout(
new BorderLayout());
191 new PropertyChangeListener() {
193 public void propertyChange(PropertyChangeEvent evt) {
211 JLabel navigationLabel1 =
new JLabel(
"Vertex # ");
212 JLabel navigationLabel2 =
new JLabel(
"Current library size: ");
215 navigSpinner =
new JSpinner(
new SpinnerNumberModel(0, 0, 0, 1));
216 navigSpinner.setToolTipText(
"Move to vertex number # in the currently loaded library.");
228 btnAddVrtx.setToolTipText(
"Append vertices taken from a file.");
229 btnAddVrtx.addActionListener(
new ActionListener() {
230 public void actionPerformed(ActionEvent e) {
232 if (inFile ==
null || inFile.getAbsolutePath().equals(
""))
237 ArrayList<Vertex> vrtxLib =
new ArrayList<>();
240 }
catch (Exception e1) {
241 e1.printStackTrace();
243 "<html>Could not read building blocks from file"
244 +
"<br>'" + inFile +
"'"
245 +
"<br>Hint on cause: " + e1.getMessage()
248 JOptionPane.ERROR_MESSAGE,
249 UIManager.getIcon(
"OptionPane.errorIcon"));
253 if (vrtxLib.size() == 0)
256 "<html>No building blocks in file"
257 +
"<br>'" + inFile +
"'</html>",
259 JOptionPane.ERROR_MESSAGE,
260 UIManager.getIcon(
"OptionPane.errorIcon"));
264 if (vrtxLib.size() == 1)
270 String[] options =
new String[]{
"All",
273 String txt =
"<html><body width='%1s'>Do you want to "
274 +
"append all building blocks or only selected ones?"
276 int res = JOptionPane.showOptionDialog(
btnAddVrtx,
277 String.format(txt,200),
278 "Append Building Blocks",
279 JOptionPane.DEFAULT_OPTION,
280 JOptionPane.QUESTION_MESSAGE,
281 UIManager.getIcon(
"OptionPane.warningIcon"),
297 ArrayList<Vertex> selectedVrtxs =
298 new ArrayList<Vertex>();
302 vrtxSelector.
load(vrtxLib, 0);
305 if (selected !=
null)
307 @SuppressWarnings(
"unchecked")
308 ArrayList<ArrayList<Integer>> selList =
309 (ArrayList<ArrayList<Integer>>) selected;
310 for (ArrayList<Integer> pair : selList)
312 selectedVrtxs.add(vrtxLib.get(pair.get(0)));
324 btnDelVrtx.setToolTipText(
"Remove the present building block from the "
326 btnDelVrtx.addActionListener(
new ActionListener() {
327 public void actionPerformed(ActionEvent e) {
331 System.out.println(
"Exception while removing the current "
332 +
"building block:");
333 e1.printStackTrace();
345 JLabel lblImportStruct =
new JLabel(
"Import a structure from");
347 btnOpenMol.setToolTipText(
"Imports a chemical system"
349 btnOpenMol.addActionListener(
new ActionListener() {
350 public void actionPerformed(ActionEvent e) {
352 if (inFile ==
null || inFile.getAbsolutePath().equals(
""))
363 +
" from SMILES string.<br>The conversion of SMILES "
364 +
"to 3D structure requires"
365 +
"<br> an internet connection.</html>");
367 public void actionPerformed(ActionEvent e) {
369 "Please input SMILES: ");
370 if (smiles !=
null && !smiles.trim().equals(
""))
378 lyoImportStructure.setAutoCreateGaps(
true);
379 lyoImportStructure.setAutoCreateContainerGaps(
true);
380 lyoImportStructure.setHorizontalGroup(lyoImportStructure.createParallelGroup(
381 GroupLayout.Alignment.CENTER)
382 .addComponent(lblImportStruct)
383 .addGroup(lyoImportStructure.createSequentialGroup()
386 lyoImportStructure.setVerticalGroup(lyoImportStructure.createSequentialGroup()
387 .addComponent(lblImportStruct)
388 .addGroup(lyoImportStructure.createParallelGroup()
397 btnEmptFrag.setToolTipText(
"<html>Creates an empty vertex:<br>a vertex "
398 +
"that contains no molecular structure.<html>");
399 btnEmptFrag.addActionListener(
new ActionListener() {
400 public void actionPerformed(ActionEvent e) {
403 makeEmptyVertexDialog.pack();
404 Object ev = makeEmptyVertexDialog.
showDialog();
409 ArrayList<Vertex> lst =
new ArrayList<Vertex>(1);
413 fragSelector.
load(lst, 0);
414 fragSelector.
btnDone.setText(
"Confirm");
415 fragSelector.
ctrlPane.setVisible(
false);
418 if (selected ==
null)
432 btnAtmToAP.setToolTipText(
"<html>Replaces the selected atoms with "
433 +
"attachment points.<br>Click on atoms to select"
434 +
" them. Click again to unselect.<br>"
435 +
"<br><b>WARNING:</b> this action cannot be undone!<html>");
436 btnAtmToAP.addActionListener(
new ActionListener() {
437 public void actionPerformed(ActionEvent e) {
440 ArrayList<IAtom> selectedAtms =
443 if (selectedAtms.size() == 0)
446 "<html>No atom selected! Click on atoms to select"
447 +
" them.<br>Click again to unselect.</html>",
449 JOptionPane.ERROR_MESSAGE,
450 UIManager.getIcon(
"OptionPane.errorIcon"));
464 if (selectedAPCs.size() == 0)
469 String apClass = selectedAPCs.get(0).toString();
471 ArrayList<IAtom> failed =
new ArrayList<IAtom>();
472 for (IAtom atm : selectedAtms)
479 for (IAtom atm : failed)
481 selectedAtms.remove(atm);
483 if (selectedAtms.size() == 0)
501 btnChop =
new JButton(
"Chop Structure");
502 btnChop.setToolTipText(String.format(
"<html><body width='%1s'>"
503 +
"Applies cutting rules on "
504 +
"the current structure to generate fragments.</html>", 400));
505 btnChop.addActionListener(
new ActionListener() {
506 public void actionPerformed(ActionEvent event) {
511 JOptionPane.showMessageDialog(
btnChop,
512 "<html>System contains 0 bonds. "
513 +
"Nothing to chop.</html>",
515 JOptionPane.ERROR_MESSAGE,
516 UIManager.getIcon(
"OptionPane.errorIcon"));
523 this.getClass().getClassLoader(),
529 String pathnameLastUsedCutRules =
531 if (pathnameLastUsedCutRules !=
null
532 && !pathnameLastUsedCutRules.isBlank())
534 GUIPreferences.lastCutRulesFile =
535 new File(pathnameLastUsedCutRules);
539 List<Vertex> fragments;
548 JOptionPane.showMessageDialog(
btnChop,String.format(
549 "<html><body width='%1s'"
550 +
"Could not complete fragmentation. Hint: "
551 + e.getMessage() +
"</html>", 400),
553 JOptionPane.ERROR_MESSAGE,
554 UIManager.getIcon(
"OptionPane.errorIcon"));
559 for (
Vertex frag : fragments)
566 if (fragments.size() < 1 || (fragments.size() == 1 &&
570 "<html>Fragmentation produced no fragments!</html>",
572 JOptionPane.WARNING_MESSAGE,
573 UIManager.getIcon(
"OptionPane.warningIcon"));
580 String[] options =
new String[]{
"All",
583 String txt =
"<html><body width='%1s'>Fragmentation produced "
584 + fragments.size() +
" fragments. Do you want to "
585 +
"append all or select some?"
587 int answer = JOptionPane.showOptionDialog(
btnAddVrtx,
588 String.format(txt,200),
589 "Append Building Blocks",
590 JOptionPane.DEFAULT_OPTION,
591 JOptionPane.QUESTION_MESSAGE,
592 UIManager.getIcon(
"OptionPane.warningIcon"),
608 List<Vertex> selectedVrtxs =
609 new ArrayList<Vertex>();
613 vrtxSelector.
load(fragments, 0);
616 if (selected !=
null)
618 @SuppressWarnings(
"unchecked")
619 List<ArrayList<Integer>> selList =
620 (ArrayList<ArrayList<Integer>>) selected;
621 for (ArrayList<Integer> pair : selList)
623 selectedVrtxs.add(fragments.get(pair.get(0)));
640 btnDelSel.setToolTipText(
"<html>Removes all selected atoms from the "
641 +
"system.<br><br><b>WARNING:</b> this action cannot be "
643 btnDelSel.addActionListener(
new ActionListener() {
644 public void actionPerformed(ActionEvent e) {
645 ArrayList<IAtom> selectedAtms =
648 if (selectedAtms.size() == 0)
651 "<html>No atom selected! Click on atoms to select"
652 +
" them.<br>Click again to unselect.</html>",
654 JOptionPane.ERROR_MESSAGE,
655 UIManager.getIcon(
"OptionPane.errorIcon"));
678 btnSaveEdits.setToolTipText(
"<html>Save the current system replacing"
679 +
" <br>the original one in the loaded library.</html>");
681 public void actionPerformed(ActionEvent e) {
687 this.add(
ctrlPane, BorderLayout.EAST);
692 super.add(commandsPane, BorderLayout.SOUTH);
694 btnOpenVrtxs =
new JButton(
"Load Library of Building Blocks");
695 btnOpenVrtxs.setToolTipText(
"Reads building blocks or structures from "
698 public void actionPerformed(ActionEvent e) {
700 if (inFile ==
null || inFile.getAbsolutePath().equals(
""))
704 ArrayList<Vertex> vrtxLib =
new ArrayList<>();
707 }
catch (Exception e1) {
708 e1.printStackTrace();
710 "<html>Could not read building blocks from file"
711 +
"<br>'" + inFile +
"'"
712 +
"<br>Hint on cause: " + e1.getMessage()
715 JOptionPane.ERROR_MESSAGE,
716 UIManager.getIcon(
"OptionPane.errorIcon"));
720 if (vrtxLib.size() == 0)
723 "<html>No building blocks in file"
724 +
"<br>'" + inFile +
"'</html>",
726 JOptionPane.ERROR_MESSAGE,
727 UIManager.getIcon(
"OptionPane.errorIcon"));
735 JButton btnSaveVrtxs =
new JButton(
"Save Library of Building Blocks");
736 btnSaveVrtxs.setToolTipText(
"Write all building blocks to a file.");
737 btnSaveVrtxs.addActionListener(
new ActionListener() {
738 public void actionPerformed(ActionEvent e) {
741 if (fileAndFormat ==
null)
745 File outFile = fileAndFormat.
file;
756 ex.printStackTrace();
757 JOptionPane.showMessageDialog(btnSaveVrtxs,
758 "Could not write to '" + outFile +
"'! "
759 +
"Hint: "+ex.getMessage(),
761 JOptionPane.PLAIN_MESSAGE,
762 UIManager.getIcon(
"OptionPane.errorIcon"));
772 commandsPane.
add(btnSaveVrtxs);
774 JButton btnCanc =
new JButton(
"Close Tab");
775 btnCanc.setToolTipText(
"Closes this tab.");
777 commandsPane.
add(btnCanc);
779 JButton btnHelp =
new JButton(
"?");
780 btnHelp.setToolTipText(
"<html>Hover over the buttons and fields "
781 +
"to get a tip.</html>");
782 btnHelp.addActionListener(
new ActionListener() {
783 public void actionPerformed(ActionEvent e) {
784 String txt =
"<html><body width='%1s'>"
785 +
"<p>This tab allows to create, inspect, and edit "
786 +
"building blocks and "
787 +
"three-dimensional molecular fragments.</p>"
788 +
"<p>New fragments can be created starting from any "
789 +
"chemical structure that can be loaded from file or "
790 +
"generated from SMILES (SMILES-to-3D conversion "
791 +
"requires an Internet connection).</p>"
792 +
"<p>Any terminal atom (i.e., atoms that have only "
793 +
"one connected neighbor) can be transformed into "
794 +
"on attachment point (AP). Click on the atom to "
795 +
"select it, and press <code><b>Atom to AP</b></code>."
797 +
"<p>Attachment points are depicted in the molecular "
798 +
"viewer as yellow arrows in the 3D space, and their "
799 +
"attachment point class (APClass) is specified in "
800 +
"the table below the viewer. Double-click on a "
801 +
"specific APClass field to change its value.</p>"
803 +
"<p>Hover over buttons get a tip.</p>"
805 +
"<p>Right-click on the Jmol viewer will open the "
806 +
"Jmol menu. However, since Jmol cannot handle the "
807 +
"attachment points data. Therefore, Jmol "
808 +
"functionality should only be used on systems "
809 +
"that have no attachment points, or for alterations "
810 +
"of the molecular structure that do not change the "
811 +
"list of atoms au to the last atom decorated with an "
812 +
"attachment point.</p></html>";
813 JOptionPane.showMessageDialog(btnHelp,
814 String.format(txt, 400),
816 JOptionPane.PLAIN_MESSAGE);
819 commandsPane.
add(btnHelp);
837 boolean setMolToGraphSettings)
841 List<CuttingRule> defaultCuttingRules =
new ArrayList<CuttingRule>();
842 BufferedReader reader =
null;
846 reader =
new BufferedReader(
847 new InputStreamReader(classLoader.getResourceAsStream(
848 "data/cutting_rules")));
855 }
catch (Exception e )
858 JOptionPane.showMessageDialog(parent,String.format(
859 "<html><body width='%1s'>"
860 +
"Could not read default cutting rules from "
863 + e.getMessage() +
"</html>", 400),
865 JOptionPane.ERROR_MESSAGE,
866 UIManager.getIcon(
"OptionPane.errorIcon"));
871 List<CuttingRule> customCuttingRules =
new ArrayList<CuttingRule>();
872 boolean useDefaultCuttingRules =
true;
880 useDefaultCuttingRules =
false;
884 JOptionPane.showMessageDialog(parent,String.format(
885 "<html><body width='%1s'"
886 +
"Could not read last-used cutting rules from '"
889 + e.getMessage() +
"</html>", 400),
891 JOptionPane.ERROR_MESSAGE,
892 UIManager.getIcon(
"OptionPane.errorIcon"));
899 if (setMolToGraphSettings)
902 defaultCuttingRules, customCuttingRules,
903 useDefaultCuttingRules, parent, settings);
906 defaultCuttingRules, customCuttingRules,
907 useDefaultCuttingRules, parent, settings);
910 crs.setVisible(
true);
916 if (pathnameLastUsedCutRules !=
null
917 && !pathnameLastUsedCutRules.isBlank())
919 GUIPreferences.lastCutRulesFile =
new File(pathnameLastUsedCutRules);
929 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
957 }
catch (Exception e) {
958 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
960 JOptionPane.showMessageDialog(
this,
961 "<html>Could not read file '" + file.getAbsolutePath()
962 +
"'!<br>Hint about reason: " + e.getCause() +
"</html>",
964 JOptionPane.PLAIN_MESSAGE,
965 UIManager.getIcon(
"OptionPane.errorIcon"));
968 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
981 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
989 }
catch (Exception e) {
990 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1009 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1020 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1022 ArrayList<Vertex> vrtxLib =
new ArrayList<>();
1025 }
catch (Exception e1) {
1026 e1.printStackTrace();
1028 "<html>Could not read building blocks from file"
1029 +
"<br>'" + file +
"'"
1030 +
"<br>Hint on cause: " + e1.getMessage()
1033 JOptionPane.ERROR_MESSAGE,
1034 UIManager.getIcon(
"OptionPane.errorIcon"));
1038 if (vrtxLib.size() == 0)
1041 "<html>No building blocks in file"
1042 +
"<br>'" + file +
"'</html>",
1044 JOptionPane.ERROR_MESSAGE,
1045 UIManager.getIcon(
"OptionPane.errorIcon"));
1049 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1060 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1063 boolean libFromScrtch =
false;
1066 libFromScrtch =
true;
1074 boolean addedOne =
false;
1075 if (fragments.size() > 0)
1094 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1095 JOptionPane.showMessageDialog(
this,
1096 "<html>No vertices to import from the given list.</html>",
1098 JOptionPane.PLAIN_MESSAGE,
1099 UIManager.getIcon(
"OptionPane.errorIcon"));
1101 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1118 JOptionPane.showMessageDialog(
this,
1119 "No list of building blocks loaded.",
1121 JOptionPane.PLAIN_MESSAGE,
1122 UIManager.getIcon(
"OptionPane.errorIcon"));
1182 str = str +
" " + atm.getSymbol()
1185 System.out.println(
"Connected atoms: "+str);
1187 JOptionPane.showMessageDialog(
this,
1188 "<html>Atom "+ trgAtm.getSymbol()
1190 +
" has zero or more than one neighbour.<br>I can only "
1192 +
" that have one and only one neighbour.</html>",
1194 JOptionPane.ERROR_MESSAGE,
1195 UIManager.getIcon(
"OptionPane.errorIcon"));
1201 srcAtm.getBond(trgAtm).getOrder().toString());
1205 Point3d vector =
new Point3d();
1206 vector.x = srcP3d.x + (trgP3d.x - srcP3d.x);
1207 vector.y = srcP3d.y + (trgP3d.y - srcP3d.y);
1208 vector.z = srcP3d.z + (trgP3d.z - srcP3d.z);
1211 String[] parts = ruleAndSubClass.split(
1217 Integer.parseInt(parts[1]), bt), vector);
1219 e.printStackTrace();
1220 JOptionPane.showMessageDialog(
this,
1221 "<html>Could not make AP.<br>Possible cause: "
1222 + e.getMessage() +
"</html>",
1224 JOptionPane.ERROR_MESSAGE,
1225 UIManager.getIcon(
"OptionPane.errorIcon"));
1240 ArrayList<IBond> bnsToDel =
new ArrayList<IBond>();
1241 for (IAtom atm : atmsToDels)
1243 for (IBond bnd : frag.
bonds())
1245 if (bnd.contains(atm))
1251 for (IBond bnd : bnsToDel)
1255 for (IAtom atm : atmsToDels)
1283 this.inEnabled = var;
1324 .getTextField().setEditable(
true);
1326 .getTextField().setForeground(Color.BLACK);
1349 .getTextField().setEditable(
false);
1351 .getTextField().setForeground(Color.GRAY);
1371 String[] options =
new String[]{
"Yes",
"No"};
1372 int res = JOptionPane.showOptionDialog(
this,
1373 "<html>Removing unsaved vertex?",
1375 JOptionPane.DEFAULT_OPTION,
1376 JOptionPane.QUESTION_MESSAGE,
1377 UIManager.getIcon(
"OptionPane.warningIcon"),
1409 navigSpinner.setModel(
new SpinnerNumberModel(0,0,0,1));
1428 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
1434 for (
int i=0; i<tabModel.getRowCount(); i++)
1436 int apId = ((Integer) tabModel.getValueAt(i, 0)).intValue();
1437 String currApClass = tabModel.getValueAt(i, 1).toString();
1442 apcDefiner.setTitle(
"Confirm APClass on AP #"+i);
1447 Object[] pair = (Object[]) chosen;
1448 currApClass = pair[0].toString();
1450 currApClass =
"dafaultAPClass:0";
1453 Map<Integer, AttachmentPoint> mapAPs =
1456 if (mapAPs.containsKey(apId))
1458 String origApClass = mapAPs.get(apId).getAPClass().toString();
1459 if (!origApClass.equals(currApClass))
1462 mapAPs.get(apId).setAPClass(currApClass);
1466 e.printStackTrace();
1468 "<html>Could not save due to errors setting a "
1469 +
"new APClass.<br>Please report this to the "
1470 +
"DENOPTIM team.</html>",
1472 JOptionPane.PLAIN_MESSAGE,
1473 UIManager.getIcon(
"OptionPane.errorIcon"));
1481 "<html>Could not save due to mistmatch between AP "
1482 +
"table and map.<br>Please report this to the "
1483 +
"DENOPTIM team.</html>",
1485 JOptionPane.PLAIN_MESSAGE,
1486 UIManager.getIcon(
"OptionPane.errorIcon"));
1499 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1508 }
catch (Throwable t) {
1519 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1533 boolean singleSelection)
1536 DefaultListModel<String> apClassLstModel =
1537 new DefaultListModel<String>();
1538 JList<String> apClassList =
new JList<String>(apClassLstModel);
1541 apClassLstModel.addElement(apc);
1544 apClassLstModel.addElement(
1545 "<html><b><i>Define a new APClass...<i></b></html>");
1546 if (singleSelection)
1548 apClassList.setSelectionMode(
1549 ListSelectionModel.SINGLE_SELECTION);
1551 apClassList.setSelectionMode(
1552 ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
1554 if (apClassList.getModel().getSize() == 1)
1556 apClassList.setSelectedIndex(0);
1558 apClassList.setSelectedIndex(apClassLstModel.getSize()-1);
1562 JPanel chooseApPanel =
new JPanel();
1563 JLabel header =
new JLabel(
"Choose APClass:");
1564 JScrollPane apClassScroll =
new JScrollPane(apClassList);
1565 chooseApPanel.add(header);
1566 chooseApPanel.add(apClassScroll);
1568 int res = JOptionPane.showConfirmDialog(parent,
1570 "Choose APClasses to Add",
1571 JOptionPane.OK_CANCEL_OPTION,
1572 JOptionPane.PLAIN_MESSAGE,
1574 if (res != JOptionPane.OK_OPTION)
1576 return new ArrayList<APClass>();
1580 ArrayList<APClass> selectedSPCs =
new ArrayList<APClass>();
1581 int[] selectedIds = apClassList.getSelectedIndices();
1582 if (selectedIds.length > 0)
1584 for (
int ii=0; ii<selectedIds.length; ii++)
1587 Integer idAPC = selectedIds[ii];
1590 if (idAPC.intValue() == (apClassLstModel.size()-1))
1598 Object[] pair = (Object[]) chosen;
1603 apc =
APClass.
make(apClassLstModel.getElementAt(idAPC));
1605 }
catch (Exception e1) {
1609 selectedSPCs.add(apc);
1612 return selectedSPCs;
1626 String title,
boolean mustReply, JComponent parent)
1632 if (currApRule !=
"")
1634 preStr =
"APRule '" + currApRule +
"' is not valid!<br>"
1635 +
"The valid syntax for APClass is:<br><br><code>APRule"
1636 + DENOPTIMConstants.SEPARATORAPPROPSCL
1637 +
"subClass</code><br><br> where "
1638 +
"<ul><li><code>APRule</code>"
1639 +
" is the string you should provide now, and is "
1640 +
"typically any string with no spaces,</li>"
1641 +
"<li><code>subClass</code> is an integer.</ul>";
1644 currApRule = JOptionPane.showInputDialog(parent,String.format(
1645 "<html><body width='%1s'>" + preStr
1646 +
" Please, provide a valid APClass rule string: </html>",
1649 JOptionPane.PLAIN_MESSAGE);
1651 if (currApRule ==
null)
General set of constants used in DENOPTIM.
static final String ATMPROPAPS
String tag of Atom property used to store attachment points.
static final String APSTAG
SDF tag defining attachment points.
static final String SEPARATORAPPROPSCL
Separator between APClass and APSubClass and coordinates.
static void addToRecentFiles(String fileName, FileFormat ff)
Appends an entry to the list of recent files.
static List< String > getAllAPClassesAsString()
Returns the list of the names of all APClasses.
static boolean isValidAPRuleString(String s)
Evaluates the given string as a candidate attachment point rule, i.e., as name of a fragmentation rul...
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
An empty vertex has the behaviors of a vertex, but has no molecular structure.
Class representing a continuously connected portion of chemical object holding attachment points.
IBond removeBond(int position)
List< IAtom > getConnectedAtomsList(IAtom atom)
AttachmentPoint addAPOnAtom(IAtom srcAtm, APClass apc, Point3d vector)
Add an attachment point to the specifies atom.
List< AttachmentPoint > getAttachmentPoints()
ArrayList< AttachmentPoint > getAPsFromAtom(IAtom srcAtm)
void removeAtom(IAtom atom)
void updateAPs()
Changes the properties of each APs as to reflect the current atom list.
Iterable< IBond > bonds()
int getConnectedAtomsCount(IAtom atom)
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
abstract IAtomContainer getIAtomContainer()
A modal dialog to define parameters for fragmentation and fragment filtering.
void setPreDefinedAPClass(String text)
Sets the content of the text field with the given predefined text.
Remove the card from the deck of cards and takes care of removing also the entry in the list of activ...
Class of GUI panels meant to occupy one card in the deck-of-cards layout of the main panel.
GUIMainPanel mainPanel
The main panel (cards deck)
File opener for DENOPTIM GUI.
static File pickFile(Component parent)
GUI component to provide pathname where to save stuff.
static FileAndFormat pickFileForSavingVertexes(Component parent)
The main panel is a deck of cards that occupies all the GUI frame.
JButton btnDone
The button that is used to launch the processing of the data given to the open dialog,...
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.
The collection of tunable preferences.
static File lastCutRulesFile
File with last used cutting rules.
void setEnabled(boolean var)
Enables/disable the listener.
void stateChanged(ChangeEvent event)
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...
void updateVrtxListSpinner()
void clearCurrentSystem()
static String ensureGoodAPRuleString(String currApRule, String title, boolean mustReply, JComponent parent)
Forces the user to specify a properly formatted APRule, i.e., the first component of an APClass.
void saveUnsavedChanges()
ArrayList< Vertex > verticesLibrary
The currently loaded list of fragments.
final VrtxSpinnerChangeEvent vrtxSpinnerListener
Vertex vertex
The currently loaded vertex.
void importStructureFromSMILES(String smiles)
Imports the given SMILES into the viewer.
void deprotectEditedSystem()
static AtomicInteger prepVrtxTabUID
Unique identified for instances of this inspector.
void importVerticesFromFile(File file)
Imports fragments from a file.
VertexViewPanel vertexViewer
void importVertices(List< Vertex > fragments)
Imports vertices.
boolean convertAtomToAP(IAtom trgAtm, String ruleAndSubClass)
Removes an atom and replaces it with an attachment point.
boolean unsavedChanges
Flag signaling that loaded data has changes since last save.
void importStructureFromFile(File file)
int currVrtxIdx
The index of the currently loaded fragment [0–(n-1)}.
boolean hasUnsavedChanges()
Check whether there are unsaved changes.
static List< APClass > choseOrCreateNewAPClass(JComponent parent, boolean singleSelection)
Runs a dialog aimed at selecting an existing APClass or defining a new one.
GUIVertexInspector(GUIMainPanel mainPanel)
Constructor.
void initialize()
Initialize the panel and add buttons.
void protectEditedSystem()
void loadCurrentVrtxIdxToViewer()
Loads the fragments corresponding to the field index.
void removeAtoms(ArrayList< IAtom > atmsToDels)
static final long serialVersionUID
Version UID.
static boolean dialogToDefineCuttingRules(FragmenterParameters settings, ClassLoader classLoader, Component parent, boolean setMolToGraphSettings)
Starts a dialog to define the on-the-fly fragmentation settings.
void activateTabEditsListener(boolean var)
A modal dialog with a viewer that understands the different types of DENOPTIM vertex and allows to se...
void load(List< Vertex > fragments, int initialId)
Load the list of vertexes to choose from.
void setRequireApSelection(boolean enforced)
Allows to control whether confirming the selection of a vertex without having selected an attachment ...
A panel for visualizing vertices.
void clearCurrentSystem()
Removes the currently visualized molecule and AP table.
boolean hasUnsavedAPEdits()
Check for unsaved edits to the AP data.
DefaultTableModel getAPTableModel()
void activateTabEditsListener(boolean var)
Allows to activate and deactivate the listener.
Map< Integer, AttachmentPoint > getActiveMapAPs()
Returns the map of attachment points in the currently active viewer.
void deprotectEdits()
Overrides the flag signaling unsaved edits to saying that there are no altered data.
void loadVertexToViewer(Vertex v)
Loads the given vertex to this viewer.
Vertex getLoadedStructure()
Returns the currently loaded vertex.
void loadPlainStructure(IAtomContainer mol)
Loads a structure in the Jmol viewer.
boolean loadSMILES(String smiles)
Loads a molecule build from a smiles string.
void setSwitchable(boolean switchable)
Enable/disable switch-able view.
ArrayList< IAtom > getAtomsSelectedFromJMol()
Identifies the atoms that are selected in the Jmol viewer.
void clearMolecularViewer(boolean dataIsComing)
Clears the molecular viewer.
Utility methods for input/output.
static File writeVertexesToFile(File file, FileFormat format, List< Vertex > vertexes)
Writes vertexes to file.
static void readCuttingRules(BufferedReader reader, List< CuttingRule > cutRules, String source)
Read cutting rules from a stream.
static ArrayList< Vertex > readVertexes(File file, Vertex.BBType bbt)
Reads Vertexes from any file that can contain such items.
static List< IAtomContainer > readAllAtomContainers(File file)
Returns a single collection with all atom containers found in a file of any format.
Logger getLogger()
Get the name of the program specific logger.
Logger startConsoleLogger(String loggerIdentifier)
Starts a program-specific logger that prints to System.err stream.
Parameters controlling execution of the fragmenter.
double getLinearAngleLimit()
String getCuttingRulesFilePathname()
List< CuttingRule > getCuttingRules()
Toll to add/remove dummy atoms from linearities or multi-hapto sites.
static void addDummiesOnLinearities(Fragment frag, double angLim)
Append dummy atoms on otherwise linear arrangements of atoms.
Utilities for molecule conversion.
static Point3d getPoint3d(IAtom atm)
Return the 3D coordinates, if present.
Possible chemical bond types an edge can represent.
The type of building block.
Interface for all vertex viewers that intend to allow selection of attachment points.
final String APDATACHANGEEVENT