Example usage for android.graphics Paint Paint

List of usage examples for android.graphics Paint Paint

Introduction

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

Prototype

public Paint() 

Source Link

Document

Create a new paint with default settings.

Usage

From source file:com.example.ecgfile.DeviceControlActivity.java

public void init_ecg() {
    setTitle("");
    mSurfaceView_ECG = (SurfaceView) findViewById(R.id.surfaceView_ecg); //
    mSurfaceView_ECG.setOnTouchListener(new TouchEvent());
    mPaint = new Paint();
    mPaint.setColor(Color.GREEN); // 
    mPaint.setStrokeWidth(2); // 

    zoomX = (ZoomControls) this.findViewById(R.id.zoomControls_x);
    MyZoomControls.convert(zoomX);//from w  w  w. j  av a  2 s  . c  o m
    zoomX.setOnZoomOutClickListener(new View.OnClickListener() { //       
        @Override
        public void onClick(View v) {
            if (rateX > rateXmin) {
                rateX--;
                zoomX.setIsZoomInEnabled(true);
            } else {
                zoomX.setIsZoomOutEnabled(false);
            }
        }
    });
    zoomX.setOnZoomInClickListener(new View.OnClickListener() { // 

        @Override
        public void onClick(View v) {
            if (rateX < rateXmax) {
                rateX++;
                zoomX.setIsZoomOutEnabled(true);
            } else {
                zoomX.setIsZoomInEnabled(false);
            }
        }
    });
    zoomY = (ZoomControls) this.findViewById(R.id.zoomControls_y);
    MyZoomControls.convert(zoomY);
    zoomY.setOnZoomInClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (rateY > rateYmin) {
                rateY--;
                zoomY.setIsZoomOutEnabled(true);
            } else {
                zoomY.setIsZoomInEnabled(false);
            }
        }
    });
    zoomY.setOnZoomOutClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (rateY < rateYmax) {
                rateY++;
                zoomY.setIsZoomInEnabled(true);
            } else {
                zoomY.setIsZoomOutEnabled(false);
            }
        }
    });

    mHandler = new Handler();
    mButton_start = (ToggleButton) findViewById(R.id.bt_start);
    mButton_save = (ToggleButton) findViewById(R.id.bt_sava);
    mButton_remoteUpload_enable = (ToggleButton) findViewById(R.id.bt_realTime);

    //
    mButton_start.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            //
            if (firstConnect) {
                String data = "1";
                if (mNCharW == null) {
                    Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
                    DeviceControlActivity.this.finish();
                    return;
                }
                mNCharW.setValue(data.getBytes());
                mBluetoothLeService.writeCharacteristic(mNCharW);
                //
                mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, true);
                firstConnect = false;
                StartDraw(); //
                mButton_save.setClickable(true);
                mButton_remoteUpload_enable.setClickable(true);
                return;
            }

            if (mButton_start.isChecked()) { //
                mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, true);
                mButton_remoteUpload_enable.setClickable(true);
                mButton_save.setClickable(true);
                StartDraw(); //
            } else { //
                mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, false);
                mButton_remoteUpload_enable.setClickable(false);
                mButton_save.setClickable(false);
                mButton_remoteUpload_enable.setChecked(false);
                StopDraw();
            }
        }
    });

    // ,15       
    mButton_save.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (intentData == null && mButton_save.isChecked()) {
                Toast.makeText(DeviceControlActivity.this, "", Toast.LENGTH_SHORT).show();
                return;
            }
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    timeString = "";
                    mButton_save.setClickable(true);
                    mButton_start.setClickable(true);
                    mButton_remoteUpload_enable.setClickable(true);
                    mButton_save.setChecked(false);
                }
            }, CommonVar.PERIOD_15);
            SimpleDateFormat formatter = new SimpleDateFormat("/yyyy-MM-dd HH:mm:ss");
            Date curDate = new Date(System.currentTimeMillis());
            timeString = formatter.format(curDate);
            //
            mButton_start.setClickable(false);
            mButton_save.setClickable(false);
            mButton_remoteUpload_enable.setClickable(false);
            Toast.makeText(DeviceControlActivity.this, "15", Toast.LENGTH_SHORT)
                    .show();
        }
    });
    mButton_save.setClickable(false);

    //
    mButton_remoteUpload_enable.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mButton_remoteUpload_enable.isChecked()) {
                //
                mButton_save.setChecked(false);
                mButton_save.setClickable(false);
                //
                isRealTimeUp = true;
                //
                if (NetConnect.checkNet(getApplication())) {
                    //wifi
                    NetConnect.checkWifi(DeviceControlActivity.this);
                    // /15
                    TimerTask();
                    //
                    RTUploadTask();
                    Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
                } else {
                    return;
                }
            } else {
                if (mButton_start.isChecked()) {
                    mButton_save.setClickable(true);
                }
                //
                isRealTimeUp = false;
                Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
            }
        }
    });
    mButton_remoteUpload_enable.setClickable(false);
}

