List of usage examples for android.graphics Paint setColor
public void setColor(@ColorInt int color)
From source file:info.papdt.blacklight.ui.common.LinearViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Draw the indicator line int position = mCurrentPage * mTabWidth + (int) (mOffset * mTabWidth); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(mForeground); canvas.drawRect(position, (mHeight - mHeight / 18), position + mTabWidth, mHeight, paint); if (DEBUG) {/*from ww w. ja v a 2 s .co m*/ Log.d(TAG, "mWidth = " + mWidth + "; mHeight = " + mHeight + "; mTabWidth = " + mTabWidth); Log.d(TAG, "mCurrentPage = " + mCurrentPage); } }
From source file:com.frapim.windwatch.Notifier.java
public Bitmap createIcon(Context context, Wind wind) { Paint paint = new Paint(); int color = wind.scale.getColor(context); paint.setColor(color); paint.setStyle(Style.FILL_AND_STROKE); Bitmap bitmap = Bitmap.createBitmap(mBigIconSize, mBigIconSize, Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Bitmap backgroundBmp = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.turbine); Bitmap backgroundScaled = Bitmap.createScaledBitmap(backgroundBmp, mBigIconSize, mBigIconSize, false); canvas.drawBitmap(backgroundScaled, new Matrix(), new Paint()); canvas.drawPath(getArrowPath(wind.degrees), paint); return bitmap; }
From source file:com.jasonchen.microlang.view.LinearViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Draw the indicator line int position = mCurrentPage * mTabWidth + (int) (mOffset * mTabWidth); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(mForeground); canvas.drawRect(position, (mHeight - mHeight / 18), position + mTabWidth, mHeight, paint); /*if (DEBUG) {/* w ww . ja v a2 s. c om*/ Log.d(TAG, "mWidth = " + mWidth + "; mHeight = " + mHeight + "; mTabWidth = " + mTabWidth); Log.d(TAG, "mCurrentPage = " + mCurrentPage); }*/ }
From source file:krt.com.cityguide.Fragments.PageMapFragment.java
public void addObjectMarker(ObjectModel objectModel) { // googleMap.addCircle(new CircleOptions().center(new LatLng(objectModel.getLat(), objectModel.getLon())) // .fillColor(0x000000).radius(1)); // if (objectModel == null || googleMap == null) return; try {//w w w . j ava 2s .co m Bitmap.Config conf = Bitmap.Config.ARGB_8888; Bitmap bmp = Bitmap.createBitmap(20, 20, conf); Canvas canvas1 = new Canvas(bmp); // paint defines the text color, stroke width and size Paint color = new Paint(); color.setTextSize(35); color.setColor(Color.BLACK); canvas1.drawCircle(10, 10, 10, color); googleMap.addMarker(new MarkerOptions().position(new LatLng(objectModel.getLat(), objectModel.getLon())) .title(objectModel.getName()).snippet("snippet").icon(BitmapDescriptorFactory.fromBitmap(bmp))); } catch (NullPointerException e) { Log.d("error", e.getMessage()); } }
From source file:com.blogspot.ksoichiro.viewIndicator.ViewIndicator.java
@SuppressLint("DrawAllocation") @Override/* w ww. j a v a2s. c om*/ protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setStrokeWidth(1); paint.setStrokeCap(Paint.Cap.ROUND); paint.setColor(Color.BLACK); paint.setAntiAlias(true); for (int i = 0; i < mNumOfViews; i++) { float cx = (getWidth() - (mNumOfViews - 1) * DISTANCE) / 2 + i * DISTANCE; float cy = getHeight() / 2.0f; if (mPosition == i) { paint.setStyle(Paint.Style.FILL_AND_STROKE); } else { paint.setStyle(Paint.Style.STROKE); } canvas.drawCircle(cx, cy, RADIUS, paint); } }
From source file:com.sun.toy.widget.CalendarView.java
private Paint makePaint(int color) { Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); p.setColor(color); p.setTextSize(mDefaultTextSize);// ww w. j a va2 s . c om return p; }
From source file:com.jaspersoft.android.jaspermobile.widget.AnnotationView.java
private void addPath() { Paint annotationPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); annotationPaint.setColor(mColor); annotationPaint.setStyle(Paint.Style.STROKE); annotationPaint.setStrokeJoin(Paint.Join.ROUND); annotationPaint.setStrokeCap(Paint.Cap.ROUND); DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); int strokeSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mSize, metrics); annotationPaint.setStrokeWidth(strokeSize); Path annotationPath = new Path(); annotationPath.moveTo(mStartX, mStartY); mDrawingCache.add(new Pair<>(annotationPaint, annotationPath)); }
From source file:com.snippet.widget.ViewIndicator.java
@SuppressLint("DrawAllocation") @Override//from ww w .j a va 2 s. co m protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setStrokeWidth(1); paint.setStrokeCap(Paint.Cap.ROUND); paint.setColor(Color.BLACK); paint.setAntiAlias(true); for (int i = 0; i < mNumOfViews; i++) { float cx = (getWidth() - (mNumOfViews - 1) * mDistance) / 2 + i * mDistance; float cy = getHeight() / 2.0f; if (mPosition == i) { paint.setStyle(Paint.Style.FILL_AND_STROKE); } else { paint.setStyle(Paint.Style.STROKE); } canvas.drawCircle(cx, cy, mRadius, paint); } }
From source file:pl.mg6.newmaps.demo.MarkersExampleActivity.java
private Bitmap prepareBitmap() { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arrow_left); bitmap = bitmap.copy(Config.ARGB_8888, true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true);//from ww w. j av a 2 s. c o m paint.setColor(Color.WHITE); paint.setTextAlign(Align.CENTER); paint.setTextSize(getResources().getDimension(R.dimen.text_size)); String text = "mg6"; Rect bounds = new Rect(); paint.getTextBounds(text, 0, text.length(), bounds); float x = bitmap.getWidth() / 2.0f; float y = (bitmap.getHeight() - bounds.height()) / 2.0f - bounds.top; canvas.drawText(text, x, y, paint); return bitmap; }
From source file:com.snowpuppet.alert.formclock.FormClockView.java
private void updatePaints() { FormClockRenderer.ClockPaints paints = new FormClockRenderer.ClockPaints(); Paint paint = new Paint(); paint.setAntiAlias(true);//from w w w . j a va2 s . c om paint.setColor(mColor1); paints.fills[0] = paint; paint = new Paint(paint); paint.setColor(mColor2); paints.fills[1] = paint; paint = new Paint(paint); paint.setColor(mColor3); paints.fills[2] = paint; mHourMinRenderer.setPaints(paints); mSecondsRenderer.setPaints(paints); invalidate(); }