@Test public void testOnRender() throws Exception { BubbleFormatter formatter = spy(new BubbleFormatter()); BubbleRenderer br = formatter.getRendererInstance(xyPlot); BubbleRenderer renderer = spy(br); doReturn(renderer.getClass()).when(formatter).getRendererClass(); doReturn(renderer).when(formatter).getRendererInstance(any(XYPlot.class)); BubbleSeries bs = new BubbleSeries(1, 2, 3, 4, 5, 6, 7, 8, 9); xyPlot.addSeries(bs, formatter); renderer.onRender(canvas, plotArea, bs, formatter, renderStack); }
@Override protected void onRender(Canvas canvas, RectF plotArea, BubbleSeries series, FormatterType formatter, RenderStack stack) { Region magnitudeBounds = calculateBounds(); for(int i = 0; i < series.size(); i++) { if(series.getY(i) != null && series.getZ(i).doubleValue() > 0) { final PointF centerPoint = getPlot().getBounds(). transform(series.getX(i), series.getY(i), plotArea, false, true); float bubbleRadius = magnitudeBounds. transform(bubbleScaleMode == BubbleScaleMode.SQUARE_ROOT ? Math.sqrt(series.getZ(i).doubleValue()) : series.getZ(i).doubleValue(), bubbleBounds).floatValue(); drawBubble(canvas, formatter, series, i, centerPoint, bubbleRadius); } } }
BubbleRenderer extends XYSeriesRenderer<BubbleSeries, FormatterType> { @Override protected void onRender(Canvas canvas, RectF plotArea, BubbleSeries series, FormatterType formatter, RenderStack stack) { Region magnitudeBounds = calculateBounds(); for(int i = 0; i < series.size(); i++) { if(series.getY(i) != null && series.getZ(i).doubleValue() > 0) { final PointF centerPoint = getPlot().getBounds(). transform(series.getX(i), series.getY(i), plotArea, false, true); float bubbleRadius = magnitudeBounds. transform(bubbleScaleMode == BubbleScaleMode.SQUARE_ROOT ? Math.sqrt(series.getZ(i).doubleValue()) : series.getZ(i).doubleValue(), bubbleBounds).floatValue(); drawBubble(canvas, formatter, series, i, centerPoint, bubbleRadius); } } } }
BubbleRenderer extends XYSeriesRenderer<BubbleSeries, FormatterType> { @Override protected void onRender(Canvas canvas, RectF plotArea, BubbleSeries series, FormatterType formatter, RenderStack stack) { Region magnitudeBounds = calculateBounds(); for(int i = 0; i < series.size(); i++) { if(series.getY(i) != null && series.getZ(i).doubleValue() > 0) { final PointF centerPoint = getPlot().getBounds(). transform(series.getX(i), series.getY(i), plotArea, false, true); float bubbleRadius = magnitudeBounds. transform(bubbleScaleMode == BubbleScaleMode.SQUARE_ROOT ? Math.sqrt(series.getZ(i).doubleValue()) : series.getZ(i).doubleValue(), bubbleBounds).floatValue(); drawBubble(canvas, formatter, series, i, centerPoint, bubbleRadius); } } } BubbleRenderer(XYPlot plot); }
BubbleRenderer extends XYSeriesRenderer<BubbleSeries, FormatterType> { @Override protected void onRender(Canvas canvas, RectF plotArea, BubbleSeries series, FormatterType formatter, RenderStack stack) { Region magnitudeBounds = calculateBounds(); for(int i = 0; i < series.size(); i++) { if(series.getY(i) != null && series.getZ(i).doubleValue() > 0) { final PointF centerPoint = getPlot().getBounds(). transform(series.getX(i), series.getY(i), plotArea, false, true); float bubbleRadius = magnitudeBounds. transform(bubbleScaleMode == BubbleScaleMode.SQUARE_ROOT ? Math.sqrt(series.getZ(i).doubleValue()) : series.getZ(i).doubleValue(), bubbleBounds).floatValue(); drawBubble(canvas, formatter, series, i, centerPoint, bubbleRadius); } } } BubbleRenderer(XYPlot plot); float getMinBubbleRadius(); void setMinBubbleRadius(float minBubbleRadius); float getMaxBubbleRadius(); void setMaxBubbleRadius(float maxBubbleRadius); BubbleScaleMode getBubbleScaleMode(); void setBubbleScaleMode(BubbleScaleMode bubbleScaleMode); }
BubbleRenderer extends XYSeriesRenderer<BubbleSeries, FormatterType> { @Override protected void onRender(Canvas canvas, RectF plotArea, BubbleSeries series, FormatterType formatter, RenderStack stack) { Region magnitudeBounds = calculateBounds(); for(int i = 0; i < series.size(); i++) { if(series.getY(i) != null && series.getZ(i).doubleValue() > 0) { final PointF centerPoint = getPlot().getBounds(). transform(series.getX(i), series.getY(i), plotArea, false, true); float bubbleRadius = magnitudeBounds. transform(bubbleScaleMode == BubbleScaleMode.SQUARE_ROOT ? Math.sqrt(series.getZ(i).doubleValue()) : series.getZ(i).doubleValue(), bubbleBounds).floatValue(); drawBubble(canvas, formatter, series, i, centerPoint, bubbleRadius); } } } BubbleRenderer(XYPlot plot); float getMinBubbleRadius(); void setMinBubbleRadius(float minBubbleRadius); float getMaxBubbleRadius(); void setMaxBubbleRadius(float maxBubbleRadius); BubbleScaleMode getBubbleScaleMode(); void setBubbleScaleMode(BubbleScaleMode bubbleScaleMode);  }