CandlestickRenderer extends GroupRenderer<FormatterType> { @Override public void onRender(Canvas canvas, RectF plotArea, List<SeriesBundle<XYSeries, ? extends FormatterType>> sfList, int seriesSize, RenderStack stack) { final FormatterType formatter = sfList.get(0).getFormatter(); for(int i = 0; i < seriesSize; i++) { final XYSeries highSeries = sfList.get(HIGH_INDEX).getSeries(); final XYSeries lowSeries = sfList.get(LOW_INDEX).getSeries(); final XYSeries openSeries = sfList.get(OPEN_INDEX).getSeries(); final XYSeries closeSeries = sfList.get(CLOSE_INDEX).getSeries(); Number x = highSeries.getX(i); Number high = highSeries.getY(i); Number low = lowSeries.getY(i); Number open = openSeries.getY(i); Number close = closeSeries.getY(i); final PointF highPix = getPlot().getBounds().transformScreen(x, high, plotArea); final PointF lowPix = getPlot().getBounds().transformScreen(x, low, plotArea); final PointF openPix = getPlot().getBounds().transformScreen(x, open, plotArea); final PointF closePix = getPlot().getBounds().transformScreen(x, close, plotArea); drawWick(canvas, highPix, lowPix, formatter); drawBody(canvas, openPix, closePix, formatter); drawUpperCap(canvas, highPix, formatter); drawLowerCap(canvas, lowPix, formatter); final PointLabelFormatter plf = formatter.hasPointLabelFormatter() ? formatter.getPointLabelFormatter() : null; final PointLabeler pointLabeler = formatter.getPointLabeler(); if(plf != null && pointLabeler != null) { drawTextLabel(canvas, highPix, pointLabeler.getLabel(highSeries, i), plf); drawTextLabel(canvas, lowPix, pointLabeler.getLabel(lowSeries, i), plf); drawTextLabel(canvas, openPix, pointLabeler.getLabel(openSeries, i), plf); drawTextLabel(canvas, closePix, pointLabeler.getLabel(closeSeries, i), plf); } } } CandlestickRenderer(XYPlot plot); @Override void onRender(Canvas canvas, RectF plotArea, List<SeriesBundle<XYSeries,
                ? extends FormatterType>> sfList, int seriesSize,  RenderStack stack);  }
@Test public void testOnRender() throws Exception { CandlestickFormatter formatter = spy(new CandlestickFormatter()); CandlestickRenderer renderer = spy((CandlestickRenderer) formatter.doGetRendererInstance(xyPlot)); doReturn(renderer.getClass()).when(formatter).getRendererClass(); doReturn(renderer).when(formatter).doGetRendererInstance(any(XYPlot.class)); XYSeries openVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); XYSeries closeVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); XYSeries highVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); XYSeries lowVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); CandlestickMaker.make(xyPlot, formatter, openVals, closeVals, highVals, lowVals); renderer.onRender(canvas, plotArea, openVals, formatter, renderStack); }