Search in sources :

Example 1 with JChemPaintPanel

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();
}
Also used : JPanel(javax.swing.JPanel) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.silent.AtomContainer) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) JChemPaintPanel(org.openscience.jchempaint.JChemPaintPanel) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension)

Example 2 with JChemPaintPanel

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);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) QueryAtomContainer(org.openscience.cdk.isomorphism.matchers.QueryAtomContainer) AtomContainer(org.openscience.cdk.silent.AtomContainer) JChemPaintPanel(org.openscience.jchempaint.JChemPaintPanel) Dimension(java.awt.Dimension) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Aggregations

Dimension (java.awt.Dimension)2 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)2 AtomContainer (org.openscience.cdk.silent.AtomContainer)2 JChemPaintPanel (org.openscience.jchempaint.JChemPaintPanel)2 BorderLayout (java.awt.BorderLayout)1 Container (java.awt.Container)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JDialog (javax.swing.JDialog)1 JOptionPane (javax.swing.JOptionPane)1 JPanel (javax.swing.JPanel)1 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)1