List of usage examples for android.graphics Paint setColor
public void setColor(@ColorInt int color)
From source file:gov.sfmta.sfpark.AnnotationsOverlay.java
public void draw(Canvas canvas, MapView mapv, boolean shadow) { if (shadow) { return;/* w w w . j a va 2 s .c om*/ } Projection projection = mapv.getProjection(); Point from = new Point(); Point to = new Point(); Paint mPaint = new Paint(); mPaint.setStyle(Style.STROKE); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(6); mPaint.setStrokeCap(Paint.Cap.ROUND); // could have NPE: try { for (MyAnnotation a : MainScreenActivity.annotations) { if (a.onStreet) { projection.toPixels(a.nw, from); projection.toPixels(a.se, to); if (MainScreenActivity.showPrice) { mPaint.setColor(a.blockColorPrice); canvas.drawLine(from.x, from.y, to.x, to.y, mPaint); } else { // new: no more availability data on blockfaces. // mPaint.setColor(a.blockColorAvailability); } } } } catch (NullPointerException npe) { // oh sadface! just ignore. } super.draw(canvas, mapv, shadow); }
From source file:comingle.dragracing.TrackActivity.java
private void initEndFlag() { Paint text_paint = new Paint(); text_paint.setColor(Color.BLACK); text_paint.setTextSize(20);/*from www . j a va2 s . co m*/ switch (lanes) { case 1: case 2: case 3: track_canvas.drawRect(780, 250, 800, 380, text_paint); break; case 4: track_canvas.drawRect(780, 250, 800, 420, text_paint); break; case 5: track_canvas.drawRect(780, 250, 800, 460, text_paint); break; case 6: track_canvas.drawRect(780, 250, 800, 500, text_paint); break; } }
From source file:comingle.dragracing.TrackActivity.java
private void initMarkers(LinkedList<Integer> locs) { Paint text_paint = new Paint(); text_paint.setColor(Color.BLACK); text_paint.setTextSize(20);// w w w. ja va 2 s . co m String prev = "Start"; String next = "End"; int x = locs.indexOf(getLocation()); if (x == locs.size() - 1) { initEndFlag(); } if (x == 0) { initStartFlag(); } if (x > 0) { prev = String.format("<< %s", INTERVAL_MARKERS[x - 1]); } if (x < locs.size() - 1) { next = String.format("%s >>", INTERVAL_MARKERS[x]); } //adjusted placement of markers track_canvas.drawText(prev, 20, TOP_MARGIN - 70, text_paint); track_canvas.drawText(next, 800 - 50, TOP_MARGIN - 70, text_paint); }
From source file:com.cssweb.android.view.FinanceMini.java
public void drawHKIndex(Canvas canvas) { Paint paint = this.mPaint; paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true);//from w w w . j a v a2s . co m if (quoteData != null) { try { JSONArray jArr = quoteData.getJSONArray("data"); JSONObject jo = jArr.getJSONObject(0); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(mTextSize); paint.setColor(GlobalColor.colorLabelName); 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, -DY * 3); paint.setColor(GlobalColor.colorpriceUp); canvas.translate(0, DY); canvas.drawText(String.valueOf(jo.getInt("zj")), x - tips, y, paint); paint.setColor(GlobalColor.colorPriceEqual); canvas.translate(0, DY); canvas.drawText(String.valueOf(jo.getInt("pj")), x - tips, y, paint); paint.setColor(GlobalColor.colorPriceDown); canvas.translate(0, DY); canvas.drawText(String.valueOf(jo.getInt("dj")), x - tips, y, paint); } catch (JSONException e) { Log.e(TAG, e.toString()); } } }
From source file:com.cssweb.android.view.FinanceMini.java
public void drawIndex(Canvas canvas) { //canvas.restore(); Paint paint = this.mPaint; paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true);//from ww w . java2 s. c o m if (quoteData != null) { try { JSONArray jArr = quoteData.getJSONArray("data"); JSONObject jo = jArr.getJSONObject(0); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(mTextSize); paint.setColor(GlobalColor.colorLabelName); 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.RIGHT); canvas.translate(width, -DY * 5); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(jo.getDouble("a"), true), x, y, paint); canvas.translate(0, DY); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(jo.getDouble("b"), true), x, y, paint); canvas.translate(0, DY); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(jo.getDouble("govbond"), true), x, y, paint); canvas.translate(0, DY); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(jo.getDouble("fund"), true), x, y, paint); canvas.translate(0, DY); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(jo.getDouble("warrant"), true), x, y, paint); canvas.translate(0, DY); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(jo.getDouble("bond"), true), x, y, paint); } catch (JSONException e) { Log.e(TAG, e.toString()); } } }
From source file:comingle.dragracing.TrackActivity.java
private void placeCarAvailable(int car_idx, int left_margin, int pos_idx) { if (car_idx >= CAR_COLORS.length) { return;// www. j a v a2 s . co m } Paint car_paint = new Paint(); if (car_idx >= 0) { car_paint.setColor(CAR_COLORS[car_idx]); } else { car_paint.setColor(BG_COLOR); } int left = left_margin + TRACK_WIDTH * pos_idx + 20; int right = left_margin + TRACK_WIDTH * (pos_idx + 1) + 20; int top = LEGEND_MARGIN + 2; int bottom = LEGEND_MARGIN + TRACK_WIDTH - 2; Rect sprite = new Rect(left, top, right, bottom); track_canvas.drawRect(sprite, car_paint); }
From source file:comingle.dragracing.TrackActivity.java
private void initStartFlag() { Paint text_paint = new Paint(); text_paint.setColor(Color.BLACK); text_paint.setTextSize(20);// w w w . j a v a 2 s.c o m switch (lanes) { case 1: case 2: case 3: for (int j = 0; j <= 50; j = j + 50) { for (int i = 250; i <= 380; i = i + 40) { track_canvas.drawRect(j, i, j + 25, i + 20, text_paint); } } for (int k = 270; k <= 400; k = k + 40) { track_canvas.drawRect(25, k, 50, k + 20, text_paint); } break; case 4: for (int j = 0; j <= 50; j = j + 50) { for (int i = 250; i <= 420; i = i + 40) { track_canvas.drawRect(j, i, j + 25, i + 20, text_paint); } } for (int k = 270; k <= 440; k = k + 40) { track_canvas.drawRect(25, k, 50, k + 20, text_paint); } ; break; case 5: for (int j = 0; j <= 50; j = j + 50) { for (int i = 250; i <= 460; i = i + 40) { track_canvas.drawRect(j, i, j + 25, i + 20, text_paint); } } for (int k = 270; k <= 480; k = k + 40) { track_canvas.drawRect(25, k, 50, k + 20, text_paint); } ; break; case 6: for (int j = 0; j <= 50; j = j + 50) { for (int i = 250; i <= 500; i = i + 40) { track_canvas.drawRect(j, i, j + 25, i + 20, text_paint); } } for (int k = 270; k <= 520; k = k + 40) { track_canvas.drawRect(25, k, 50, k + 20, text_paint); } ; break; } }
From source file:com.yk.notification.util.BitmapUtil.java
/** * //from w w w . j a va 2 s .co m * @param bitmap * @return */ public static Bitmap createRoundImageWithBorder(Context context, Bitmap bitmap) { // int bitmapWidth = bitmap.getWidth(); // int bitmapHeight = bitmap.getHeight(); // pixel int borderWidthHalf = 20; //?? int bitmapSquareWidth = Math.min(bitmapWidth, bitmapHeight); //? int newBitmapSquareWidth = bitmapSquareWidth + borderWidthHalf; Bitmap roundedBitmap = Bitmap.createBitmap(newBitmapSquareWidth, newBitmapSquareWidth, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(roundedBitmap); int x = borderWidthHalf + bitmapSquareWidth - bitmapWidth; int y = borderWidthHalf + bitmapSquareWidth - bitmapHeight; //???,?X,Y?2 ?? canvas.drawBitmap(bitmap, x / 2, y / 2, null); Paint borderPaint = new Paint(); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setStrokeWidth(borderWidthHalf); borderPaint.setColor(Color.WHITE); // canvas.drawCircle(canvas.getWidth() / 2, canvas.getWidth() / 2, newBitmapSquareWidth / 2, borderPaint); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), roundedBitmap); roundedBitmapDrawable.setGravity(Gravity.CENTER); roundedBitmapDrawable.setCircular(true); return getBitmapFromDrawable(roundedBitmapDrawable); }
From source file:com.wiipu.bimu.adapter.AreaSelect.WheelView.java
/** * Draws rect for current value/*from w w w. j a v a 2 s.c om*/ * @param canvas the canvas for drawing */ private void drawCenterRect(Canvas canvas) { int center = getHeight() / 2; int offset = (int) (getItemHeight() / 2 * 1.2); /*/ Remarked by wulianghuan 2014-11-27 ??? Rect rect = new Rect(left, top, right, bottom) centerDrawable.setBounds(bounds) centerDrawable.setBounds(0, center - offset, getWidth(), center + offset); centerDrawable.draw(canvas); //*/ Paint paint = new Paint(); paint.setColor(Color.parseColor("#999999")); // paint.setStrokeWidth((float) 3); // canvas.drawLine(0, center - offset, getWidth(), center - offset, paint); // canvas.drawLine(0, center + offset, getWidth(), center + offset, paint); //*/ }
From source file:com.cssweb.android.view.FinanceMini.java
public void drawHKPrice(Canvas canvas) { Paint paint = this.mPaint; paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true);// w w w.j av a2 s .com if (quoteData != null) { try { JSONArray jArr = quoteData.getJSONArray("data"); JSONObject jo = jArr.getJSONObject(0); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(mTextSize); paint.setColor(GlobalColor.colorLabelName); 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); paint.setColor(GlobalColor.colorStockName); canvas.translate(width / 2, -DY * 4); canvas.drawText(Utils.getAmountFormat(jo.getInt("cjsl"), false), x - tips, y, paint); canvas.translate(0, DY); // 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-tips, y, paint); canvas.drawText(Utils.getAmountFormat(jo.getInt("cjje"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorpriceUp); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getInt("msgs"), true), x - tips, y, paint); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.translate(0, -DY * 3); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); // canvas.drawText("", x, y, paint); 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 * 3); paint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1, jo.getInt("tp")), x - tips, y, paint); canvas.translate(0, DY); // 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); // } paint.setColor(GlobalColor.colorPriceDown); canvas.drawText("", x - tips, y, paint); 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("cjje"), true), x-tips, y, paint); } catch (JSONException e) { Log.e(TAG, e.toString()); } } }