Depict a reaction.

@param rxn reaction instance
@return depiction
@throws CDKException a depiction could not be generated
183236
public Depiction depict(IReaction rxn) throws CDKException {

        ensure2dLayout(rxn); // can reorder components!

        final Color fgcol = getParameterValue(StandardGenerator.AtomColor.class).getAtomColor(rxn.getBuilder()
                                                                                                 .newInstance(IAtom.class, "C"));

        final List<IAtomContainer> reactants = toList(rxn.getReactants());
        final List<IAtomContainer> products = toList(rxn.getProducts());
        final List<IAtomContainer> agents = toList(rxn.getAgents());
        List<LayoutBackup> layoutBackups = new ArrayList<>();

        // set ids for tagging elements
        int molId = 0;
        for (IAtomContainer mol : reactants) {
            setIfMissing(mol, MarkedElement.ID_KEY, "mol" + ++molId);
            setIfMissing(mol, MarkedElement.CLASS_KEY, "reactant");
            layoutBackups.add(new LayoutBackup(mol));
        }
        for (IAtomContainer mol : products) {
            setIfMissing(mol, MarkedElement.ID_KEY, "mol" + ++molId);
            setIfMissing(mol, MarkedElement.CLASS_KEY, "product");
            layoutBackups.add(new LayoutBackup(mol));
        }
        for (IAtomContainer mol : agents) {
            setIfMissing(mol, MarkedElement.ID_KEY, "mol" + ++molId);
            setIfMissing(mol, MarkedElement.CLASS_KEY, "agent");
            layoutBackups.add(new LayoutBackup(mol));
        }

        final Map<IChemObject, Color> myHighlight = new HashMap<>();
        if (highlightAtomMap) {
            myHighlight.putAll(makeHighlightAtomMap(reactants, products));
        }
        // user highlight buffer pushes out the atom-map highlight if provided
        myHighlight.putAll(highlight);
        highlight.clear();

        prepareCoords(reactants);
        prepareCoords(products);
        prepareCoords(agents);

        // highlight parts
        for (Map.Entry<IChemObject, Color> e : myHighlight.entrySet())
            e.getKey().setProperty(StandardGenerator.HIGHLIGHT_COLOR, e.getValue());

        // setup the model scale based on bond length
        final double scale = this.caclModelScale(rxn);
        final DepictionGenerator copy = this.withParam(BasicSceneGenerator.Scale.class, scale);
        final RendererModel model = copy.getModel();

        // reactant/product/agent element generation, we number the reactants, then products then agents
        List<Bounds> reactantBounds = copy.generate(reactants, model, 1);
        List<Bounds> productBounds = copy.generate(toList(rxn.getProducts()), model, rxn.getReactantCount());
        List<Bounds> agentBounds = copy.generate(toList(rxn.getAgents()), model, rxn.getReactantCount() + rxn.getProductCount());

        // remove current highlight buffer
        for (IChemObject obj : myHighlight.keySet())
            obj.removeProperty(StandardGenerator.HIGHLIGHT_COLOR);

        // generate a 'plus' element
        Bounds plus = copy.generatePlusSymbol(scale, fgcol);

        // reset the coordinates to how they were before we invoked depict
        for (LayoutBackup backup : layoutBackups)
            backup.reset();

        final Bounds emptyBounds = new Bounds();
        final Bounds title = copy.getParameterValue(BasicSceneGenerator.ShowReactionTitle.class) ? copy.generateTitle(rxn, scale) : emptyBounds;
        final List<Bounds> reactantTitles = new ArrayList<>();
        final List<Bounds> productTitles = new ArrayList<>();
        if (copy.getParameterValue(BasicSceneGenerator.ShowMoleculeTitle.class)) {
            for (IAtomContainer reactant : reactants)
                reactantTitles.add(copy.generateTitle(reactant, scale));
            for (IAtomContainer product : products)
                productTitles.add(copy.generateTitle(product, scale));
        }

        final Bounds conditions = generateReactionConditions(rxn, fgcol, model.get(BasicSceneGenerator.Scale.class));

        return new ReactionDepiction(model,
                                     reactantBounds, productBounds, agentBounds,
                                     plus, rxn.getDirection(), dimensions,
                                     reactantTitles,
                                     productTitles,
                                     title,
                                     conditions,
                                     fgcol);
    }
