Example usage for android.graphics Canvas translate

List of usage examples for android.graphics Canvas translate

Introduction

In this page you can find the example usage for android.graphics Canvas translate.

Prototype

public void translate(float dx, float dy) 

Source Link

Document

Preconcat the current matrix with the specified translation

Usage

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardView.java

@Override
public void onDraw(Canvas canvas) {
    final boolean keyboardChanged = mKeyboardChanged;
    super.onDraw(canvas);
    // switching animation
    if (mAnimationLevel != AnimationsLevel.None && keyboardChanged && (mInAnimation != null)) {
        startAnimation(mInAnimation);//from www.  j  a va  2  s. c o  m
        mInAnimation = null;
    }
    // text pop out animation
    if (mPopOutText != null && mAnimationLevel != AnimationsLevel.None) {
        final int maxVerticalTravel = getHeight() / 2;
        final long currentAnimationTime = SystemClock.elapsedRealtime() - mPopOutTime;
        if (currentAnimationTime > TEXT_POP_OUT_ANIMATION_DURATION) {
            mPopOutText = null;
        } else {
            final float popOutPositionProgress = ((float) currentAnimationTime)
                    / ((float) TEXT_POP_OUT_ANIMATION_DURATION);
            final float animationProgress = mPopOutTextReverting ? 1f - popOutPositionProgress
                    : popOutPositionProgress;
            final float animationInterpolatorPosition = getPopOutAnimationInterpolator(false,
                    animationProgress);
            final int y = mPopOutStartPoint.y - (int) (maxVerticalTravel * animationInterpolatorPosition);
            final int x = mPopOutStartPoint.x;
            final int alpha = mPopOutTextReverting ? (int) (255 * animationProgress)
                    : 255 - (int) (255 * animationProgress);
            // drawing
            setPaintToKeyText(mPaint);
            // will disappear over time
            mPaint.setAlpha(alpha);
            mPaint.setShadowLayer(5, 0, 0, Color.BLACK);
            // will grow over time
            mPaint.setTextSize(mPaint.getTextSize() * (1.0f + animationInterpolatorPosition));
            canvas.translate(x, y);
            canvas.drawText(mPopOutText, 0, mPopOutText.length(), 0, 0, mPaint);
            canvas.translate(-x, -y);
            //we're doing reverting twice much faster
            if (mPopOutTextReverting) {
                mPopOutTime = mPopOutTime - (int) (60 * popOutPositionProgress);
            }
            // next frame
            postInvalidateDelayed(1000 / 60);// doing 60 frames per second;
        }
    }
    //showing alpha/beta icon if needed
    if (BuildConfig.TESTING_BUILD) {
        final float textSizeForBuildSign = mPaint.getTextSize() / 2f;
        final float x = getWidth() - (mBuildTypeSignText.length() * textSizeForBuildSign);
        final float y = getHeight() - textSizeForBuildSign - getPaddingBottom();
        canvas.translate(x, y);
        canvas.drawText(mBuildTypeSignText, 0, mBuildTypeSignText.length(), 0, 0, mBuildTypeSignPaint);
        canvas.translate(-x, -y);
    }
}

From source file:com.jzh.stuapp.view.MyViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mLeftEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();

            canvas.rotate(270);//from ww  w.java2s .  c o m
            canvas.translate(-height + getPaddingTop(), 0);
            mLeftEdge.setSize(height, getWidth());
            needsInvalidate |= mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mRightEdge.setSize(height, width);
            needsInvalidate |= mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
    }

    if (needsInvalidate) {
        invalidate();
    }
}

From source file:com.yimeng.babymom.view.LazyViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mLeftEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();

            canvas.rotate(270);/*  w  w w.j  a va2  s  . c  o m*/
            canvas.translate(-height + getPaddingTop(), 0);
            mLeftEdge.setSize(getWidth(), height);
            needsInvalidate = mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mRightEdge.setSize(width, height);
            needsInvalidate |= mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    }
}

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  www. j  av  a2  s. c  o  m
    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());
        }
    }
}

From source file:com.cssweb.android.view.PriceView.java

