Search in sources :

Example 6 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ChartToJson method serializeConstantBands.

public static Map<Object, Object> serializeConstantBands(List<ConstantBand> constantBands) {
    List result = new ArrayList();
    for (ConstantBand item : constantBands) {
        result.add(toJson(item));
    }
    Map<Object, Object> value = new LinkedHashMap<>();
    value.put(XYChartSerializer.CONSTANT_BANDS, toJsonList(result));
    return value;
}
Also used : ArrayList(java.util.ArrayList) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) List(java.util.List) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class XYChartSerializerTest method serializeConstantBandsOfXYChartPlot_resultJsonHasConstantBands.

@Test
public void serializeConstantBandsOfXYChartPlot_resultJsonHasConstantBands() throws IOException {
    // given
    ConstantBand constantBand = new ConstantBand();
    plot.add(constantBand);
    // when
    xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("constant_bands")).isTrue();
    Assertions.assertThat(actualObj.get("constant_bands")).isNotEmpty();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 8 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeVisibleConstantBand_resultJsonHasVisible.

@Test
public void serializeVisibleConstantBand_resultJsonHasVisible() throws IOException {
    // when
    ConstantBand constantBand = new ConstantBand();
    constantBand.setVisible(true);
    constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("visible")).isTrue();
    Assertions.assertThat(actualObj.get("visible").asBoolean()).isTrue();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 9 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeBigIntXWithNanoPlotType_resultJsonHasStringXs.

@Test
public void serializeBigIntXWithNanoPlotType_resultJsonHasStringXs() throws IOException {
    // when
    ConstantBand constantBand = new ConstantBand();
    constantBand.setX(Arrays.asList(new BigInteger("12345678901234567891000"), new BigInteger("12345678901234567892000")));
    constantBand.setPlotType(NanoPlot.class);
    constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("x")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("x");
    Assertions.assertThat(arrayNode.get(0).isTextual()).isTrue();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) BigInteger(java.math.BigInteger) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.junit.Test)

Example 10 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeColorConstantBand_resultJsonHasColor.

@Test
public void serializeColorConstantBand_resultJsonHasColor() throws IOException {
    // when
    ConstantBand constantBand = new ConstantBand();
    constantBand.setColor(Color.GREEN);
    constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("color")).isTrue();
    Assertions.assertThat(actualObj.get("color").get("rgb").asInt()).isEqualTo(Color.GREEN.getRGB());
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

ConstantBand (com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand)11 Test (org.junit.Test)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)8 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 ConstantLine (com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine)1 Rasters (com.twosigma.beakerx.chart.xychart.plotitem.Rasters)1 Text (com.twosigma.beakerx.chart.xychart.plotitem.Text)1 BigInteger (java.math.BigInteger)1 Map (java.util.Map)1