From source file:net.kourlas.voipms_sms.Utils.java

/**
 * Applies a circular mask to a bitmap.// w ww  .j a va2  s  .  com
 *
 * @param bitmap The bitmap to apply the mask to.
 */
public static Bitmap applyCircularMask(Bitmap bitmap) {
    final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(output);
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);
    paint.setAntiAlias(true);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}

From source file:android.support.designox.widget.TextInputLayout.java

private LayoutParams updateEditTextMargin(ViewGroup.LayoutParams lp) {
    // Create/update the LayoutParams so that we can add enough top margin
    // to the EditText so make room for the label
    LayoutParams llp = lp instanceof LayoutParams ? (LayoutParams) lp : new LayoutParams(lp);

    if (mHintEnabled) {
        if (mTmpPaint == null) {
            mTmpPaint = new Paint();
        }//from ww w.  ja v  a2s  . c o m
        mTmpPaint.setTypeface(mCollapsingTextHelper.getCollapsedTypeface());
        mTmpPaint.setTextSize(mCollapsingTextHelper.getCollapsedTextSize());
        llp.topMargin = (int) -mTmpPaint.ascent();
    } else {
        llp.topMargin = 0;
    }

    return llp;
}

From source file:com.scigames.registration.Registration4PhotoActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_REQUEST) {
        or.setVisibility(View.VISIBLE);
        retakeButton.setVisibility(View.VISIBLE);
        saveButton.setVisibility(View.VISIBLE);
        takePhotoButton.setVisibility(View.INVISIBLE);

        if (data.hasExtra("data")) {
            //change to new view
            photo = (Bitmap) data.getExtras().get("data");
            //photoUri = data.getExtras().get("data");
            Log.d(TAG, "photoDensity: ");
            Log.d(TAG, String.valueOf(photo.getDensity()));
            Log.d(TAG, "photo getHeight:");
            Log.d(TAG, String.valueOf(photo.getHeight()));
            Log.d(TAG, "photo getWidth");
            Log.d(TAG, String.valueOf(photo.getWidth()));
            Log.d(TAG, "photo config:");
            if (photo.getHeight() < photo.getWidth()) {
                Log.d(TAG, "height < width");

                Log.d(TAG, photo.getConfig().toString());
                photoToSend = Bitmap.createBitmap(120, 160, photo.getConfig());
                //photoToSend = Bitmap.createBitmap(photo);
                Canvas canvas = new Canvas(photoToSend);
                Log.d(TAG, "photo getScaledHeight:");
                Log.d(TAG, String.valueOf(photo.getScaledHeight(canvas)));
                Log.d(TAG, "photo getScaledWidth");
                Log.d(TAG, String.valueOf(photo.getScaledWidth(canvas)));
                Matrix matrix = new Matrix();
                //matrix.preScale(-1.0f, 1.0f);
                //Bitmap mirroredBitmap = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight());
                matrix.setRotate(270, photo.getWidth() / 2, photo.getHeight() / 2);

                //matrix.postTranslate(photo.getWidth(),photo.getHeight());
                Log.d(TAG, matrix.toString());
                canvas.drawBitmap(photo, matrix, new Paint());
            } else {
                Log.d(TAG, photo.getConfig().toString());
                photoToSend = Bitmap.createBitmap(120, 160, photo.getConfig());
                //photoToSend = Bitmap.createBitmap(photo); 
                Canvas canvas = new Canvas(photoToSend);
                Log.d(TAG, "photo getScaledHeight:");
                Log.d(TAG, String.valueOf(photo.getScaledHeight(canvas)));
                Log.d(TAG, "photo getScaledWidth");
                Log.d(TAG, String.valueOf(photo.getScaledWidth(canvas)));
                Matrix matrix = new Matrix();
                //matrix.preScale(-1.0f, 1.0f);
                //Bitmap mirroredBitmap = Bitmap.createBitmap(photo, 0, 0, photo.getWidth(), photo.getHeight());
                //matrix.setRotate(0, photo.getWidth()/2, photo.getHeight()/2);
                //matrix.setScale(0.9f, 0.9f);
                Log.d(TAG, matrix.toString());
                //matrix.postTranslate(photo.getWidth(),photo.getHeight());

                canvas.drawBitmap(photo, matrix, new Paint());
                avatarPhoto.setScaleX(0.95f);
                avatarPhoto.setScaleY(0.95f);
                avatarPhoto.setX(180f);//from   www. j ava2  s .c  om
                avatarPhoto.setY(440f);
            }
            avatarPhoto.setImageBitmap(photoToSend);

            Log.d(TAG, "photoToSendDensity: ");
            Log.d(TAG, String.valueOf(photoToSend.getDensity()));
            Log.d(TAG, "photoToSend getScaledHeight:");
            Log.d(TAG, String.valueOf(photoToSend.getHeight()));
            Log.d(TAG, "photoToSend getScaledWidth");
            Log.d(TAG, String.valueOf(photoToSend.getWidth()));
        } else {
            or.setVisibility(View.INVISIBLE);
            saveButton.setVisibility(View.INVISIBLE);
            retakeButton.setVisibility(View.INVISIBLE);
            takePhotoButton.setVisibility(View.VISIBLE);
            //instruction.setText("");
        }
    }
}

