Hi,

When I draw the single oxygen in the JChemPaint Applet
(http://www.ebi.ac.uk/steinbeck-srv/jchempaint-nightly/EditorApplet.html),
it automatically adds the implicit "H2". I would like to do this as
well, but could not find a way to accomplish that. I only get a single
"O". Do I need to set a parameter for one of the generators or
something like this? Any help would be appreciated.

Thanks,
Martin



String smiles = "O";
SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
mol = m_parser.parseSmiles(smiles);
StructureDiagramGenerator sdg = new StructureDiagramGenerator(mol);
sdg.generateCoordinates();
mol = sdg.getMolecule();

int height = 150;
int width = 150;

java.awt.Rectangle drawArea = new java.awt.Rectangle(width, height);
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);

List<IGenerator<IAtomContainer>> generators = new
ArrayList<IGenerator<IAtomContainer>>();
generators.add(new BasicSceneGenerator());
generators.add(new BasicBondGenerator());
generators.add(new RingGenerator());
generators.add(new BasicAtomGenerator());
// the renderer needs to have a toolkit-specific font manager
AtomContainerRenderer renderer = new AtomContainerRenderer(generators,
new AWTFontManager());

// the call to 'setup' only needs to be done on the first paint
renderer.setup(mol, drawArea);
java.awt.Rectangle rect = renderer.calculateDiagramBounds(mol);
renderer.setZoomToFit(width, height, rect.width, rect.height);
// paint the background
Graphics2D g2 = (Graphics2D) image.getGraphics();
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, width, height);
// the paint method also needs a toolkit-specific renderer
renderer.paint(mol, new AWTDrawVisitor(g2));

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to