Example usage for android.graphics Paint setStyle

List of usage examples for android.graphics Paint setStyle

Introduction

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

Prototype

public void setStyle(Style style) 

Source Link

Document

Set the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes Fill).

Usage

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

public void drawIndex(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);//  w  w  w . j a  v  a2 s  . c om
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            double zrsp = jo.getDouble("zrsp");

            double zjcj = jo.getDouble("zjcj");
            paint.setTextSize(mTextSize * 2);
            setColor(paint, zjcj, zrsp);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.translate(DX * 0.5f, DY * 2f);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x, y, paint);

            paint.setStyle(Paint.Style.STROKE);
            paint.setTextSize(mTextSize);

            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 * 0.8f);
            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(DX * 3.5f, 0);
            String zhangfu = Utils.dataFormation(zhangf * 100, stockdigit);
            if (zhangfu.equals("-"))
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(zhangfu + "%", x, y, paint);

            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(-DX * 3.5f, DY * 1.2f);
            //canvas.translate(-DX*0.5f, DY*2f);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("??", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("??", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);

            paint.setColor(GlobalColor.colorLabelName);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.translate(width / 2 - DX, -DY * 7);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(0, 0);
            canvas.drawText(Utils.dataFormation(zrsp, stockdigit), x, y, paint);

            canvas.translate(width / 2, -DY * 3);
            paint.setTextAlign(Paint.Align.RIGHT);

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

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

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

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

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjsl"), true), x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x, y, paint);

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

        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    } else {//?????
        paint.setTextAlign(Paint.Align.LEFT);
        paint.setColor(GlobalColor.colorLabelName);

        canvas.translate(DX, DY * 2f);
        canvas.drawText("-", x, y, paint);

        paint.setStyle(Paint.Style.STROKE);
        paint.setTextSize(mTextSize);

        canvas.translate(-DX / 2, DY * 0.8f);
        canvas.drawText("-", x, y, paint);

        canvas.translate(DX * 2.5f, 0);
        canvas.drawText("-", x, y, paint);
        canvas.translate(-DX * 2.5f, DY * 1.2f);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("??", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("??", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);

        paint.setTextAlign(Paint.Align.LEFT);
        canvas.translate(width / 2 - DX, -DY * 7);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
    }
}

From source file:com.semfapp.adamdilger.semf.Take5PdfDocument.java

/**
 * Draw headers, for sec 3,4,5// w  w w .j  a v a  2s .co m
 * @param xLoc left location
 * @param yLoc top location
 * @param string header string
 * @param index header index
 */
private void drawSmallCircle(int xLoc, int yLoc, String string, int index) {
    int RADIUS = 14;
    float INNER_RADIUS = 13;
    int centre = yLoc + RADIUS;
    int width = xLoc + 176;
    Paint paint = new Paint();
    Paint paintW = new Paint();
    paintW.setTypeface(impact);
    paint.setTypeface(impact);
    paintW.setColor(Color.WHITE);
    paintW.setTextSize(FONT12);
    paint.setTextSize(FONT12);

    can.drawCircle(xLoc + RADIUS, centre, RADIUS, paint);
    can.drawRect(xLoc + RADIUS, centre - RADIUS, width, centre + RADIUS, paint);
    can.drawCircle(width, centre, RADIUS, paint);
    can.drawCircle(xLoc + RADIUS, centre, INNER_RADIUS, paintW);
    can.drawText(string, xLoc + 29, centre + 4.5f, paintW);
    paint.setTextSize(FONT16);
    can.drawText(String.valueOf(index), xLoc + RADIUS - 4, centre + 6, paint);

    //drawSmallCircle(8, 331, "Assess the level of risk", 3);
    drawText(mCheckBoxSectionThree.get(index - 3).getHeading(), xLoc + 8, yLoc + 35, FONT12, carlitoBold);

    drawText("YES", xLoc + 95, yLoc + 35, FONT14, impact);
    drawText("NO", xLoc + 138, yLoc + 35, FONT14, impact);

    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(.5f);
    can.drawRect(xLoc + 118, yLoc + 36, xLoc + 118 + 14, yLoc + 36 + 14, paint);

    paint.setStrokeWidth(1.5f);
    can.drawRect(xLoc + 156, yLoc + 36, xLoc + 156 + 14, yLoc + 36 + 14, paint);

    Take5Data.CheckValue isYes = mCheckBoxSectionThree.get(index - 3).getCheckValue();
    if (isYes == Take5Data.CheckValue.YES) {
        drawCheck(xLoc + 118, yLoc + 36, paint);
    } else if (isYes == Take5Data.CheckValue.NO) {
        drawCheck(xLoc + 156, yLoc + 36, paint);
    }
}

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

