/** * Returns the string representation of the molecule formula based on Hill * System with numbers wrapped in <sub></sub> tags and the * isotope of each Element in <sup></sup> tags and the total * charge of IMolecularFormula in <sup></sup> tags. Useful for * displaying formulae in Swing components or on the web. * * * @param formula The IMolecularFormula object * @param chargeB True, If it has to show the charge * @param isotopeB True, If it has to show the Isotope mass * @return A HTML representation of the molecular formula * @see #getHTML(IMolecularFormula) * */ public static String getHTML(IMolecularFormula formula, boolean chargeB, boolean isotopeB) { String[] orderElements; if (containsElement(formula, formula.getBuilder().newInstance(IElement.class, "C"))) orderElements = generateOrderEle_Hill_WithCarbons(); else orderElements = generateOrderEle_Hill_NoCarbons(); return getHTML(formula, orderElements, chargeB, isotopeB); }
/** * Returns the string representation of the molecule formula. * Based on Hill System. The Hill system is a system of writing * chemical formulas such that the number of carbon atoms in a * molecule is indicated first, the number of hydrogen atoms next, * and then the number of all other chemical elements subsequently, * in alphabetical order. When the formula contains no carbon, all * the elements, including hydrogen, are listed alphabetically. * * @param formula The IMolecularFormula Object * @param setOne True, when must be set the value 1 for elements with * one atom * @return A String containing the molecular formula * * @see #getHTML(IMolecularFormula) */ public static String getString(IMolecularFormula formula, boolean setOne) { if (containsElement(formula, formula.getBuilder().newInstance(IElement.class, "C"))) return getString(formula, generateOrderEle_Hill_WithCarbons(), setOne, false); else return getString(formula, generateOrderEle_Hill_NoCarbons(), setOne, false); }
/** * Returns the string representation of the molecule formula. * Based on Hill System. The Hill system is a system of writing * chemical formulas such that the number of carbon atoms in a * molecule is indicated first, the number of hydrogen atoms next, * and then the number of all other chemical elements subsequently, * in alphabetical order. When the formula contains no carbon, all * the elements, including hydrogen, are listed alphabetically. * * @param formula The IMolecularFormula Object * @param setOne True, when must be set the value 1 for elements with * one atom * @param setMassNumber If the formula contains an isotope of an element that is the * non-major isotope, the element is represented as <code>[XE]</code> where * <code>X</code> is the mass number and <code>E</code> is the element symbol * @return A String containing the molecular formula * * @see #getHTML(IMolecularFormula) */ public static String getString(IMolecularFormula formula, boolean setOne, boolean setMassNumber) { if (containsElement(formula, formula.getBuilder().newInstance(IElement.class, "C"))) return getString(formula, generateOrderEle_Hill_WithCarbons(), setOne, setMassNumber); else return getString(formula, generateOrderEle_Hill_NoCarbons(), setOne, setMassNumber); }