817696
public void render (Graphics2D gfx)
    {
        Object oalias = SwingUtil.activateAntiAliasing(gfx);
        gfx.setColor(getBackground());
        gfx.fill(_shape);

        gfx.setColor(_outline);
        gfx.draw(_shape);
        SwingUtil.restoreAntiAliasing(gfx, oalias);

        if (_icon != null) {
            _icon.paintIcon(_owner.getTarget(), gfx, _ipos.x, _ipos.y);
        }

        gfx.setColor(Color.BLACK);
        _label.render(gfx, _lpos.x, _lpos.y);
    }
1066913
@Override
    public <T extends IChemObject> T read(T object) throws CDKException {
        if (object instanceof IChemFile) {
            try {
                return (T) readChemFile((IChemFile) object);
            } catch (IOException e) {
                logger.error("Input/Output error while reading from input: " + e.getMessage());
                throw new CDKException(e.getMessage(), e);
            }
        } else if (object instanceof ICrystal) {
            try {
                return (T) readCrystal((ICrystal) object);
            } catch (IOException e) {
                logger.error("Input/Output error while reading from input: " + e.getMessage());
                throw new CDKException(e.getMessage(), e);
            }
        } else {
            throw new CDKException("Only supported is reading of ChemFile.");
        }
    }
81477
private void layoutMolecule(List ringSetMolecule, IAtomContainer molecule, AtomPlacer3D ap3d,
            AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws CDKException, IOException,
            CloneNotSupportedException {
        //logger.debug("****** LAYOUT MOLECULE MAIN *******");
        IAtomContainer ac = null;
        int safetyCounter = 0;
        IAtom atom = null;
        //Place rest Chains/Atoms
        do {
            safetyCounter++;
            atom = ap3d.getNextPlacedHeavyAtomWithUnplacedRingNeighbour(molecule);
            if (atom != null) {
                //logger.debug("layout RingSystem...");
                IAtom unplacedAtom = ap3d.getUnplacedRingHeavyAtom(molecule, atom);
                IRingSet ringSetA = getRingSetOfAtom(ringSetMolecule, unplacedAtom);
                IAtomContainer ringSetAContainer = RingSetManipulator.getAllInOneContainer(ringSetA);
                templateHandler.mapTemplates(ringSetAContainer, ringSetAContainer.getAtomCount());

                if (checkAllRingAtomsHasCoordinates(ringSetAContainer)) {
                } else {
                    throw new IOException(
                            "RingAtomLayoutError: Not every ring atom is placed! Molecule cannot be layout.Sorry");
                }

                Point3d firstAtomOriginalCoord = unplacedAtom.getPoint3d();
                Point3d centerPlacedMolecule = ap3d.geometricCenterAllPlacedAtoms(molecule);

                setBranchAtom(molecule, unplacedAtom, atom, ap3d.getPlacedHeavyAtoms(molecule, atom), ap3d, atlp3d);
                layoutRingSystem(firstAtomOriginalCoord, unplacedAtom, ringSetA, centerPlacedMolecule, atom, ap3d);
                searchAndPlaceBranches(molecule, ringSetAContainer, ap3d, atlp3d, atomPlacer);
                //logger.debug("Ready layout Ring System");
                ringSetA = null;
                unplacedAtom = null;
                firstAtomOriginalCoord = null;
                centerPlacedMolecule = null;
            } else {
                //logger.debug("layout chains...");
                setAtomsToUnVisited(molecule);
                atom = ap3d.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(molecule);
                if (atom != null) {
                    ac = atom.getBuilder().newInstance(IAtomContainer.class);
                    ac.addAtom(atom);
                    searchAndPlaceBranches(molecule, ac, ap3d, atlp3d, atomPlacer);
                    ac = null;
                }
            }
        } while (!ap3d.allHeavyAtomsPlaced(molecule) || safetyCounter > molecule.getAtomCount());
    }
393560
@Override
    public <T extends IChemObject> T read(T object) throws CDKException {
        if (object instanceof IChemFile) {
            IChemFile cf = (IChemFile) object;
            try {
                cf = readChemFile(cf);
            } catch (IOException e) {
                logger.error("Input/Output error while reading from input.");
            }
            return (T) cf;
        } else {
            throw new CDKException("Only supported is reading of ChemFile.");
        }
    }
1088645
public void showRPN(final StringBuilder sb) throws Exception
    {
        for (final EquPart part : rpn)
        {
            sb.append(part.toString());
            sb.append("\n");
        }
    }
501419
public LineElement generateInnerElement(IBond bond, IRing ring, RendererModel model) {
        Point2d center = GeometryUtil.get2DCenter(ring);
        Point2d a = bond.getBegin().getPoint2d();
        Point2d b = bond.getEnd().getPoint2d();

        // the proportion to move in towards the ring center
        double distanceFactor = model.getParameter(TowardsRingCenterProportion.class).getValue();
        double ringDistance = distanceFactor * IDEAL_RINGSIZE / ring.getAtomCount();
        if (ringDistance < distanceFactor / MIN_RINGSIZE_FACTOR) ringDistance = distanceFactor / MIN_RINGSIZE_FACTOR;

        Point2d w = new Point2d();
        w.interpolate(a, center, ringDistance);
        Point2d u = new Point2d();
        u.interpolate(b, center, ringDistance);

        double alpha = 0.2;
        Point2d ww = new Point2d();
        ww.interpolate(w, u, alpha);
        Point2d uu = new Point2d();
        uu.interpolate(u, w, alpha);

        double width = getWidthForBond(bond, model);
        Color color = getColorForBond(bond, model);

        return new LineElement(u.x, u.y, w.x, w.y, width, color);
    }
101221
@Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.translate(x, y);

        double coef1 = (double) this.width / (double) getOrigWidth();
        double coef2 = (double) this.height / (double) getOrigHeight();
        g2d.scale(coef1, coef2);
        paint(g2d);
        g2d.dispose();
    }