public void drawQihuo(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);// w ww  .  j  a  v a 2s . co m
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            String str = "";
            double zrsp = jo.getDouble("zrsp");

            double zjcj = jo.getDouble("zjcj");
            paint.setTextSize(mTextSize * 2);
            setColor(paint, zjcj, zrsp);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.translate(DX, DY * 2f);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x, y, paint);

            paint.setStyle(Paint.Style.STROKE);
            paint.setTextSize(mTextSize);

            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(-DX / 2, DY * 0.8f);
            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(DX * 2.5f, 0);
            String zhangfu = Utils.dataFormation(zhangf * 100, 1);
            if (zhangfu.equals("-") || zhangfu.equals(""))
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(zhangfu + "%", x, y, paint);

            paint.setColor(GlobalColor.colorLabelName);

            canvas.translate(-DX * 3, DY * 1.2f);
            canvas.drawText("?", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(" ", x, y, paint);

            canvas.translate(width / 2, -DY * 2);
            paint.setTextAlign(Paint.Align.RIGHT);
            double temp2 = jo.getDouble("sjw1");
            setColor(paint, temp2, zrsp);
            str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
            canvas.drawText(str, x - tips, y, paint);

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

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jrkc"), 0, jo.getInt("tp")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorLabelName);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.translate(0, -DY * 5);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("??", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(" ", x, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, -DY * 5);
            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);

            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("ssl1"), false), x - tips, y, paint);

            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("bsl1"), false), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jrpc"), 0, jo.getInt("tp")), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    } else {//?????
        paint.setTextAlign(Paint.Align.LEFT);
        paint.setColor(GlobalColor.colorLabelName);

        canvas.translate(DX, DY * 2f);
        canvas.drawText("-", x, y, paint);

        paint.setStyle(Paint.Style.STROKE);
        paint.setTextSize(mTextSize);

        canvas.translate(-DX / 2, DY * 0.8f);
        canvas.drawText("-", x, y, paint);

        canvas.translate(DX * 2.5f, 0);
        canvas.drawText("-", x, y, paint);
        canvas.translate(-DX * 3, DY * 1.2f);
        canvas.drawText("?", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText(" ", x, y, paint);

        paint.setTextAlign(Paint.Align.LEFT);
        canvas.translate(width / 2, -DY * 5);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("??", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("?", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText(" ", x, y, paint);
    }
}

From source file:org.de.jmg.learn.SettingsActivity.java

public void init(boolean blnRestart) throws Exception {
    if (_Intent == null || _main == null || SettingsView == null || _blnInitialized) {
        return;/*w w w  . j av  a 2s.  c om*/
    }
    try {
        //lib.ShowToast(_main, "Settings Start");

        RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutSettings); // id fetch from xml
        ShapeDrawable rectShapeDrawable = new ShapeDrawable(); // pre defined class
        int pxPadding = lib.dpToPx(10);
        rectShapeDrawable.setPadding(pxPadding, pxPadding, pxPadding,
                pxPadding * ((lib.NookSimpleTouch()) ? 2 : 1));
        Paint paint = rectShapeDrawable.getPaint();
        paint.setColor(Color.BLACK);
        paint.setStyle(Style.STROKE);
        paint.setStrokeWidth(5); // you can change the value of 5
        lib.setBg(layout, rectShapeDrawable);

        mainView = _main.findViewById(Window.ID_ANDROID_CONTENT);
        //Thread.setDefaultUncaughtExceptionHandler(ErrorHandler);
        prefs = _main.getPreferences(Context.MODE_PRIVATE);

        TextView txtSettings = (TextView) findViewById(R.id.txtSettings);
        SpannableString Settings = new SpannableString(txtSettings.getText());
        Settings.setSpan(new UnderlineSpan(), 0, Settings.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        txtSettings.setText(Settings);
        initCheckBoxes();
        initSpinners(blnRestart);
        initButtons();
        initHelp();
        edDataDir = (EditText) findViewById(R.id.edDataDir);
        edDataDir.setSingleLine(true);
        edDataDir.setText(_main.JMGDataDirectory);
        edDataDir.setImeOptions(EditorInfo.IME_ACTION_DONE);
        edDataDir.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    String strDataDir = edDataDir.getText().toString();
                    File fileSelected = new File(strDataDir);
                    if (fileSelected.isDirectory() && fileSelected.exists()) {
                        _main.setJMGDataDirectory(fileSelected.getPath());
                        edDataDir.setText(_main.JMGDataDirectory);
                        Editor editor = prefs.edit();
                        editor.putString("JMGDataDirectory", fileSelected.getPath());
                        editor.commit();
                    }
                }
                return true;
            }
        });
        edDataDir.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ShowDataDirDialog();
                return true;
            }
        });
        if (!(lib.NookSimpleTouch()) && !_main.isSmallDevice) {
            SettingsView.getViewTreeObserver()
                    .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

                        @Override
                        public void onGlobalLayout() {
                            // Ensure you call it only once :
                            lib.removeLayoutListener(SettingsView.getViewTreeObserver(), this);

                            // Here you can get the size :)
                            resize(0);
                            //lib.ShowToast(_main, "Resize End");
                        }
                    });

        } else {
            //resize(1.8f);
            mScale = 1.0f;
        }
        _blnInitialized = true;
    } catch (Exception ex) {
        lib.ShowException(_main, ex);
    }

}

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

