User 76d45de7d2
08-07-2008 20:09:01
I changed the smiles string in the sample code to this:
OC1C(O)C(O)C(O[P](O)(=O)OCC(COC([H])=O)OC([C3H7])=O)C(O)C1O
It can be correctly displayed in PubMed (http://pubchem.ncbi.nlm.nih.gov/edit/index.html), but cannot be displayed properly using MolPrinter. See the attahcment for my screen shot.
Any one can help me with this?
import chemaxon.marvin.MolPrinter;
import chemaxon.struc.Molecule;
import chemaxon.formats.MolImporter;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class MolPrinterTest {
static BufferedImage createTestImage() throws IOException {
// Create a molecule
Molecule mol = MolImporter.importMol("CN1C=NC2=C1C(=O)N(C)C(=O)N2C");
// Create a writable image
BufferedImage im = new BufferedImage(400, 400,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = im.createGraphics();
// Clear background
g.setColor(Color.white);
g.fillRect(0, 0, im.getWidth(), im.getHeight());
// Draw the bounding rectangle
g.setColor(Color.red);
Rectangle r = new Rectangle(20, 20, 360, 200);
g.draw(r);
// Paint the molecule
MolPrinter p = new MolPrinter(mol);
p.setScale(p.maxScale(r)); // fit image in the rectangle
p.paint(g, r);
return im;
}
public static void main(String[] args) throws Exception {
BufferedImage im = createTestImage();
ImageIO.write(im, "png", new File("test.png"));
}
}
OC1C(O)C(O)C(O[P](O)(=O)OCC(COC([H])=O)OC([C3H7])=O)C(O)C1O
It can be correctly displayed in PubMed (http://pubchem.ncbi.nlm.nih.gov/edit/index.html), but cannot be displayed properly using MolPrinter. See the attahcment for my screen shot.
Any one can help me with this?
import chemaxon.marvin.MolPrinter;
import chemaxon.struc.Molecule;
import chemaxon.formats.MolImporter;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class MolPrinterTest {
static BufferedImage createTestImage() throws IOException {
// Create a molecule
Molecule mol = MolImporter.importMol("CN1C=NC2=C1C(=O)N(C)C(=O)N2C");
// Create a writable image
BufferedImage im = new BufferedImage(400, 400,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = im.createGraphics();
// Clear background
g.setColor(Color.white);
g.fillRect(0, 0, im.getWidth(), im.getHeight());
// Draw the bounding rectangle
g.setColor(Color.red);
Rectangle r = new Rectangle(20, 20, 360, 200);
g.draw(r);
// Paint the molecule
MolPrinter p = new MolPrinter(mol);
p.setScale(p.maxScale(r)); // fit image in the rectangle
p.paint(g, r);
return im;
}
public static void main(String[] args) throws Exception {
BufferedImage im = createTestImage();
ImageIO.write(im, "png", new File("test.png"));
}
}