* currently displayed and all their implicit and explicit Hs.
*
* @return The formula.
*/
public String getFormula() {
IMolecularFormula wholeModel = getIChemModel().getBuilder()
.newInstance(IMolecularFormula.class);
Iterator<IAtomContainer> containers = ChemModelManipulator
.getAllAtomContainers(chemModel).iterator();
int implicitHs = 0;
while (containers.hasNext()) {
for (IAtom atom : containers.next().atoms()) {
wholeModel.addIsotope(atom);
if (atom.getImplicitHydrogenCount() != null) {
implicitHs += atom.getImplicitHydrogenCount();
}
}
}
try {
if (implicitHs > 0)
wholeModel
.addIsotope(XMLIsotopeFactory.getInstance(
wholeModel.getBuilder()).getMajorIsotope(1),
implicitHs);
} catch (IOException e) {
// do nothing
}
return MolecularFormulaManipulator.getHTML(wholeModel, true, false);