Skip to content

Instantly share code, notes, and snippets.

@johnmay
Last active May 15, 2016 20:57
Show Gist options
  • Select an option

  • Save johnmay/959448e556e8aef3c465565d01274938 to your computer and use it in GitHub Desktop.

Select an option

Save johnmay/959448e556e8aef3c465565d01274938 to your computer and use it in GitHub Desktop.
StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule(mol, false);
sdg.generateCoordinates();
AtomContainerRenderer renderer =
new AtomContainerRenderer(Arrays.asList(new BasicSceneGenerator(),
new BasicBondGenerator(),
new ExtendedAtomGenerator()),
new AWTFontManager());
BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = img.createGraphics();
g2.setBackground(Color.WHITE);
g2.clearRect(0, 0, 256, 256);
IDrawVisitor visitor = new AWTDrawVisitor(g2);
Rectangle2D bounds = new Rectangle2D.Double(0, 0, 256, 256);
renderer.paint(mol, visitor, bounds, true);
g2.dispose();
ImageIO.write(img, "PNG", new File("myoutput.png"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment