Search in sources :

Example 1 with CombinedPlot

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;
}
Also used : XYChart(com.twosigma.beakerx.chart.xychart.XYChart) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot)

Example 2 with CombinedPlot

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();
}
Also used : CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 3 with CombinedPlot

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);
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 4 with CombinedPlot

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");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 5 with CombinedPlot

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");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Aggregations

CombinedPlot (com.twosigma.beakerx.chart.xychart.CombinedPlot)15 Test (org.junit.Test)14 KernelTest (com.twosigma.beakerx.KernelTest)13 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)12 SimpleTimePlot (com.twosigma.beakerx.chart.xychart.SimpleTimePlot)4 Plot (com.twosigma.beakerx.chart.xychart.Plot)3 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)1 XYChart (com.twosigma.beakerx.chart.xychart.XYChart)1