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