From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java

private void DrawEvents() {
    Bitmap charty = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
    Canvas EventsCanvas = new Canvas(charty);
    final Paint paint = new Paint();

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(getResources().getColor(R.color.DarkBlue));
    paint.setAntiAlias(true);//from w ww  . j a  v  a 2  s  .  c  o  m
    EventsCanvas.drawOval(new RectF(1, 1, 199, 199), paint);

    RadialGradient gradient = new RadialGradient(200, 200, 200, 0xFF6b7681, 0xFF000000,
            android.graphics.Shader.TileMode.CLAMP);
    paint.setDither(true);
    paint.setShader(gradient);
    EventsCanvas.drawOval(new RectF(6, 6, 194, 194), paint);

    //Special Bits
    int Scale = 100;

    if (EventCount > 100)
        ;
    Scale = EventCount + 50;

    drawScale(EventsCanvas, true, EventCount, Scale);
    drawGaugeTitle(EventsCanvas, "Events Count");
    drawGaugeNeedle(EventsCanvas, EventCount, Scale);
    //drawGloss(EventsCanvas);

    ((ImageView) findViewById(R.id.EventsGauge)).setImageBitmap(charty);
}

From source file:com.FluksoViz.FluksoVizActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Display display = getWindowManager().getDefaultDisplay();
    screen_width = display.getWidth();/*from ww  w  .  j  a va 2s .c o  m*/
    if (screen_width == 320) {
        setContentView(R.layout.main_lowres);
    } else
        setContentView(R.layout.main);

    context = getApplicationContext();
    SharedPreferences my_app_prefs = PreferenceManager.getDefaultSharedPreferences(this);

    try {
        versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    sensor_number = Integer.parseInt(my_app_prefs.getString("sensor_number", "1"));
    api_server_ip = my_app_prefs.getString("api_server", "178.79.177.6");
    skip_initial_sensor_checks = (Boolean) my_app_prefs.getBoolean("skip_initial_sensor_checks", false);
    ip_addr = (String) my_app_prefs.getString("flukso_ip_addr", "10.10.10.10");
    api_key_1 = (String) my_app_prefs.getString("sensor_1_api_key", "0.0.0.0");
    api_key_2 = (String) my_app_prefs.getString("sensor_2_api_key", "0.0.0.0");
    api_key_3 = (String) my_app_prefs.getString("sensor_3_api_key", "0.0.0.0");
    api_token_1 = (String) my_app_prefs.getString("sensor_1_token", "0.0.0.0");
    api_token_2 = (String) my_app_prefs.getString("sensor_2_token", "0.0.0.0");
    api_token_3 = (String) my_app_prefs.getString("sensor_3_token", "0.0.0.0");
    cost_fixedpart = Double.parseDouble(my_app_prefs.getString("cost_perkwh", "0"));
    cost_perkwh = Double.parseDouble(my_app_prefs.getString("cost_perkwh", "0"));
    cost_currencycode = (String) my_app_prefs.getString("cost_currencycode", "PLN");

    Napis = (TextView) findViewById(R.id.textView1);
    Napis2 = (TextView) findViewById(R.id.textView2);
    Napis01 = (TextView) findViewById(R.id.textView01);
    Napis3 = (TextView) findViewById(R.id.textView_r1);
    Napis4 = (TextView) findViewById(R.id.textView_rd1);
    tv_p1 = (TextView) findViewById(R.id.textView_p1);
    tv_p1.setTextColor(Color.WHITE);
    tv_p1.setVisibility(TextView.INVISIBLE);
    tv_p2 = (TextView) findViewById(R.id.textView_p2);
    tv_p2.setTextColor(Color.WHITE);
    tv_p2.setVisibility(TextView.INVISIBLE);
    tv_p3 = (TextView) findViewById(R.id.textView_p3);
    tv_p3.setTextColor(Color.WHITE);
    tv_p3.setVisibility(TextView.INVISIBLE);
    tv_today_kwh = (TextView) findViewById(R.id.TextView_r2);
    tv_today_cost = (TextView) findViewById(R.id.TextView_r4);
    tv_today_percent = (TextView) findViewById(R.id.TextView_r6);
    tv_today_avg = (TextView) findViewById(R.id.TextView_r22);
    tv_week_kwh = (TextView) findViewById(R.id.TextView_rd2);
    tv_week_avg = (TextView) findViewById(R.id.TextView_rd22);
    tv_week_cost = (TextView) findViewById(R.id.TextView_rd4);
    tv_week_percent = (TextView) findViewById(R.id.TextView_rd6);

    tv_month_kwh = (TextView) findViewById(R.id.TextView_rt2);
    tv_month_avg = (TextView) findViewById(R.id.TextView_rt22);
    tv_month_cost = (TextView) findViewById(R.id.TextView_rt4);
    tv_month_percent = (TextView) findViewById(R.id.TextView_rt6);

    tv_curr1 = (TextView) findViewById(R.id.TextView_r5);
    tv_curr2 = (TextView) findViewById(R.id.TextView_rd5);
    tv_curr3 = (TextView) findViewById(R.id.TextView_rt5);
    tv_curr1.setText(cost_currencycode);
    tv_curr2.setText(cost_currencycode);
    tv_curr3.setText(cost_currencycode);

    Napis01.setText("" + sensor_number);

    iv1 = (ImageView) findViewById(R.id.arrow_image1);
    iv2 = (ImageView) findViewById(R.id.arrow_image2);
    iv3 = (ImageView) findViewById(R.id.arrow_image3);

    W = (TextView) findViewById(R.id.textView4);
    napis_delta = (TextView) findViewById(R.id.textView_delta);
    napis_delta.setText("" + (char) 0x0394);
    napis_delta.setTextColor(Color.WHITE);
    napis_delta.setVisibility(TextView.INVISIBLE);

    Plot1 = (XYPlot) findViewById(R.id.Plot1);
    Plot2 = (XYPlot) findViewById(R.id.Plot2);

    series1m = new SimpleXYSeries("seria 1m");
    series2m = new SimpleXYSeries("seria 2m");
    series3m = new SimpleXYSeries("seria 3m");

    series_p2_1 = new SimpleXYSeries("plot 2 - 1");

    series1mFormat = new LineAndPointFormatter(Color.rgb(0, 180, 0), // line
            Color.rgb(50, 100, 0), // point color
            null);
    line1mFill = new Paint();
    line1mFill.setAlpha(100);
    line1mFill.setShader(
            new LinearGradient(0, 0, 0, 200, Color.rgb(0, 100, 0), Color.BLACK, Shader.TileMode.MIRROR));
    series1mFormat.getLinePaint().setStrokeWidth(3);
    series1mFormat.getVertexPaint().setStrokeWidth(0);
    series1mFormat.setFillPaint(line1mFill);

    series2mFormat = new LineAndPointFormatter( // FAZA 2 formater
            Color.rgb(0, 200, 0), // line color
            Color.rgb(0, 100, 50), // point color
            null);
    line2mFill = new Paint();
    line2mFill.setAlpha(100);
    line2mFill.setShader(
            new LinearGradient(0, 0, 0, 200, Color.rgb(0, 100, 0), Color.BLACK, Shader.TileMode.MIRROR));
    series2mFormat.getLinePaint().setStrokeWidth(3);
    series2mFormat.getVertexPaint().setStrokeWidth(0);
    series2mFormat.setFillPaint(line2mFill);

    series3mFormat = new LineAndPointFormatter( // FAZA 3 formater
            Color.rgb(0, 220, 0), // line color
            Color.rgb(0, 150, 0), // point color
            null);
    line3mFill = new Paint();
    line3mFill.setAlpha(100);
    line3mFill.setShader(
            new LinearGradient(0, 0, 0, 200, Color.rgb(0, 200, 0), Color.BLACK, Shader.TileMode.MIRROR));
    series3mFormat.getLinePaint().setStrokeWidth(3);
    // series3mFormat.getVertexPaint().setStrokeWidth(0);
    series3mFormat.setFillPaint(line3mFill);

    series4mFormat = new LineAndPointFormatter(Color.rgb(0, 140, 220), // line
            Color.rgb(0, 120, 190), // point color
            null);
    line4mFill = new Paint();
    line4mFill.setAlpha(190);
    line4mFill.setShader(
            new LinearGradient(0, 0, 0, 200, Color.rgb(0, 140, 220), Color.BLACK, Shader.TileMode.MIRROR));
    series4mFormat.getLinePaint().setStrokeWidth(5);
    series4mFormat.setFillPaint(line4mFill);

    make_graph_pretty(Plot1); // All formating of the graph goes into
    // seperate method
    make_graph_pretty(Plot2);

    Napis.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (delta_mode) {
                napis_delta.setVisibility(TextView.INVISIBLE);
                delta_mode = false;
                delta_value = 0;
                // Plot1.removeMarker(marker1);
            } else {
                napis_delta.setVisibility(TextView.VISIBLE);
                delta_mode = true;
                try {
                    delta_value = seriesSUM123linkedlist.getLast().intValue();
                    // marker1 = new YValueMarker(delta_value, "" + (char)
                    // 0x0394, new
                    // XPositionMetric(3,XLayoutStyle.ABSOLUTE_FROM_LEFT),
                    // Color.GREEN, Color.WHITE);
                    // Plot1.addMarker(marker1);
                } catch (NullPointerException e) {
                    delta_value = 0;
                }
            }
            ;

        }
    });

    W.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Napis01.setText("restarted");
            thread1_running = true;
            thread2_running = true;

        }
    });

    Plot1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            /*
             * Change the switch block to an increment and one 
             * if statement. Also, avoid magic numbers
             */
            plot1_mode++;
            if (plot1_mode > MAX_PLOT1_CLICK)
                plot1_mode = 0;

            switch (sensor_number) {
            case 1:
            case 2:
            case 3: {
                switch (plot1_mode) {
                case 0: {
                    Plot1.setTitle("Power (W) - last minute -  stacked");
                    Plot1.removeSeries(series1m);
                    Plot1.addSeries(series2m, series2mFormat);
                    Plot1.addSeries(series3m, series3mFormat);
                    Plot1.addSeries(series1m, series1mFormat);
                    Plot1.redraw();
                    break;
                }
                case 1: {
                    Plot1.setTitle("Power (W) - last minute -  with details");
                    Plot1.redraw(); // update title even if series are not updating (like in set prefs)

                    setDetailsVisibility(true); // show details
                    break;
                }
                case 2: {
                    Plot1.setTitle("Power (W) - last minute -  Total only");
                    Plot1.removeSeries(series2m);
                    Plot1.removeSeries(series1m);
                    Plot1.redraw();

                    setDetailsVisibility(false); // hide details
                    break;
                }
                }
                break;
            }
            case 4: {
                switch (plot1_mode) {
                case 0: {
                    Plot1.setTitle("Power (W) - last minute -  stacked");
                    Plot1.redraw();
                    break;
                }
                case 1: {
                    Plot1.setTitle("Power (W) - last minute -  with details");
                    Plot1.redraw(); // This update plot title even if the series update is stoped

                    setDetailsVisibility(true); // show details
                    break;
                }
                case 2: {
                    Plot1.setTitle("Power (W) - last minute ");
                    // Plot1.removeSeries(series2m);
                    // Plot1.removeSeries(series1m);
                    Plot1.redraw();

                    setDetailsVisibility(false); // hide details
                    break;
                }
                }
                break;
            }
            }

        }
    });

    series1m.setModel(series1linkedlist, SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED);
    series2m.setModel(series2linkedlist, SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED);
    series3m.setModel(series3linkedlist, SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED);

    Plot1.addSeries(series2m, series2mFormat);
    Plot1.addSeries(series3m, series3mFormat);
    Plot1.addSeries(series1m, series1mFormat);

    series_p2_1.setModel(series_day1_linkedlist, SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED);
    Plot2.addSeries(series_p2_1, series4mFormat);

    if (skip_initial_sensor_checks) {
        thread_updater1s.start();
        thread_updater2.start();
    } else {
        run_network_token_test();
        // Alert dialog when application starts
        new AlertDialog.Builder(this).setTitle(R.string.nw_chk_results).setMessage(network_checks_results)
                .setIcon(android.R.drawable.ic_menu_agenda)
                .setPositiveButton(R.string.run_both_th_local_remote, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        thread_updater1s.start();
                        thread_updater2.start();
                    }
                }).setNeutralButton(R.string.run_just_local_th, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        thread_updater1s.start();
                        Plot2.setTitle(getString(R.string.disabled));
                        tv_today_kwh.setVisibility(TextView.INVISIBLE);
                        tv_today_cost.setVisibility(TextView.INVISIBLE);
                        tv_today_percent.setVisibility(TextView.INVISIBLE);
                        tv_today_avg.setVisibility(TextView.INVISIBLE);
                        tv_week_kwh.setVisibility(TextView.INVISIBLE);
                        tv_week_avg.setVisibility(TextView.INVISIBLE);
                        tv_week_cost.setVisibility(TextView.INVISIBLE);
                        tv_week_percent.setVisibility(TextView.INVISIBLE);
                        tv_month_kwh.setVisibility(TextView.INVISIBLE);
                        tv_month_avg.setVisibility(TextView.INVISIBLE);
                        tv_month_cost.setVisibility(TextView.INVISIBLE);
                        tv_month_percent.setVisibility(TextView.INVISIBLE);
                    }
                })
                .setNegativeButton(R.string.let_me_fix_the_prefs_first, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();
    } // end of if for skip initial tests

}

