Example usage for android.graphics Paint setTypeface

List of usage examples for android.graphics Paint setTypeface

Introduction

In this page you can find the example usage for android.graphics Paint setTypeface.

Prototype

public Typeface setTypeface(Typeface typeface) 

Source Link

Document

Set or clear the typeface object.

Usage

From source file:com.cssn.samplesdk.MainActivity.java

/**
 *
 *//*from w  w  w.j a va 2s .co  m*/
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    if (Util.LOG_ENABLED) {
        Utils.appendLog(TAG, "protected void onCreate(Bundle savedInstanceState)");
    }

    // load the model
    if (savedInstanceState == null) {
        if (Util.LOG_ENABLED) {
            Utils.appendLog(TAG, "if (savedInstanceState == null)");
        }
        mainActivityModel = new MainActivityModel();
    } else {
        if (Util.LOG_ENABLED) {
            Utils.appendLog(TAG, "if (savedInstanceState != null)");
        }
        mainActivityModel = DataContext.getInstance().getMainActivityModel();
        // if coming from background and kill the app, restart the model
        if (mainActivityModel == null) {
            mainActivityModel = new MainActivityModel();
        }
    }
    DataContext.getInstance().setContext(getApplicationContext());

    String licenseKey = DataContext.getInstance().getLicenseKey();

    // load the controller instance
    acuantAndroidMobileSdkControllerInstance = AcuantAndroidMobileSDKController.getInstance(this, licenseKey);
    if (!Util.isTablet(this)) {
        acuantAndroidMobileSdkControllerInstance
                .setPdf417BarcodeImageDrawable(getResources().getDrawable(R.drawable.barcode));
    }

    acuantAndroidMobileSdkControllerInstance.setWebServiceListener(this);
    acuantAndroidMobileSdkControllerInstance.setCloudUrl("cssnwebservices.com");
    acuantAndroidMobileSdkControllerInstance.setWatermarkText("Powered By Acuant", 0, 0, 30, 0);
    DisplayMetrics metrics = this.getResources().getDisplayMetrics();

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int height = displaymetrics.heightPixels;
    int width = displaymetrics.widthPixels;
    int minLength = (int) (Math.min(width, height) * 0.9);
    int maxLength = (int) (minLength * 1.5);
    int left = minLength / 2 - 50;
    int top = maxLength / 2 - 100;
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    Typeface currentTypeFace = textPaint.getTypeface();
    Typeface bold = Typeface.create(currentTypeFace, Typeface.BOLD);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(50);
    textPaint.setTextAlign(Paint.Align.LEFT);
    textPaint.setTypeface(bold);
    Paint.FontMetrics metric = textPaint.getFontMetrics();
    acuantAndroidMobileSdkControllerInstance.setInstructionText("Blink Slowly", left, top, textPaint);
    //acuantAndroidMobileSdkControllerInstance.setShowActionBar(false);
    //acuantAndroidMobileSdkControllerInstance.setShowStatusBar(false);
    acuantAndroidMobileSdkControllerInstance.setFlashlight(false);
    //acuantAndroidMobileSdkControllerInstance.setFlashlight(0,0,50,0);
    //acuantAndroidMobileSdkControllerInstance.setFlashlightImageDrawable(getResources().getDrawable(R.drawable.lighton), getResources().getDrawable(R.drawable.lightoff));
    //acuantAndroidMobileSdkControllerInstance.setShowInitialMessage(true);
    //acuantAndroidMobileSdkControllerInstance.setCropBarcode(true);
    //acuantAndroidMobileSdkControllerInstance.setPdf417BarcodeDialogWaitingBarcode("AcuantAndroidMobileSampleSDK","ALIGN AND TAP", 10, "Try Again", "Yes");
    acuantAndroidMobileSdkControllerInstance.setCanShowBracketsOnTablet(true);
    // load several member variables
    setContentView(R.layout.activity_main);

    layoutCards = (LinearLayout) findViewById(R.id.cardImagesLayout);
    layoutBackImage = (RelativeLayout) findViewById(R.id.relativeLayoutBackImage);
    layoutFrontImage = (RelativeLayout) findViewById(R.id.relativeLayoutFrontImage);

    frontImageView = (ImageView) findViewById(R.id.frontImageView);
    backImageView = (ImageView) findViewById(R.id.backImageView);

    editTextLicense = (EditText) findViewById(R.id.editTextLicenceKey);
    editTextLicense.setText(DataContext.getInstance().getLicenseKey());

    txtTapToCaptureFront = (TextView) findViewById(R.id.txtTapToCaptureFront);
    txtTapToCaptureBack = (TextView) findViewById(R.id.txtTapToCaptureBack);

    activateLicenseButton = (Button) findViewById(R.id.activateLicenseButton);

    processCardButton = (Button) findViewById(R.id.processCardButton);
    processCardButton.setVisibility(View.INVISIBLE);

    editTextLicense.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            validateLicenseKey(editTextLicense.getText().toString());
            DataContext.getInstance().setLicenseKey(editTextLicense.getText().toString());
            return true;
        }
    });

    // it is necessary to use a post UI call, because of the previous set text on 'editTextLicense'
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            editTextLicense.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    mainActivityModel.setState(State.NO_VALIDATED);
                    updateActivateLicenseButtonFromModel();
                }

                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }
            });
        }
    });

    editTextLicense.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                hideVirtualKeyboard();
            }
        }
    });

    // update the UI from the model
    updateUI();
    acuantAndroidMobileSdkControllerInstance.setCardCroppingListener(this);
    acuantAndroidMobileSdkControllerInstance.setAcuantErrorListener(this);
    if (Utils.LOG_ENABLED) {
        Utils.appendLog(TAG, "getScreenOrientation()=" + Util.getScreenOrientation(this));
    }
}

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

protected void setPaintForLabelText(Paint paint) {
    paint.setTextSize(mLabelTextSize);
    paint.setTypeface(Typeface.DEFAULT_BOLD);
}

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

protected void setPaintToKeyText(final Paint paint) {
    paint.setTextSize(mKeyTextSize);
    paint.setTypeface(mKeyTextStyle);
}

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 ww  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());
        }
    }
}

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);//from w ww. j  a v a 2s.  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 drawPrice(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);//from   ww w  .j  a  v  a 2s . 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 * 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());
        }
    }
}

From source file:biz.bokhorst.xprivacy.ActivityMain.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    int userId = Util.getUserId(Process.myUid());
    boolean mounted = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
    boolean updates = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingUpdates, false);

    menu.findItem(R.id.menu_export).setEnabled(mounted);
    menu.findItem(R.id.menu_import).setEnabled(mounted);

    menu.findItem(R.id.menu_submit).setEnabled(Util.hasValidFingerPrint(this));

    menu.findItem(R.id.menu_pro).setVisible(!Util.isProEnabled() && Util.hasProLicense(this) == null);

    menu.findItem(R.id.menu_dump).setVisible(Util.isDebuggable(this));

    menu.findItem(R.id.menu_update).setVisible(updates);
    menu.findItem(R.id.menu_update).setEnabled(mounted);

    // Update filter count

    // Get settings
    boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
    boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
    boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
    boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
    boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
    boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
    boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);

    // Count number of active filters
    int numberOfFilters = 0;
    if (fUsed)/*from   w  w w.  j  av  a 2  s.c  o m*/
        numberOfFilters++;
    if (fInternet)
        numberOfFilters++;
    if (fRestriction)
        numberOfFilters++;
    if (fPermission)
        numberOfFilters++;
    if (fOnDemand)
        numberOfFilters++;
    if (fUser)
        numberOfFilters++;
    if (fSystem)
        numberOfFilters++;

    if (numberOfFilters > 0) {
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_filter)
                .copy(Bitmap.Config.ARGB_8888, true);

        Paint paint = new Paint();
        paint.setStyle(Style.FILL);
        paint.setColor(Color.GRAY);
        paint.setTextSize(bitmap.getWidth() / 3);
        paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));

        String text = Integer.toString(numberOfFilters);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawText(text, bitmap.getWidth() - paint.measureText(text), bitmap.getHeight(), paint);

        MenuItem fMenu = menu.findItem(R.id.menu_filter);
        fMenu.setIcon(new BitmapDrawable(getResources(), bitmap));
    }

    return super.onPrepareOptionsMenu(menu);
}

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

protected FontMetrics setPaintToKeyText(final Paint paint) {
    final FontMetrics fm;
    paint.setTextSize(mKeyTextSize);//from www .ja  va2  s.  c  o m
    paint.setTypeface(mKeyTextStyle);
    if (mTextFM == null)
        mTextFM = paint.getFontMetrics();
    fm = mTextFM;
    return fm;
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void drawDayHeaderLoop(Rect r, Canvas canvas, Paint p) {
    p.setTypeface(mBold);
    p.setTextAlign(Align.RIGHT);/*from www  . jav a  2 s .com*/
    int cell = mFirstJulianDay;

    String[] dayNames;
    if (mDateStrWidthLong < mCellWidth && mNumDays == 1) {
        dayNames = mDayStrsLong;
    } else if (mDateStrWidth < mCellWidth) {
        dayNames = mDayStrs;
    } else {
        dayNames = mDayStrs2Letter;
    }

    p.setAntiAlias(true);
    for (int day = 0; day < mNumDays; day++, cell++) {
        int dayOfWeek = day + mFirstVisibleDayOfWeek;
        if (dayOfWeek >= 14) {
            dayOfWeek -= 14;
        }

        int color = mCalendarDateBannerTextColor;
        if (mNumDays == 1) {
            if (dayOfWeek == Time.SATURDAY) {
                color = mWeek_saturdayColor;
            } else if (dayOfWeek == Time.SUNDAY) {
                color = mWeek_sundayColor;
            }
        } else {
            final int column = day % 7;
            if (DayUtils.isSaturday(column, mFirstDayOfWeek)) {
                color = mWeek_saturdayColor;
            } else if (DayUtils.isSunday(column, mFirstDayOfWeek)) {
                color = mWeek_sundayColor;
            }
        }

        p.setColor(color);
        if (mNumDays == 1) {
            Time time = new Time();
            time.setJulianDay(mFirstJulianDay);
            String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false)));
            drawDayHeader(dayNames[dayOfWeek], day, s, canvas, p);
        } else {
            int dateNum = mFirstVisibleDate + day;
            if (dateNum > mMonthLength) {
                dateNum -= mMonthLength;
            }
            drawDayHeader(dayNames[dayOfWeek], day, String.valueOf(dateNum), canvas, p);
        }
    }
    p.setTypeface(null);
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void setupHourTextPaint(Paint p) {
    p.setColor(mCalendarHourLabelColor);
    p.setTextSize(HOURS_TEXT_SIZE);//from  w  w w.  j a va2  s  .c  om
    p.setTypeface(Typeface.DEFAULT);
    p.setTextAlign(Align.RIGHT);
    p.setAntiAlias(true);
}