Java Code Examples for android.graphics.Paint#setStyle()

The following examples show how to use android.graphics.Paint#setStyle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinePieChart.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public LinePieChart(Context context)
{
    super(context);
    d = 0;
    i = ((BitmapDrawable)context.getResources().getDrawable(0x7f020078)).getBitmap();
    j = new Paint(1);
    k = new Paint(1);
    j.setColor(Color.parseColor("#e8edf3"));
    j.setStrokeWidth(1.33F * mDensity);
    j.setStyle(android.graphics.Paint.Style.STROKE);
    k.setColor(Color.parseColor("#33e8edf3"));
    k.setStrokeWidth(1.33F * mDensity);
    k.setStyle(android.graphics.Paint.Style.STROKE);
    l = 16.33F * mDensity;
    m = new Paint(1);
    m.setColor(Color.parseColor("#33e8edf3"));
    m.setStrokeWidth(4F);
    m.setStyle(android.graphics.Paint.Style.STROKE);
    n = new Paint(1);
    n.setColor(Color.parseColor("#ffffffff"));
    n.setStrokeWidth(4F);
    n.setStyle(android.graphics.Paint.Style.STROKE);
    e.setStrokeWidth(4F);
    e.setStyle(android.graphics.Paint.Style.STROKE);
}
 
Example 2
Source File: ELetter.java    From ReadMark with Apache License 2.0 6 votes vote down vote up
@Override
protected void initConfig(int x, int y) {
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(mStrokeWidth);
    mPaint.setAntiAlias(true);
    mPaint.setColor(Config.WHITE);
    mPaint.setStrokeCap(Paint.Cap.SQUARE);

    mRectF = new RectF(x - MAX_RADIUS_CIRCLE
            , y - MAX_RADIUS_CIRCLE
            , x + MAX_RADIUS_CIRCLE
            , y + MAX_RADIUS_CIRCLE);
    mFirstPoint = new Point(x - MAX_RADIUS_CIRCLE, y);
    mSecondPoint = new Point(mFirstPoint);
}
 
Example 3
Source File: ImageLoadingView.java    From ImageLoadingView with Apache License 2.0 6 votes vote down vote up
private void initView(Context context, AttributeSet attrs) {
    this.mContext = context;
    if (null == attrs) {
        if (!(getLayoutParams() instanceof FrameLayout.LayoutParams)) {
            FrameLayout.LayoutParams layoutParams =
                    new FrameLayout.LayoutParams(
                            dip2Px(50),
                            dip2Px(50),
                            Gravity.CENTER);
            setLayoutParams(layoutParams);
        }
    }
    mPaint1 = new Paint();
    mPaint1.setAntiAlias(true);
    mPaint1.setColor(Color.WHITE);
    mPaint2 = new Paint();
    mPaint2.setAntiAlias(true);
    mPaint2.setStyle(Paint.Style.STROKE);
    mPaint2.setColor(Color.WHITE);
}
 
Example 4
Source File: ScannerView.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
public ScannerView(final Context context, final AttributeSet attrs)
{
    super(context, attrs);

    final Resources res = getResources();
    maskColor = res.getColor(R.color.scan_mask);
    resultColor = res.getColor(R.color.scan_result_view);
    final int laserColor = res.getColor(R.color.scan_laser);
    final int dotColor = res.getColor(R.color.scan_dot);

    maskPaint = new Paint();
    maskPaint.setStyle(Style.FILL);

    laserPaint = new Paint();
    laserPaint.setColor(laserColor);
    laserPaint.setStrokeWidth(DOT_SIZE);
    laserPaint.setStyle(Style.STROKE);

    dotPaint = new Paint();
    dotPaint.setColor(dotColor);
    dotPaint.setAlpha(DOT_OPACITY);
    dotPaint.setStyle(Style.STROKE);
    dotPaint.setStrokeWidth(DOT_SIZE);
    dotPaint.setAntiAlias(true);
}
 
Example 5
Source File: Hasher.java    From crystal-preloaders with Apache License 2.0 6 votes vote down vote up
@Override
public void onDraw(Canvas canvas, Paint fgPaint, Paint bgPaint, float width, float height, float cx, float cy) {
    //canvas.drawColor(Color.YELLOW);

    fgPaint.setStyle(Paint.Style.FILL);
    fgPaint.setStrokeWidth(3f);
    fgPaint.setAntiAlias(true);

    canvas.save();
    canvas.scale(0.75f, 0.75f, cx, cy);
    canvas.rotate(degree, cx, cy);

    canvas.drawPath(path, fgPaint);
    canvas.restore();

    canvas.drawCircle(cx, cx, factor + factor - factor / 8, bgPaint);
    canvas.drawCircle(cx, cx, factor + factor - factor / 8 - 4, fgPaint);
    canvas.drawCircle(cx, cx, factor / 3, bgPaint);

}
 
Example 6
Source File: CustomShadow.java    From HaiNaBaiChuan with Apache License 2.0 6 votes vote down vote up
public CustomShadow(
        Resources resources, int backgroundColor, float radius,
        float shadowSize, float maxShadowSize
) {
    mShadowStartColor = resources.getColor(R.color.cardview_shadow_start_color);
    mShadowEndColor = resources.getColor(R.color.cardview_shadow_end_color);
    mInsetShadow = resources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow);
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setColor(backgroundColor);
    mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mCornerShadowPaint.setStyle(Paint.Style.FILL);
    mCornerRadius = (int) (radius + .5f);
    mCardBounds = new RectF();
    mEdgeShadowPaint = new Paint(mCornerShadowPaint);
    mEdgeShadowPaint.setAntiAlias(false);
    setShadowSize(shadowSize, maxShadowSize);

    CustomShadow.sRoundRectHelper = new RoundRectHelper() {
        @Override
        public void drawRoundRect(Canvas canvas, RectF bounds, float cornerRadius,
                                  Paint paint) {
            canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
        }
    };
}
 
Example 7
Source File: CircularProgressDrawable.java    From Mover with Apache License 2.0 5 votes vote down vote up
private CircularProgressDrawable(int[] colors,
                                 float borderWidth,
                                 float sweepSpeed,
                                 float rotationSpeed,
                                 int minSweepAngle,
                                 int maxSweepAngle,
                                 Style style,
                                 Interpolator angleInterpolator,
                                 Interpolator sweepInterpolator) {
  mSweepInterpolator = sweepInterpolator;
  mAngleInterpolator = angleInterpolator;
  mBorderWidth = borderWidth;
  mCurrentIndexColor = 0;
  mColors = colors;
  mCurrentColor = mColors[0];
  mSweepSpeed = sweepSpeed;
  mRotationSpeed = rotationSpeed;
  mMinSweepAngle = minSweepAngle;
  mMaxSweepAngle = maxSweepAngle;

  mPaint = new Paint();
  mPaint.setAntiAlias(true);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(borderWidth);
  mPaint.setStrokeCap(style == Style.ROUNDED ? Paint.Cap.ROUND : Paint.Cap.BUTT);
  mPaint.setColor(mColors[0]);

  setupAnimations();
}
 
Example 8
Source File: LockPatternView.java    From LockPattern with MIT License 5 votes vote down vote up
private void initItems(){
    mLPV = this;

    mVibrator = (Vibrator)mContext.getSystemService(Context.VIBRATOR_SERVICE);

    getStatusBarHeight();

    mCurrentLockStatus = SET_PATTERN;

    mDotLinePaint = new Paint();
    mDotLinePaint.setColor(mDotColorTouched);
    mDotLinePaint.setAntiAlias(true);
    mDotLinePaint.setStrokeWidth(mDotLineWidth);
    mDotLinePaint.setStyle(Paint.Style.STROKE);
    mDotLinePaint.setStrokeCap(Paint.Cap.ROUND);
    mPatternPath = new Path();
    mPatternPaint = new Paint(Paint.DITHER_FLAG);
    if (mIsPatternBgEnable){
        mBgLinePaint = new Paint();
        mBgLinePaint.setAntiAlias(true);
        mBgLinePaint.setStrokeWidth(mBgLineWidth);
        mBgLinePaint.setStyle(Paint.Style.STROKE);
    }

    setWillNotDraw(false);
    clearPathBitmap();

    DisplayMetrics dm = new DisplayMetrics();
    ((Activity)getContext()).getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    mMainPatternViewSize = width - width/5;

    setViewLayoutTransition(mLPV);
}
 
Example 9
Source File: TransformView.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
private void init() {


        //
        mPaint = new Paint();
        mCamera = new Camera();
        mMatrix = new Matrix();

        initBitmap();
        //
        helpPaint = new Paint();
        helpPaint.setStyle(Paint.Style.STROKE);
    }
 
Example 10
Source File: DraggableLayout.java    From DraggableDot with MIT License 5 votes vote down vote up
/**
 * initialize some local variables.
 */
private void init() {
    //the paint instance which used to draw bezierCurve
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL);

    //the path instance which used to draw bezierCurve
    mPath = new Path();
}
 
Example 11
Source File: ArcSeekBar.java    From arc-seekbar with Apache License 2.0 5 votes vote down vote up
private void initArcPaint() {
    mArcPaint = new Paint();
    mArcPaint.setAntiAlias(true);
    mArcPaint.setStrokeWidth(mArcWidth);
    mArcPaint.setStyle(Paint.Style.STROKE);
    mArcPaint.setStrokeCap(Paint.Cap.ROUND);
}
 
Example 12
Source File: StepView.java    From StepView with Apache License 2.0 5 votes vote down vote up
private void initPaint() {
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(mColor);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(mStrokeWidth);
    mPaint.setFilterBitmap(true);
    mPaint.setAlpha(120);
}
 
Example 13
Source File: CloudTextGraphic.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
CloudTextGraphic(GraphicOverlay overlay, FirebaseVisionText.Element element) {
  super(overlay);

  this.element = element;
  this.overlay = overlay;

  rectPaint = new Paint();
  rectPaint.setColor(TEXT_COLOR);
  rectPaint.setStyle(Paint.Style.STROKE);
  rectPaint.setStrokeWidth(STROKE_WIDTH);

  textPaint = new Paint();
  textPaint.setColor(TEXT_COLOR);
  textPaint.setTextSize(TEXT_SIZE);
}
 
Example 14
Source File: ViewPagerTextDrawer.java    From IndicatorBox with MIT License 5 votes vote down vote up
public ViewPagerTextDrawer(int bigTextSize, int smallTextSize, int bigTextColor, int smallTextColor, int slashColor) {
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mBigTextSize = bigTextSize;
    mSmallTextSize = smallTextSize;
    mBigText = "1";
    mSmallText = "1";
    mBigTextColor = bigTextColor;
    mSmallTextColor = smallTextColor;
    mSlashColor = slashColor;
}
 
Example 15
Source File: Dialog.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
public DialogCardView(Context context) {
    super(context);

    mDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDividerPaint.setStyle(Paint.Style.STROKE);
    setWillNotDraw(false);
}
 
Example 16
Source File: OvalShape.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void fillAndStroke(Canvas canvas, Paint paint) {
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    canvas.drawOval(rectF, paint);
}
 