664785
public void placeAliphaticHeavyChain(IAtomContainer molecule, IAtomContainer chain) throws CDKException {
        //logger.debug("******** Place aliphatic Chain *********");
        int[] first = new int[2];
        int counter = 1;
        int nextAtomNr = 0;
        String id1 = "";
        String id2 = "";
        String id3 = "";
        first = findHeavyAtomsInChain(molecule, chain);
        distances = new double[first[1]];
        firstAtoms = new int[first[1]];
        angles = new double[first[1]];
        secondAtoms = new int[first[1]];
        dihedrals = new double[first[1]];
        thirdAtoms = new int[first[1]];
        firstAtoms[0] = first[0];
        molecule.getAtom(firstAtoms[0]).setFlag(CDKConstants.VISITED, true);
        int hybridisation = 0;
        for (int i = 0; i < chain.getAtomCount(); i++) {
            if (isHeavyAtom(chain.getAtom(i))) {
                if (!chain.getAtom(i).getFlag(CDKConstants.VISITED)) {
                    //logger.debug("Counter:" + counter);
                    nextAtomNr = molecule.indexOf(chain.getAtom(i));
                    id2 = molecule.getAtom(firstAtoms[counter - 1]).getAtomTypeName();
                    id1 = molecule.getAtom(nextAtomNr).getAtomTypeName();

                    if (molecule.getBond(molecule.getAtom(firstAtoms[counter - 1]), molecule.getAtom(nextAtomNr)) == null)
                        throw new CDKException("atoms do not form a chain, please use ModelBuilder3D");

                    distances[counter] = getBondLengthValue(id1, id2);
                    //logger.debug(" Distance:" + distances[counter]);
                    firstAtoms[counter] = nextAtomNr;
                    secondAtoms[counter] = firstAtoms[counter - 1];
                    if (counter > 1) {
                        id3 = molecule.getAtom(firstAtoms[counter - 2]).getAtomTypeName();
                        hybridisation = getHybridisationState(molecule.getAtom(firstAtoms[counter - 1]));
                        angles[counter] = getAngleValue(id1, id2, id3);
                        //Check if sp,sp2
                        if (angles[counter] == -1) {
                            if (hybridisation == 3) {
                                angles[counter] = DEFAULT_SP3_ANGLE;
                            } else if (hybridisation == 2) {
                                angles[counter] = DEFAULT_SP2_ANGLE;
                            } else if (hybridisation == 1) {
                                angles[counter] = DEFAULT_SP_ANGLE;
                            }
                        }
                        thirdAtoms[counter] = firstAtoms[counter - 2];
                        //logger.debug(" Angle:" + angles[counter]);
                    } else {
                        angles[counter] = -1;
                        thirdAtoms[counter] = -1;
                    }
                    if (counter > 2) {
                        //double bond
                        try {
                            if (getDoubleBondConfiguration2D(
                                    molecule.getBond(molecule.getAtom(firstAtoms[counter - 1]),
                                            molecule.getAtom(firstAtoms[counter - 2])),
                                    (molecule.getAtom(firstAtoms[counter])).getPoint2d(),
                                    (molecule.getAtom(firstAtoms[counter - 1])).getPoint2d(),
                                    (molecule.getAtom(firstAtoms[counter - 2])).getPoint2d(),
                                    (molecule.getAtom(firstAtoms[counter - 3])).getPoint2d()) == 5) {
                                dihedrals[counter] = DIHEDRAL_BRANCHED_CHAIN;
                            } else {
                                dihedrals[counter] = DIHEDRAL_EXTENDED_CHAIN;
                            }
                        } catch (CDKException ex1) {
                            dihedrals[counter] = DIHEDRAL_EXTENDED_CHAIN;
                        }
                    } else {
                        dihedrals[counter] = -1;
                    }
                    counter++;
                }
            }
        }
    }
