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;
}
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();
}
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);
}
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() {
};
}
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());
}
Aggregations