@Test public void testDoOnDraw() throws Exception { Context context = Mockit.setUpMock(new MockContext()); XYPlot plot = new XYPlot(context, "Test", Plot.RenderMode.USE_MAIN_THREAD); SimpleXYSeries s1 = new SimpleXYSeries((Arrays.asList(1, 2, 3)), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1"); plot.addSeries(s1, new LineAndPointFormatter( Color.RED, Color.GREEN, Color.BLUE, (PointLabelFormatter)null)); assertEquals(1, plot.getSeriesSet().size()); Deencapsulation.invoke(plot, "onSizeChanged", 100, 100, 100, 100); plot.redraw(); Deencapsulation.invoke(plot, "onDraw", new Canvas()); plot.removeSeries(s1); assertEquals(0, plot.getSeriesSet().size()); plot.addSeries(s1, new BarFormatter(Color.RED, Color.GREEN)); plot.redraw(); Deencapsulation.invoke(plot, "onDraw", new Canvas()); }
@Override protected synchronized void doOnDraw(Canvas canvas, RectF widgetRect) { if(plot.isEmpty()) { return; } TreeSet<Map.Entry<XYRegionFormatter, String>> sortedRegions = new TreeSet<Map.Entry<XYRegionFormatter, String>>(new RegionEntryComparator()); int seriesCount = 0; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if(sfl != null) { seriesCount += sfl.size(); } Hashtable<XYRegionFormatter, String> urf = renderer.getUniqueRegionFormatters(); sortedRegions.addAll(urf.entrySet()); } seriesCount += sortedRegions.size(); Iterator<RectF> it = tableModel.getIterator(widgetRect, seriesCount); RectF cellRect; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList<XYSeries,XYSeriesFormatter> sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if (sfl != null) { for (int i = 0; i < sfl.size() && it.hasNext(); i++) { cellRect = it.next(); XYSeriesFormatter formatter = sfl.getFormatter(i); drawSeriesLegendCell(canvas, renderer, formatter, cellRect, sfl.getSeries(i).getTitle()); } } } for(Map.Entry<XYRegionFormatter, String> entry : sortedRegions) { if(!it.hasNext()) { break; } cellRect = it.next(); XYRegionFormatter formatter = entry.getKey(); drawRegionLegendCell(canvas, formatter, cellRect, entry.getValue()); } }
XYLegendWidget extends Widget { @Override protected synchronized void doOnDraw(Canvas canvas, RectF widgetRect) { if(plot.isEmpty()) { return; } TreeSet<Map.Entry<XYRegionFormatter, String>> sortedRegions = new TreeSet<Map.Entry<XYRegionFormatter, String>>(new RegionEntryComparator()); int seriesCount = 0; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if(sfl != null) { seriesCount += sfl.size(); } Hashtable<XYRegionFormatter, String> urf = renderer.getUniqueRegionFormatters(); sortedRegions.addAll(urf.entrySet()); } seriesCount += sortedRegions.size(); Iterator<RectF> it = tableModel.getIterator(widgetRect, seriesCount); RectF cellRect; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList<XYSeries,XYSeriesFormatter> sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if (sfl != null) { for (int i = 0; i < sfl.size() && it.hasNext(); i++) { cellRect = it.next(); XYSeriesFormatter formatter = sfl.getFormatter(i); drawSeriesLegendCell(canvas, renderer, formatter, cellRect, sfl.getSeries(i).getTitle()); } } } for(Map.Entry<XYRegionFormatter, String> entry : sortedRegions) { if(!it.hasNext()) { break; } cellRect = it.next(); XYRegionFormatter formatter = entry.getKey(); drawRegionLegendCell(canvas, formatter, cellRect, entry.getValue()); } } }
XYLegendWidget extends Widget { @Override protected synchronized void doOnDraw(Canvas canvas, RectF widgetRect) { if(plot.isEmpty()) { return; } TreeSet<Map.Entry<XYRegionFormatter, String>> sortedRegions = new TreeSet<Map.Entry<XYRegionFormatter, String>>(new RegionEntryComparator()); int seriesCount = 0; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if(sfl != null) { seriesCount += sfl.size(); } Hashtable<XYRegionFormatter, String> urf = renderer.getUniqueRegionFormatters(); sortedRegions.addAll(urf.entrySet()); } seriesCount += sortedRegions.size(); Iterator<RectF> it = tableModel.getIterator(widgetRect, seriesCount); RectF cellRect; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList<XYSeries,XYSeriesFormatter> sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if (sfl != null) { for (int i = 0; i < sfl.size() && it.hasNext(); i++) { cellRect = it.next(); XYSeriesFormatter formatter = sfl.getFormatter(i); drawSeriesLegendCell(canvas, renderer, formatter, cellRect, sfl.getSeries(i).getTitle()); } } } for(Map.Entry<XYRegionFormatter, String> entry : sortedRegions) { if(!it.hasNext()) { break; } cellRect = it.next(); XYRegionFormatter formatter = entry.getKey(); drawRegionLegendCell(canvas, formatter, cellRect, entry.getValue()); } } XYLegendWidget(LayoutManager layoutManager, XYPlot plot,
                          SizeMetrics widgetSizeMetrics,
                          TableModel tableModel,
                          SizeMetrics iconSizeMetrics); }