746840
private IReaction readReaction(IChemObjectBuilder builder) throws CDKException {
        logger.debug("Reading new reaction");
        int linecount = 0;
        IReaction reaction = builder.newInstance(IReaction.class);
        try {
            input.readLine(); // first line should be $RXN
            input.readLine(); // second line
            input.readLine(); // third line
            input.readLine(); // fourth line
        } catch (IOException exception) {
            logger.debug(exception);
            throw new CDKException("Error while reading header of RXN file", exception);
        }

        int reactantCount = 0;
        int productCount = 0;
        try {
            String countsLine = input.readLine();
            linecount++;
            if (countsLine == null) {
                return null;
            }
            logger.debug("Line " + linecount + ": " + countsLine);
            if (countsLine.startsWith("$$$$")) {
                logger.debug("File is empty, returning empty reaction");
                return reaction;
            }
            /*
             * this line contains the number of reactants and products
             */
            StringTokenizer tokenizer = new StringTokenizer(countsLine);
            reactantCount = Integer.valueOf(tokenizer.nextToken()).intValue();
            logger.info("Expecting " + reactantCount + " reactants in file");
            productCount = Integer.valueOf(tokenizer.nextToken()).intValue();
            logger.info("Expecting " + productCount + " products in file");
        } catch (IOException | NumberFormatException exception) {
            logger.debug(exception);
            throw new CDKException("Error while counts line of RXN file", exception);
        }

        // now read the reactants
        try {
            for (int i = 1; i <= reactantCount; i++) {
                StringBuffer molFile = new StringBuffer();
                input.readLine(); // announceMDLFileLine
                String molFileLine = "";
                do {
                    molFileLine = input.readLine();
                    molFile.append(molFileLine);
                    molFile.append('\n');
                } while (!molFileLine.equals("M  END"));

                // read MDL molfile content
                MDLReader reader = new MDLReader(new StringReader(molFile.toString()));
                IAtomContainer reactant = (IAtomContainer) reader.read(builder.newInstance(IAtomContainer.class));
                reader.close();

                // add reactant
                reaction.addReactant(reactant);
            }
        } catch (CDKException exception) {
            // rethrow exception from MDLReader
            throw exception;
        } catch (IOException | IllegalArgumentException exception) {
            logger.debug(exception);
            throw new CDKException("Error while reading reactant", exception);
        }

        // now read the products
        try {
            for (int i = 1; i <= productCount; i++) {
                StringBuffer molFile = new StringBuffer();
                input.readLine(); // String announceMDLFileLine =
                String molFileLine = "";
                do {
                    molFileLine = input.readLine();
                    molFile.append(molFileLine);
                    molFile.append('\n');
                } while (!molFileLine.equals("M  END"));

                // read MDL molfile content
                MDLReader reader = new MDLReader(new StringReader(molFile.toString()), super.mode);
                IAtomContainer product = (IAtomContainer) reader.read(builder.newInstance(IAtomContainer.class));
                reader.close();

                // add reactant
                reaction.addProduct(product);
            }
        } catch (CDKException exception) {
            // rethrow exception from MDLReader
            throw exception;
        } catch (IOException | IllegalArgumentException exception) {
            logger.debug(exception);
            throw new CDKException("Error while reading products", exception);
        }

        // now try to map things, if wanted
        logger.info("Reading atom-atom mapping from file");
        // distribute all atoms over two AtomContainer's
        IAtomContainer reactingSide = builder.newInstance(IAtomContainer.class);
        Iterator<IAtomContainer> molecules = reaction.getReactants().atomContainers().iterator();
        while (molecules.hasNext()) {
            reactingSide.add(molecules.next());
        }
        IAtomContainer producedSide = builder.newInstance(IAtomContainer.class);
        molecules = reaction.getProducts().atomContainers().iterator();
        while (molecules.hasNext()) {
            producedSide.add(molecules.next());
        }

        // map the atoms
        int mappingCount = 0;
        //        IAtom[] reactantAtoms = reactingSide.getAtoms();
        //        IAtom[] producedAtoms = producedSide.getAtoms();
        for (int i = 0; i < reactingSide.getAtomCount(); i++) {
            for (int j = 0; j < producedSide.getAtomCount(); j++) {
                IAtom eductAtom = reactingSide.getAtom(i);
                IAtom productAtom = producedSide.getAtom(j);
                if (eductAtom.getProperty(CDKConstants.ATOM_ATOM_MAPPING) != null
                        && eductAtom.getProperty(CDKConstants.ATOM_ATOM_MAPPING).equals(
                                productAtom.getProperty(CDKConstants.ATOM_ATOM_MAPPING))) {
                    reaction.addMapping(builder.newInstance(IMapping.class, eductAtom, productAtom));
                    mappingCount++;
                    break;
                }
            }
        }
        logger.info("Mapped atom pairs: " + mappingCount);

        return reaction;
    }