public void drawPrice(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);// w w w .  j  a v  a 2s  .  c  o  m
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            String str = "";
            double zrsp = jo.getDouble("zrsp");

            double zjcj = jo.getDouble("zjcj");
            paint.setTextSize(mTextSize * 2);
            setColor(paint, zjcj, zrsp);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.translate(DX, DY * 2f);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x, y, paint);

            paint.setStyle(Paint.Style.STROKE);
            paint.setTextSize(mTextSize);

            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(-DX / 2, DY * 0.8f);
            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(DX * 2.5f, 0);
            //String zhangfu = Utils.dataFormation(zhangf*100, stockdigit);
            //?????2?
            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.colorLabelName);
            canvas.translate(-DX * 3, DY * 1.2f);
            canvas.drawText("?", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x, y, paint);

            canvas.translate(DX * 2, -DY * 4);
            for (int i = 1; i <= 5; 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 != 5)
                    canvas.translate(0, DY);
            }

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

            paint.setColor(GlobalColor.colorLabelName);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.translate(0, -DY * 7);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x, y, paint);

            //paint.setTextAlign(Paint.Align.CENTER);
            canvas.translate(DX * 2, -DY * 7);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit, jo.getInt("tp")), x, 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, 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, y, paint);

            canvas.translate(0, DY);
            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 - DX * 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);
            }
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    } else {//?????
        paint.setTextAlign(Paint.Align.LEFT);
        paint.setColor(GlobalColor.colorLabelName);

        canvas.translate(DX, DY * 2f);
        canvas.drawText("-", x, y, paint);

        paint.setStyle(Paint.Style.STROKE);
        paint.setTextSize(mTextSize);

        canvas.translate(-DX / 2, DY * 0.8f);
        canvas.drawText("-", x, y, paint);

        canvas.translate(DX * 2.5f, 0);
        canvas.drawText("-", x, y, paint);
        canvas.translate(-DX * 3, DY * 1.2f);
        canvas.drawText("?", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("?", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("?", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("?", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("?", x, y, paint);

        paint.setTextAlign(Paint.Align.LEFT);
        canvas.translate(width / 2, -DY * 7);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
        canvas.translate(0, DY);
        canvas.drawText("", x, y, paint);
    }
}

From source file:com.simadanesh.isatis.ScreenSlideActivity.java

void makeBMP(CalculationResult res) {

    Bitmap bmp = Bitmap.createBitmap(400, 800, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bmp);

    //canvas.drawARGB(155, 253, 255, 253);
    canvas.drawARGB(255, 255, 255, 255);
    Paint p = new Paint();
    p.setTypeface(Utility.getNazaninFont());
    p.setTextSize(25);/*from ww  w  . j  a v  a2  s  .c om*/
    p.setAntiAlias(true);

    int y = 20;
    Drawable d = getResources().getDrawable(R.drawable.abfa);
    d.setBounds(100, 10, 300, 210);
    d.draw(canvas);
    p.setTextAlign(Paint.Align.CENTER);
    y += 210;
    canvas.drawText("   ?  ", 200, y, p);
    y += 40;
    canvas.drawText("  ", 200, y, p);
    y += 40;
    canvas.drawText("  ", 200, y, p);
    y += 40;
    canvas.drawText(":" + Utility.NowDate(), 200, y, p);
    y += 40;
    canvas.drawText("___________________________", 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.CustomerNumber, 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.Title, 200, y, p);
    y += 40;
    canvas.drawText(" :" + Seprate3(res.BillAmount), 200, y, p);
    y += 40;
    canvas.drawText(" :" + Seprate3(res.PreviousDebt), 200, y, p);

    y += 40;
    Paint p1 = new Paint();
    p1.setTypeface(Utility.getNazaninFont());
    p1.setARGB(255, 0, 0, 0);
    p1.setAntiAlias(true);
    p1.setStrokeWidth(40);
    p1.setStyle(Paint.Style.STROKE);
    canvas.drawLine(10, y, 390, y, p1);
    p.setARGB(255, 255, 255, 255);
    canvas.drawText("  :" + Seprate3(res.TotalAmount) + " ", 200, y, p);
    p.setARGB(255, 0, 0, 0);

    y += 40;
    canvas.drawText("__________________________", 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.BillIdentifier, 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.PaymentIdentifier, 200, y, p);

    /* Path pth = new Path();
     pth.addArc(10, 20, 390, 790, 0, 360);
            
     p.setColor(Color.argb(20, 10, 10, 10));
     p.setTextSize(30);
     String watermark = "";
     for (int i = 0; i < 15; i++) {
     watermark += "  ";
     }
     canvas.drawTextOnPath(watermark, pth, 0, 0, p);*/
    //File file = new File(getCacheDir()+ "/billing.png");
    File file = new File("/sdcard/billing.png");
    FileOutputStream outfile;
    try {
        outfile = new FileOutputStream(file);
        bmp.compress(Bitmap.CompressFormat.PNG, 100, outfile);

        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file), "image/*");
        startActivity(intent);

    } catch (Exception ex) {
        Log.e("error", ex.toString());
    }

}

From source file:com.simadanesh.isatis.ScreenSlideActivity.java

void makePDF(CalculationResult res) {

    PdfDocument doc = new PdfDocument();
    PdfDocument.PageInfo inf = new PdfDocument.PageInfo.Builder(400, 800, 1).create();
    PdfDocument.Page page = doc.startPage(inf);

    Canvas canvas = page.getCanvas();

    //canvas.drawARGB(155, 253, 255, 253);
    canvas.drawARGB(255, 255, 255, 255);
    Paint p = new Paint();
    p.setTypeface(Utility.getNazaninFont());
    p.setTextSize(25);//w  w  w . j  a va2 s . c om
    p.setAntiAlias(true);

    int y = 20;
    Drawable d = getResources().getDrawable(R.drawable.abfa);
    d.setBounds(100, 10, 300, 210);
    d.draw(canvas);
    p.setTextAlign(Paint.Align.CENTER);
    y += 210;
    canvas.drawText("   ?  ", 200, y, p);
    y += 40;
    canvas.drawText("  ", 200, y, p);
    y += 40;
    canvas.drawText("  ", 200, y, p);
    y += 40;
    canvas.drawText(":" + Utility.NowDate(), 200, y, p);
    y += 40;
    canvas.drawText("___________________________", 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.CustomerNumber, 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.Title, 200, y, p);
    y += 40;
    canvas.drawText(" :" + Seprate3(res.BillAmount), 200, y, p);
    y += 40;
    canvas.drawText(" :" + Seprate3(res.PreviousDebt), 200, y, p);

    y += 40;
    Paint p1 = new Paint();
    p1.setTypeface(Utility.getNazaninFont());
    p1.setARGB(255, 0, 0, 0);
    p1.setAntiAlias(true);
    p1.setStrokeWidth(40);
    p1.setStyle(Paint.Style.STROKE);
    canvas.drawLine(10, y, 390, y, p1);
    p.setARGB(255, 255, 255, 255);
    canvas.drawText("  :" + Seprate3(res.TotalAmount) + " ", 200, y, p);
    p.setARGB(255, 0, 0, 0);

    y += 40;
    canvas.drawText("__________________________", 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.BillIdentifier, 200, y, p);
    y += 40;
    canvas.drawText(" :" + res.PaymentIdentifier, 200, y, p);

    doc.finishPage(page);
    //File file = new File(getCacheDir()+ "/billing.png");
    File file = new File("/sdcard/billing.pdf");
    FileOutputStream outfile;
    try {
        outfile = new FileOutputStream(file);
        //bmp.compress(Bitmap.CompressFormat.PNG, 100, outfile);
        doc.writeTo(outfile);
        doc.close();

        Intent intent = new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        //intent.setDataAndType(Uri.fromFile(file), "image/*");
        intent.setDataAndType(Uri.fromFile(file), "application/pdf");
        startActivity(intent);
        //new RetrieveFeedTask().execute(bmp);

    } catch (Exception ex) {
        Log.e("error", ex.toString());
        new AlertDialog.Builder(this).setMessage(
                "    ? pdf    ? \n https://cafebazaar.ir/app/com.kdanmobile.android.pdfreader.google.pad/?l=fa   ")
                .show();
    }

}

From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java

public void drawCompareImage(Canvas canvas, Bitmap image) {
    MasterImage master = MasterImage.getImage();
    boolean showsOriginal = master.showsOriginal();
    if (!showsOriginal && !mTouchShowOriginal)
        return;/*from   w w  w  . j a  va  2 s .co  m*/
    canvas.save();
    if (image != null) {
        if (mShowOriginalDirection == 0) {
            if (Math.abs(mTouch.y - mTouchDown.y) > Math.abs(mTouch.x - mTouchDown.x)) {
                mShowOriginalDirection = UNVEIL_VERTICAL;
            } else {
                mShowOriginalDirection = UNVEIL_HORIZONTAL;
            }
        }

        int px = 0;
        int py = 0;
        if (mShowOriginalDirection == UNVEIL_VERTICAL) {
            px = mImageBounds.width();
            py = mTouch.y - mImageBounds.top;
        } else {
            px = mTouch.x - mImageBounds.left;
            py = mImageBounds.height();
            if (showsOriginal) {
                px = mImageBounds.width();
            }
        }

        Rect d = new Rect(mImageBounds.left, mImageBounds.top, mImageBounds.left + px, mImageBounds.top + py);
        if (mShowOriginalDirection == UNVEIL_HORIZONTAL) {
            if (mTouchDown.x - mTouch.x > 0) {
                d.set(mImageBounds.left + px, mImageBounds.top, mImageBounds.right, mImageBounds.top + py);
            }
        } else {
            if (mTouchDown.y - mTouch.y > 0) {
                d.set(mImageBounds.left, mImageBounds.top + py, mImageBounds.left + px, mImageBounds.bottom);
            }
        }
        canvas.clipRect(d);
        Matrix m = master.computeImageToScreen(image, 0, false);
        canvas.drawBitmap(image, m, mPaint);
        Paint paint = new Paint();
        paint.setColor(Color.BLACK);
        paint.setStrokeWidth(3);

        if (mShowOriginalDirection == UNVEIL_VERTICAL) {
            canvas.drawLine(mImageBounds.left, mTouch.y, mImageBounds.right, mTouch.y, paint);
        } else {
            canvas.drawLine(mTouch.x, mImageBounds.top, mTouch.x, mImageBounds.bottom, paint);
        }

        Rect bounds = new Rect();
        paint.setAntiAlias(true);
        paint.setTextSize(mOriginalTextSize);
        paint.getTextBounds(mOriginalText, 0, mOriginalText.length(), bounds);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(3);
        canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin,
                mImageBounds.top + bounds.height() + mOriginalTextMargin, paint);
        paint.setStyle(Paint.Style.FILL);
        paint.setStrokeWidth(1);
        paint.setColor(Color.WHITE);
        canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin,
                mImageBounds.top + bounds.height() + mOriginalTextMargin, paint);
    }
    canvas.restore();
}

