List of usage examples for android.graphics Canvas drawText
public void drawText(@NonNull String text, float x, float y, @NonNull Paint paint)
From source file:com.zzti.fyg.widgets.SwipeProgressBar.java
private void drawBar(Canvas canvas, int height) { mPaint.setAntiAlias(true);//w w w . j a va 2s. c om Bitmap bitmap = null; if (state == FINISHED) { bitmap = getFinishedBitmap(); } else { bitmap = getBitmap(); } Matrix matrix = new Matrix(); matrix.setTranslate(bitmap.getWidth() >> 1, bitmap.getHeight() >> 1); if (mRunning) { long now = AnimationUtils.currentAnimationTimeMillis(); matrix.postRotate((now - mStartTime) % 360); } else { if (type == ROTATE) { if (state != FINISHED) { matrix.postRotate(height % 360); } } else { if (direction == 0) { if (state == RELEASE_TO_REFRESH) { matrix.postRotate(180); } } else if (direction == 1) { if (state == PULL_TO_REFRESH) { matrix.postRotate(180); } } } } dstbmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); int originalWidth = bitmap.getWidth(); int originalHeight = bitmap.getHeight(); int dstWidth = dstbmp.getWidth(); int dstHeight = dstbmp.getHeight(); int fontHeight = (int) DisplayUtil.getFontHeight(textSize); mPaint.setTextSize(textSize); mPaint.setColor(textColor); if (direction == 0) { //canvas.drawBitmap(dstbmp, (width >> 1) - ((int)mPaint.measureText(latestRefreshTime) >> 1) - drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), (mBounds.bottom - (originalHeight >> 1)) + ((originalHeight >> 1) - (dstHeight >> 1)) - (fontHeight << 1) , mPaint); canvas.drawBitmap(dstbmp, drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), (mBounds.bottom - (originalHeight >> 1)) + ((originalHeight >> 1) - (dstHeight >> 1)) - (fontHeight << 1), mPaint); mPaint.setFakeBoldText(true); canvas.drawText(tips, (width >> 1) - ((int) mPaint.measureText(tips) >> 1), (mBounds.bottom - (fontHeight << 1)), mPaint); mPaint.setFakeBoldText(false); canvas.drawText(latestRefreshTime, (width >> 1) - ((int) mPaint.measureText(latestRefreshTime) >> 1), (mBounds.bottom - fontHeight), mPaint); } else { float y = mBounds.top + ((textMarginTop + (fontHeight << 1)) >> 1) + textMarginTop - (dstHeight >> 1); // canvas.drawBitmap(dstbmp, (width >> 1) - ((int)mPaint.measureText(latestRefreshTime) >> 1) - drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), y , mPaint); canvas.drawBitmap(dstbmp, drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), y, mPaint); mPaint.setFakeBoldText(true); canvas.drawText(tips, (width >> 1) - ((int) mPaint.measureText(tips) >> 1), (mBounds.top + textMarginTop + fontHeight), mPaint); mPaint.setFakeBoldText(false); canvas.drawText(latestRefreshTime, (width >> 1) - ((int) mPaint.measureText(latestRefreshTime) >> 1), (mBounds.top + (fontHeight << 1) + (textMarginTop << 1)), mPaint); } }
From source file:com.borax12.materialdaterangepicker.date.MonthView.java
protected void drawMonthDayLabels(Canvas canvas) { int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2); int dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2); for (int i = 0; i < mNumDays; i++) { int x = (2 * i + 1) * dayWidthHalf + mEdgePadding; int calendarDay = (i + mWeekStart) % mNumDays; mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); Locale locale = Locale.getDefault(); String localWeekDisplayName = mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);//w w w .j av a 2s. c o m String weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 1, len); } if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); } } canvas.drawText(weekString, x, y, mMonthDayLabelPaint); } }
From source file:org.akop.crosswords.view.CrosswordView.java
private void renderCell(Canvas canvas, Cell cell, RectF cellRect, Paint fillPaint) { canvas.drawRect(cellRect, fillPaint); canvas.drawRect(cellRect, mCellStrokePaint); if (cell.mCircled) { canvas.drawCircle(cellRect.centerX(), cellRect.centerY(), mCircleRadius, mCircleStrokePaint); }//from w w w.j a v a 2s . c o m if (cell.mNumber != null) { mNumberTextPaint.getTextBounds(cell.mNumber, 0, cell.mNumber.length(), mTempRect); float numberX = cellRect.left + mNumberTextPadding + (mTempRect.width() / 2); float numberY = cellRect.top + mNumberTextPadding + mTempRect.height(); if (cell.mCircled) { canvas.drawText(cell.mNumber, numberX, numberY, mNumberStrokePaint); } canvas.drawText(cell.mNumber, numberX, numberY, mNumberTextPaint); } if (cell.mCheated) { Path path = new Path(); path.moveTo(cellRect.right, cellRect.bottom); path.lineTo(cellRect.right - mMarkerSideLength, cellRect.bottom); path.lineTo(cellRect.right, cellRect.bottom - mMarkerSideLength); path.close(); canvas.drawPath(path, mCheatedCellFillPaint); canvas.drawPath(path, mCellStrokePaint); } if (cell.mError) { Path path = new Path(); path.moveTo(cellRect.left, cellRect.bottom); path.lineTo(cellRect.left + mMarkerSideLength, cellRect.bottom); path.lineTo(cellRect.left, cellRect.bottom - mMarkerSideLength); path.close(); canvas.drawPath(path, mMistakeCellFillPaint); canvas.drawPath(path, mCellStrokePaint); } if (!cell.isEmpty()) { mAnswerTextPaint.getTextBounds(cell.mCharStr, 0, cell.mCharStr.length(), mTempRect); canvas.drawText(cell.mCharStr, cellRect.left + mCellSize / 2, cellRect.top + mCellSize - mAnswerTextPadding, mAnswerTextPaint); } }
From source file:org.androfarsh.widget.DragGridLayout.java
private void drawCellGrid(Canvas canvas) { if (mCellDrawable != null) { int i = 0; for (final Cell cell : mCells) { mTmpRect.set(cell.rect);/*from ww w . j a v a2 s. c om*/ final int[] stateSet = new int[] { (mEditMode ? 1 : -1) * R.attr.state_editing, (mPressedCell == cell ? 1 : -1) * android.R.attr.state_pressed }; canvas.save(); canvas.clipRect(cell.rect); mCellDrawable.setState(stateSet); mCellDrawable.setBounds(cell.rect); mCellDrawable.draw(canvas); if (mDebugMode) { mPaint.setTextAlign(Align.CENTER); mPaint.setTextSize(30); mPaint.setTypeface(Typeface.DEFAULT_BOLD); mPaint.setColor(Color.GREEN); canvas.drawText(Integer.toString(i), cell.rect.centerX(), cell.rect.centerY(), mPaint); ++i; } canvas.restore(); } } if (mDebugMode) { mPaint.setColor(Color.GREEN); mPaint.setStyle(Style.STROKE); mPaint.setStrokeWidth(1.5f); canvas.drawPath(mCellsRegion.getBoundaryPath(), mPaint); } }
From source file:com.wanikani.androidnotifier.graph.HistogramPlot.java
protected void drawBar(Canvas canvas, Samples bar, float left, float right) { long base, height; float top, tbl; Paint lpaint;/*from ww w. j a v a 2s .com*/ Paint paint; Path path; RectF rect; top = vp.getY(vp.yMax); base = 0; for (Sample sample : bar.samples) { if (sample.value > 0) { height = sample.value; if (base > vp.yMax) ; else if (base + height > vp.yMax) { path = new Path(); path.moveTo(left, vp.getY(base)); path.lineTo(left, top); path.lineTo(left + (right - left) / 3, top - 10); path.lineTo(left + (right - left) * 2 / 3, top + 5); path.lineTo(right, top); path.lineTo(right, vp.getY(base)); path.close(); canvas.drawPath(path, pas.series.get(sample.series)); } else { rect = new RectF(left, vp.getY(base + height), right, vp.getY(base)); rect.intersect(meas.plotArea); paint = pas.series.get(sample.series); paint.setStyle(Style.FILL); canvas.drawRect(rect, paint); paint.setStyle(Style.STROKE); canvas.drawRect(rect, paint); } base += height; } } if (base <= vp.yMax) { lpaint = pas.levelupPaint; tbl = vp.getY(base) - meas.headroom / 2; } else { lpaint = pas.levelupPaintInside; tbl = vp.getY(vp.yMax) + meas.margin; } if (base > 0 && drawTotal) canvas.drawText(Long.toString(base), (left + right) / 2, tbl, lpaint); }
From source file:com.codetroopers.betterpickers.radialtimepicker.AmPmCirclesView.java
@Override public void onDraw(Canvas canvas) { int viewWidth = getWidth(); if (viewWidth == 0 || !mIsInitialized) { return;// w w w . ja v a 2 s. c o m } if (!mDrawValuesReady) { int layoutXCenter = getWidth() / 2; int layoutYCenter = getHeight() / 2; int circleRadius = (int) (Math.min(layoutXCenter, layoutYCenter) * mCircleRadiusMultiplier); mAmPmCircleRadius = (int) (circleRadius * mAmPmCircleRadiusMultiplier); int textSize = mAmPmCircleRadius * 3 / 4; mPaint.setTextSize(textSize); // Line up the vertical center of the AM/PM circles with the bottom of the main circle. mAmPmYCenter = layoutYCenter - mAmPmCircleRadius / 2 + circleRadius; // Line up the horizontal edges of the AM/PM circles with the horizontal edges // of the main circle. mAmXCenter = layoutXCenter - circleRadius + mAmPmCircleRadius; mPmXCenter = layoutXCenter + circleRadius - mAmPmCircleRadius; mDrawValuesReady = true; } // We'll need to draw either a lighter blue (for selection), a darker blue (for touching) // or white (for not selected). int amColor = mUnselectedColor; int amAlpha = mUnselectedAlpha; int pmColor = mUnselectedColor; int pmAlpha = mUnselectedAlpha; if (mAmOrPm == AM) { amColor = mSelectedColor; amAlpha = mSelectedAlpha; } else if (mAmOrPm == PM) { pmColor = mSelectedColor; pmAlpha = mSelectedAlpha; } if (mAmOrPmPressed == AM) { amColor = mSelectedColor; amAlpha = mSelectedAlpha; } else if (mAmOrPmPressed == PM) { pmColor = mSelectedColor; pmAlpha = mSelectedAlpha; } // Draw the two circles. mPaint.setColor(amColor); mPaint.setAlpha(amAlpha); canvas.drawCircle(mAmXCenter, mAmPmYCenter, mAmPmCircleRadius, mPaint); mPaint.setColor(pmColor); mPaint.setAlpha(pmAlpha); canvas.drawCircle(mPmXCenter, mAmPmYCenter, mAmPmCircleRadius, mPaint); // Draw the AM/PM texts on top. mPaint.setColor(mAmPmTextColor); int textYCenter = mAmPmYCenter - (int) (mPaint.descent() + mPaint.ascent()) / 2; canvas.drawText(mAmText, mAmXCenter, textYCenter, mPaint); canvas.drawText(mPmText, mPmXCenter, textYCenter, mPaint); }
From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java
/** * Draw the 12 text values at the positions specified by the textGrid parameters. */// www . java 2s. c om private void drawTextElements(Canvas canvas, float textSize, Typeface typeface, ColorStateList textColor, String[] texts, float[] textX, float[] textY, Paint paint, int alpha, boolean showActivated, int activatedDegrees, boolean activatedOnly) { paint.setTextSize(textSize); paint.setTypeface(typeface); // The activated index can touch a range of elements. final float activatedIndex = activatedDegrees / (360.0f / NUM_POSITIONS); final int activatedFloor = (int) activatedIndex; final int activatedCeil = ((int) Math.ceil(activatedIndex)) % NUM_POSITIONS; for (int i = 0; i < 12; i++) { final boolean activated = (activatedFloor == i || activatedCeil == i); if (activatedOnly && !activated) { continue; } final int[] stateMask = new int[] { android.R.attr.state_enabled, (showActivated && activated ? android.R.attr.state_selected : 0) }; final int color = textColor.getColorForState(stateMask, 0); paint.setColor(color); paint.setAlpha(getMultipliedAlpha(color, alpha)); canvas.drawText(texts[i], textX[i], textY[i], paint); } }
From source file:com.limxing.library.PullToRefresh.SwipeProgressBar.java
private void drawBar(Canvas canvas, int height) { mPaint.setAntiAlias(true);//ww w. j av a 2 s . com Bitmap bitmap = null; if (state == FINISHED) { bitmap = getFinishedBitmap(); } else { bitmap = getBitmap(); } Matrix matrix = new Matrix(); matrix.setTranslate(bitmap.getWidth() >> 1, bitmap.getHeight() >> 1); if (mRunning) { long now = AnimationUtils.currentAnimationTimeMillis(); matrix.postRotate(((now - mStartTime) % 360) / 2); } else { if (type == ROTATE) { if (state != FINISHED) { matrix.postRotate(height % 360); } } else { if (direction == 0) { if (state == RELEASE_TO_REFRESH) { matrix.postRotate(180); } } else if (direction == 1) { if (state == PULL_TO_REFRESH) { matrix.postRotate(180); } } } } dstbmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); int originalWidth = bitmap.getWidth(); int originalHeight = bitmap.getHeight(); int dstWidth = dstbmp.getWidth(); int dstHeight = dstbmp.getHeight(); int fontHeight = (int) DisplayUtil.getFontHeight(textSize); mPaint.setTextSize(textSize); mPaint.setColor(textColor); if (direction == 0) { // canvas.drawBitmap(dstbmp, (width >> 1) - // ((int)mPaint.measureText(latestRefreshTime) >> 1) - // drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), // (mBounds.bottom - (originalHeight >> 1)) + ((originalHeight >> 1) // - (dstHeight >> 1)) - (fontHeight << 1) , mPaint); canvas.drawBitmap(dstbmp, drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), (mBounds.bottom - (originalHeight >> 1)) + ((originalHeight >> 1) - (dstHeight >> 1)) - (fontHeight << 1), mPaint); mPaint.setFakeBoldText(true); canvas.drawText(tips, (width >> 1) - ((int) mPaint.measureText(tips) >> 1), (mBounds.bottom - (fontHeight << 1)), mPaint); mPaint.setFakeBoldText(false); canvas.drawText(latestRefreshTime, (width >> 1) - ((int) mPaint.measureText(latestRefreshTime) >> 1), (mBounds.bottom - fontHeight), mPaint); } else { float y = mBounds.top + ((textMarginTop + (fontHeight << 1)) >> 1) + textMarginTop - (dstHeight >> 1); // canvas.drawBitmap(dstbmp, (width >> 1) - // ((int)mPaint.measureText(latestRefreshTime) >> 1) - // drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), // y , mPaint); canvas.drawBitmap(dstbmp, drawable_margin_left - ((dstWidth >> 1) - (originalWidth >> 1)), y, mPaint); mPaint.setFakeBoldText(true); canvas.drawText(tips, (width >> 1) - ((int) mPaint.measureText(tips) >> 1), (mBounds.top + textMarginTop + fontHeight), mPaint); mPaint.setFakeBoldText(false); canvas.drawText(latestRefreshTime, (width >> 1) - ((int) mPaint.measureText(latestRefreshTime) >> 1), (mBounds.top + (fontHeight << 1) + (textMarginTop << 1)), mPaint); } }
From source file:org.florescu.android.rangeseekbar.RangeSeekBar.java
/** * Draws text above thumbs accounting for collision * * @param canvas The canvas to draw on//from w w w . j a va 2 s . c o m */ private void drawThumbText(final Canvas canvas) { T selectedMinValue = getSelectedMinValue(); T selectedMaxValue = getSelectedMaxValue(); String minText = formatter == null ? String.valueOf(selectedMinValue) : formatter.format(selectedMinValue); String maxText = formatter == null ? String.valueOf(selectedMaxValue) : formatter.format(selectedMaxValue); if (customMinValueLabel != null && selectedMinValue.equals(absoluteMinValue)) { minText = customMinValueLabel; } if (customMaxValueLabel != null && selectedMaxValue.equals(absoluteMaxValue)) { maxText = customMaxValueLabel; } float minTextWidth = paint.measureText(minText) + offset; float minTextHalfWidth = minTextWidth / 2; float maxTextWidth = paint.measureText(maxText) + offset; float maxTextHalfWidth = maxTextWidth / 2; float minTextX = normalizedToScreen(normalizedMinValue, minTextHalfWidth) - minTextHalfWidth - mThumbHalfWidth; float maxTextX = normalizedToScreen(normalizedMaxValue, maxTextHalfWidth) - maxTextHalfWidth + mThumbHalfWidth; if (!mSingleThumb) { Pair<Float, Float> values = getTextOverlapOffset(minTextX, maxTextX, minTextWidth, maxTextWidth); minTextX = values.first; maxTextX = values.second; canvas.drawText(minText, minTextX, mDistanceToTop + mTextSize, paint); } canvas.drawText(maxText, maxTextX, mDistanceToTop + mTextSize, paint); }
From source file:com.cssweb.android.view.PriceView.java
private void drawQihuo(Canvas canvas) { //stockdigit = 0; Paint paint = this.mPaint; tPaint.setColor(GlobalColor.clrLine); tPaint.setStyle(Paint.Style.STROKE); tPaint.setStrokeWidth(1);/*from w w w . j a v a2s. c om*/ this.x = 0; this.y = 0; startX = x + tips / 2; endX = width - tips / 2; canvas.drawRect(startX, DY / 4, endX, height - DY / 4, tPaint); canvas.drawLine(startX, DY * 2 + DY / 4, endX, DY * 2 + DY / 4, tPaint); canvas.drawLine(startX, DY * 8 + DY / 4, endX, DY * 8 + DY / 4, tPaint); canvas.drawLine(startX, DY * 11 + DY / 4, endX, DY * 11 + DY / 4, tPaint); //canvas.drawLine(startX, DY*16+DY/4, endX, DY*16+DY/4, tPaint); if (quoteData != null) { try { JSONArray jArr = quoteData.getJSONArray("data"); JSONObject jo = jArr.getJSONObject(0); String str = ""; double zrsp = jo.getDouble("zrsp"); canvas.translate(0, DY); paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true); paint.setTextSize(mTextSize); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.drawText("?", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY); double temp2 = jo.getDouble("sjw1"); setColor(paint, temp2, zrsp); str = Utils.dataFormation(temp2, stockdigit); canvas.drawText(str, x, y, paint); canvas.translate(0, DY); temp2 = jo.getDouble("bjw1"); setColor(paint, temp2, zrsp); str = Utils.dataFormation(temp2, stockdigit); canvas.drawText(str, x, y, paint); canvas.translate(0, -DY); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.drawText("??", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("?", x + tips, y, paint); paint.setColor(GlobalColor.colorStockName); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY); canvas.drawText(Utils.getAmountFormat(jo.getInt("ssl1"), true), x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getInt("bsl1"), true), x - tips, y, paint); canvas.translate(-width, DY); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("?", x + tips, y, paint); canvas.translate(width / 2, -DY * 5); paint.setTextAlign(Paint.Align.RIGHT); double zjcj = jo.getDouble("zjcj"); setColor(paint, zjcj, zrsp); canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x, y, paint); canvas.translate(0, DY); double zhangd = jo.getDouble("zd"); if (zhangd < 0) { paint.setColor(GlobalColor.colorPriceDown); } else if (zhangd > 0) { paint.setColor(GlobalColor.colorpriceUp); } else { paint.setColor(GlobalColor.colorPriceEqual); } String zhangdie = Utils.dataFormation(zhangd, stockdigit); if (zhangdie.equals("-")) canvas.drawText("", x, y, paint); else canvas.drawText(zhangdie, x, y, paint); double zhangf = jo.getDouble("zf"); if (zhangf < 0) { paint.setColor(GlobalColor.colorPriceDown); } else if (zhangf > 0) { paint.setColor(GlobalColor.colorpriceUp); } else { paint.setColor(GlobalColor.colorPriceEqual); } canvas.translate(0, DY); String zhangfu = Utils.dataFormation(zhangf * 100, 1); if (zhangfu.equals("-")) canvas.drawText("", x, y, paint); else canvas.drawText(zhangfu + "%", x, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("jrjs"), stockdigit), x, y, paint); paint.setColor(GlobalColor.colorpriceUp); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), true), x, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getInt("cjsl"), true), x, y, paint); canvas.translate(0, -DY * 5); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("?", x + tips, y, paint); canvas.translate(width / 2, -DY * 5); paint.setTextAlign(Paint.Align.RIGHT); double jrkp = jo.getDouble("jrkp"); setColor(paint, jrkp, zrsp); canvas.drawText(Utils.dataFormation(jrkp, stockdigit), x - tips, y, paint); canvas.translate(0, DY); double zg = jo.getDouble("zgcj"); setColor(paint, zg, zrsp); canvas.drawText(Utils.dataFormation(zg, stockdigit), x - tips, y, paint); canvas.translate(0, DY); double zd = jo.getDouble("zdcj"); setColor(paint, zd, zrsp); canvas.drawText(Utils.dataFormation(zd, stockdigit), x - tips, y, paint); paint.setColor(GlobalColor.colorLabelName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("zrjs"), stockdigit), x - tips, y, paint); paint.setColor(GlobalColor.colorPriceDown); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), true), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x - tips, y, paint); canvas.translate(-width, DY); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.drawText("?", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("?", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText(" ", x + tips, y, paint); canvas.translate(width / 2, -DY * 2); paint.setTextAlign(Paint.Align.RIGHT); double zt = jo.getDouble("zt"); setColor(paint, zt, zrsp); canvas.drawText(Utils.dataFormation(zt, stockdigit), x, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("jrcc"), 0), x, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("jrkc"), 0), x, y, paint); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.translate(0, -DY * 2); canvas.drawText("?", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText("", x + tips, y, paint); canvas.translate(0, DY); canvas.drawText(" ", x + tips, y, paint); canvas.translate(width / 2, -DY * 2); paint.setTextAlign(Paint.Align.RIGHT); double dt = jo.getDouble("dt"); setColor(paint, dt, zrsp); canvas.drawText(Utils.dataFormation(dt, stockdigit), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("zc"), 0), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("jrpc"), 0), x - tips, y, paint); } catch (JSONException e) { Log.e(TAG, e.toString()); } } }