Skip to content

Commit

Permalink
Change the getHTML method to return the elements in the Hill System o…
Browse files Browse the repository at this point in the history
…rder (bug #3432131).

Change-Id: I0ca3c26a87f9af88de29e2c1a6b339a16b23ddf4
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
tomas-pluskal authored and egonw committed Jun 25, 2012
1 parent 3d05fab commit 3f3fab5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Expand Up @@ -304,9 +304,9 @@ public static String getHillString(IMolecularFormula formula) {
}

/**
* Returns the string representation of the molecule formula with
* numbers wrapped in &lt;sub&gt;&lt;/sub&gt; tags.
* Useful for displaying formulae in Swing components or on the web.
* Returns the string representation of the molecule formula based on Hill
* System with numbers wrapped in &lt;sub&gt;&lt;/sub&gt; tags. Useful for
* displaying formulae in Swing components or on the web.
*
*
* @param formula The IMolecularFormula object
Expand All @@ -320,11 +320,11 @@ public static String getHTML(IMolecularFormula formula) {
}

/**
* Returns the string representation of the molecule formula with
* numbers wrapped in &lt;sub&gt;&lt;/sub&gt; tags and the isotope
* of each Element in &lt;sup&gt;&lt;/sup&gt; tags and the total
* charge of IMolecularFormula in &lt;sup&gt;&lt;/sup&gt; tags.
* Useful for displaying formulae in Swing components or on the web.
* Returns the string representation of the molecule formula based on Hill
* System with numbers wrapped in &lt;sub&gt;&lt;/sub&gt; tags and the
* isotope of each Element in &lt;sup&gt;&lt;/sup&gt; tags and the total
* charge of IMolecularFormula in &lt;sup&gt;&lt;/sup&gt; tags. Useful for
* displaying formulae in Swing components or on the web.
*
*
* @param formula The IMolecularFormula object
Expand All @@ -337,7 +337,11 @@ public static String getHTML(IMolecularFormula formula) {
@TestMethod("testGetHTML_IMolecularFormula_boolean_boolean")
public static String getHTML(IMolecularFormula formula, boolean chargeB, boolean isotopeB) {
String htmlString = "";
String[] orderElements = generateOrderEle();
String[] orderElements;
if (containsElement(formula, formula.getBuilder().newInstance(IElement.class,"C")))
orderElements = generateOrderEle_Hill_WithCarbons();
else
orderElements = generateOrderEle_Hill_NoCarbons();
for (String orderElement : orderElements) {
IElement element = formula.getBuilder().newInstance(IElement.class,orderElement);
if (containsElement(formula, element)) {
Expand Down
Expand Up @@ -535,7 +535,7 @@ public void testGetHTML_IMolecularFormula() {
formula.addIsotope(builder.newInstance(IIsotope.class,"Cl"),2);
formula.addIsotope(builder.newInstance(IIsotope.class,"O"),2);

Assert.assertEquals("C<sub>8</sub>H<sub>10</sub>O<sub>2</sub>Cl<sub>2</sub>", MolecularFormulaManipulator.getHTML(formula));
Assert.assertEquals("C<sub>8</sub>H<sub>10</sub>Cl<sub>2</sub>O<sub>2</sub>", MolecularFormulaManipulator.getHTML(formula));
}
@Test
public void testGetHTML_IMolecularFormula_boolean_boolean() {
Expand Down

0 comments on commit 3f3fab5

Please sign in to comment.