From source file:net.droidsolutions.droidcharts.core.renderer.xy.AbstractXYItemRenderer.java

/**
 * Draws a vertical line on the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device./*  w  w w  .j  av a  2  s .  c o m*/
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawDomainMarker(Canvas g2, XYPlot plot, ValueAxis domainAxis, Marker marker,
        Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = domainAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double v = domainAxis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge());

        PlotOrientation orientation = plot.getOrientation();
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
        } else if (orientation == PlotOrientation.VERTICAL) {
            line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
        }

        Paint paint = marker.getPaint();
        int oldAlpha = paint.getAlpha();
        paint.setAlpha(marker.getAlpha());
        Float stroke = marker.getStroke();

        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(stroke);

        g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(), (float) line.getY2(),
                paint);

        String label = marker.getLabel();
        RectangleAnchor anchor = marker.getLabelAnchor();
        if (label != null) {
            Font labelFont = marker.getLabelFont();

            Paint lPaint = marker.getLabelPaint();
            lPaint.setTypeface(labelFont.getTypeFace());
            lPaint.setTextSize(labelFont.getSize());
            int lOldAlpha = lPaint.getAlpha();
            lPaint.setAlpha(marker.getAlpha());
            Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2, orientation, dataArea,
                    line.getBounds2D(), marker.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor);
            TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(),
                    marker.getLabelTextAnchor(), lPaint);
            lPaint.setAlpha(lOldAlpha);
        }
        paint.setAlpha(oldAlpha);
    } else if (marker instanceof IntervalMarker) {
        IntervalMarker im = (IntervalMarker) marker;
        double start = im.getStartValue();
        double end = im.getEndValue();
        Range range = domainAxis.getRange();
        if (!(range.intersects(start, end))) {
            return;
        }

        double start2d = domainAxis.valueToJava2D(start, dataArea, plot.getDomainAxisEdge());
        double end2d = domainAxis.valueToJava2D(end, dataArea, plot.getDomainAxisEdge());
        double low = Math.min(start2d, end2d);
        double high = Math.max(start2d, end2d);

        PlotOrientation orientation = plot.getOrientation();
        Rectangle2D rect = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            // clip top and bottom bounds to data area
            low = Math.max(low, dataArea.getMinY());
            high = Math.min(high, dataArea.getMaxY());
            rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low);
        } else if (orientation == PlotOrientation.VERTICAL) {
            // clip left and right bounds to data area
            low = Math.max(low, dataArea.getMinX());
            high = Math.min(high, dataArea.getMaxX());
            rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight());
        }

        Paint p = marker.getPaint();
        int oldAlpha = p.getAlpha();
        p.setAlpha(marker.getAlpha());
        p.setStyle(Paint.Style.FILL);

        g2.drawRect((float) rect.getMinX(), (float) rect.getMinY(), (float) rect.getMaxX(),
                (float) rect.getMaxY(), p);
        p.setAlpha(oldAlpha);
        // now draw the outlines, if visible...
        if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {
            if (orientation == PlotOrientation.VERTICAL) {
                Line2D line = new Line2D.Double();
                double y0 = dataArea.getMinY();
                double y1 = dataArea.getMaxY();
                Paint oPiant = im.getOutlinePaint();
                oPiant.setStyle(Paint.Style.STROKE);
                int oOldAlpha = oPiant.getAlpha();
                oPiant.setAlpha(marker.getAlpha());
                oPiant.setStrokeWidth(im.getOutlineStroke());

                if (range.contains(start)) {
                    line.setLine(start2d, y0, start2d, y1);
                    g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(),
                            (float) line.getY2(), oPiant);
                }
                if (range.contains(end)) {
                    line.setLine(end2d, y0, end2d, y1);
                    g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(),
                            (float) line.getY2(), oPiant);
                }
                oPiant.setAlpha(oOldAlpha);
            } else { // PlotOrientation.HORIZONTAL
                Line2D line = new Line2D.Double();
                double x0 = dataArea.getMinX();
                double x1 = dataArea.getMaxX();
                Paint oPiant = im.getOutlinePaint();
                oPiant.setStyle(Paint.Style.STROKE);
                int oOldAlpha = oPiant.getAlpha();
                oPiant.setAlpha(marker.getAlpha());
                oPiant.setStrokeWidth(im.getOutlineStroke());
                if (range.contains(start)) {
                    line.setLine(x0, start2d, x1, start2d);
                    g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(),
                            (float) line.getY2(), oPiant);
                }
                if (range.contains(end)) {
                    line.setLine(x0, end2d, x1, end2d);
                    g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(),
                            (float) line.getY2(), oPiant);
                }
                oPiant.setAlpha(oOldAlpha);
            }
        }

        String label = marker.getLabel();
        RectangleAnchor anchor = marker.getLabelAnchor();
        if (label != null) {
            Font labelFont = marker.getLabelFont();
            Paint paint = marker.getLabelPaint();
            paint.setTypeface(labelFont.getTypeFace());
            paint.setTextSize(labelFont.getSize());
            Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2, orientation, dataArea, rect,
                    marker.getLabelOffset(), marker.getLabelOffsetType(), anchor);
            TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(),
                    marker.getLabelTextAnchor(), paint);
        }

    }

}

From source file:com.example.SmartBoard.DrawingView.java

@Override
protected void onDraw(Canvas canvas) {

    drawCanvas.drawPath(drawPath, drawPaint);
    drawCanvas.drawPath(drawPathRecv, drawPaintSender);

    if (rectMode) {
        //draw rectangle
        drawPaint.setXfermode(null);//from   ww  w.  j av  a2s  . co m
        onDrawRectangle(canvas);
    } else if (circleMode) {
        drawPaint.setXfermode(null);
        onDrawCircle(canvas);
    } else if (lineMode) {
        drawPaint.setXfermode(null);
        onDrawLine(canvas);
    } else if (textMode) {
        drawPaint.setXfermode(null);
        onDrawText(canvas);
    } else if (dragMode && !dragFinished) {
        drawPaint.setXfermode(null);
        onDragDraw(canvas, dragX, dragY);
    } else if (colorDropperMode) {
        drawPaint.setXfermode(null);
        onDrawColorDropper(canvas, dropperX, dropperY);
    } else if (textSizeMode) {
        drawPaint.setXfermode(null);
    }

    canvas.drawBitmap(canvasBitmap, 0, 0, canvasPaint);

    //redraw objects

    Paint tempPaint = new Paint();
    tempPaint.setStyle(Paint.Style.STROKE);

    for (String key : textObjects.keySet()) {
        if (key.compareTo("") == 0) {
            continue;
        }
        JSONObject o = textObjects.get(key);

        tempPaint.setColor(o.optInt("color"));
        tempPaint.setStrokeWidth(o.optInt("size"));

        canvas.drawBitmap(mqtt.stringToBitmap(o.optString("textBitmap")), o.optInt("x"), o.optInt("y"),
                tempPaint);

    }

    for (String key : objectDrawables.keySet()) {
        //hashtable problems no time to explain. But it creates a duplicate of last item I add to the table.
        //So dont print duplicates which have empty string key values
        if (key.compareTo("") == 0) {
            continue;
        }
        JSONObject o = objectDrawables.get(key);

        String objectType = o.optString("type");
        tempPaint.setColor(o.optInt("color"));
        tempPaint.setStrokeWidth(o.optInt("size"));

        if (objectType.compareTo("Circle") == 0) {
            canvas.drawCircle(o.optInt("x"), o.optInt("y"), o.optInt("radius"), tempPaint);

        } else if (objectType.compareTo("Line") == 0) {
            canvas.drawLine(o.optInt("startx"), o.optInt("starty"), o.optInt("stopx"), o.optInt("stopy"),
                    tempPaint);

        } else if (objectType.compareTo("Rectangle") == 0) {
            canvas.drawRect(Rect.unflattenFromString(o.optString("dimens")), tempPaint);
        } else if (objectType.compareTo("Text") == 0) {
            //canvas.drawRect(Rect.unflattenFromString(o.optString("region")), drawPaint);
            canvas.drawBitmap(mqtt.stringToBitmap(o.optString("textBitmap")), o.optInt("x"), o.optInt("y"),
                    tempPaint);

        }
    }

}