Commit df4aa861 authored by dgelessus's avatar dgelessus
Browse files

Use new high-level dot and table visualization APIs

parent 17c0c37a
Pipeline #50742 passed with stage
in 5 minutes and 4 seconds
......@@ -15,7 +15,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import de.prob.animator.command.GetAllDotCommands;
import de.prob.animator.command.GetSvgForVisualizationCommand;
import de.prob.animator.domainobjects.DotVisualizationCommand;
import de.prob.animator.domainobjects.DynamicCommandItem;
import de.prob.animator.domainobjects.FormulaExpand;
import de.prob.animator.domainobjects.IEvalElement;
......@@ -105,9 +105,8 @@ public final class DotCommand implements Command {
}
final Trace trace = this.animationSelector.getCurrentTrace();
final GetAllDotCommands cmd1 = new GetAllDotCommands(trace.getCurrentState());
trace.getStateSpace().execute(cmd1);
final DynamicCommandItem item = cmd1.getCommands().stream()
final DotVisualizationCommand dotCommand = DotVisualizationCommand.getAll(trace.getCurrentState())
.stream()
.filter(i -> command.equals(i.getCommand()))
.findAny()
.orElseThrow(() -> new UserErrorException("No such dot command: " + command));
......@@ -118,9 +117,8 @@ public final class DotCommand implements Command {
} catch (final IOException e) {
throw new UncheckedIOException("Failed to create temp file", e);
}
final GetSvgForVisualizationCommand cmd2 = new GetSvgForVisualizationCommand(trace.getCurrentState(), item, outPath.toFile(), dotCommandArgs);
// Provide source code (if any) to error highlighter
final Runnable execute = () -> trace.getStateSpace().execute(cmd2);
final Runnable execute = () -> dotCommand.visualizeAsSvgToFile(outPath, dotCommandArgs);
if (code != null) {
CommandUtils.withSourceCode(code, execute);
} else {
......@@ -153,7 +151,8 @@ public final class DotCommand implements Command {
final GetAllDotCommands cmd = new GetAllDotCommands(trace.getCurrentState());
trace.getStateSpace().execute(cmd);
final String prefix = commandName.substring(0, at);
final List<String> commands = cmd.getCommands().stream()
final List<String> commands = DotVisualizationCommand.getAll(trace.getCurrentState())
.stream()
.filter(DynamicCommandItem::isAvailable)
.map(DynamicCommandItem::getCommand)
.filter(s -> s.startsWith(prefix))
......
......@@ -7,12 +7,10 @@ import java.util.stream.Collectors;
import com.google.inject.Inject;
import com.google.inject.Provider;
import de.prob.animator.command.GetAllTableCommands;
import de.prob.animator.command.GetTableForVisualizationCommand;
import de.prob.animator.domainobjects.DynamicCommandItem;
import de.prob.animator.domainobjects.FormulaExpand;
import de.prob.animator.domainobjects.IEvalElement;
import de.prob.animator.domainobjects.TableData;
import de.prob.animator.domainobjects.TableVisualizationCommand;
import de.prob.statespace.AnimationSelector;
import de.prob.statespace.Trace;
import de.prob.unicode.UnicodeTranslator;
......@@ -75,15 +73,12 @@ public final class TableCommand implements Command {
final String code = kernel.insertLetVariables(args.get(EXPRESSION_PARAM));
final IEvalElement formula = CommandUtils.withSourceCode(code, () -> kernel.parseFormula(code, FormulaExpand.EXPAND));
final GetAllTableCommands cmd1 = new GetAllTableCommands(trace.getCurrentState());
trace.getStateSpace().execute(cmd1);
final DynamicCommandItem dc = cmd1.getCommands().stream()
final TableData table = TableVisualizationCommand.getAll(trace.getCurrentState())
.stream()
.filter(c -> "expr_as_table".equals(c.getCommand()))
.findAny()
.orElseThrow(AssertionError::new);
final GetTableForVisualizationCommand cmd2 = new GetTableForVisualizationCommand(trace.getCurrentState(), dc, Collections.singletonList(formula));
trace.getStateSpace().execute(cmd2);
final TableData table = cmd2.getTable();
.orElseThrow(AssertionError::new)
.visualize(Collections.singletonList(formula));
final StringBuilder sbPlain = new StringBuilder();
final StringBuilder sbMarkdown = new StringBuilder();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment