/** * Returns a recyclable MPPointF instance. * Returns the center point of the chart (the whole View) in pixels. * * @return */ public MPPointF getCenter() { return MPPointF.getInstance(getWidth() / 2f, getHeight() / 2f); }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = mSize.width; float height = mSize.height; if (width == 0.f && mDrawable != null) { width = mDrawable.getIntrinsicWidth(); } if (height == 0.f && mDrawable != null) { height = mDrawable.getIntrinsicHeight(); } if (posX + mOffset2.x < 0) { mOffset2.x = - posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = - posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = getWidth(); float height = getHeight(); if (posX + mOffset2.x < 0) { mOffset2.x = - posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = - posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
/** * Draws the description text in the bottom right corner of the chart (per default) */ protected void drawDescription(Canvas c) { // check if description should be drawn if (mDescription != null && mDescription.isEnabled()) { MPPointF position = mDescription.getPosition(); mDescPaint.setTypeface(mDescription.getTypeface()); mDescPaint.setTextSize(mDescription.getTextSize()); mDescPaint.setColor(mDescription.getTextColor()); mDescPaint.setTextAlign(mDescription.getTextAlign()); float x, y; // if no position specified, draw on default position if (position == null) { x = getWidth() - mViewPortHandler.offsetRight() - mDescription.getXOffset(); y = getHeight() - mViewPortHandler.offsetBottom() - mDescription.getYOffset(); } else { x = position.x; y = position.y; } c.drawText(mDescription.getText(), x, y, mDescPaint); } }
/** * Returns a recyclable MPPointF instance. * Returns the center point of the chart (the whole View) in pixels. * * @return */ public MPPointF getCenter() { return MPPointF.getInstance(getWidth() / 2f, getHeight() / 2f); }
/** * Returns a recyclable MPPointF instance. * Returns the center point of the chart (the whole View) in pixels. * * @return */ public MPPointF getCenter() { return MPPointF.getInstance(getWidth() / 2f, getHeight() / 2f); }
/** * Returns a recyclable MPPointF instance. * Returns the center point of the chart (the whole View) in pixels. * * @return */ public MPPointF getCenter() { return MPPointF.getInstance(getWidth() / 2f, getHeight() / 2f); }
/** * Returns a recyclable MPPointF instance. * Returns the center point of the chart (the whole View) in pixels. * * @return */ public MPPointF getCenter() { return MPPointF.getInstance(getWidth() / 2f, getHeight() / 2f); }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = mSize.width; float height = mSize.height; if (width == 0.f && mDrawable != null) { width = mDrawable.getIntrinsicWidth(); } if (height == 0.f && mDrawable != null) { height = mDrawable.getIntrinsicHeight(); } if (posX + mOffset2.x < 0) { mOffset2.x = - posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = - posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = getWidth(); float height = getHeight(); if (posX + mOffset2.x < 0) { mOffset2.x = -posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = -posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = getWidth(); float height = getHeight(); if (posX + mOffset2.x < 0) { mOffset2.x = - posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = - posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = getWidth(); float height = getHeight(); if (posX + mOffset2.x < 0) { mOffset2.x = - posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = - posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
@Override public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) { MPPointF offset = getOffset(); mOffset2.x = offset.x; mOffset2.y = offset.y; Chart chart = getChartView(); float width = getWidth(); float height = getHeight(); if (posX + mOffset2.x < 0) { mOffset2.x = - posX; } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) { mOffset2.x = chart.getWidth() - posX - width; } if (posY + mOffset2.y < 0) { mOffset2.y = - posY; } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) { mOffset2.y = chart.getHeight() - posY - height; } return mOffset2; }
/** * Draws the description text in the bottom right corner of the chart (per default) */ protected void drawDescription(Canvas c) { // check if description should be drawn if (mDescription != null && mDescription.isEnabled()) { MPPointF position = mDescription.getPosition(); mDescPaint.setTypeface(mDescription.getTypeface()); mDescPaint.setTextSize(mDescription.getTextSize()); mDescPaint.setColor(mDescription.getTextColor()); mDescPaint.setTextAlign(mDescription.getTextAlign()); float x, y; // if no position specified, draw on default position if (position == null) { x = getWidth() - mViewPortHandler.offsetRight() - mDescription.getXOffset(); y = getHeight() - mViewPortHandler.offsetBottom() - mDescription.getYOffset(); } else { x = position.x; y = position.y; } c.drawText(mDescription.getText(), x, y, mDescPaint); } }
/** * Draws the description text in the bottom right corner of the chart (per default) */ protected void drawDescription(Canvas c) { // check if description should be drawn if (mDescription != null && mDescription.isEnabled()) { MPPointF position = mDescription.getPosition(); mDescPaint.setTypeface(mDescription.getTypeface()); mDescPaint.setTextSize(mDescription.getTextSize()); mDescPaint.setColor(mDescription.getTextColor()); mDescPaint.setTextAlign(mDescription.getTextAlign()); float x, y; // if no position specified, draw on default position if (position == null) { x = getWidth() - mViewPortHandler.offsetRight() - mDescription.getXOffset(); y = getHeight() - mViewPortHandler.offsetBottom() - mDescription.getYOffset(); } else { x = position.x; y = position.y; } c.drawText(mDescription.getText(), x, y, mDescPaint); } }
/** * Draws the description text in the bottom right corner of the chart (per default) */ protected void drawDescription(Canvas c) { // check if description should be drawn if (mDescription != null && mDescription.isEnabled()) { MPPointF position = mDescription.getPosition(); mDescPaint.setTypeface(mDescription.getTypeface()); mDescPaint.setTextSize(mDescription.getTextSize()); mDescPaint.setColor(mDescription.getTextColor()); mDescPaint.setTextAlign(mDescription.getTextAlign()); float x, y; // if no position specified, draw on default position if (position == null) { x = getWidth() - mViewPortHandler.offsetRight() - mDescription.getXOffset(); y = getHeight() - mViewPortHandler.offsetBottom() - mDescription.getYOffset(); } else { x = position.x; y = position.y; } c.drawText(mDescription.getText(), x, y, mDescPaint); } }