public IRenderingElement generate(IAtomContainer ac, RendererModel model) { if (generators == null) return EMPTY_ELEMENT; if (use) { ElementGroup group = new ElementGroup(); for (IGenerator generator : generators) { group.add(generator.generate(ac, model)); } return group; } else return EMPTY_ELEMENT; }
private IRenderingElement generate(IAtomContainer molecule, RendererModel model, int atomNum) throws CDKException { // tag the atom and bond ids String molId = molecule.getProperty(MarkedElement.ID_KEY); if (molId != null) { int atomId = 0, bondid = 0; for (IAtom atom : molecule.atoms()) setIfMissing(atom, MarkedElement.ID_KEY, molId + "atm" + ++atomId); for (IBond bond : molecule.bonds()) setIfMissing(bond, MarkedElement.ID_KEY, molId + "bnd" + ++bondid); } if (annotateAtomNum) { for (IAtom atom : molecule.atoms()) { if (atom.getProperty(StandardGenerator.ANNOTATION_LABEL) != null) throw new UnsupportedOperationException("Multiple annotation labels are not supported."); atom.setProperty(StandardGenerator.ANNOTATION_LABEL, Integer.toString(atomNum++)); } } else if (annotateAtomVal) { for (IAtom atom : molecule.atoms()) { if (atom.getProperty(StandardGenerator.ANNOTATION_LABEL) != null) throw new UnsupportedOperationException("Multiple annotation labels are not supported."); atom.setProperty( StandardGenerator.ANNOTATION_LABEL, atom.getProperty(CDKConstants.COMMENT)); } } else if (annotateAtomMap) { for (IAtom atom : molecule.atoms()) { if (atom.getProperty(StandardGenerator.ANNOTATION_LABEL) != null) throw new UnsupportedOperationException("Multiple annotation labels are not supported."); int mapidx = accessAtomMap(atom); if (mapidx > 0) { atom.setProperty(StandardGenerator.ANNOTATION_LABEL, Integer.toString(mapidx)); } } } ElementGroup grp = new ElementGroup(); for (IGenerator<IAtomContainer> gen : gens) grp.add(gen.generate(molecule, model)); // cleanup if (annotateAtomNum || annotateAtomMap) { for (IAtom atom : molecule.atoms()) { atom.removeProperty(StandardGenerator.ANNOTATION_LABEL); } } return grp; }
/** * Create a depiction generator that will render atom labels using the specified AWT font. * * @param font the font to use to display */ public DepictionGenerator(Font font) { gens.add(new BasicSceneGenerator()); gens.add(new StandardGenerator(this.font = font)); for (IGenerator<IAtomContainer> gen : gens) { for (IGeneratorParameter<?> param : gen.getParameters()) { params.put(param.getClass(), param); } } for (IGeneratorParameter<?> param : new RendererModel().getRenderingParameters()) { params.put(param.getClass(), param); } // default margin and separation is automatic // since it depends on raster (px) vs vector (mm) setParam(BasicSceneGenerator.Margin.class, AUTOMATIC); setParam(RendererModel.Padding.class, AUTOMATIC); }