List of usage examples for android.graphics Paint Paint
public Paint()
From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = pixels; paint.setAntiAlias(true);//from w ww .j a v a 2 s .c o m canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }
From source file:com.cssweb.android.view.KlineView.java
public void drawQuoteWin(Canvas canvas, JSONObject quoteData, int idx) throws JSONException { Paint mPaint = new Paint(); mPaint.setTextAlign(Paint.Align.LEFT); mPaint.setStyle(Paint.Style.STROKE); mPaint.setTypeface(Typeface.DEFAULT_BOLD); mPaint.setAntiAlias(true);/*from www. j a va2 s . co m*/ mPaint.setColor(GlobalColor.colorKlinePopub); mPaint.setTextSize(sTextSize); canvas.drawText(":", 0, axisLabelHeight, mPaint); canvas.drawText(":", 0, axisLabelHeight * 3, mPaint); canvas.drawText(":", 0, axisLabelHeight * 5, mPaint); canvas.drawText(":", 0, axisLabelHeight * 7, mPaint); canvas.drawText(":", 0, axisLabelHeight * 9, mPaint); canvas.drawText(":", 0, axisLabelHeight * 11, mPaint); canvas.drawText("??:", 0, axisLabelHeight * 13, mPaint); canvas.drawText("??:", 0, axisLabelHeight * 15, mPaint); mPaint.setTextAlign(Paint.Align.RIGHT); String qt = quoteData.getJSONArray("K").getJSONArray(idx).getString(0); double jrkp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(1); double zg = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(2); double zd = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(3); double sp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4); double preclose; if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) { switch (idx) { case 0: preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(7); break; default: preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(7); break; } if (quoteData.getJSONArray("K").length() == 1) { preclose = quoteData.getJSONArray("K").getJSONArray(0).getDouble(7); } } else { switch (idx) { case 0: preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4); break; default: preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(4); break; } if (quoteData.getJSONArray("K").length() == 1) { preclose = quoteData.getDouble("zrsp");//quoteData.getJSONArray("K").getJSONArray(0).getDouble(4); } } mPaint.setColor(getcolor(jrkp, preclose)); canvas.drawText(Utils.dataFormation(jrkp, stockdigit), klineX, axisLabelHeight * 2, mPaint); mPaint.setColor(getcolor(zg, preclose)); canvas.drawText(Utils.dataFormation(zg, stockdigit), klineX, axisLabelHeight * 4, mPaint); mPaint.setColor(getcolor(zd, preclose)); canvas.drawText(Utils.dataFormation(zd, stockdigit), klineX, axisLabelHeight * 6, mPaint); mPaint.setColor(getcolor(sp, preclose)); canvas.drawText(Utils.dataFormation(sp, stockdigit), klineX, axisLabelHeight * 8, mPaint); double zhangdie = sp - preclose; if (zhangdie > 0) mPaint.setColor(GlobalColor.colorpriceUp); else if (zhangdie < 0) mPaint.setColor(GlobalColor.colorPriceDown); else mPaint.setColor(GlobalColor.colorPriceEqual); canvas.drawText(Utils.dataFormation(zhangdie, stockdigit), klineX, axisLabelHeight * 10, mPaint); // if(quoteData.getString("period").equals("min5") || // quoteData.getString("period").equals("min15") || // quoteData.getString("period").equals("min30") || // quoteData.getString("period").equals("min60")){ // qt = qt.substring(4,6)+'/'+qt.substring(6,8)+' '+qt.substring(8); // }else{ // qt = qt.substring(2,4)+qt.substring(4,6)+qt.substring(6,8); // } qt = qt.substring(2, 4) + qt.substring(4, 6) + qt.substring(6, 8); mPaint.setColor(GlobalColor.colorLabelName); canvas.drawText(qt, klineX, axisLabelHeight * 12, mPaint); mPaint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(quoteData.getJSONArray("K").getJSONArray(idx).getDouble(5), false), klineX, axisLabelHeight * 14, mPaint); mPaint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(quoteData.getJSONArray("K").getJSONArray(idx).getDouble(6), false), klineX, axisLabelHeight * 16, mPaint); }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
public Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight();/* w w w .j a va2 s. co m*/ 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); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
From source file:com.example.psumaps.MapView.java
private void drawMarker(LatLng point, String str) { // Creating an instance of MarkerOptions MarkerOptions markerOptions = new MarkerOptions(); //IconGenerator tc = new IconGenerator(this); //Bitmap bmp = tc.makeIcon("hello"); Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.bubble_white);// get the image same as your EditText int h = bitmap.getHeight() * 2; int w = bitmap.getWidth() * 2; bitmap = convertToMutable(bitmap);// converting the bitmap to mutable Bitmap incrsize = Bitmap.createScaledBitmap(bitmap, w, h, false); Canvas cs = new Canvas(incrsize); Paint pt = new Paint(); pt.setColor(Color.BLACK);//w w w. j a va2 s . c om //Typeface tf = Typeface.create("Helvetica",Typeface.BOLD); pt.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); String iam = str.toUpperCase(Locale.getDefault()); pt.setTextSize(25); cs.drawText(iam, 0, iam.length(), (h / 2) + 10, (w / 2) / 2, pt); //pt.setColor(Color.RED); //cs.drawText("this is praki", 0, 13, h / 2, w / 3, pt); // Setting latitude and longitude for the marker markerOptions.position(point).title(str).icon(BitmapDescriptorFactory.fromBitmap(incrsize)); // Adding marker on the Google Map map.addMarker(markerOptions); }
From source file:net.exclaimindustries.geohashdroid.wiki.WikiPictureEditor.java
private void makePaints() { // These are for efficiency's sake so we don't rebuild paints uselessly. if (mBackgroundPaint == null) { mBackgroundPaint = new Paint(); mBackgroundPaint.setStyle(Style.FILL); mBackgroundPaint.setColor(getResources().getColor(R.color.infobox_background)); }//from w ww . ja va 2 s . c o m if (mTextPaint == null) { mTextPaint = new Paint(); mTextPaint.setColor(getResources().getColor(R.color.infobox_text)); mTextPaint.setTextSize(getResources().getDimension(R.dimen.infobox_picture_fontsize)); mTextPaint.setAntiAlias(true); } }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
/** * Creates Paint objects once when first needed. *//* www. jav a 2s . c o m*/ private void createPaints() { if (bitmapPaint == null) { bitmapPaint = new Paint(); bitmapPaint.setAntiAlias(true); bitmapPaint.setFilterBitmap(true); bitmapPaint.setDither(true); } if (debugPaint == null && debug) { debugPaint = new Paint(); debugPaint.setTextSize(18); debugPaint.setColor(Color.MAGENTA); debugPaint.setStyle(Style.STROKE); } }
From source file:de.madvertise.android.sdk.MadvertiseView.java
/** * Draw the ad background for a text banner * * @param canvas//w w w . j a v a2 s . com * @param rectangle * @param backgroundColor * @param mTextColor */ private void drawTextBannerBackground(final Canvas canvas, final Rect rectangle, final int backgroundColor, int shineColor) { Paint paint = new Paint(); paint.setColor(backgroundColor); paint.setAntiAlias(true); canvas.drawRect(rectangle, paint); int upperColor = Color.argb(GRADIENT_TOP_ALPHA, Color.red(shineColor), Color.green(shineColor), Color.blue(shineColor)); int[] gradientColors = { upperColor, shineColor }; GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, gradientColors); int stop = (int) (rectangle.height() * GRADIENT_STOP) + rectangle.top; gradientDrawable.setBounds(rectangle.left, rectangle.top, rectangle.right, stop); gradientDrawable.draw(canvas); Rect shadowRect = new Rect(rectangle.left, stop, rectangle.right, rectangle.bottom); Paint shadowPaint = new Paint(); shadowPaint.setColor(shineColor); canvas.drawRect(shadowRect, shadowPaint); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
public static Bitmap graphics_addWaterMarkToImage(Bitmap src, String watermark, Point location, int size, boolean underline) { Bitmap result = null;/*from w w w. j a v a 2 s .c o m*/ try { int w = src.getWidth(); int h = src.getHeight(); result = Bitmap.createBitmap(w, h, src.getConfig()); Canvas canvas = new Canvas(result); canvas.drawBitmap(src, 0, 0, null); Paint paint = new Paint(); paint.setColor(Color.RED); //paint.setAlpha(alpha); paint.setTextSize(size); paint.setAntiAlias(true); paint.setUnderlineText(underline); canvas.drawText(watermark, location.x, location.y, paint); } catch (Exception e) { result = null; if (LOG_ENABLE) Log.e(TAG, "ERROR: graphics_addWaterMarkToImage() [" + e.getMessage() + "]", e); } return result; }
From source file:android.support.designox.widget.CoordinatorLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp.mBehavior != null && lp.mBehavior.getScrimOpacity(this, child) > 0.f) { if (mScrimPaint == null) { mScrimPaint = new Paint(); }//from w ww . java2 s.c o m mScrimPaint.setColor(lp.mBehavior.getScrimColor(this, child)); // TODO: Set the clip appropriately to avoid unnecessary overdraw. canvas.drawRect(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom(), mScrimPaint); } return super.drawChild(canvas, child, drawingTime); }