From: <and...@us...> - 2012-05-15 07:43:25
|
Revision: 1258 http://jsbml.svn.sourceforge.net/jsbml/?rev=1258&view=rev Author: andreas-draeger Date: 2012-05-15 07:43:14 +0000 (Tue, 15 May 2012) Log Message: ----------- The pow function in the formula compiler was not working properly. Modified Paths: -------------- branches/jsbml-0.8/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java Modified: branches/jsbml-0.8/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java =================================================================== --- branches/jsbml-0.8/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2012-05-15 07:43:01 UTC (rev 1257) +++ branches/jsbml-0.8/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2012-05-15 07:43:14 UTC (rev 1258) @@ -453,9 +453,13 @@ * @throws SBMLException */ private String checkDenominatorBrackets(ASTNode nodes) throws SBMLException { + if ((nodes.getType() == Type.POWER) && (nodes.getChildCount() > 1) + && nodes.getRightChild().toString().equals("1")) { + return checkDenominatorBrackets(nodes.getLeftChild()); + } String term = nodes.compile(this).toString(); if (nodes.isSum() || nodes.isDifference() || nodes.isUMinus() - || nodes.getType() == Type.TIMES) { + || (nodes.getType() == Type.TIMES)) { term = brackets(term).toString(); } return term; @@ -1010,18 +1014,7 @@ * org.sbml.jsbml.ASTNode) */ public ASTNodeValue pow(ASTNode left, ASTNode right) throws SBMLException { - - // Adding brackets all the time for the exponent/right ASTNode - - if (left.getChildCount() < 2) { - return new ASTNodeValue(StringTools.concat(left.compile(this), "^", "(", - right.compile(this), ")").toString(), this); - } else { - return new ASTNodeValue(StringTools.concat(Character.valueOf('('), - left.compile(this), Character.valueOf(')'), "^", "(", - right.compile(this), ")").toString(), this); - } - + return new ASTNodeValue(pow(left.compile(this), right.compile(this)).toString(), this); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |