Anyway, here is example code for how to mark a substructure. It a variations of the triazole examples I have given earlier. First thing is to add the proper generator:
// generators make the image elements
List<IGenerator> generators = new ArrayList<IGenerator>();
generators.add(new BasicSceneGenerator());
generators.add(new ExternalHighlightGenerator());
generators.add(new BasicBondGenerator());
generators.add(new BasicAtomGenerator());
model = renderer.getRenderer2DModel();
model.set(
ExternalHighlightGenerator.ExternalHighlightDistance.class,
(double)12
);
model.set(
RendererModel.ExternalHighlightColor.class,
Color.red
);
Finally, we set the selection we like to color:
IAtomContainer selection = new AtomContainer();
for (int i=0; i<2; i++) {
bond = triazole.getBond(i);
selection.addAtom(bond.getAtom(0));
selection.addAtom(bond.getAtom(1));
selection.addBond(bond);
}
model.setExternalSelectedPart(selection);
And the result then looks like this:
The full script can be downloaded here. A downside of this script is that the background of the symbol is not in the same color as the selection highlight. Also I do not think you can color multiple selection at the same time. But, I guess it is a start of an answer.
BTW, the new JChemPaint applet/application can be downloaded its new hangout at jchempaint.github.com.
