23import java.awt.Cursor;
24import java.awt.Dimension;
25import java.awt.event.ActionEvent;
26import java.awt.event.ActionListener;
27import java.awt.event.MouseEvent;
28import java.awt.event.MouseListener;
30import java.util.HashSet;
32import java.util.Map.Entry;
34import java.util.TreeMap;
35import java.util.TreeSet;
37import javax.swing.JCheckBoxMenuItem;
38import javax.swing.JOptionPane;
39import javax.swing.JPopupMenu;
40import javax.swing.JScrollPane;
41import javax.swing.JSplitPane;
42import javax.swing.JTable;
43import javax.swing.UIManager;
44import javax.swing.table.DefaultTableModel;
45import javax.swing.table.JTableHeader;
47import org.openscience.cdk.CDKConstants;
48import org.openscience.cdk.interfaces.IAtomContainer;
50import denoptim.constants.DENOPTIMConstants;
51import denoptim.exception.DENOPTIMException;
52import denoptim.graph.Candidate;
53import denoptim.io.DenoptimIO;
88 private final String
NL = System.getProperty(
"line.separator");
114 @SuppressWarnings(
"serial")
117 this.setOrientation(JSplitPane.VERTICAL_SPLIT);
118 this.setOneTouchExpandable(
true);
119 this.setDividerLocation(dividerPosition);
128 public boolean isCellEditable(
int row,
int column) {
133 String column_names[]= {
"<html><b>Property</b></html>",
134 "<html><b>Value</b></html>"};
137 dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
138 dataTable.getColumnModel().getColumn(0).setMaxWidth(75);
139 dataTable.getColumnModel().getColumn(1).setMinWidth(750);
140 dataTable.setGridColor(Color.LIGHT_GRAY);
141 dataTable.addMouseListener(
new MouseListener() {
143 public void mouseReleased(MouseEvent e) {
147 public void mousePressed(MouseEvent e) {
150 public void mouseExited(MouseEvent e) {}
151 public void mouseEntered(MouseEvent e) {}
153 public void mouseClicked(MouseEvent e) {
157 JTableHeader dataTabHeader =
dataTable.getTableHeader();
158 dataTabHeader.setPreferredSize(
new Dimension(100, 20));
159 dataTabHeader.addMouseListener(
new MouseListener() {
161 public void mouseReleased(MouseEvent e) {
165 public void mousePressed(MouseEvent e) {
168 public void mouseExited(MouseEvent e) {}
169 public void mouseEntered(MouseEvent e) {}
171 public void mouseClicked(MouseEvent e) {
176 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
177 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
189 if (!e.isPopupTrigger() ||
item ==
null)
196 TreeMap<String,String> availableProps =
new TreeMap<String,String>();
200 }
catch (Exception e1) {
203 for (Object propRef : mol.getProperties().keySet())
205 String key = propRef.toString();
211 availableProps.put(key,val);
215 for (Entry<String, String> entry : availableProps.entrySet())
217 JCheckBoxMenuItem mi =
new JCheckBoxMenuItem(entry.getValue());
220 mi.setSelected(
true);
222 mi.setSelected(
false);
224 mi.addActionListener(
new ActionListener() {
225 public void actionPerformed(ActionEvent e) {
238 if (!mi.isSelected())
240 mi.setSelected(
false);
243 mi.setSelected(
true);
276 System.out.println(
"Could not write molecular representation to "
277 +
"tmp file. Thus, could not load it into Jmol viewer.");
292 File file =
new File(pathName);
316 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
323 JOptionPane.showMessageDialog(
this,
324 "<html>Could not load data from file <br>'" + file +
"'.",
326 JOptionPane.PLAIN_MESSAGE,
327 UIManager.getIcon(
"OptionPane.errorIcon"));
328 this.setCursor(Cursor.getPredefinedCursor(
329 Cursor.DEFAULT_CURSOR));
340 file).get(0),
false,
true);
341 }
catch (Exception e1) {
346 }
catch (Exception e2) {
347 e1.printStackTrace();
348 this.setCursor(Cursor.getPredefinedCursor(
349 Cursor.DEFAULT_CURSOR));
364 }
catch (InterruptedException e)
373 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
384 IAtomContainer mol =
null;
389 }
catch (Exception e) {
390 System.out.println(
"Could not read descriptors from '"
391 + molFile +
"': "+e.getLocalizedMessage());
407 Set<String> fromDnMol =
new HashSet<String>();
408 fromDnMol.add(CDKConstants.TITLE);
412 fromDnMol.add(
"Generation");
418 if (
item.
getName() !=
null && chosen.contains(CDKConstants.TITLE))
421 defPropMap.get(CDKConstants.TITLE),
451 defPropMap.get(
"Generation"),
466 Object p = mol.getProperty(key);
467 if (p ==
null || fromDnMol.contains(key))
499 for (
int i=0; i<initRowCount; i++)
526 StringBuilder sb =
new StringBuilder();
527 sb.append(
"select none").append(
NL);
528 sb.append(
"SelectionHalos ON").append(
NL);
529 sb.append(
"set picking ATOMS").append(
NL);
General set of constants used in DENOPTIM.
static final String PROVENANCE
SDF tag containing provenance data for a graph.
static final String UNIQUEIDTAG
SDF tag containing the unique identifier of a candidate.
static final String MOLERRORTAG
SDF tag containing errors during execution of molecule specific tasks.
static final String FITNESSTAG
SDF tag containing the fitness of a candidate.
A candidate is the combination of a denoptim graph with molecular representation and may include also...
boolean hasFitness
Flag signaling the presence of a fitness value associated.
static Candidate fromAtomContainerNoGraph(IAtomContainer iac, boolean allowNoUID)
Wraps an atom container as a candidate even if a graph is not available.
int getGeneration()
The generation this candidate belong to is that in which it was generated.
The collection of tunable preferences.
static TreeSet< String > chosenSDFTags
MolecularViewer: list of SDF tags specifying which properties to display.
static Map< String, String > defualtSDFTags
MolecularViewer: default list of SDF tags with corresponding string to display instead of tag.
A panel with a molecular viewer and data table.
void cleardataTable()
Clears the table of attachment points.
void clearMolecularViewer(boolean dataIsComing)
Clears the molecular viewer.
void enablePartialData(boolean enable)
Sets the behavior in case of request to visualize partial data.
void initialize(int dividerPosition)
MoleculeViewPanel()
Constructor.
void clearAll(boolean dataIsComing)
Removes the currently visualized molecule and AP table.
Candidate item
The currently loaded item.
void loadChemicalStructureFromFile(File file)
Loads a structure in the Jmol viewer.
void loadChemicalStructure(IAtomContainer mol)
Loads a structure in the Jmol viewer.
void fillDataTable(File molFile)
static final long serialVersionUID
Version UID.
void loadChemicalStructureFromFile(String pathName)
Loads a structure in the Jmol viewer.
boolean toleratePartialData
Flag controlling behavior in case of partial data (e.r., lack of fitness/error)
MoleculeViewPanel(int dividerPosition)
Constructor that allows to specify whether the data table is editable or not.
void fillDataTable(IAtomContainer mol)
JPopupMenu dataTabPopMenu
DefaultTableModel dataTabModel
void showPopup(MouseEvent e)
static String getTempFile(String tmpFileName)
Returns the pathname to a tmp file.
Utility methods for input/output.
static ArrayList< Candidate > readCandidates(File file)
Reads SDF files that represent one or more tested candidates.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
static List< IAtomContainer > readAllAtomContainers(File file)
Returns a single collection with all atom containers found in a file of any format.