$darkmode
DENOPTIM
MolToGraphParametersDialog.java
Go to the documentation of this file.
1package denoptim.gui;
2
3import java.awt.Component;
4import java.awt.FlowLayout;
5import java.awt.event.ActionEvent;
6import java.awt.event.ActionListener;
7import java.util.List;
8
9import javax.swing.JComboBox;
10import javax.swing.JLabel;
11import javax.swing.JPanel;
12import javax.swing.JRadioButton;
13import javax.swing.JSeparator;
14import javax.swing.JTextField;
15
16import denoptim.fragmenter.ScaffoldingPolicy;
17import denoptim.graph.Template.ContractLevel;
18import denoptim.graph.Vertex.BBType;
19import denoptim.programs.fragmenter.CuttingRule;
20import denoptim.programs.fragmenter.FragmenterParameters;
21
23{
24
28 private static final long serialVersionUID = 1L;
29
30 private JPanel lineEmbTmpl;
31 private JRadioButton rdbEmbTmpl;
32
33 private JPanel lineScaffoldingPolicy;
34 private JLabel lblScaffoldingPolicy;
35 private JComboBox<String> cmbScaffoldingPolicy;
36 private JTextField txtScaffoldingPolicy;
37
38 private JPanel lineTemplateContract;
39 private JLabel lblTemplateContract;
40 private JComboBox<String> cmbTemplateContract;
41
42//------------------------------------------------------------------------------
43
44 public MolToGraphParametersDialog(List<CuttingRule> defaultCuttingRules,
45 List<CuttingRule> customCuttingRules, boolean preselectDefault,
46 Component refForPlacement, FragmenterParameters settings)
47 {
48 super(defaultCuttingRules, customCuttingRules, preselectDefault,
49 refForPlacement, settings);
50
51 setTitle("Settings for Converting Molecules to Graphs");
52
53 appendToCentralPanel(new JSeparator());
54
55 String toolTipScaffoldingPolicy = String.format("<html><body width='%1s'>"
56 + "Defines the policy used to choose a vertex and make it be "
57 + "the scaffold of the graph obtained by converting a "
58 + "molecule.</html>", 400);
59 lineScaffoldingPolicy = new JPanel(new FlowLayout(FlowLayout.LEFT));
60 lblScaffoldingPolicy = new JLabel("Policy to identify the "
61 + BBType.SCAFFOLD.toString().toLowerCase()
62 + " vertex: ");
63 lblScaffoldingPolicy.setToolTipText(toolTipScaffoldingPolicy);
64 ScaffoldingPolicy[] policies = ScaffoldingPolicy.values();
65 String[] stringArr = new String[policies.length];
66 for (int i=0;i<policies.length;i++)
67 stringArr[i]=policies[i].toString();
68 cmbScaffoldingPolicy = new JComboBox<String>(stringArr);
69 cmbScaffoldingPolicy.setToolTipText(toolTipScaffoldingPolicy);
71 cmbScaffoldingPolicy.addActionListener(new ActionListener() {
72 @Override
73 public void actionPerformed(ActionEvent e)
74 {
75 if (cmbScaffoldingPolicy.getSelectedItem().toString().equals(
76 ScaffoldingPolicy.ELEMENT.toString()))
77 {
78 txtScaffoldingPolicy.setEnabled(true);
79 txtScaffoldingPolicy.setEditable(true);
80 } else {
81 txtScaffoldingPolicy.setEnabled(false);
82 txtScaffoldingPolicy.setEditable(false);
83 }
84 }
85 });
86 txtScaffoldingPolicy = new JTextField("Specify label here...");
87 txtScaffoldingPolicy.setPreferredSize(strFieldSize);
88 txtScaffoldingPolicy.setToolTipText(String.format(
89 "<html><body width='%1s'>"
90 + "Use this field to provide any additional string that is "
91 + "needed to characterized some type of policy.</html>", 400));
92 txtScaffoldingPolicy.setEnabled(false);
93 txtScaffoldingPolicy.setEditable(false);
94 lineScaffoldingPolicy.setToolTipText(toolTipScaffoldingPolicy);
99
100 String toolTipEmbTmpl = String.format("<html><body width='%1s'>"
101 + "Require converting ggubstrags that define ring systems into "
102 + "Templates that embed the subgraph of an entire ring syste. "
103 + "Ring systems that are separated by at least one acyclic "
104 + "edge are mbedded into separate Templates.</html>", 400);
105 lineEmbTmpl = new JPanel(new FlowLayout(FlowLayout.LEFT));
106 rdbEmbTmpl = new JRadioButton("Embed rings into Templates");
107 rdbEmbTmpl.setToolTipText(toolTipEmbTmpl);
108 rdbEmbTmpl.addActionListener(new ActionListener() {
109 @Override
110 public void actionPerformed(ActionEvent e)
111 {
112 if (rdbEmbTmpl.isSelected())
113 cmbTemplateContract.setEnabled(true);
114 else
115 cmbTemplateContract.setEnabled(false);
116 }
117 });
118 lineEmbTmpl.setToolTipText(toolTipEmbTmpl);
121
122 String toolTipTemplateContract = String.format("<html><body width='%1s'>"
123 + "Defines the constraints of the templates used to embed ring"
124 + "systems. </html>", 400);
125 lineTemplateContract = new JPanel(new FlowLayout(FlowLayout.LEFT));
126 lblTemplateContract = new JLabel(
127 "Contract for ring-embedding Templates: ");
128 lblTemplateContract.setToolTipText(toolTipTemplateContract);
129 ContractLevel[] contracts = ContractLevel.values();
130 String[] stringContracts = new String[contracts.length];
131 for (int i=0;i<contracts.length;i++)
132 stringContracts[i]=contracts[i].toString();
133 cmbTemplateContract = new JComboBox<String>(stringContracts);
134 cmbTemplateContract.setSelectedItem(ContractLevel.FREE);
135 cmbTemplateContract.setToolTipText(toolTipTemplateContract);
136 cmbTemplateContract.setEnabled(false);
137 lineTemplateContract.setToolTipText(toolTipTemplateContract);
141 }
142
143//-----------------------------------------------------------------------------
144
145 @Override
146 protected void saveResults()
147 {
148 super.saveResults();
152 }
153
154//------------------------------------------------------------------------------
155
156 public boolean getEmbedRingsInTemplate()
157 {
158 return rdbEmbTmpl.isSelected();
159 }
160
161//------------------------------------------------------------------------------
162
164 {
166 cmbScaffoldingPolicy.getSelectedItem().toString());
167 sp.label = txtScaffoldingPolicy.getText();
168 return sp;
169 }
170
171//------------------------------------------------------------------------------
172
174 {
175 return ContractLevel.valueOf(
176 cmbTemplateContract.getSelectedItem().toString());
177 }
178
179//------------------------------------------------------------------------------
180
181}
A modal dialog to define parameters for fragmentation and fragment filtering.
FragmenterParameters frgParams
Parameter storage were we store parameters.
void appendToCentralPanel(JComponent panel)
Method to append a panel to the bottom of the central panel.
final Dimension strFieldSize
Default sizes for mid-long text.
MolToGraphParametersDialog(List< CuttingRule > defaultCuttingRules, List< CuttingRule > customCuttingRules, boolean preselectDefault, Component refForPlacement, FragmenterParameters settings)
Parameters controlling execution of the fragmenter.
void setEmbeddedRingsContract(ContractLevel embeddedRingsContract)
void setEmbedRingsInTemplate(boolean embedRingsInTemplate)
Defines how to define the scaffold vertex of a graph.
Enum specifying to what extent the template's inner graph can be changed.
Definition: Template.java:104
FREE
Inner graphs are free to change within the confines of the required AttachmentPoints.
Definition: Template.java:109
The type of building block.
Definition: Vertex.java:86