User 704eeef1ba
05-09-2013 17:21:55
I tried to print one RxnMolecule and it worked fine.But when it comes to many RxnMolecules(reactions) how can i print it in the MSketchPane(at once).
MSketchPane p = new MSketchPane();
RxnMolecule mol = new RxnMolecule();
Molecule reactant1 = MolImporter.importMol("CC(=C)C");
Molecule product = MolImporter.importMol("C(Cl)(C)(C)C");
mol.addComponent(reactant1, RxnMolecule.REACTANTS);
mol.addComponent(product, RxnMolecule.PRODUCTS);
mol.setReactionArrowType(RxnMolecule.REGULAR_SINGLE);
p.setMol(MolExporter.exportToFormat(mol, "mol"));
ChemAxon 2c555f5717
06-09-2013 14:38:04
Dear Emma!
Marvin Sketch can only handle one reactions at the same time. You can build a multiple reaction visualiser like this with MViewPane:
public static void main(String[] args) throws IOException {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
for(int i=3; i<8; ++i) {
MViewPane mvp = new MViewPane();
Molecule reaction = buildMadeUpReaction(i);
mvp.setM(0, reaction); //Always set it to 0
mvp.setPreferredSize(new Dimension(300, 100));
mvp.setEditable(2); //This is for the double-click editing feature
panel.add(mvp);
}
JScrollPane jsp = new JScrollPane(panel);
jsp.setPreferredSize(new Dimension(400, 200));
frame.add(jsp);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
I have attached the full source. I hope it can help you.
Regards:
Balázs
User 704eeef1ba
07-09-2013 08:02:08
tnx alot for the quick response. I will try this out.