@Test public void addPointsAndLineToNanoPlot_nanoPlotHasGraphicsListSizeIsTwo() { NanoPlot nanoPlot = new NanoPlot(); //when nanoPlot.add(points); nanoPlot.add(line); //then Assertions.assertThat(nanoPlot.getGraphics().size()).isEqualTo(2); }
@Test public void createNanoPlotByEmptyConstructor_nanoPlotHasGraphicsListIsEmpty() { //when NanoPlot nanoPlot = new NanoPlot(); //then Assertions.assertThat(nanoPlot.getGraphics().size()).isEqualTo(0); }
@Test public void nanoPlotSubclassIsNanoPlot() { class FemtoPlot extends NanoPlot { } NanoPlot plot = new FemtoPlot(); Assertions.assertThat(NanoPlot.isNanoPlotClass(plot.getClass())).isTrue(); }
@Test public void parseNanoPlotWithPointsScript_returnNanoPlotObjectWithPoints() { //when Object result = parseClassFromScript( "def today = new Date()\n" + "def millis = today.time\n" + "def nanos = millis * 1000 * 1000g // g makes it arbitrary precision\n" + "def np = new NanoPlot()\n" + "np << new Points(x:(0..10).collect{nanos + 7 * it}, y:(0..10))"); //then Assertions.assertThat(result instanceof NanoPlot).isTrue(); NanoPlot nanoPlot = (NanoPlot) result; Assertions.assertThat(nanoPlot.getGraphics()).isNotEmpty(); }
@Override public void serialize(Text text, JsonGenerator jgen, SerializerProvider sp) throws IOException, JsonProcessingException { boolean isNanoPlot = NanoPlot.isNanoPlotClass(text.getPlotType()); jgen.writeStartObject(); jgen.writeObjectField(TYPE, SerializerUtil.getTypeName(text)); jgen.writeObjectField("x", isNanoPlot ? processLargeNumber(text.getX()) : text.getX()); jgen.writeObjectField("y", text.getY()); jgen.writeObjectField("show_pointer", text.getShowPointer()); jgen.writeObjectField("text", text.getText()); jgen.writeObjectField("pointer_angle", text.getPointerAngle()); jgen.writeObjectField("color", text.getColor()); jgen.writeObjectField("size", text.getSize()); jgen.writeEndObject(); }
@Test public void addPointsToNanoPlot_nanoPlotHasGraphicsListSizeIsOne() { NanoPlot nanoPlot = new NanoPlot(); //when nanoPlot.add(points); //then Assertions.assertThat(nanoPlot.getGraphics().size()).isEqualTo(1); }
@Override public void serialize(ConstantBand constantBand, JsonGenerator jgen, SerializerProvider sp) throws IOException, JsonProcessingException { jgen.writeStartObject(); boolean isNanoPlot = NanoPlot.isNanoPlotClass(constantBand.getPlotType()); jgen.writeObjectField(TYPE, SerializerUtil.getTypeName(constantBand)); jgen.writeObjectField("x", isNanoPlot ? processLargeNumbers(constantBand.getX()) : constantBand.getX()); jgen.writeObjectField("y", constantBand.getY()); jgen.writeObjectField("visible", constantBand.getVisible()); jgen.writeObjectField("yAxis", constantBand.getYAxis()); if (constantBand.getColor() == null){ jgen.writeObjectField("color", new Color(0, 127, 255, 127)); }else{ jgen.writeObjectField("color", constantBand.getColor()); } jgen.writeEndObject(); }
@Test public void addLineToNanoPlot_nanoPlotHasGraphicsListSizeIsOne() { NanoPlot nanoPlot = new NanoPlot(); //when nanoPlot.add(line); //then Assertions.assertThat(nanoPlot.getGraphics().size()).isEqualTo(1); }
@Override public void serialize(ConstantLine constantLine, JsonGenerator jgen, SerializerProvider sp) throws IOException, JsonProcessingException { jgen.writeStartObject(); boolean isNanoPlot = NanoPlot.isNanoPlotClass(constantLine.getPlotType()); jgen.writeObjectField(TYPE, SerializerUtil.getTypeName(constantLine)); jgen.writeObjectField("x", isNanoPlot ? processLargeNumber(constantLine.getX()) : constantLine.getX()); jgen.writeObjectField("y", constantLine.getY()); jgen.writeObjectField("visible", constantLine.getVisible()); jgen.writeObjectField("yAxis", constantLine.getYAxis()); jgen.writeObjectField("showLabel", constantLine.getShowLabel()); if (constantLine.getWidth() != null) { jgen.writeObjectField("width", constantLine.getWidth()); } if (constantLine.getStyle() != null) { jgen.writeObjectField("style", constantLine.getStyle().toString()); } if (constantLine.getColor() instanceof Color) { jgen.writeObjectField("color", constantLine.getColor()); } jgen.writeEndObject(); }
@Override public void serialize(T xyGraphics, JsonGenerator jgen, SerializerProvider sp) throws IOException { validate(xyGraphics); super.serialize(xyGraphics, jgen, sp); boolean isNanoPlot = NanoPlot.isNanoPlotClass(xyGraphics.getPlotType()); jgen.writeObjectField("x", isNanoPlot ? processLargeNumbers(xyGraphics.getX()) : xyGraphics.getX()); jgen.writeObjectField("y", xyGraphics.getY()); jgen.writeObjectField(DISPLAY_NAME, xyGraphics.getDisplayName()); if (xyGraphics.getLodFilter() != null){ jgen.writeObjectField("lod_filter", xyGraphics.getLodFilter().getText()); } List<String> toolTips = xyGraphics.getToolTips(); if (toolTips != null) { jgen.writeObjectField("tooltips", toolTips); } }