Hit alignment coloring not visible in image files

User 93ffa33d02

29-03-2014 11:58:40

Hello, I am using your sample code for hit alignment coloring.


private void run() throws Exception {
Molecule query = MolImporter.importMol(QUERY);
Molecule target = MolImporter.importMol(TARGET);
Molecule display = getDisplayMol(query, target, getDisplayOptions());

DisplayUtil.showMolecule(query, 0, "Query");
DisplayUtil.showMolecule(target, 1, "Target");
DisplayUtil.showMolecule(display, 2, "Colored target");
}

In the opened JFrame there are visible nice coloring of red and green for the display molecule. 

The problem is that I cannot figure out how to transform display molecule into image (jpeg) file that would still contain red and green coloring.

If I use MolExporter methods exportToBinFormat or exportToObject, I get black and white image of the display molecule. Is there a way to get image with hit coloring?

            byte[] d4 = (byte[])MolExporter.exportToObject(display, "jpeg:w300,h300");
FileOutputStream fos = new FileOutputStream(path);
fos.write(d4);
fos.close();

ChemAxon 7936325a45

01-04-2014 16:20:21

Hi,

 You are almost done, just add setcolors parameter in export:


byte[] d4 = (byte[])MolExporter.exportToObject(display, "jpeg:w300,h300,setcolors");

I tested this solution with JChem 6.2, but this should work with older releases as well.

Regards,
István Őri 


PS.: You can read more about image export parameters at https://www.chemaxon.com/marvin/help/formats/images-doc.html