Search in sources :

Example 1 with LatexNotebookOutput

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);
}
Also used : MagicCommandAutocompletePatterns(com.twosigma.beakerx.autocomplete.MagicCommandAutocompletePatterns) LatexNotebookOutput(com.twosigma.beakerx.symjamma.output.LatexNotebookOutput) SymjaMMAAutocomplete(com.twosigma.beakerx.symjamma.autocomplete.SymjaMMAAutocomplete) IOInit(org.matheclipse.io.IOInit) ImportPath(com.twosigma.beakerx.kernel.ImportPath) MIMEContainer(com.twosigma.beakerx.mimetype.MIMEContainer) TryResult(com.twosigma.beakerx.TryResult) Prefix(org.matheclipse.core.interfaces.IExpr.SourceCodeProperties.Prefix) BeakerCellExecutor(com.twosigma.beakerx.jvm.threads.BeakerCellExecutor) MarkdownNotebookOutput(com.twosigma.beakerx.symjamma.output.MarkdownNotebookOutput) ExecutionOptions(com.twosigma.beakerx.kernel.ExecutionOptions) Locale(java.util.Locale) BeakerXClient(com.twosigma.beakerx.BeakerXClient) JobDescriptor(com.twosigma.beakerx.evaluator.JobDescriptor) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) EvalEngine(org.matheclipse.core.eval.EvalEngine) EnvVariablesFilter.envVariablesFilter(com.twosigma.beakerx.symjamma.evaluator.EnvVariablesFilter.envVariablesFilter) F(org.matheclipse.core.expression.F) TeXFormFactory(org.matheclipse.core.form.tex.TeXFormFactory) File(java.io.File) Executors(java.util.concurrent.Executors) OutputFormFactory(org.matheclipse.core.form.output.OutputFormFactory) Classpath(com.twosigma.beakerx.kernel.Classpath) SourceCodeProperties(org.matheclipse.core.interfaces.IExpr.SourceCodeProperties) TempFolderFactory(com.twosigma.beakerx.evaluator.TempFolderFactory) BaseEvaluator(com.twosigma.beakerx.evaluator.BaseEvaluator) CellExecutor(com.twosigma.beakerx.jvm.threads.CellExecutor) TempFolderFactoryImpl(com.twosigma.beakerx.evaluator.TempFolderFactoryImpl) IExpr(org.matheclipse.core.interfaces.IExpr) ExprEvaluator(org.matheclipse.core.eval.ExprEvaluator) ParserConfig(org.matheclipse.parser.client.ParserConfig) EvaluatorParameters(com.twosigma.beakerx.kernel.EvaluatorParameters) PathToJar(com.twosigma.beakerx.kernel.PathToJar) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) TeXFormFactory(org.matheclipse.core.form.tex.TeXFormFactory) LatexNotebookOutput(com.twosigma.beakerx.symjamma.output.LatexNotebookOutput)

Aggregations

BeakerXClient (com.twosigma.beakerx.BeakerXClient)1 TryResult (com.twosigma.beakerx.TryResult)1 AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)1 MagicCommandAutocompletePatterns (com.twosigma.beakerx.autocomplete.MagicCommandAutocompletePatterns)1 BaseEvaluator (com.twosigma.beakerx.evaluator.BaseEvaluator)1 JobDescriptor (com.twosigma.beakerx.evaluator.JobDescriptor)1 TempFolderFactory (com.twosigma.beakerx.evaluator.TempFolderFactory)1 TempFolderFactoryImpl (com.twosigma.beakerx.evaluator.TempFolderFactoryImpl)1 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)1 BeakerCellExecutor (com.twosigma.beakerx.jvm.threads.BeakerCellExecutor)1 CellExecutor (com.twosigma.beakerx.jvm.threads.CellExecutor)1 Classpath (com.twosigma.beakerx.kernel.Classpath)1 EvaluatorParameters (com.twosigma.beakerx.kernel.EvaluatorParameters)1 ExecutionOptions (com.twosigma.beakerx.kernel.ExecutionOptions)1 ImportPath (com.twosigma.beakerx.kernel.ImportPath)1 PathToJar (com.twosigma.beakerx.kernel.PathToJar)1 MIMEContainer (com.twosigma.beakerx.mimetype.MIMEContainer)1 SymjaMMAAutocomplete (com.twosigma.beakerx.symjamma.autocomplete.SymjaMMAAutocomplete)1 EnvVariablesFilter.envVariablesFilter (com.twosigma.beakerx.symjamma.evaluator.EnvVariablesFilter.envVariablesFilter)1 LatexNotebookOutput (com.twosigma.beakerx.symjamma.output.LatexNotebookOutput)1