Search in sources :

Example 6 with ConstantLine

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

the class PlotTest method addListOfPlotObjects_hasAllPlotObjects.

@Test
public void addListOfPlotObjects_hasAllPlotObjects() {
    // given
    Rasters rasters = new Rasters();
    List<Number> value = Collections.singletonList(1);
    rasters.setY(value);
    rasters.setWidth(value);
    rasters.setHeight(value);
    // when
    plot.add(Arrays.asList(line, new ConstantLine(), new ConstantBand(), rasters, new Text()));
    // then
    assertThat(plot.getGraphics().size()).isEqualTo(1);
    assertThat(plot.getConstantLines().size()).isEqualTo(1);
    assertThat(plot.getConstantBands().size()).isEqualTo(1);
    assertThat(plot.getRasters().size()).isEqualTo(1);
    assertThat(plot.getTexts().size()).isEqualTo(1);
}
Also used : Rasters(com.twosigma.beakerx.chart.xychart.plotitem.Rasters) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) Text(com.twosigma.beakerx.chart.xychart.plotitem.Text) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Example 7 with ConstantLine

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

the class ChartToJson method serializeConstantLines.

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

Example 8 with ConstantLine

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

the class XYChartSerializerTest method serializeConstantLinesOfXYChartPlot_resultJsonHasConstantLines.

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

Example 9 with ConstantLine

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

the class ConstantLineSerializerTest method serializeYAxisConstantLine_resultJsonHasYAxis.

@Test
public void serializeYAxisConstantLine_resultJsonHasYAxis() throws IOException {
    // when
    ConstantLine constantLine = new ConstantLine();
    constantLine.setyAxis("Y Axis name");
    constantLineSerializer.serialize(constantLine, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("yAxis")).isTrue();
    Assertions.assertThat(actualObj.get("yAxis").asText()).isEqualTo("Y Axis name");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Example 10 with ConstantLine

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

the class ConstantLineSerializerTest method serializeColorConstantLine_resultJsonHasColor.

@Test
public void serializeColorConstantLine_resultJsonHasColor() throws IOException {
    // when
    ConstantLine constantLine = new ConstantLine();
    constantLine.setColor(Color.GREEN);
    constantLineSerializer.serialize(constantLine, 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) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Aggregations

ConstantLine (com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine)14 Test (org.junit.Test)13 JsonNode (com.fasterxml.jackson.databind.JsonNode)11 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)11 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 ConstantBand (com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand)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