use of org.openscience.jchempaint.JChemPaintPanel in project ambit-mirror by ideaconsult.
the class JChemPaintDialog method addWidgets.
// protected void addWidgets(JChemPaintModel jcpm,DataModule toxdata) {
protected void addWidgets(IChemModel jcpm) {
// this.data = toxdata;
// setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
// jcpep = new JChemPaintPanel(jcpm, JChemPaint.GUI_APPLICATION,
// false,null);
jcpep = new JChemPaintPanel(jcpm);
// show aromatic ring circles
jcpep.getRenderPanel().getRenderer().getRenderer2DModel().setShowAromaticity(true);
// new JChemPaintPanel(jcpm,JChemPaint.GUI_APPLICATION,true,null);
Dimension dcp = new Dimension(400, 400);
jcpep.setPreferredSize(dcp);
// jcpep.setEmbedded();
// jcpep.registerModel(jcpm);
// jcpep.setJChemPaintModel(jcpm,dcp);
getContentPane().add(jcpep);
// setTitle(jcpm.getTitle());
JButton cancelButton = new JButton("Cancel");
JButton okButton = new JButton("OK");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelAction();
}
});
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okAction();
}
});
getRootPane().setDefaultButton(okButton);
// Lay out the buttons from left to right.
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(okButton);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(cancelButton);
Dimension d = new Dimension(400, 48);
buttonPane.setPreferredSize(d);
buttonPane.setMinimumSize(d);
// Put everything together, using the content pane's BorderLayout.
Container contentPane = getContentPane();
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setMinimumSize(new Dimension(400, 200));
panel.add(buttonPane, BorderLayout.SOUTH);
panel.add(jcpep, BorderLayout.CENTER);
contentPane.add(panel);
pack();
}
use of org.openscience.jchempaint.JChemPaintPanel in project ambit-mirror by ideaconsult.
the class MoleculeEditAction method actionPerformed.
public void actionPerformed(ActionEvent arg0) {
if (modal) {
if (molecules != null) {
jcpModel.setMoleculeSet(molecules);
// JChemPaintPanel jcpep = new JChemPaintPanel(jcpModel,
// JChemPaint.GUI_APPLICATION, false,null);
JChemPaintPanel jcpep = new JChemPaintPanel(jcpModel);
Dimension d = new Dimension(500, 500);
jcpep.setPreferredSize(d);
// jcpep.registerModel(jcpModel);
// jcpep.setJChemPaintModel(jcpModel,d);
JOptionPane pane = new JOptionPane(jcpep, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
JDialog dialog = pane.createDialog(parentComponent, "Edit rule");
dialog.setBounds(200, 200, 600, 600);
dialog.setVisible(true);
if (pane.getValue() == null)
return;
int value = ((Integer) pane.getValue()).intValue();
if (value == 0) {
// ok
molecules = jcpep.getChemModel().getMoleculeSet();
if (molecule == null)
molecule = new AtomContainer();
else
molecule.removeAllElements();
for (int i = 0; i < molecules.getAtomContainerCount(); i++) molecule.add(molecules.getAtomContainer(i));
updateMolecule(molecule);
return;
}
}
} else
editMolecule(true, parentComponent);
}
Aggregations