Example 17
Source File: LineDrawStrategy.java    From FancyView with Apache License 2.0 4 votes vote down vote up
@Override
public void drawAppIcon(Canvas canvas, float fraction, Drawable icon, int colorOfIcon,
                        WidthAndHeightOfView widthAndHeightOfView) {
    int centerX = widthAndHeightOfView.getWidth() / 2;
    int centerY = widthAndHeightOfView.getHeight() / 2;
    Bitmap bitmap = BitmapUtils.drawableToBitmap(icon);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(colorOfIcon);
    paint.setStrokeWidth(3);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStyle(Paint.Style.STROKE);
    float bitmapLeft = centerX - 250;
    float bitmapRight = bitmapLeft + bitmap.getWidth() * 1.7f;
    float bitmapTop = centerY - 250;
    float bitmapBottom = bitmapTop + bitmap.getHeight() * 1.7f;
    canvas.save();
    if (fraction <= 0.75) {
        float newfraction = fraction / 0.75f;
        if (newfraction <= 0.25) {
            canvas.drawLine(bitmapLeft, bitmapBottom, bitmapLeft,
                    bitmapBottom - (bitmapBottom - bitmapTop) * (newfraction / 0.25f), paint);
          //  path.lineTo(bitmapLeft, bitmapBottom + (bitmapBottom - bitmapTop) * (newfraction / 0.25f));
        } else {
            canvas.drawLine(bitmapLeft, bitmapBottom, bitmapLeft, bitmapTop, paint);
          //  path.lineTo(bitmapLeft, bitmapTop);
        }
        if (newfraction > 0.25) {
            if (newfraction <= 0.50) {
                canvas.drawLine(bitmapLeft, bitmapTop,
                        bitmapLeft + (bitmapRight - bitmapLeft) * ((newfraction - 0.25f)/0.25f),
                        bitmapTop, paint);
              //  path.lineTo(bitmapLeft + (bitmapRight - bitmapLeft) * ((newfraction - 0.25f)/0.25f),
               //         bitmapTop);
            } else {
                canvas.drawLine(bitmapLeft, bitmapTop, bitmapRight, bitmapTop, paint);
               // path.lineTo(bitmapRight, bitmapTop);
            }
        }
        if (newfraction > 0.50) {
            if (newfraction <= 0.75) {
                canvas.drawLine(bitmapRight, bitmapTop, bitmapRight,
                        bitmapTop + (bitmapBottom - bitmapTop) * ((newfraction - 0.50f) / 0.25f),
                        paint);
                //path.lineTo(bitmapRight, bitmapTop + (bitmapBottom - bitmapTop) * ((fraction - 0.50f) / 0.25f));
            } else {
                canvas.drawLine(bitmapRight, bitmapTop, bitmapRight, bitmapBottom, paint);
                //path.lineTo(bitmapRight, bitmapBottom);
            }
        }
        if (newfraction > 0.75) {
            if (newfraction <= 1) {
                canvas.drawLine(bitmapRight, bitmapBottom, bitmapRight - (bitmapRight - bitmapLeft) * ((newfraction - 0.75f)/ 0.25f),
                                 bitmapBottom, paint);
               // path.lineTo(bitmapLeft + (bitmapRight - bitmapLeft) * ((fraction - 0.75f)/ 0.25f),
               //         bitmapBottom);
            } else {
                canvas.drawLine(bitmapRight, bitmapBottom, bitmapLeft, bitmapBottom, paint);
               // path.lineTo(bitmapLeft, bitmapBottom);
            }
        }
    }
    canvas.restore();
    canvas.save();
    if (fraction > 0.75) {
        canvas.clipRect(bitmapLeft + (bitmap.getWidth()/2f) * ((1 - fraction) /0.25f),
                bitmapTop + (bitmap.getHeight()/2f)* ((1 - fraction) / 0.25f),
                bitmapRight - (bitmap.getWidth()/2f) * ((1 - fraction) /0.25f),
                bitmapBottom - (bitmap.getHeight()/2f)* ((1 - fraction) / 0.25f));
        Matrix matrix = new Matrix();
        matrix.postScale(1.7f, 1.7f, (bitmapLeft + bitmapRight) * 0.5f,
                (bitmapTop + bitmapBottom) * 0.5f);
        canvas.concat(matrix);
        canvas.drawBitmap(bitmap, (bitmapLeft + bitmapRight) / 2 - bitmap.getWidth() / 2,
                (bitmapTop + bitmapBottom) / 2 - bitmap.getHeight() / 2, paint);
    }
    canvas.restore();
}
 
