use of com.twosigma.beakerx.widget.DisplayableWidget in project beakerx by twosigma.
the class ScalaEvaluatorTest method displayTable.
@Test
public void displayTable() throws Exception {
// given
String code = "val table = new TableDisplay(new CSV().readFile(\"src/test/resources/tableRowsTest.csv\"))\n" + "table";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = scalaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result() instanceof DisplayableWidget).isTrue();
}
use of com.twosigma.beakerx.widget.DisplayableWidget in project beakerx by twosigma.
the class MIMEContainerFactory method createMIMEContainersFromObject.
private static List<MIMEContainer> createMIMEContainersFromObject(final Object data) {
Object input = DisplayerDataMapper.convert(data);
if (input instanceof DisplayableWidget) {
((DisplayableWidget) input).display();
return HIDDEN_MIME;
}
TableDisplay table = getTableDisplay(input);
if (table != null) {
table.display();
return HIDDEN_MIME;
}
if (input instanceof Collection) {
return singletonList(MIMEContainer.Text(collectionToString((Collection<?>) input)));
}
if (input instanceof XYGraphics) {
new Plot().add((XYGraphics) input).display();
return HIDDEN_MIME;
}
if (input instanceof MIMEContainer) {
return singletonList((MIMEContainer) input);
}
return Displayers.display(input).entrySet().stream().map(item -> new MIMEContainer(item.getKey(), item.getValue())).collect(Collectors.toList());
}
Aggregations