832344
private void writeReaction(IReaction reaction) throws CDKException {
        int reactantCount = reaction.getReactantCount();
        int productCount = reaction.getProductCount();
        if (reactantCount <= 0 || productCount <= 0) {
            throw new CDKException("Either no reactants or no products present.");
        }

        try {
            // taking care of the $$$$ signs:
            // we do not write such a sign at the end of the first reaction, thus we have to write on BEFORE the second reaction
            if (reactionNumber == 2) {
                writer.write("$$$$");
                writer.write('\n');
            }

            writer.write("$RXN");
            writer.write('\n');
            // reaction name
            String line = (String) reaction.getProperty(CDKConstants.TITLE);
            if (line == null) line = "";
            if (line.length() > 80) line = line.substring(0, 80);
            writer.write(line);
            writer.write('\n');
            // user/program/date&time/reaction registry no. line
            writer.write('\n');
            // comment line
            line = (String) reaction.getProperty(CDKConstants.REMARK);
            if (line == null) line = "";
            if (line.length() > 80) line = line.substring(0, 80);
            writer.write(line);
            writer.write('\n');

            line = "";
            line += formatMDLInt(reactantCount, 3);
            line += formatMDLInt(productCount, 3);
            writer.write(line);
            writer.write('\n');

            int i = 0;
            for (IMapping mapping : reaction.mappings()) {
                Iterator<IChemObject> it = mapping.relatedChemObjects().iterator();
                it.next().setProperty(CDKConstants.ATOM_ATOM_MAPPING, i + 1);
                it.next().setProperty(CDKConstants.ATOM_ATOM_MAPPING, i + 1);
                i++;
            }
            writeAtomContainerSet(reaction.getReactants());
            writeAtomContainerSet(reaction.getProducts());

            //write sdfields, if any
            if (rdFields != null) {
                Set<String> set = rdFields.keySet();
                Iterator<String> iterator = set.iterator();
                while (iterator.hasNext()) {
                    Object element = iterator.next();
                    writer.write("> <" + (String) element + ">");
                    writer.write('\n');
                    writer.write(rdFields.get(element).toString());
                    writer.write('\n');
                    writer.write('\n');
                }
            }
            // taking care of the $$$$ signs:
            // we write such a sign at the end of all except the first molecule
            if (reactionNumber != 1) {
                writer.write("$$$$");
                writer.write('\n');
            }
            reactionNumber++;

        } catch (IOException ex) {
            logger.error(ex.getMessage());
            logger.debug(ex);
            throw new CDKException("Exception while writing MDL file: " + ex.getMessage(), ex);
        }
    }
