use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class GroovyEvaluatorChartTest method parseKeyboardCodesScript_returnLineObjectWithKeyTags.
@Test
public void parseKeyboardCodesScript_returnLineObjectWithKeyTags() {
// when
Object result = parseClassFromScript("line = new Line(y: (0..10))\n" + "line.onKey(KeyboardCodes.F1, \"tag1\")\n" + "new Plot() << line ");
// then
Assertions.assertThat(result instanceof Plot).isTrue();
Plot plot = (Plot) result;
Assertions.assertThat(plot.getGraphics().get(0).getKeyTags()).isNotEmpty();
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class JavaEvaluatorTest method evaluatePlot_shouldCreatePlotObject.
@Test
public void evaluatePlot_shouldCreatePlotObject() throws Exception {
// given
String code = "import com.twosigma.beakerx.chart.xychart.*;\n" + "Plot plot = new Plot(); plot.setTitle(\"test title\");\n" + "return plot;";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = javaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result() instanceof Plot).isTrue();
assertThat(((Plot) evaluate.result()).getTitle()).isEqualTo("test title");
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class XYChartSerializerTest method initTestStubData.
@Before
public void initTestStubData() throws IOException {
KernelManager.register(new KernelTest());
sw = new StringWriter();
jgen = mapper.getJsonFactory().createJsonGenerator(sw);
plot = new Plot();
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class TabbedOutputContainerLayoutManagerTest method shouldSendChildModel.
@Test
public void shouldSendChildModel() throws Exception {
// given
TabbedOutputContainerLayoutManager layout = new TabbedOutputContainerLayoutManager();
OutputContainer outputContainer = new OutputContainer();
outputContainer.setLayoutManager(layout);
outputContainer.addItem(new Plot(), "1990/01");
// when
outputContainer.display();
// then
Map model = getValueForProperty(plotUpdateMsg(), MODEL, Map.class);
assertTrue("Child model should be sent.", model != null);
}
use of com.twosigma.beakerx.chart.xychart.Plot 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