/** draw Y Text */ private void drawYText(GraphCanvasWrapper graphCanvas) { for (int i = 0; mLineGraphVO.getIncrement() * i <= mLineGraphVO.getMaxValue(); i++) { String mark = Float.toString(mLineGraphVO.getIncrement() * i); float y = yLength * mLineGraphVO.getIncrement() * i / mLineGraphVO.getMaxValue(); pMarkText.measureText(mark); pMarkText.setTextSize(20); Rect rect = new Rect(); pMarkText.getTextBounds(mark, 0, mark.length(), rect); // Log.e(TAG, "rect = height()" + rect.height()); // Log.e(TAG, "rect = width()" + rect.width()); graphCanvas.drawText(mark, -(rect.width() + 20), y - rect.height() / 2, pMarkText); } }
/** draw X Text */ private void drawXText(GraphCanvasWrapper graphCanvas) { float x = 0; float y = 0; float xGap = xLength / (mLineGraphVO.getArrGraph().get(0).getCoordinateArr().length - 1); for (int i = 0; i < mLineGraphVO.getLegendArr().length; i++) { x = xGap * i; String text = mLineGraphVO.getLegendArr()[i]; pMarkText.measureText(text); pMarkText.setTextSize(20); Rect rect = new Rect(); pMarkText.getTextBounds(text, 0, text.length(), rect); graphCanvas.drawText(text, x - (rect.width() / 2), -(20 + rect.height()), pMarkText); } }