1239332
@Override
    public <T extends IChemObject> T read(T object) throws CDKException {
        if (object instanceof IChemFile) {
            try {
                return (T) readChemFile((IChemFile) object);
            } catch (IOException e) {
                return null;
            }
        } else {
            throw new CDKException("Only supported is reading of ChemFile objects.");
        }
    }
153971
private IChemFile readChemFile(IChemFile chemFile) throws CDKException {
        IChemSequence chemSequence = chemFile.getBuilder().newInstance(IChemSequence.class);

        IChemModel chemModel = chemFile.getBuilder().newInstance(IChemModel.class);
        chemSequence.addChemModel(readChemModel(chemModel));
        chemFile.addChemSequence(chemSequence);
        return chemFile;
    }
3693
@Override
    public IRingSet getRingSet(IAtomContainer molecule) throws CDKException {

        Collection<List<IAtom>> cycles = findRings(molecule);

        IRingSet ringSet = molecule.getBuilder().newInstance(IRingSet.class);

        for (List<IAtom> ringAtoms : cycles) {
            IRing ring = molecule.getBuilder().newInstance(IRing.class);
            for (IAtom atom : ringAtoms) {
                atom.setFlag(CDKConstants.ISINRING, true);
                ring.addAtom(atom);
                for (IAtom atomNext : ringAtoms) {
                    if (!atom.equals(atomNext)) {
                        IBond bond = molecule.getBond(atom, atomNext);
                        if (bond != null) {
                            bond.setFlag(CDKConstants.ISINRING, true);
                            ring.addElectronContainer(bond);
                        }
                    }
                }
            }
            ringSet.addAtomContainer(ring);
        }
        return ringSet;
    }
