@Override public <T> ASTNode2Value<String> factorial(ASTNode2 node) { try { return function("factorial", node); } catch (SBMLException e) { e.printStackTrace(); } return null; }
/** * @param args */ public static void main(String[] args) { ASTNode formula_base = new ASTNode(Double.NaN); System.out.println(formula_base.toMathML()); try { System.out.println(formula_base.toFormula()); } catch (SBMLException e) { e.printStackTrace(); } double x = 0.0050; double y = 1.0; double z = 1.66E-4; double zz = 12548698515426596325478965230.33254; System.out.println("Test Double formatting "); // NumberFormat format = DecimalFormat.getInstance(); DecimalFormat format = new DecimalFormat(StringTools.REAL_FORMAT, new DecimalFormatSymbols(Locale.ENGLISH)); System.out.println("x = " + format.format(x)); System.out.println("y = " + format.format(y)); System.out.println("z = " + format.format(z) + " " + format.getMaximumFractionDigits()); System.out.println("zz = " + format.format(zz) + " "); }
/** * Returns the infix formula representing this ASTNode or an empty String if there was * a problem to construct the formula. * * @return the infix formula representing this ASTNode */ public String printASTNode() { String formula = ""; try { formula = toFormula(); } catch (SBMLException e) { // log the exception e.printStackTrace(); if (isDebugEnabled) { logger.error(MessageFormat.format(resourceBundle.getString("ASTNode.toString"), e.getMessage()), e); } else { // TODO: Do not print this message if parsing the file !!! Or remove it logger.warn(MessageFormat.format(resourceBundle.getString("ASTNode.toString"), e.getMessage())); } } catch (RuntimeException e) { // added to prevent a crash when we cannot create the formula if (isDebugEnabled) { logger.error(MessageFormat.format(resourceBundle.getString("ASTNode.toString"), e.getMessage()), e); } } return formula; }
/** * @param args */ public static void main(String[] args) { ASTCnRealNode formula_base = new ASTCnRealNode(Double.NaN); System.out.println(formula_base.toMathML()); try { System.out.println(formula_base.toFormula()); } catch (SBMLException e) { e.printStackTrace(); } double x = 0.0050; double y = 1.0; double z = 1.66E-4; double zz = 12548698515426596325478965230.33254; System.out.println("Test Double formatting "); // NumberFormat format = DecimalFormat.getInstance(); DecimalFormat format = new DecimalFormat(StringTools.REAL_FORMAT, new DecimalFormatSymbols(Locale.ENGLISH)); System.out.println("x = " + format.format(x)); System.out.println("y = " + format.format(y)); System.out.println("z = " + format.format(z) + " " + format.getMaximumFractionDigits()); System.out.println("zz = " + format.format(zz) + " "); } /**
/** * Converts a {@link ASTNode2} to a {@link ASTNode}. * * @param astNode2 {@link ASTNode2} * @return astNode {@link ASTNode} */ public static ASTNode toASTNode(ASTNode2 astNode2) { // TODO implement function without parsing. IFormulaParser parser = new FormulaParserLL3(new StringReader("")); ASTNode astNode = null; try { astNode = ASTNode.parseFormula(astNode2.toFormula(), parser); } catch (SBMLException e) { e.printStackTrace(); } catch (org.sbml.jsbml.text.parser.ParseException e) { e.printStackTrace(); } return astNode; }
@Override public String toString() { if (isNode()) { try { return MathMLParser.toMathML(MathMLParser.createMathMLDocumentFor(toNode(), getLevel()), true, true, 2); } catch (IOException e) { e.printStackTrace(); } catch (SBMLException e) { e.printStackTrace(); } } String val = (value != null) ? value.toString() : super.toString(); if (isSetUnit()) { val += ' ' + UnitDefinition.printUnits(getUnits(), true); } return val; }
@Override public String toString() { if (isNode()) { try { return MathMLParser.toMathML(MathMLParser.createMathMLDocumentFor(toNode(), getLevel()), true, true, 2); } catch (IOException e) { e.printStackTrace(); } catch (SBMLException e) { e.printStackTrace(); } } String val = (value != null) ? value.toString() : super.toString(); if (isSetUnit()) { val += ' ' + UnitDefinition.printUnits(getUnits(), true); } return val; }