XYLegendWidget extends Widget { @Override protected synchronized void doOnDraw(Canvas canvas, RectF widgetRect) { if(plot.isEmpty()) { return; } TreeSet<Map.Entry<XYRegionFormatter, String>> sortedRegions = new TreeSet<Map.Entry<XYRegionFormatter, String>>(new RegionEntryComparator()); int seriesCount = 0; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if(sfl != null) { seriesCount += sfl.size(); } Hashtable<XYRegionFormatter, String> urf = renderer.getUniqueRegionFormatters(); sortedRegions.addAll(urf.entrySet()); } seriesCount += sortedRegions.size(); Iterator<RectF> it = tableModel.getIterator(widgetRect, seriesCount); RectF cellRect; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList<XYSeries,XYSeriesFormatter> sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if (sfl != null) { for (int i = 0; i < sfl.size() && it.hasNext(); i++) { cellRect = it.next(); XYSeriesFormatter formatter = sfl.getFormatter(i); drawSeriesLegendCell(canvas, renderer, formatter, cellRect, sfl.getSeries(i).getTitle()); } } } for(Map.Entry<XYRegionFormatter, String> entry : sortedRegions) { if(!it.hasNext()) { break; } cellRect = it.next(); XYRegionFormatter formatter = entry.getKey(); drawRegionLegendCell(canvas, formatter, cellRect, entry.getValue()); } } XYLegendWidget(LayoutManager layoutManager, XYPlot plot,
                          SizeMetrics widgetSizeMetrics,
                          TableModel tableModel,
                          SizeMetrics iconSizeMetrics); synchronized void setTableModel(TableModel tableModel); Paint getTextPaint(); void setTextPaint(Paint textPaint); boolean isDrawIconBackgroundEnabled(); void setDrawIconBackgroundEnabled(boolean drawIconBackgroundEnabled); boolean isDrawIconBorderEnabled(); void setDrawIconBorderEnabled(boolean drawIconBorderEnabled); TableModel getTableModel(); SizeMetrics getIconSizeMetrics(); void setIconSizeMetrics(SizeMetrics iconSizeMetrics); }
XYLegendWidget extends Widget { @Override protected synchronized void doOnDraw(Canvas canvas, RectF widgetRect) { if(plot.isEmpty()) { return; } TreeSet<Map.Entry<XYRegionFormatter, String>> sortedRegions = new TreeSet<Map.Entry<XYRegionFormatter, String>>(new RegionEntryComparator()); int seriesCount = 0; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if(sfl != null) { seriesCount += sfl.size(); } Hashtable<XYRegionFormatter, String> urf = renderer.getUniqueRegionFormatters(); sortedRegions.addAll(urf.entrySet()); } seriesCount += sortedRegions.size(); Iterator<RectF> it = tableModel.getIterator(widgetRect, seriesCount); RectF cellRect; for(XYSeriesRenderer renderer : plot.getRendererList()) { SeriesAndFormatterList<XYSeries,XYSeriesFormatter> sfl = plot.getSeriesAndFormatterListForRenderer(renderer.getClass()); if (sfl != null) { for (int i = 0; i < sfl.size() && it.hasNext(); i++) { cellRect = it.next(); XYSeriesFormatter formatter = sfl.getFormatter(i); drawSeriesLegendCell(canvas, renderer, formatter, cellRect, sfl.getSeries(i).getTitle()); } } } for(Map.Entry<XYRegionFormatter, String> entry : sortedRegions) { if(!it.hasNext()) { break; } cellRect = it.next(); XYRegionFormatter formatter = entry.getKey(); drawRegionLegendCell(canvas, formatter, cellRect, entry.getValue()); } } XYLegendWidget(LayoutManager layoutManager, XYPlot plot,
                          SizeMetrics widgetSizeMetrics,
                          TableModel tableModel,
                          SizeMetrics iconSizeMetrics); synchronized void setTableModel(TableModel tableModel); Paint getTextPaint(); void setTextPaint(Paint textPaint); boolean isDrawIconBackgroundEnabled(); void setDrawIconBackgroundEnabled(boolean drawIconBackgroundEnabled); boolean isDrawIconBorderEnabled(); void setDrawIconBorderEnabled(boolean drawIconBorderEnabled); TableModel getTableModel(); SizeMetrics getIconSizeMetrics(); void setIconSizeMetrics(SizeMetrics iconSizeMetrics);  }