use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.
the class ChartDetails method getGraphics.
/**
* Taken from code{@code com.twosigma.beaker.groovy.rest.ChartRest#getGraphics}
*
* @param info GraphicsActionObject
* @param chart ChartDetails
* @return list of Graphics for given plot data
*/
protected List<? extends Graphics> getGraphics(GraphicsActionObject info, ChartDetails chart) {
List<? extends Graphics> graphics = null;
if (chart instanceof XYChart) {
graphics = ((XYChart) chart).getGraphics();
} else if (chart instanceof CategoryPlot) {
graphics = ((CategoryPlot) chart).getGraphics();
} else if (chart instanceof CombinedPlot) {
XYChart subplot = ((CombinedPlot) chart).getSubplots().get(((CombinedPlotActionObject) info).getSubplotIndex());
graphics = subplot.getGraphics();
}
return graphics;
}
use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.
the class PlotObjectSerializerTest method serializeCombinedPlot_returnTrue.
@Test
public void serializeCombinedPlot_returnTrue() throws Exception {
// when
boolean result = plotObjectSerializer.writeObject(new CombinedPlot(), jgen, true);
// then
Assertions.assertThat(result).isTrue();
}
use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.
the class CombinedPlotSerializerTest method serializeInitHeightOfCombinedPlot_resultJsonHasInitHeight.
@Test
public void serializeInitHeightOfCombinedPlot_resultJsonHasInitHeight() throws IOException {
// when
CombinedPlot combinedPlot = new CombinedPlot();
combinedPlot.setInitHeight(300);
combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("init_height")).isTrue();
Assertions.assertThat(actualObj.get("init_height").asInt()).isEqualTo(300);
}
use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.
the class CombinedPlotSerializerTest method serializeCombinedPlot_resultJsonHasVersion.
@Test
public void serializeCombinedPlot_resultJsonHasVersion() throws IOException {
// when
CombinedPlot combinedPlot = new CombinedPlot();
combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("version")).isTrue();
Assertions.assertThat(actualObj.get("version").asText()).isEqualTo("groovy");
}
use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.
the class CombinedPlotSerializerTest method serializeTimePlotTypeOfCombinedPlot_resultJsonHasTimePlotType.
@Test
public void serializeTimePlotTypeOfCombinedPlot_resultJsonHasTimePlotType() throws IOException {
// when
CombinedPlot combinedPlot = new CombinedPlot();
combinedPlot.add(new SimpleTimePlot(createDataForSimpleTimePlot(), Arrays.asList("m3", "time")));
combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("plot_type")).isTrue();
Assertions.assertThat(actualObj.get("plot_type").asText()).isEqualTo("TimePlot");
}
Aggregations