Example 18
Source File: Histogram.java    From Chart with Apache License 2.0 4 votes vote down vote up
private void drawHistogram(Canvas canvas) {
    //如果没有设置x轴数据
    if (xData == null){
        throw new NullPointerException("x轴数据源不能为空!");
    }
    //如果没有设置y轴数据
    if (yData == null){
        throw new NullPointerException("y轴数据源不能为空!");
    }
    Paint histogramPaint = new Paint();
    histogramPaint.setAntiAlias(true);
    histogramPaint.setStyle(Paint.Style.FILL);
    histogramPaint.setStrokeWidth((float) 5.0);
    //矩形上具体数据画笔
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(rect_text_size);
    textPaint.setColor(rect_text_color);
    DecimalFormat formater = new DecimalFormat("0.000");
    for (int i=0; i<xpCount; i++){
        try {
            histogramPaint.setColor(rect_color == null
                    ? getResources().getColor(R.color.colorPrimary)
                    : rect_color[i]);
        }catch (ArrayIndexOutOfBoundsException e){
            histogramPaint.setColor(getResources().getColor(R.color.colorPrimary));
        }
        int alpha = anims[i].getAlpha();
        textPaint.setAlpha(alpha);
        histogramPaint.setAlpha(alpha);
        //计算执行动画当前y坐标
        float top = anims[i].getCurrentY();
        float left = oX+xCoordinates[i]-xSpacing/3;
        float right = oX+xCoordinates[i]+xSpacing/3;
        String ydata = formater.format(yData[i]);
        int[] textSize = getTextSize(xData[i],textPaint);
        float textY = top - textSize[1]/2;
        //画矩形上文字
        canvas.drawText(ydata,left,textY,textPaint);
        //画每一个矩形
        canvas.drawRect(left,top,right,oY,histogramPaint);
    }
}
 
Example 19
Source File: PathShape.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void draw(Canvas canvas, Paint paint) {
    paint.setStyle(Paint.Style.STROKE);
    canvas.drawPath(path, paint);
}
 
Example 20
Source File: RoundedThumbnailView.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a RoundedThumbnailView.
 */
public RoundedThumbnailView(Context context, AttributeSet attrs)
{
    super(context, attrs);

    mCallback = Optional.absent();

    // Make the view clickable.
    setClickable(true);
    setOnClickListener(mOnClickListener);

    mThumbnailPadding = getResources().getDimension(R.dimen.rounded_thumbnail_padding);

    // Load thumbnail pop-out effect constants.
    mThumbnailStretchDurationMs = THUMBNAIL_STRETCH_DURATION_MS;
    mThumbnailShrinkDurationMs = THUMBNAIL_SHRINK_DURATION_MS;
    mThumbnailStretchDiameterBegin =
            getResources().getDimension(R.dimen.rounded_thumbnail_diameter_min);
    mThumbnailStretchDiameterEnd =
            getResources().getDimension(R.dimen.rounded_thumbnail_diameter_max);
    mThumbnailShrinkDiameterBegin = mThumbnailStretchDiameterEnd;
    mThumbnailShrinkDiameterEnd =
            getResources().getDimension(R.dimen.rounded_thumbnail_diameter_normal);
    // Load ripple effect constants.
    float startDelayRatio = 0.5f;
    mRippleStartDelayMs = (long) (mThumbnailStretchDurationMs * startDelayRatio);
    mRippleDurationMs = RIPPLE_DURATION_MS;
    mRippleRingDiameterEnd =
            getResources().getDimension(R.dimen.rounded_thumbnail_ripple_ring_diameter_max);

    mViewRect = new RectF(0, 0, mRippleRingDiameterEnd, mRippleRingDiameterEnd);

    mRippleRingDiameterBegin =
            getResources().getDimension(R.dimen.rounded_thumbnail_ripple_ring_diameter_min);
    mRippleRingThicknessBegin =
            getResources().getDimension(R.dimen.rounded_thumbnail_ripple_ring_thick_max);
    mRippleRingThicknessEnd =
            getResources().getDimension(R.dimen.rounded_thumbnail_ripple_ring_thick_min);

    mCurrentHitStateCircleOpacity = HIT_STATE_CIRCLE_OPACITY_HIDDEN;
    // Draw the reveal while circle.
    mHitStateCirclePaint = new Paint();
    mHitStateCirclePaint.setAntiAlias(true);
    mHitStateCirclePaint.setColor(Color.WHITE);
    mHitStateCirclePaint.setStyle(Paint.Style.FILL);

    mRipplePaint = new Paint();
    mRipplePaint.setAntiAlias(true);
    mRipplePaint.setColor(Color.WHITE);
    mRipplePaint.setStyle(Paint.Style.STROKE);

    mRevealCirclePaint = new Paint();
    mRevealCirclePaint.setAntiAlias(true);
    mRevealCirclePaint.setColor(Color.WHITE);
    mRevealCirclePaint.setStyle(Paint.Style.FILL);
}