use of com.twosigma.beakerx.symjamma.output.LatexNotebookOutput in project symja_android_library by axkr.
the class SymjaMMAEvaluator method printForm.
/**
* Print the result in the default output form
*
* @param symjaMMACodeRunner
* @param result
* @return
*/
TryResult printForm(final SymjaMMACodeRunner symjaMMACodeRunner, final Object result) {
switch(fUsedForm) {
case SymjaMMAEvaluator.JAVAFORM:
return TryResult.createResult(((IExpr) result).internalJavaString(JAVA_FORM_PROPERTIES, -1, x -> null));
case SymjaMMAEvaluator.TRADITIONALFORM:
StringBuilder traditionalBuffer = new StringBuilder();
fOutputTraditionalFactory.reset(false);
if (fOutputTraditionalFactory.convert(traditionalBuffer, (IExpr) result)) {
return TryResult.createResult(traditionalBuffer.toString());
} else {
return TryResult.createResult("ERROR-IN-TRADITIONALFORM");
}
// return "";
case SymjaMMAEvaluator.INPUTFORM:
StringBuilder inputBuffer = new StringBuilder();
fInputFactory.reset(false);
if (fInputFactory.convert(inputBuffer, (IExpr) result)) {
return TryResult.createResult(inputBuffer.toString());
} else {
return TryResult.createResult("ERROR-IN-INPUTFORM");
}
case SymjaMMAEvaluator.TEXFORM:
final TeXFormFactory fTeXFactory = new TeXFormFactory();
final StringBuilder texBuilder = new StringBuilder();
texBuilder.append("$$");
if (fTeXFactory.convert(texBuilder, (IExpr) result, 0)) {
texBuilder.append("$$");
return TryResult.createResult(new LatexNotebookOutput(texBuilder.toString()));
} else {
return TryResult.createResult("ERROR-IN-TEXFORM");
}
}
return TryResult.createResult(result);
}
Aggregations