public void drawIndex(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);/*from  w  w  w. j  av a2s  .co  m*/
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);
    this.x = 0;
    this.y = 0;
    startX = x + tips / 2;
    endX = width - tips / 2;
    canvas.drawRect(startX, DY + DY / 4, endX, height - DY / 4, tPaint);
    canvas.drawLine(startX, DY * 7 + DY / 2, endX, DY * 7 + DY / 2, tPaint);
    canvas.drawLine(startX, DY * 18 + DY / 4, endX, DY * 18 + DY / 4, tPaint);
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            double zrsp = jo.getDouble("zrsp");

            paint.setTextSize(mTextSize);
            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(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 * 1.5f);
            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(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, -DY * 15.5f);
            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("a"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("b"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("govbond"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("fund"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("warrant"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("bond"), true), x - tips, y, paint);

            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);
            canvas.translate(0, DY * 1.5f);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText(Utils.dataFormation(zrsp, stockdigit), x - tips, y, paint);

            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);
            }
            canvas.translate(0, DY);
            String zhangdie = Utils.dataFormation(zhangd, stockdigit);
            if (zhangdie.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangdie, x - tips, 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, stockdigit);
            if (zhangfu.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangfu + "%", x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("amp") * 100, 1) + "%", x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjsl"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), 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);

            canvas.translate(-width, DY * 1.7f);

            paint.setTextSize(mTextSize);
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(width / 2, 0);
            canvas.drawText(String.valueOf(jo.getInt("zj")), x, y, paint);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(width / 2, 0);
            canvas.drawText(String.valueOf(jo.getInt("dj")), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mLeftEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();

            canvas.rotate(270);/*from ww w . ja  va  2 s.  c  om*/
            canvas.translate(-height + getPaddingTop(), 0);
            mLeftEdge.setSize(height, getWidth());
            needsInvalidate |= mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mRightEdge.setSize(height, width);
            needsInvalidate |= mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating  
        invalidate();
    }
}

From source file:com.cssweb.android.view.PriceView.java

public void drawHKPrice(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);//  w  w w . j  ava 2  s . co  m
    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+DY/4, endX, DY+DY/4, tPaint);
    canvas.drawLine(startX, DY * 5 + DY / 4, endX, DY * 5 + DY / 4, tPaint);
    canvas.drawLine(startX, DY * 10 + DY / 4, endX, DY * 10 + 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);
            //
            //            paint.setTextAlign(Paint.Align.RIGHT);
            //            canvas.translate(width/2, 0);
            //            if(jo.getDouble("wb")<0)
            //               paint.setColor(GlobalColor.colorPriceDown);
            //            else if(jo.getDouble("wb")>0)
            //               paint.setColor(GlobalColor.colorpriceUp);
            //            else 
            //               paint.setColor(GlobalColor.colorPriceEqual);
            //            canvas.drawText(Utils.dataFormation(jo.getDouble("wb")*100, 1)+"%", x, y, paint);
            //            
            //            paint.setTextAlign(Paint.Align.LEFT);
            //            paint.setColor(GlobalColor.colorLabelName);
            //            canvas.drawText("", x+tips, y, paint);
            //
            //            paint.setTextAlign(Paint.Align.RIGHT);
            //            canvas.translate(width/2, 0);
            //            if(jo.getDouble("wc")<0) {
            //               paint.setColor(GlobalColor.colorPriceDown);
            //               canvas.drawText("-" + Utils.getAmountFormat(Math.abs(jo.getDouble("wc")), true), x-tips, y, paint);
            //            }
            //            else if(jo.getDouble("wc")>0) {
            //               paint.setColor(GlobalColor.colorpriceUp);
            //               canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), true), x-tips, y, paint);
            //            }
            //            else {
            //               paint.setColor(GlobalColor.colorPriceEqual);
            //               canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), 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);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 5; i >= 1; i--) {
                double temp2 = jo.getDouble("sjw" + i);
                setColor(paint, temp2, zrsp);
                str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
                canvas.drawText(str, x, y, paint);
                if (i != 1)
                    canvas.translate(0, DY);
            }

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 5; i >= 1; i--) {
                paint.setTextAlign(Paint.Align.RIGHT);
                canvas.drawText(Utils.getAmountFormat(jo.getInt("ssl" + i), false), x - tips, y, paint);
                if (i != 1)
                    canvas.translate(0, DY);
            }

            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(width / 2, -DY * 4);
            paint.setTextAlign(Paint.Align.RIGHT);
            for (int i = 1; i <= 5; i++) {
                double temp2 = jo.getDouble("bjw" + i);
                setColor(paint, temp2, zrsp);
                str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
                canvas.drawText(str, x, y, paint);
                if (i != 5)
                    canvas.translate(0, DY);
            }

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 1; i <= 5; i++) {
                paint.setTextAlign(Paint.Align.RIGHT);
                canvas.drawText(Utils.getAmountFormat(jo.getInt("bsl" + i), false), x - tips, y, paint);
                if (i != 5)
                    canvas.translate(0, DY);
            }

            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(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 6);

            paint.setTextAlign(Paint.Align.RIGHT);
            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit, jo.getInt("tp")), 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, jo.getInt("tp"));
            if (zhangdie.equals("-") || 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, jo.getInt("tp"));
            if (zhangfu.equals("-") || 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.getAmountFormat(jo.getInt("cjsl"), false), x, y, paint);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), false), x, y, paint);
            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("msgs"), 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.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, jo.getInt("tp")), x - tips, y, paint);

            canvas.translate(0, DY);
            double zg = jo.getDouble("zgcj");
            setColor(paint, zg, zrsp);
            canvas.drawText(Utils.dataFormation(zg, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            canvas.translate(0, DY);
            double zd = jo.getDouble("zdcj");
            setColor(paint, zd, zrsp);
            canvas.drawText(Utils.dataFormation(zd, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            //            canvas.translate(0, DY);
            //            canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), false), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), false), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.cssweb.android.view.PriceView.java

public void drawHKIndex(Canvas canvas) {
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);/* w ww .  j a v  a  2  s  . c  o  m*/
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);
    this.x = 0;
    this.y = 0;
    startX = x + tips / 2;
    endX = width - tips / 2;
    canvas.drawRect(startX, DY + DY / 4, endX, height - DY / 4, tPaint);
    canvas.drawLine(startX, DY * 5 + DY / 2, endX, DY * 5 + DY / 2, tPaint);
    canvas.drawLine(startX, DY * 11 + DY / 8, endX, DY * 11 + DY / 8, 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);
            double zrsp = jo.getDouble("zrsp");

            paint.setTextSize(mTextSize);
            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(0, DY);
            canvas.drawText("", x + tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            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(0, DY * 1.5f);
            //            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, -DY * 13f);
            paint.setTextAlign(Paint.Align.RIGHT);

            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);

            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x - tips, y, paint);

            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);
            }
            canvas.translate(0, DY);
            String zhangdie = Utils.dataFormation(zhangd, stockdigit);
            if (zhangdie.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangdie, x - tips, 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, stockdigit);
            if (zhangfu.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangfu + "%", x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("amp") * 100, 1) + "%", x - tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText(Utils.dataFormation(zrsp, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            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.colorStockName);
            //canvas.translate(0, DY);
            //canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjsl"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x - tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            //canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1), x - tips, y, paint);

            paint.setColor(GlobalColor.colorpriceUp);
            //canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("zj")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceEqual);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("pj")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("dj")), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.guodong.sun.guodong.widget.ZoomImageView.java

@Override
protected void onDraw(Canvas canvas) {
    if (getDrawable() == null) {
        return; // couldn't resolve the URI
    }/*from  w ww  . ja  v a  2s  .co  m*/

    if (mState == STATE_TRANSFORM_IN || mState == STATE_TRANSFORM_OUT) {
        if (mTransformStart) {
            initTransform();
        }
        if (mTransfrom == null) {
            super.onDraw(canvas);
            return;
        }

        if (mTransformStart) {
            if (mState == STATE_TRANSFORM_IN) {
                mTransfrom.initStartIn();
            } else {
                mTransfrom.initStartOut();
            }
        }

        if (mTransformStart) {
            Log.d("Dean", "mTransfrom.startScale:" + mTransfrom.startScale);
            Log.d("Dean", "mTransfrom.startScale:" + mTransfrom.endScale);
            Log.d("Dean", "mTransfrom.scale:" + mTransfrom.scale);
            Log.d("Dean", "mTransfrom.startRect:" + mTransfrom.startRect.toString());
            Log.d("Dean", "mTransfrom.endRect:" + mTransfrom.endRect.toString());
            Log.d("Dean", "mTransfrom.rect:" + mTransfrom.rect.toString());
        }

        mPaint.setAlpha(mBgAlpha);
        canvas.drawPaint(mPaint);

        int saveCount = canvas.getSaveCount();
        canvas.save();
        // ?Matrix
        getBmpMatrix();
        canvas.translate(mTransfrom.rect.left, mTransfrom.rect.top);
        canvas.clipRect(0, 0, mTransfrom.rect.width, mTransfrom.rect.height);
        canvas.concat(mSmoothMatrix);
        getDrawable().draw(canvas);
        canvas.restoreToCount(saveCount);
        if (mTransformStart) {
            mTransformStart = false;
            startTransform(mState);
        }
    } else {
        //Transform In???Activity??
        mPaint.setAlpha(255);
        canvas.drawPaint(mPaint);
        super.onDraw(canvas);
    }
}

From source file:com.cssweb.android.view.PriceView.java

public void drawPrice(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);//from w w w .  ja v  a 2 s . 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 + DY / 4, endX, DY + DY / 4, tPaint);
    canvas.drawLine(startX, DY * 6 + DY / 4, endX, DY * 6 + 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);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, 0);
            if (jo.getDouble("wb") < 0)
                paint.setColor(GlobalColor.colorPriceDown);
            else if (jo.getDouble("wb") > 0)
                paint.setColor(GlobalColor.colorpriceUp);
            else
                paint.setColor(GlobalColor.colorPriceEqual);
            if (jo.getInt("tp") == 1)
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(Utils.dataFormation(jo.getDouble("wb") * 100, 1) + "%", x, y, paint);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, 0);
            if (jo.getDouble("wc") < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
                canvas.drawText("-" + Utils.getAmountFormat(Math.abs(jo.getDouble("wc")), true), x - tips, y,
                        paint);
            } else if (jo.getDouble("wc") > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
                canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), true), x - tips, y, paint);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
                canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), false), 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);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 5; i >= 1; i--) {
                double temp2 = jo.getDouble("sjw" + i);
                setColor(paint, temp2, zrsp);
                str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
                //paint.setTextAlign(Paint.Align.CENTER);
                canvas.drawText(str, x, y, paint);
                if (i != 1)
                    canvas.translate(0, DY);
            }

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 5; i >= 1; i--) {
                paint.setTextAlign(Paint.Align.RIGHT);
                canvas.drawText(Utils.getAmountFormat(jo.getInt("ssl" + i), false), x - tips, y, paint);
                if (i != 1)
                    canvas.translate(0, DY);
            }

            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(width / 2, -DY * 4);
            paint.setTextAlign(Paint.Align.RIGHT);
            for (int i = 1; i <= 5; i++) {
                double temp2 = jo.getDouble("bjw" + i);
                setColor(paint, temp2, zrsp);
                str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
                canvas.drawText(str, x, y, paint);
                if (i != 5)
                    canvas.translate(0, DY);
            }

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 1; i <= 5; i++) {
                paint.setTextAlign(Paint.Align.RIGHT);
                canvas.drawText(Utils.getAmountFormat(jo.getInt("bsl" + i), false), x - tips, y, paint);
                if (i != 5)
                    canvas.translate(0, DY);
            }

            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(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            int syjd = jo.getInt("syjd");
            switch (syjd) {
            case 1:
                canvas.drawText("()", x + tips, y, paint);
                break;
            case 2:
                canvas.drawText("()", x + tips, y, paint);
                break;
            case 3:
                canvas.drawText("()", x + tips, y, paint);
                break;
            case 4:
                canvas.drawText("()", x + tips, y, paint);
                break;
            default:
                canvas.drawText("()", x + tips, y, paint);
                break;
            }

            canvas.translate(width / 2, -DY * 7);

            paint.setTextAlign(Paint.Align.RIGHT);
            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit, jo.getInt("tp")), 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, jo.getInt("tp"));
            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, stockdigit, jo.getInt("tp"));
            if (zhangfu.equals("-") || 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.getAmountFormat(jo.getInt("cjsl"), false), x, y, paint);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), false), x, y, paint);
            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("hs") * 100, 1) + "%", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jz"), 1), x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("mgsy"), 2), x, y, paint);

            canvas.translate(0, -DY * 7);

            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(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            if (NameRule.isBond(type))
                canvas.drawText("", x + tips, y, paint);
            else
                canvas.drawText("PE()", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 7);

            paint.setTextAlign(Paint.Align.RIGHT);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            canvas.translate(0, DY);
            double zg = jo.getDouble("zgcj");
            setColor(paint, zg, zrsp);
            canvas.drawText(Utils.dataFormation(zg, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            canvas.translate(0, DY);
            double zd = jo.getDouble("zdcj");
            setColor(paint, zd, zrsp);
            canvas.drawText(Utils.dataFormation(zd, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1, jo.getInt("tp")), x - tips, y, paint);
            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), false), x - tips, y, paint);
            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("gb"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("ltsl") * 100, true), x - tips, y, paint);
            canvas.translate(0, DY);
            if (NameRule.isBond(type)) {
                canvas.drawText(Utils.dataFormation(jo.getDouble("fullprice"), 1), x - tips, y, paint);
            } else {
                canvas.drawText(Utils.dataFormation(jo.getDouble("sy"), 1), x - tips, y, paint);
            }
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}