### Question:
ScatterGraph2DRenderer extends Graph2DRenderer<ScatterGraph2DRendererUpdate> { public void draw(Graphics2D g, Point2DDataset data) { calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange()); this.g = g; calculateLabels(); calculateGraphArea(); drawBackground(); drawGraphArea(); ListNumber xValues = data.getXValues(); ListNumber yValues = data.getYValues(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); setClip(g); g.setColor(Color.BLACK); for (int i = 0; i < xValues.size(); i++) { drawValue(g, xValues.getDouble(i), yValues.getDouble(i)); } if (interpolation != InterpolationScheme.NONE) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); drawValueLine(data.getXValues(), data.getYValues(), interpolation); } } ScatterGraph2DRenderer(int width, int height); @Override ScatterGraph2DRendererUpdate newUpdate(); @Override void update(ScatterGraph2DRendererUpdate update); void draw(Graphics2D g, Point2DDataset data); static java.util.List<InterpolationScheme> supportedInterpolationScheme; }### Answer:
@Test public void randomData() throws Exception { Point2DDataset data = randomDataset(); BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_3BYTE_BGR); ScatterGraph2DRenderer renderer = new ScatterGraph2DRenderer(300, 200); Graphics2D graphics = (Graphics2D) image.getGraphics(); renderer.draw(graphics, data); ImageAssert.compareImages("scatterGraph2D.randomData", image); }
@Test public void regularData() throws Exception { Point2DDataset data = regularDataset(); BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_3BYTE_BGR); ScatterGraph2DRenderer renderer = new ScatterGraph2DRenderer(300, 200); Graphics2D graphics = (Graphics2D) image.getGraphics(); renderer.draw(graphics, data); ImageAssert.compareImages("scatterGraph2D.regularData", image); }
@Test public void oneNaN() throws Exception { Point2DDataset data = oneNaNDataset(); BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_3BYTE_BGR); ScatterGraph2DRenderer renderer = new ScatterGraph2DRenderer(300, 200); Graphics2D graphics = (Graphics2D) image.getGraphics(); renderer.draw(graphics, data); ImageAssert.compareImages("scatterGraph2D.oneNaN", image); }