From: <nik...@us...> - 2016-01-27 14:33:02
|
Revision: 2475 http://sourceforge.net/p/jsbml/code/2475 Author: niko-rodrigue Date: 2016-01-27 14:33:00 +0000 (Wed, 27 Jan 2016) Log Message: ----------- corrected the bug reported by Miguel de Alba + several other corrections to the formula output to correct some cases where jsbml divert from the expected output Modified Paths: -------------- trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerLibSBML.java Modified: trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2016-01-25 20:54:22 UTC (rev 2474) +++ trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java 2016-01-27 14:33:00 UTC (rev 2475) @@ -70,7 +70,7 @@ /** * */ - public static final String FORMULA_ARGUMENT_SEPARATOR = ""; + public static final String FORMULA_ARGUMENT_SEPARATOR = " "; /** * Basic method which links several elements with a mathematical operator. @@ -449,7 +449,9 @@ protected String checkBrackets(ASTNode node) throws SBMLException { String term = node.compile(this).toString(); - if (node.isSum() || node.isDifference() || node.isUMinus()) { + if (node.isSum() || node.isDifference() || node.isUMinus() + || node.isRelational() || node.isLogical()) + { term = brackets(term).toString(); } else if (node.isReal()) { if (node.getReal() < 0d) { @@ -491,11 +493,13 @@ String term = node.compile(this).toString(); - if (node.isRelational() || node.isNumber() || node.isString() + if (node.isNumber() || node.isString() || node.isFunction()) { return term; } + // for node.isRelational() and node.isLogical(), we want to put brackets + return term = brackets(term).toString(); } Modified: trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerLibSBML.java =================================================================== --- trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerLibSBML.java 2016-01-25 20:54:22 UTC (rev 2474) +++ trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerLibSBML.java 2016-01-27 14:33:00 UTC (rev 2475) @@ -63,7 +63,7 @@ return function("eq", ((ASTNode) left.getParent()).getListOfNodes()); } - return new ASTNodeValue(relation(left, " == ", right), this); + return new ASTNodeValue(relation(left, "==", right), this); } /* (non-Javadoc) @@ -86,7 +86,7 @@ return function("geq", ((ASTNode) left.getParent()).getListOfNodes()); } - return new ASTNodeValue(relation(left, " >= ", right), this); + return new ASTNodeValue(relation(left, ">=", right), this); } @@ -101,7 +101,7 @@ return function("gt", ((ASTNode) left.getParent()).getListOfNodes()); } - return new ASTNodeValue(relation(left, " > ", right), this); + return new ASTNodeValue(relation(left, ">", right), this); } @@ -116,7 +116,7 @@ return function("leq", ((ASTNode) left.getParent()).getListOfNodes()); } - return new ASTNodeValue(relation(left, " <= ", right), this); + return new ASTNodeValue(relation(left, "<=", right), this); } @@ -131,7 +131,7 @@ return function("lt", ((ASTNode) left.getParent()).getListOfNodes()); } - return new ASTNodeValue(relation(left, " < ", right), this); + return new ASTNodeValue(relation(left, "<", right), this); } @@ -140,7 +140,7 @@ */ @Override public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " != ", right), this); + return new ASTNodeValue(relation(left, "!=", right), this); } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |