/** * Renders the plot onto a canvas. Used by both main thread to draw directly onto the View's * canvas as well as by background draw to render onto a Bitmap buffer. At the end of the day this * is the main entry for a plot's "heavy lifting". * * @param canvas */ protected synchronized void renderOnCanvas(Canvas canvas) { try { // any series interested in synchronizing with plot should // implement PlotListener.onBeforeDraw(...) and do a read lock from within its // invocation. This is the entry point into that call: notifyListenersBeforeDraw(canvas); try { // need to completely erase what was on the canvas before redrawing, otherwise // some odd aliasing artifacts begin to build up around the edges of aa'd entities // over time. canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); if (backgroundPaint != null) { drawBackground(canvas, displayDims.marginatedRect); } layoutManager.draw(canvas); if (getBorderPaint() != null) { drawBorder(canvas, displayDims.marginatedRect); } } catch (PlotRenderException e) { Log.e(TAG, "Exception while rendering Plot.", e); } catch (Exception e) { Log.e(TAG, "Exception while rendering Plot.", e); } } finally { isIdle = true; // any series interested in synchronizing with plot should // implement PlotListener.onAfterDraw(...) and do a read unlock from within that // invocation. This is the entry point for that invocation. notifyListenersAfterDraw(canvas); } }