1017815
public IRingSet assignAtomTyps(IAtomContainer molecule) throws CDKException {
        IAtom atom = null;
        String hoseCode = "";
        HOSECodeGenerator hcg = new HOSECodeGenerator();
        int NumberOfRingAtoms = 0;
        IRingSet ringSetA = null;
        IRingSet ringSetMolecule = Cycles.sssr(molecule).toRingSet();
        boolean isInHeteroRing = false;
        try {
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
            Aromaticity.cdkLegacy().apply(molecule);
        } catch (Exception cdk1) {
            throw new CDKException("AROMATICITYError: Cannot determine aromaticity due to: " + cdk1.getMessage(), cdk1);
        }

        for (int i = 0; i < molecule.getAtomCount(); i++) {
            atom = molecule.getAtom(i);
            if (ringSetMolecule.contains(atom)) {
                NumberOfRingAtoms = NumberOfRingAtoms + 1;
                atom.setFlag(CDKConstants.ISINRING, true);
                atom.setFlag(CDKConstants.ISALIPHATIC, false);
                ringSetA = ringSetMolecule.getRings(atom);
                RingSetManipulator.sort(ringSetA);
                IRing sring = (IRing) ringSetA.getAtomContainer(ringSetA.getAtomContainerCount() - 1);
                atom.setProperty("RING_SIZE", Integer.valueOf(sring.getRingSize()));
                isInHeteroRing = false;
                Iterator<IAtomContainer> containers = RingSetManipulator.getAllAtomContainers(ringSetA).iterator();
                while (!isInHeteroRing && containers.hasNext()) {
                    isInHeteroRing = isHeteroRingSystem(containers.next());
                }
            } else {
                atom.setFlag(CDKConstants.ISALIPHATIC, true);
                atom.setFlag(CDKConstants.ISINRING, false);
                isInHeteroRing = false;
            }
            atom.setProperty("MAX_BOND_ORDER", new Double(molecule.getMaximumBondOrder(atom).numeric()));

            try {
                hoseCode = hcg.getHOSECode(molecule, atom, 3);
                //logger.debug("HOSECODE GENERATION: ATOM "+i+" HoseCode: "+hoseCode+" ");
            } catch (CDKException ex1) {
                System.out.println("Could not build HOSECode from atom " + i + " due to " + ex1.toString());
                throw new CDKException("Could not build HOSECode from atom " + i + " due to " + ex1.toString(), ex1);
            }
            try {
                configureAtom(atom, hoseCode, isInHeteroRing);
            } catch (CDKException ex2) {
                System.out.println("Could not final configure atom " + i + " due to " + ex2.toString());
                throw new CDKException("Could not final configure atom due to problems with force field", ex2);
            }
        }

        //		IBond[] bond = molecule.getBonds();
        String bondType;
        for (IBond bond : molecule.bonds()) {

            //logger.debug("bond[" + i + "] properties : " + molecule.getBond(i).getProperties());
            bondType = "0";
            if (bond.getOrder() == IBond.Order.SINGLE) {
                if ((bond.getBegin().getAtomTypeName().equals("Csp2"))
                        && ((bond.getEnd().getAtomTypeName().equals("Csp2")) || (bond.getEnd().getAtomTypeName()
                                .equals("C=")))) {
                    bondType = "1";
                }

                if ((bond.getBegin().getAtomTypeName().equals("C="))
                        && ((bond.getEnd().getAtomTypeName().equals("Csp2")) || (bond.getEnd().getAtomTypeName()
                                .equals("C=")))) {
                    bondType = "1";
                }

                if ((bond.getBegin().getAtomTypeName().equals("Csp"))
                        && (bond.getEnd().getAtomTypeName().equals("Csp"))) {
                    bondType = "1";
                }
            }
            //			molecule.getBond(i).setProperty("MMFF94 bond type", bondType);
            bond.setProperty("MMFF94 bond type", bondType);
            //logger.debug("bond[" + i + "] properties : " + molecule.getBond(i).getProperties());
        }

        return ringSetMolecule;
    }
794131
protected boolean showCarbon(IAtom carbonAtom, IAtomContainer container, RendererModel model) {

        if ((Boolean) model.get(KekuleStructure.class)) return true;

        if (carbonAtom.getFormalCharge() != 0) return true;

        int connectedBondCount = container.getConnectedBondsList(carbonAtom).size();

        if (connectedBondCount < 1) return true;

        if ((Boolean) model.get(ShowEndCarbons.class) && connectedBondCount == 1) return true;

        if (carbonAtom.getProperty(ProblemMarker.ERROR_MARKER) != null) return true;

        if (container.getConnectedSingleElectronsCount(carbonAtom) > 0) return true;

        return false;
    }
580985
public void paintIcon (Component c, Graphics g, int x, int y)
    {
        Graphics2D gfx = (Graphics2D) g;
        AffineTransform otrans = gfx.getTransform();
        RenderingHints ohints = gfx.getRenderingHints();

        gfx.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        gfx.scale(_scale, _scale);
        _icon.paintIcon(c, g, x, y);

        gfx.setTransform(otrans);
        gfx.setRenderingHints(ohints);
    }