21import java.awt.BorderLayout;
23import java.awt.Component;
24import java.awt.Cursor;
25import java.awt.Dimension;
26import java.awt.FlowLayout;
27import java.awt.event.ActionEvent;
28import java.awt.event.ActionListener;
29import java.awt.event.MouseEvent;
30import java.awt.event.MouseListener;
31import java.beans.PropertyChangeEvent;
32import java.beans.PropertyChangeListener;
33import java.beans.PropertyChangeListenerProxy;
35import java.util.ArrayList;
36import java.util.Arrays;
37import java.util.Collections;
38import java.util.HashMap;
39import java.util.HashSet;
42import java.util.SortedSet;
43import java.util.TreeSet;
45import javax.swing.BorderFactory;
46import javax.swing.Box;
47import javax.swing.BoxLayout;
48import javax.swing.DefaultListModel;
49import javax.swing.GroupLayout;
50import javax.swing.JButton;
51import javax.swing.JComponent;
52import javax.swing.JLabel;
53import javax.swing.JList;
54import javax.swing.JOptionPane;
55import javax.swing.JPanel;
56import javax.swing.JScrollPane;
57import javax.swing.JTabbedPane;
58import javax.swing.JTable;
59import javax.swing.JTextField;
60import javax.swing.ListSelectionModel;
61import javax.swing.SwingConstants;
62import javax.swing.UIManager;
63import javax.swing.table.DefaultTableModel;
65import denoptim.exception.DENOPTIMException;
66import denoptim.graph.APClass;
67import denoptim.graph.Edge.BondType;
68import denoptim.io.DenoptimIO;
93 private SortedSet<String>
allAPRules =
new TreeSet<String>();
111 private HashMap<APClass, ArrayList<APClass>>
compatMap =
112 new HashMap<APClass, ArrayList<APClass>>();
119 new HashMap<APClass, APClass>();
157 @SuppressWarnings(
"serial")
160 this.setLayout(
new BorderLayout());
161 tabbedPane =
new JTabbedPane(JTabbedPane.TOP);
172 btnAddCompRul.setToolTipText(
"Add compatibility rules for a new "
173 +
"source APClass.");
175 public void actionPerformed(ActionEvent e) {
176 DefaultListModel<String> sAPCsStr =
177 new DefaultListModel<String>();
178 JList<String> srcClsList =
new JList<String>(sAPCsStr);
183 sAPCsStr.addElement(apc.toString());
186 sAPCsStr.addElement(
"<html><b><i>Define a new APClass...<i>"
188 srcClsList.setSelectionMode(
189 ListSelectionModel.SINGLE_SELECTION);
190 if (srcClsList.getModel().getSize() == 1)
192 srcClsList.setSelectedIndex(0);
195 DefaultListModel<String> trgAPCs =
196 new DefaultListModel<String>();
197 JList<String> trgClsList =
new JList<String>(trgAPCs);
200 trgAPCs.addElement(apc.toString());
202 trgAPCs.addElement(
"<html><b><i>Define a new APClass...<i>"
204 trgClsList.setSelectionMode(
205 ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
206 if (trgClsList.getModel().getSize() == 1)
208 trgClsList.setSelectedIndex(0);
211 JPanel twoListsPanel =
new JPanel();
212 JLabel headSrc =
new JLabel(
"APClass on the growing graph");
213 JLabel headTrg =
new JLabel(
"APClass on incoming fragment");
214 JScrollPane scrollSrc =
new JScrollPane(srcClsList);
215 JScrollPane scrollTrg =
new JScrollPane(trgClsList);
216 GroupLayout lyoAddCapRule =
new GroupLayout(twoListsPanel);
217 twoListsPanel.setLayout(lyoAddCapRule);
218 lyoAddCapRule.setAutoCreateGaps(
true);
219 lyoAddCapRule.setAutoCreateContainerGaps(
true);
220 lyoAddCapRule.setHorizontalGroup(
221 lyoAddCapRule.createSequentialGroup()
222 .addGroup(lyoAddCapRule.createParallelGroup()
223 .addComponent(headSrc)
224 .addComponent(scrollSrc))
226 .addGroup(lyoAddCapRule.createParallelGroup()
227 .addComponent(headTrg)
228 .addComponent(scrollTrg)));
229 lyoAddCapRule.setVerticalGroup(
230 lyoAddCapRule.createSequentialGroup()
231 .addGroup(lyoAddCapRule.createParallelGroup()
232 .addComponent(headSrc)
234 .addComponent(headTrg))
235 .addGroup(lyoAddCapRule.createParallelGroup()
236 .addComponent(scrollSrc)
237 .addComponent(scrollTrg)));
241 "New APClass compatibility rule",
242 JOptionPane.OK_CANCEL_OPTION,
243 JOptionPane.PLAIN_MESSAGE,
246 if (res != JOptionPane.OK_OPTION)
251 if (trgClsList.getSelectedIndices().length > 0
252 && srcClsList.getSelectedIndices().length > 0)
255 Integer idSrc = srcClsList.getSelectedIndices()[0];
258 if (idSrc.intValue() == (sAPCsStr.size()-1))
270 Object[] pair = (Object[]) chosen;
277 "<html>Class '<code>" + srcAPClass
278 +
"</code>' is not new!</html>",
280 JOptionPane.WARNING_MESSAGE,
282 "OptionPane.errorIcon"));
289 "<html>Error definging anew APClass.<br>"
290 +
"Please, report this to the DENOPTIM "
293 JOptionPane.WARNING_MESSAGE,
294 UIManager.getIcon(
"OptionPane.errorIcon"));
303 sAPCsStr.getElementAt(idSrc));
307 e1.printStackTrace();
311 ArrayList<APClass> trgCPClasses =
new ArrayList<APClass>();
312 for (Integer
id : trgClsList.getSelectedIndices())
314 if (
id.intValue() == (trgAPCs.size()-1))
326 Object[] pair = (Object[]) chosen;
330 trgCPClasses.add(cls);
342 (String) trgAPCs.getElementAt(
id)));
346 e1.printStackTrace();
351 if (
compatMap.keySet().contains(srcAPClass))
353 compatMap.get(srcAPClass).addAll(trgCPClasses);
367 btnCopyCompRul.setToolTipText(String.format(
"<html><body width='%1s'>"
368 +
"<p>Copy all the compatibility rules of a selected source "
369 +
"APClass to a new, user-selected source APClass.</p></html>",
372 public void actionPerformed(ActionEvent e) {
373 ArrayList<String> selected =
new ArrayList<String>();
374 for (Component lineComponent :
panelCPRules.getComponents())
380 selected.add(lineComponent.getName());
385 if (selected.size() == 1)
387 String srcOrig = selected.get(0);
389 DefaultListModel<String> srcAPCs =
390 new DefaultListModel<String>();
391 JList<String> srcClsList =
new JList<String>(srcAPCs);
396 srcAPCs.addElement(apc.toString());
399 srcClsList.setSelectionMode(
400 ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
403 new JScrollPane(srcClsList),
404 "New APClass sources",
405 JOptionPane.OK_CANCEL_OPTION,
406 JOptionPane.PLAIN_MESSAGE,
409 if (res != JOptionPane.OK_OPTION)
414 List<String> selSrc = srcClsList.getSelectedValuesList();
415 if (selSrc.size() > 0)
417 for (String srcAPClassStr : selSrc)
426 e1.printStackTrace();
428 ArrayList<APClass> newTrg =
429 new ArrayList<APClass>();
436 e1.printStackTrace();
447 "<html>Please, select one and only one source "
448 +
"APCLasss.</html>",
450 JOptionPane.WARNING_MESSAGE,
451 UIManager.getIcon(
"OptionPane.errorIcon"));
458 btnDelCompRul.setToolTipText(String.format(
"<html><body width='%1s'>"
459 +
"<p>Remove all the compatibility rules of selected "
460 +
"source APClasses. Click on the "
461 +
"name of a source APClass to select all its compatibility"
462 +
"rules. You can select multiple source APClasses."
466 public void actionPerformed(ActionEvent e) {
468 for (Component lineComponent :
panelCPRules.getComponents())
477 lineComponent.getName()));
479 lineComponent.getName()));
485 e1.printStackTrace();
498 "<html>Please, click to select at least one source "
499 +
"AP CLasss.</html>",
501 JOptionPane.WARNING_MESSAGE,
502 UIManager.getIcon(
"OptionPane.errorIcon"));
508 JButton btnSearch =
new JButton(
"Search");
509 btnSearch.setToolTipText(String.format(
"<html><body width='%1s'>Search "
510 +
"for the given APClass. Matching compatibility rules are "
511 +
"selected and highlighted accordingly.</html>",150));
512 btnSearch.addActionListener(
new ActionListener() {
513 public void actionPerformed(ActionEvent e) {
519 txtSearch.setToolTipText(String.format(
"<html><body width='%1s'>Type "
520 +
"here the APClass name or part of it. The search supports "
521 +
"regual expressions and initial and final '(.*)' are added "
522 +
"to all queries.",250));
523 txtSearch.addActionListener(
new ActionListener() {
524 public void actionPerformed(ActionEvent e) {
528 JScrollPane txtSearchPanel =
new JScrollPane(
txtSearch,
529 JScrollPane.VERTICAL_SCROLLBAR_NEVER,
530 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
531 txtSearchPanel.getHorizontalScrollBar().setPreferredSize(
new Dimension(0,2));
532 txtSearchPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
538 btnClearMatch.setToolTipText(
"Clear selection of search hits");
540 public void actionPerformed(ActionEvent e) {
550 btnHelpCPMap.setToolTipText(
"Displays the help message.");
552 public void actionPerformed(ActionEvent e) {
553 String txt =
"<html><body width='%1s'><p>Attachment points "
554 +
"(APs) can be annotated with information encoded in "
555 +
"a string of text, i.e., the attachment point class "
556 +
"(APClass). The APClass can be used to define "
557 +
"APClass compatibility rules. Namely, whether two "
558 +
"attachment point can be used to form a connection "
559 +
"between fragment or not. Each rule includes:"
561 +
"<li>the <i>Source APClass</i>, which is the class "
562 +
"of the AP on the growing molecule,</li>"
563 +
"<li>a list of compatible APClasses, i.e., an AP "
564 +
"belonging to any incoming fragment and annotated "
565 +
"with any of the compatible APClasses can be chosen "
566 +
"to form a bond with any AP annotated with the "
567 +
"<i>Source APClass</i>.</li></ul></p></html>";
569 String.format(txt, 400),
571 JOptionPane.PLAIN_MESSAGE);
575 JPanel panelBtnCPMap =
new JPanel();
576 panelBtnCPMap.setLayout(
new BoxLayout(panelBtnCPMap, BoxLayout.X_AXIS));
577 panelBtnCPMap.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
581 panelBtnCPMap.add(btnSearch);
582 panelBtnCPMap.add(txtSearchPanel);
586 panelCPMap.add(panelBtnCPMap, BorderLayout.NORTH);
590 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
591 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
593 new Dimension(15,0));
595 SwingConstants.VERTICAL));
605 String toolTipCapping = String.format(
"<html><body width='%1s'>"
606 +
"Capping rules define the attachment point class (APClass) "
607 +
"of the capping group used to saturate unused attachment "
608 +
"points of a given APClass that need to be saturated when "
609 +
"finalizing the construction of a graph.</html>",300);
613 public boolean isCellEditable(
int row,
int column) {
618 String column_name_fe[]= {
"<html><b>APClasses on graph</b></html>",
619 "<html><b>APClasses of Capping Group</b></html>"};
627 public void actionPerformed(ActionEvent e) {
628 DefaultListModel<String> srcAPCs =
629 new DefaultListModel<String>();
630 JList<String> srcClsList =
new JList<String>(srcAPCs);
635 srcAPCs.addElement(apc.toString());
638 srcAPCs.addElement(
"<html><b><i>Define a new APClass...<i>"
640 if (srcClsList.getModel().getSize() == 1)
642 srcClsList.setSelectedIndex(0);
645 DefaultListModel<String> capAPCs =
646 new DefaultListModel<String>();
647 JList<String> capClsList =
new JList<String>(capAPCs);
650 capAPCs.addElement(apc.toString());
652 capAPCs.addElement(
"<html><b><i>Define a new APClass...<i>"
654 capClsList.setSelectionMode(
655 ListSelectionModel.SINGLE_SELECTION);
656 if (capClsList.getModel().getSize() == 1)
658 capClsList.setSelectedIndex(0);
661 JPanel twoListsPanel =
new JPanel();
662 JLabel headSrc =
new JLabel(
"APClass of APs to be capped:");
663 JLabel headCap =
new JLabel(
"APClass of capping group:");
664 JScrollPane scrollSrc =
new JScrollPane(srcClsList);
665 JScrollPane scrollCap =
new JScrollPane(capClsList);
666 GroupLayout lyoAddCapRule =
new GroupLayout(twoListsPanel);
667 twoListsPanel.setLayout(lyoAddCapRule);
668 lyoAddCapRule.setAutoCreateGaps(
true);
669 lyoAddCapRule.setAutoCreateContainerGaps(
true);
670 lyoAddCapRule.setHorizontalGroup(lyoAddCapRule.createSequentialGroup()
671 .addGroup(lyoAddCapRule.createParallelGroup()
672 .addComponent(headSrc)
673 .addComponent(scrollSrc))
674 .addGroup(lyoAddCapRule.createParallelGroup()
675 .addComponent(headCap)
676 .addComponent(scrollCap)));
677 lyoAddCapRule.setVerticalGroup(lyoAddCapRule.createSequentialGroup()
678 .addGroup(lyoAddCapRule.createParallelGroup()
679 .addComponent(headSrc)
680 .addComponent(headCap))
681 .addGroup(lyoAddCapRule.createParallelGroup()
682 .addComponent(scrollSrc)
683 .addComponent(scrollCap)));
688 JOptionPane.OK_CANCEL_OPTION,
689 JOptionPane.PLAIN_MESSAGE,
692 if (res != JOptionPane.OK_OPTION)
697 if (capClsList.getSelectedIndices().length > 0
698 && srcClsList.getSelectedIndices().length > 0)
701 Integer idc = capClsList.getSelectedIndices()[0];
703 if (idc.intValue() == (capAPCs.size()-1))
715 Object[] pair = (Object[]) chosen;
722 "<html>Class '<code>" + cappingAPClass
723 +
"</code>' is not new!</html>",
725 JOptionPane.WARNING_MESSAGE,
726 UIManager.getIcon(
"OptionPane.errorIcon"));
733 "<html>Error definging a new APClass.<br>"
734 +
"Please, report this to the DENOPTIM "
737 JOptionPane.WARNING_MESSAGE,
738 UIManager.getIcon(
"OptionPane.errorIcon"));
747 (String) capAPCs.getElementAt(idc));
751 e1.printStackTrace();
755 for (Integer
id : srcClsList.getSelectedIndices())
757 if (
id.intValue() == (srcAPCs.size()-1))
769 Object[] pair = (Object[]) chosen;
776 "<html>Class '<code>" + newAPC
777 +
"</code>' is not new!</html>",
779 JOptionPane.WARNING_MESSAGE,
780 UIManager.getIcon(
"OptionPane.errorIcon"));
798 (String) srcAPCs.getElementAt(
id));
802 e1.printStackTrace();
814 btnDelCapping.setToolTipText(String.format(
"<html><body width='%1s'>"
815 +
"Remove all the selected "
816 +
"lines in the list. Click on one or more lines to select "
817 +
"them. Multiple lines can be selected by holding the "
818 +
"appropriate key (e.g., <code>shift</code>, "
819 +
"<code>alt</code>, <code>ctrl</code>, <code>cmd</code> "
820 +
"depending on your keyboard settings).</html>",250));
822 public void actionPerformed(ActionEvent e) {
828 Arrays.sort(selectedRowIds);
829 for (
int i=(selectedRowIds.length-1); i>-1; i--)
835 selectedRowIds[i], 0).toString());
839 e1.printStackTrace();
850 btnSortCapping.setToolTipText(
"Sorts according to alphabetic order.");
852 public void actionPerformed(ActionEvent e) {
860 public void actionPerformed(ActionEvent e) {
861 String txt =
"<html><body width='%1s'><p>Capping rules are "
862 +
"used to saturate free attachment points (APs) when "
863 +
"finalizing the construction of a graph. Since APs "
864 +
"are often (but not always) the representation of "
865 +
"open valences, the capping procedure serves to "
866 +
"saturate all open valences according to AP's "
867 +
"compatibility. This procedure follows the capping "
868 +
"rules defined in this table.</p>"
871 +
"rule (i.e., each line in this table) identifies "
872 +
"the combination of two attachment point classes "
875 +
"<li>APCLass of the attachment points to be "
876 +
"capped (first column).</li>"
877 +
"<li>APClass of the capping group used to "
878 +
"saturate APs above attachment points.</li>"
880 +
"<p>You can select multiple entries as intervals or "
881 +
"by multiple clicks while holding the appropriate "
882 +
"key (e.g., <code>shift</code>, <code>alt</code>, "
883 +
"<code>ctrl</code>, "
884 +
"<code>cmd</code> depending on your keyboard "
885 +
"settings).</p></html>";
887 String.format(txt, 400),
889 JOptionPane.PLAIN_MESSAGE);
893 JPanel panelBtnCapping =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
900 JScrollPane panelCappingTable =
new JScrollPane(
tableCapping);
901 panelCapping.add(panelCappingTable, BorderLayout.CENTER);
909 String toolTipFrbEnd = String.format(
"<html><body width='%1s'>Graphs "
911 +
"(i.e., unsaturated) attachment point with these "
912 +
"APClasses are considered incomplete and are not "
913 +
"submitted to fitness evaluation.</html>",300);
917 public boolean isCellEditable(
int row,
int column) {
922 String column_name_cap[]= {
"<html><b>APClasses defining the forbidden "
923 +
"ends:</b></html>"};
929 btnAddFrbEnd.setToolTipText(
"Define a new forbidden end and add it to "
932 public void actionPerformed(ActionEvent e) {
933 DefaultListModel<String> claLstModel =
934 new DefaultListModel<String>();
935 JList<String> clsList =
new JList<String>(claLstModel);
940 claLstModel.addElement(apc.toString());
943 claLstModel.addElement(
"<html><b><i>Define a new APClass..."
946 if (clsList.getModel().getSize() == 1)
948 clsList.setSelectedIndex(0);
952 new JScrollPane(clsList),
954 JOptionPane.OK_CANCEL_OPTION,
955 JOptionPane.PLAIN_MESSAGE,
958 if (res != JOptionPane.OK_OPTION)
963 for (Integer
id : clsList.getSelectedIndices())
965 if (
id.intValue() == (claLstModel.size()-1))
977 Object[] pair = (Object[]) chosen;
984 "<html>Class '<code>" + newAPC
985 +
"</code>' is not new!</html>",
987 JOptionPane.WARNING_MESSAGE,
988 UIManager.getIcon(
"OptionPane.errorIcon"));
1005 (String) claLstModel.getElementAt(
id));
1009 e1.printStackTrace();
1019 btnDelFrbEnd.setToolTipText(String.format(
"<html><body width='%1s'>"
1020 +
"Remove all the selected "
1021 +
"lines in the list. Click on one or more lines to select "
1022 +
"them. Multiple lines can be selected by holding the "
1023 +
"appropriate key (e.g., <code>shift</code>, "
1024 +
"<code>alt</code>, <code>ctrl</code>, <code>cmd</code> "
1025 +
"depending on your keyboard settings).</html>",250));
1027 public void actionPerformed(ActionEvent e) {
1032 int selectedRowIds[] =
tableFrbEnd.getSelectedRows();
1033 Arrays.sort(selectedRowIds);
1034 for (
int i=(selectedRowIds.length-1); i>-1; i--)
1037 selectedRowIds[i], 0));
1046 btnSortFrbEnd.setToolTipText(
"Sorts according to alphabetic order.");
1048 public void actionPerformed(ActionEvent e) {
1056 public void actionPerformed(ActionEvent e) {
1057 String txt =
"<html><body width='%1s'><p>Use these buttons to "
1058 +
"add/remove attachment point classes (APClasses) "
1059 +
"that define <i>forbidden ends</i>, i.e., "
1060 +
"attachment point that cannot be left free in a "
1061 +
"finished graph. Graphs holding free (i.e., "
1062 +
"unsaturated) attachment point with any of these "
1063 +
"APClasses are considered incomplete and are not "
1064 +
"submitted to fitness evaluation.</p><br>"
1065 +
"<p>You can select multiple entries as intervals or "
1066 +
"by multiple clicks while holding the appropriate "
1067 +
"key (e.g., <code>shift</code>, <code>alt</code>, "
1068 +
"<code>ctrl</code>, "
1069 +
"<code>cmd</code> depending on your keyboard "
1070 +
"settings).</p></html>";
1072 String.format(txt, 400),
1074 JOptionPane.PLAIN_MESSAGE);
1078 JPanel panelBtnFrbEnd =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
1083 panelFrbEnd.add(panelBtnFrbEnd, BorderLayout.NORTH);
1085 JScrollPane panelFrbEndTable =
new JScrollPane(
tableFrbEnd);
1086 panelFrbEnd.add(panelFrbEndTable, BorderLayout.CENTER);
1094 for (Component lineComponent :
panelCPRules.getComponents())
1110 if (query.equals(
""))
1116 for (Component lineComponent :
panelCPRules.getComponents())
1142 compatMap =
new HashMap<APClass,ArrayList<APClass>>();
1152 JOptionPane.showMessageDialog(parent,
1153 "<html>Could not read compatibility matrix data from "
1154 +
"file<br>'" + inFile +
"': " + e.getMessage() +
"</html>",
1156 JOptionPane.WARNING_MESSAGE,
1157 UIManager.getIcon(
"OptionPane.errorIcon"));
1189 JOptionPane.showMessageDialog(parent,
1190 "<html>Could not write compatibility matrix data to "
1191 +
"file<br>'" + outFile +
"'</html>",
1193 JOptionPane.WARNING_MESSAGE,
1194 UIManager.getIcon(
"OptionPane.errorIcon"));
1208 h.setAlignmentX(LEFT_ALIGNMENT);
1213 r.setAlignmentX(LEFT_ALIGNMENT);
1226 for (
int i=0; i<szTab; i++)
1233 ArrayList<APClass> sortedCappings =
new ArrayList<APClass>();
1235 Collections.sort(sortedCappings);
1238 for (
APClass apc : sortedCappings)
1241 new Object[]{apc.toString(),
cappingMap.get(apc)});
1251 for (
int i=0; i<szTab; i++)
1258 ArrayList<APClass> sortedFrbEnds =
new ArrayList<APClass>();
1260 Collections.sort(sortedFrbEnds);
1263 for (
APClass apc : sortedFrbEnds)
1287 for (ArrayList<APClass> apcs :
compatMap.values())
1333 this.setCursor(Cursor.getPredefinedCursor(
1334 Cursor.WAIT_CURSOR));
1340 for (File fragLib : fragLibs)
1350 this.setCursor(Cursor.getPredefinedCursor(
1351 Cursor.DEFAULT_CURSOR));
1366 this.setCursor(Cursor.getPredefinedCursor(
1367 Cursor.WAIT_CURSOR));
1374 for (File fragLib : fragLibs)
1384 this.setCursor(Cursor.getPredefinedCursor(
1385 Cursor.DEFAULT_CURSOR));
1416 UIManager.getLookAndFeelDefaults().getColor(
"Panel.background");
1426 this.setLayout(
new BorderLayout());
1435 srcClassName.setFont(UIManager.getLookAndFeelDefaults()
1436 .getFont(
"Label.font"));
1440 JScrollPane.VERTICAL_SCROLLBAR_NEVER,
1441 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
1443 new Dimension(0,5));
1454 trg.addPropertyChangeListener(
1455 new PropertyChangeListenerProxy(
1460 JScrollPane.VERTICAL_SCROLLBAR_NEVER,
1461 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
1463 new Dimension(0,5));
1467 btnAdd =
new JButton(
"Add");
1468 btnAdd.setToolTipText(String.format(
"<html><body width='%1s'>"
1469 +
"Add more compatible APClasses to source class <i>"
1471 btnAdd.addActionListener(
new ActionListener() {
1472 public void actionPerformed(ActionEvent e) {
1473 DefaultListModel<String> trgAPCs =
1474 new DefaultListModel<String>();
1475 JList<String> trgClsList =
new JList<String>(trgAPCs);
1478 trgAPCs.addElement(apc.toString());
1480 trgAPCs.addElement(
"<html><b><i>Define a new APClass...<i>"
1482 trgClsList.setSelectionMode(
1483 ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
1485 JScrollPane scrollTrg =
new JScrollPane(trgClsList);
1487 JOptionPane.showMessageDialog(
1490 "Choose Compatible APClasses",
1491 JOptionPane.PLAIN_MESSAGE);
1493 if (trgClsList.getSelectedIndices().length > 0)
1495 ArrayList<APClass> trgCPClasses =
1496 new ArrayList<APClass>();
1497 for (Integer
id : trgClsList.getSelectedIndices())
1499 if (
id.intValue() == (trgAPCs.size()-1))
1511 Object[] pair = (Object[]) chosen;
1517 JOptionPane.showMessageDialog(
btnAdd,
1518 "<html>Class '<code>" + newAPC
1519 +
"</code>' is not new!</html>",
1521 JOptionPane.WARNING_MESSAGE,
1523 "OptionPane.errorIcon"));
1526 trgCPClasses.add(newAPC);
1538 (String) trgAPCs.getElementAt(
id)));
1542 e1.printStackTrace();
1551 this.add(
btnAdd, BorderLayout.EAST);
1553 this.setBorder(BorderFactory.createRaisedSoftBevelBorder());
1555 addMouseListener(
this);
1584 boolean found =
false;
1685 @SuppressWarnings(
"serial")
1688 private Dimension minSrcAPClassName =
new Dimension(200,26);
1689 public final Color DEFAULTBACKGROUND =
1690 UIManager.getLookAndFeelDefaults().getColor(
"Panel.background");
1694 this.setName(
"Header");
1695 this.setBackground(DEFAULTBACKGROUND);
1696 this.setLayout(
new BorderLayout());
1698 JLabel srcClassTitle =
new JLabel(
"<html>"
1699 +
"<div style='text-align: center;'>"
1700 +
"<b>Source APClass:</b></div></html>");
1701 srcClassTitle.setBackground(DEFAULTBACKGROUND);
1702 srcClassTitle.setPreferredSize(minSrcAPClassName);
1703 srcClassTitle.setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
1704 this.add(srcClassTitle, BorderLayout.WEST);
1706 JLabel trgClassTitle =
new JLabel(
"<html>"
1707 +
"<div style='text-align: center;'>"
1708 +
"<b>Compatible APClasses of incoming fragments:</b></div></html>");
1709 trgClassTitle.setBackground(DEFAULTBACKGROUND);
1710 trgClassTitle.setPreferredSize(minSrcAPClassName);
1711 trgClassTitle.setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
1713 this.add(trgClassTitle, BorderLayout.CENTER);
1715 this.setBorder(BorderFactory.createRaisedSoftBevelBorder());
1721 @SuppressWarnings(
"serial")
1728 private final Color BTNPRESS = Color.decode(
"#fbae9d");
1729 private final Color BTNDEF = Color.decode(
"#f74922");
1731 private final Color SELECTEDBACKGROUND = Color.BLUE;
1732 private final Color DEFAULTBACKGROUND =
1733 UIManager.getLookAndFeelDefaults().getColor(
"Panel.background");
1737 this.setLayout(
new BoxLayout(
this, BoxLayout.X_AXIS));
1738 this.trgAPClass = trgAPClass;
1739 trgAPClLabel =
new JTextField(trgAPClass.
toString());
1740 trgAPClLabel.setBorder(
null);
1741 trgAPClLabel.setOpaque(
false);
1742 trgAPClLabel.setEditable(
false);
1743 trgAPClLabel.setForeground(Color.BLACK);
1744 trgAPClLabel.setFont(UIManager.getLookAndFeelDefaults()
1745 .getFont(
"Label.font"));
1746 this.add(trgAPClLabel);
1747 btnDel =
new JButton(
"X");
1748 btnDel.setMaximumSize(
new Dimension(15,15));
1749 btnDel.setBackground(BTNDEF);
1750 btnDel.setOpaque(
true);
1751 btnDel.setBorderPainted(
true);
1752 btnDel.setBorder(BorderFactory.createRaisedSoftBevelBorder());
1753 btnDel.setForeground(Color.BLACK);
1754 btnDel.setToolTipText(
"<html>Remove <code>" + trgAPClass
1755 +
"</code></html>");
1756 btnDel.addMouseListener(
new MouseListener() {
1759 public void mouseReleased(MouseEvent e)
1766 public void mousePressed(MouseEvent e)
1768 btnDel.setBackground(BTNPRESS);
1772 public void mouseExited(MouseEvent e)
1774 btnDel.setBackground(BTNDEF);
1778 public void mouseEntered(MouseEvent e) {}
1781 public void mouseClicked(MouseEvent e) {}
1784 this.add(Box.createRigidArea(
new Dimension(15,15)));
1791 return trgAPClass.
toString().matches(regex);
1800 super.setBackground(SELECTEDBACKGROUND);
1801 trgAPClLabel.setForeground(Color.WHITE);
1805 super.setBackground(DEFAULTBACKGROUND);
1806 trgAPClLabel.setForeground(Color.BLACK);
String toString()
Do not use this to make SDF representations.
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
Object showDialog()
Shows the dialog and restrains the modality to it, until the dialog gets closed.
Utility methods for input/output.
static void readCompatibilityMatrix(String fileName, HashMap< APClass, ArrayList< APClass > > compatMap, HashMap< APClass, APClass > cappingMap, Set< APClass > forbiddenEndList)
Read the APclass compatibility matrix data from file.
static Set< APClass > readAllAPClasses(File fragLib)
static void writeCompatibilityMatrix(String fileName, HashMap< APClass, ArrayList< APClass > > cpMap, HashMap< APClass, APClass > capMap, HashSet< APClass > ends)
The class compatibility matrix.
Possible chemical bond types an edge can represent.