From source file:au.com.zacher.popularmovies.activity.layout.CollapsingTitleLayout.java

private void ensureExpandedTexture() {
    if (this.mExpandedTitleTexture != null) {
        return;//from  w w  w. j  a v a  2  s. com
    }

    int w = (int) (this.getWidth() - this.mExpandedMarginLeft - this.mExpandedMarginRight);
    int h = (int) (this.mTextPaint.descent() - this.mTextPaint.ascent());

    this.mExpandedTitleTexture = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);

    Canvas c = new Canvas(this.mExpandedTitleTexture);
    c.drawText(this.mTitleToDraw, 0, h - this.mTextPaint.descent(), this.mTextPaint);

    if (this.mTexturePaint == null) {
        // Make sure we have a paint
        this.mTexturePaint = new Paint();
        this.mTexturePaint.setAntiAlias(true);
        this.mTexturePaint.setFilterBitmap(true);
    }
}

From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java

private void drawGaugeNeedle(Canvas canvas, int count, int Scale) {
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    float divisor = 360.0f / Scale;

    canvas.rotate((float) (divisor * count), 100, 100);

    //Inside//w  w w  .  j  av  a  2 s . c  o  m
    Paint needleInsidePaint = new Paint();
    needleInsidePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    needleInsidePaint.setColor(Color.WHITE);
    needleInsidePaint.setStrokeWidth(4);
    needleInsidePaint.setAntiAlias(true);

    Paint needleEdgePaint = new Paint();
    needleEdgePaint.setStyle(Paint.Style.STROKE);
    needleEdgePaint.setColor(Color.DKGRAY);
    needleEdgePaint.setStrokeWidth(0.5f);
    needleEdgePaint.setAntiAlias(true);

    canvas.drawOval(new RectF(95, 95, 105, 105), needleInsidePaint);
    canvas.drawOval(new RectF(95, 96, 105, 105), needleEdgePaint);

    Path needleInside = new Path();
    needleInside.moveTo(98, 98);
    needleInside.lineTo(100, 20);
    needleInside.lineTo(102, 102);
    canvas.drawPath(needleInside, needleInsidePaint);

    Path needleEdge = new Path();
    needleInside.moveTo(99, 99);
    needleInside.lineTo(99, 19);
    needleInside.lineTo(103, 103);

    canvas.drawPath(needleEdge, needleEdgePaint);
    canvas.restore();
}

From source file:edu.cloud.iot.reception.ocr.FaceRecognitionActivity.java

public Bitmap toGrayscale(Bitmap bmpOriginal) {
    int height = bmpOriginal.getHeight();
    int width = bmpOriginal.getWidth();

    Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bmpGrayscale);
    Paint paint = new Paint();
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);/*from  w ww .  j  ava  2 s  .co m*/

    ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
    paint.setColorFilter(f);
    c.drawBitmap(bmpOriginal, 0, 0, paint);
    return bmpGrayscale;
}

From source file:org.cocos2dx.lib.Cocos2dxBitmap.java

private static int getFontSizeAccordingHeight(int height) {
    Paint paint = new Paint();
    Rect bounds = new Rect();

    paint.setTypeface(Typeface.DEFAULT);
    int incr_text_size = 1;
    boolean found_desired_size = false;

    while (!found_desired_size) {

        paint.setTextSize(incr_text_size);
        String text = "SghMNy";
        paint.getTextBounds(text, 0, text.length(), bounds);

        incr_text_size++;// w w w  . j  a  va2 s . c  o  m

        if (height - bounds.height() <= 2) {
            found_desired_size = true;
        }
        Log.d("font size", "incr size:" + incr_text_size);
    }
    return incr_text_size;
}