Search in sources :

Example 1 with Text

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

the class ChartToJson method serializeTexts.

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

Example 2 with Text

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

the class XYChartSerializerTest method serializeTextsOfXYChartPlot_resultJsonHasTexts.

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

Example 3 with Text

use of com.twosigma.beakerx.chart.xychart.plotitem.Text 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 4 with Text

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

the class TextSerializerTest method initTestStubData.

@Before
public void initTestStubData() throws IOException {
    sw = new StringWriter();
    jgen = mapper.getJsonFactory().createJsonGenerator(sw);
    text = new Text() {
    };
}
Also used : StringWriter(java.io.StringWriter) Text(com.twosigma.beakerx.chart.xychart.plotitem.Text) Before(org.junit.Before)

Example 5 with Text

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

the class XYChartTest method shouldSendCommMsgWhenAddTextByLeftShift.

@Test
public void shouldSendCommMsgWhenAddTextByLeftShift() throws Exception {
    // given
    XYChart xyChart = createWidget();
    Text text = new Text();
    // when
    xyChart.leftShift(text);
    // then
    assertThat(xyChart.getTexts().get(0)).isEqualTo(text);
    List valueAsArray = getValueAsArray(TEXTS);
    Map actual = (Map) valueAsArray.get(0);
    assertThat(actual.get(TextSerializer.TYPE)).isEqualTo(Text.class.getSimpleName());
}
Also used : Text(com.twosigma.beakerx.chart.xychart.plotitem.Text) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AbstractChartTest(com.twosigma.beakerx.chart.AbstractChartTest) Test(org.junit.Test)

Aggregations

Text (com.twosigma.beakerx.chart.xychart.plotitem.Text)5 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)1 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 ConstantBand (com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand)1 ConstantLine (com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine)1 Rasters (com.twosigma.beakerx.chart.xychart.plotitem.Rasters)1 StringWriter (java.io.StringWriter)1 Map (java.util.Map)1 Before (org.junit.Before)1