Java Code Examples for android.graphics.CornerPathEffect

The following are top voted examples for showing how to use android.graphics.CornerPathEffect. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: LaunchEnr   File: PopupContainerWithArrow.java   Source Code and License 6 votes vote down vote up
/**
 * Adds an arrow view pointing at the original icon.
 * @param horizontalOffset the horizontal offset of the arrow, so that it
 *                              points at the center of the original icon
 */
private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) {
    LayoutParams layoutParams = new LayoutParams(width, height);
    if (mIsLeftAligned) {
        layoutParams.gravity = Gravity.START;
        layoutParams.leftMargin = horizontalOffset;
    } else {
        layoutParams.gravity = Gravity.END;
        layoutParams.rightMargin = horizontalOffset;
    }
    if (mIsAboveIcon) {
        layoutParams.topMargin = verticalOffset;
    } else {
        layoutParams.bottomMargin = verticalOffset;
    }

    View arrowView = new View(getContext());
    if (Gravity.isVertical(((FrameLayout.LayoutParams) getLayoutParams()).gravity)) {
        // This is only true if there wasn't room for the container next to the icon,
        // so we centered it instead. In that case we don't want to show the arrow.
        arrowView.setVisibility(INVISIBLE);
    } else {
        ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
                width, height, !mIsAboveIcon));
        Paint arrowPaint = arrowDrawable.getPaint();
        // Note that we have to use getChildAt() instead of getItemViewAt(),
        // since the latter expects the arrow which hasn't been added yet.
        PopupItemView itemAttachedToArrow = (PopupItemView)
                (getChildAt(mIsAboveIcon ? getChildCount() - 1 : 0));
        arrowPaint.setColor(itemAttachedToArrow.getArrowColor(mIsAboveIcon));
        // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
        int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius);
        arrowPaint.setPathEffect(new CornerPathEffect(radius));
        arrowView.setBackground(arrowDrawable);
        arrowView.setElevation(getElevation());
    }
    addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams);
    return arrowView;
}
 
Example 2
Project: CurveView   File: CurveView.java   Source Code and License 6 votes vote down vote up
private void init() {
        mCornerPathEffect = new CornerPathEffect(mCorner);

        mContentPaint = new Paint();
        mContentPaint.setStyle(Paint.Style.STROKE);
        mContentPaint.setColor(mContentColor);
        mContentPaint.setStrokeWidth(mStrokeWidth);
        mContentPaint.setPathEffect(mCornerPathEffect);

        mBackgroundPaint = new Paint();
//        mBackgroundPaint.setColor(mFillColor);

        mXAxisPaint = new TextPaint();
        mXAxisPaint.setColor(mAxisTextColor);
        mXAxisPaint.setTextSize(mAxisTextSize);

        mDotTextPaint = new TextPaint();
        mDotTextPaint.setColor(mDotTextColor);
        mDotTextPaint.setTextSize(mDotTextSize);

        mContentPath = new Path();
        //        mMaxVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity();
        mMaxVelocity = 3000;
    }
 
Example 3
Project: FlowLine   File: FlowLineView.java   Source Code and License 6 votes vote down vote up
private void init() {

        CornerPathEffect cpe = new CornerPathEffect(20);

        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(5);
        mPaint.setAntiAlias(false);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setPathEffect(cpe);
//        mPaint.setPathEffect(new DashPathEffect(new float[]{10,10},0));
//        mPaint.setPathEffect(new DiscretePathEffect(3.0f, 5.0f));
//        Path path = new Path();
//        path.addCircle(0, 0, 3, Path.Direction.CCW);
//        PathEffect pathEffect = new PathDashPathEffect(path, 12, 0, PathDashPathEffect.Style.ROTATE);
//        mPaint.setPathEffect(pathEffect);

        mBitmapPaint.setStrokeWidth(3);
        mBitmapPaint.setAntiAlias(true);
        mBitmapPaint.setStyle(Paint.Style.STROKE);
        mBitmapPaint.setPathEffect(cpe);

        makePolygon(new RectF(50, 50, 450, 450), mPath,6);
        makePolygon(new RectF(75, 75, 425, 425), mInnerPath,6);
        mBitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
        mBitmapCanvas = new Canvas(mBitmap);
    }
 
Example 4
Project: android-study   File: PathEffectView.java   Source Code and License 6 votes vote down vote up
@Override protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  //无效果
  mEffects[0] = null;
  //拐角处变得圆滑
  mEffects[1] = new CornerPathEffect(30);
  //线段上就会产生许多杂点
  mEffects[2] = new DiscretePathEffect(3.0F, 5.0F);
  //绘制虚线
  mEffects[3] = new DashPathEffect(new float[] { 20, 10, 5, 10 }, 0);
  Path path = new Path();
  path.addRect(0, 0, 8, 8, Path.Direction.CCW);
  //设置点的图形,即方形点的虚线,圆形点的虚线
  mEffects[4] = new PathDashPathEffect(path, 12, 0, PathDashPathEffect.Style.ROTATE);
  //组合PathEffect
  mEffects[5] = new ComposePathEffect(mEffects[3], mEffects[1]);
  for (int i = 0; i < mEffects.length; i++) {
    mPaint.setPathEffect(mEffects[i]);
    canvas.drawPath(mPath, mPaint);
    canvas.translate(0, 200);
  }
}
 
Example 5
Project: coinblesk-client-gui   File: AuthenticationView.java   Source Code and License 6 votes vote down vote up
public AuthenticationView(Context context, byte[] key) {
    super(context);
    byte[] digest = new byte[0];
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        messageDigest.update(key);
        digest = messageDigest.digest();
    } catch (NoSuchAlgorithmException e) {
        Log.w(TAG, "MessageDigest algorithm not found.");
    }

    this.digest = digest;
    this.dotPaint.setColor(getContext().getResources().getColor(R.color.colorPrimaryDark));
    this.dotPaint.setAntiAlias(true);
    this.dotPaint.setStyle(Paint.Style.FILL);

    this.patternPaint.setColor(Color.GREEN);
    this.patternPaint.setAntiAlias(true);
    this.patternPaint.setStyle(Paint.Style.FILL);
    this.patternPaint.setStrokeJoin(Paint.Join.ROUND);    // set the join to round you want
    this.patternPaint.setStrokeCap(Paint.Cap.ROUND);      // set the paint cap to round too
    this.patternPaint.setPathEffect(new CornerPathEffect(10));
    this.patternPaint.setDither(true);
}
 
Example 6
Project: LiteSDK   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

    mLinePaint = new Paint();
    mLinePaint.setAntiAlias(true);
    mLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mLinePaint.setStyle(Style.FILL);
    mLinePaint.setStrokeWidth(10);

    mDividerLinePaint = new Paint();
    mDividerLinePaint.setAntiAlias(true);
    mDividerLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mDividerLinePaint.setStyle(Style.FILL);
    mDividerLinePaint.setStrokeWidth(5);
}
 
Example 7
Project: OverWatchLoading   File: OWLoadingView.java   Source Code and License 6 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    viewHeight = getMeasuredHeight();
    viewWidth = getMeasuredWidth();
    if (viewWidth != 0 && viewHeight != 0) {
        center.x = viewWidth / 2f;
        center.y = viewHeight / 2f;
        float spaceRate = 1 / 100f;
        space = viewWidth <= viewHeight ? viewWidth * spaceRate : viewHeight * spaceRate;
        hexagonRadius = (float) ((viewWidth - 2 * space) / (3 * Math.sqrt(3)));
        initHexagonCenters();
        //圆角处理
        paint.setPathEffect(new CornerPathEffect(hexagonRadius * 0.1f));
        baseDataInited = true;
    }
}
 
Example 8
Project: ViewPageIndicator-underline   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获得自定义属性,tab的数量
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.ViewPagerIndicator);
	mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
			COUNT_DEFAULT_TAB);
	if (mTabVisibleCount < 0)
		mTabVisibleCount = COUNT_DEFAULT_TAB;
	a.recycle();

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffFD7580"));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 9
Project: BackgroundView   File: LeafView.java   Source Code and License 6 votes vote down vote up
private void init() {
    mPaint = new Paint();
    // 绘制贝塞尔曲线
    mPaint.setColor(mColor);
    mPaint.setStrokeWidth(8);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setTextSize(60);
    mPaint.setPathEffect(new CornerPathEffect(4));

    for (int i = 0; i < mData.length; i++) {
        mData[i] = new PointF();
    }
    for (int i = 0; i < mCtrl.length; i++) {
        mCtrl[i] = new PointF();
    }

}
 
Example 10
Project: BackgroundView   File: MountainView.java   Source Code and License 6 votes vote down vote up
private void init() {
    mPaint = new Paint();
    // 绘制贝塞尔曲线
    mPaint.setColor(mColor);
    mPaint.setStrokeWidth(8);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setTextSize(60);
    mPaint.setPathEffect(new CornerPathEffect(4));

    for (int i = 0; i < mData.length; i++) {
        mData[i] = new PointF();
    }
    for (int i = 0; i < mCtrl.length; i++) {
        mCtrl[i] = new PointF();
    }


}
 
Example 11
Project: smart-farmer-android   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);

    // 获得自定义属性,tab的数量
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ViewPagerIndicator);
    mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
            COUNT_DEFAULT_TAB);
    if (mTabVisibleCount < 0)
        mTabVisibleCount = COUNT_DEFAULT_TAB;
    a.recycle();

    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.parseColor("#ffffffff"));
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 12
Project: cidrawing   File: SmoothStrokeMode.java   Source Code and License 6 votes vote down vote up
protected CiPaint assignPaint() {
    CiPaint paint = new CiPaint(drawingContext.getPaint());
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeCap(Paint.Cap.ROUND);
    if (smoothRadius > 0) {
        CornerPathEffect effect = new CornerPathEffect(smoothRadius);
        if (paint.getPathEffect() == null) {
            paint.setPathEffect(effect);
        } else {
            ComposePathEffect composeEffect = new ComposePathEffect(paint.getPathEffect(), effect);
            paint.setPathEffect(composeEffect);
        }
    }
    return paint;
}
 
Example 13
Project: stickynavlayout   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    screenWidth = getScreenWidth(context);
    DIMENSION_TRIANGEL_WIDTH = (int) (screenWidth / 3 * RADIO_TRIANGEL);
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ViewPagerIndicator);
    mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
            COUNT_DEFAULT_TAB);
    if (mTabVisibleCount < 0)
        mTabVisibleCount = COUNT_DEFAULT_TAB;
    a.recycle();

    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.parseColor("#ffffffff"));
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));
}
 
Example 14
Project: GOpenSource_AppKit_Android_AS   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获得自定义属性,tab的数量
	mTabVisibleCount = 2;
	if (mTabVisibleCount < 0)
		mTabVisibleCount = COUNT_DEFAULT_TAB;

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffff9a23"));
	mPaint.setColor(getContext().getResources().getColor(R.color.yellow));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 15
Project: GizOpenSource_AppKit_Android   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获得自定义属性,tab的数量
	mTabVisibleCount = 2;
	if (mTabVisibleCount < 0)
		mTabVisibleCount = COUNT_DEFAULT_TAB;

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffff9a23"));
	mPaint.setColor(getContext().getResources().getColor(R.color.yellow));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 16
Project: toshi-android-client   File: FramedViewfinderView.java   Source Code and License 6 votes vote down vote up
private void initPathIfNeeded() {
    if (this.pathPaint != null) {
        return;
    }

    final Rect frame = super.framingRect;
    final float radius = 25.0f;
    final int strokeWidth = 10;
    final int offset = strokeWidth / 2;

    this.pathPaint = new Paint();
    this.pathPaint.setColor(Color.WHITE);
    this.pathPaint.setStrokeWidth(strokeWidth);
    this.pathPaint.setStyle(Paint.Style.STROKE);

    this.path = new Path();
    this.path.moveTo(frame.left + radius, frame.top - offset);
    this.path.lineTo(frame.left + frame.width() + offset, frame.top - offset);
    this.path.lineTo(frame.left + frame.width() + offset, frame.top + frame.height() + offset);
    this.path.lineTo(frame.left - offset, frame.top + frame.height() + offset);
    this.path.lineTo(frame.left - offset, frame.top - offset);
    this.path.lineTo(frame.left + frame.width() - radius, frame.top - offset);

    final CornerPathEffect cornerPathEffect = new CornerPathEffect(radius);
    this.pathPaint.setPathEffect(cornerPathEffect);
}
 
Example 17
Project: LoadingView-OverWatch   File: OverWatchViewItem.java   Source Code and License 6 votes vote down vote up
public OverWatchViewItem(OverWatchLoadingView loadingView, PointF centerPoint, int length) {
    this.mLoadingView = loadingView;
    mCenterPoint = centerPoint;
    mPaint = new Paint();
    mPaint.setColor(mLoadingView.color);
    mPaint.setStrokeWidth(3);
    mPaint.setAlpha(0);
    CornerPathEffect corEffect = new CornerPathEffect(length / CORNER_PATH_EFFECT_SCALE);
    mPaint.setPathEffect(corEffect);

    PointF[] points = getHexagonPoints(centerPoint, length);
    mPath = new Path();
    mPath.moveTo(points[1].x, points[1].y);
    mPath.lineTo(points[2].x, points[2].y);
    mPath.lineTo(points[3].x, points[3].y);
    mPath.lineTo(points[4].x, points[4].y);
    mPath.lineTo(points[5].x, points[5].y);
    mPath.lineTo(points[6].x, points[6].y);
    mPath.close();

    initInitAnimation();
}
 
Example 18
Project: zone-sdk   File: SimpleDraw.java   Source Code and License 6 votes vote down vote up
private void initView() {
    mHolder = getHolder();
    mHolder.addCallback(this);
    setFocusable(true);
    setFocusableInTouchMode(true);
    this.setKeepScreenOn(true);
    mPath = new Path();
    mPaint = new Paint();
    mPaint.setColor(Color.RED);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(20);
    mPaint.setDither(true);
    mPaint.setAntiAlias(true);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setPathEffect(new CornerPathEffect(10)); 
    
}
 
Example 19
Project: umeng_community_android   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

    mLinePaint = new Paint();
    mLinePaint.setAntiAlias(true);
    mLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mLinePaint.setStyle(Style.FILL);
    mLinePaint.setStrokeWidth(10);

    mDividerLinePaint = new Paint();
    mDividerLinePaint.setAntiAlias(true);
    mDividerLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mDividerLinePaint.setStyle(Style.FILL);
    mDividerLinePaint.setStrokeWidth(5);
}
 
Example 20
Project: FBreader   File: ZLAndroidPaintContext.java   Source Code and License 6 votes vote down vote up
ZLAndroidPaintContext(Canvas canvas, int width, int height, int scrollbarWidth) {
	myCanvas = canvas;
	myWidth = width - scrollbarWidth;
	myHeight = height;
	myScrollbarWidth = scrollbarWidth;

	myTextPaint.setLinearText(false);
	myTextPaint.setAntiAlias(AntiAliasOption.getValue());
	if (DeviceKerningOption.getValue()) {
		myTextPaint.setFlags(myTextPaint.getFlags() | Paint.DEV_KERN_TEXT_FLAG);
	} else {
		myTextPaint.setFlags(myTextPaint.getFlags() & ~Paint.DEV_KERN_TEXT_FLAG);
	}
	myTextPaint.setDither(DitheringOption.getValue());
	myTextPaint.setSubpixelText(SubpixelOption.getValue());

	myLinePaint.setStyle(Paint.Style.STROKE);

	myOutlinePaint.setColor(Color.rgb(255, 127, 0));
	myOutlinePaint.setAntiAlias(true);
	myOutlinePaint.setDither(true);
	myOutlinePaint.setStrokeWidth(4);
	myOutlinePaint.setStyle(Paint.Style.STROKE);
	myOutlinePaint.setPathEffect(new CornerPathEffect(5));
	myOutlinePaint.setMaskFilter(new EmbossMaskFilter(new float[] {1, 1, 1}, .4f, 6f, 3.5f));
}
 
Example 21
Project: AndroidExerciseProgram   File: ECGView.java   Source Code and License 6 votes vote down vote up
public ECGView(Context context, AttributeSet set) {
    super(context, set);

    setLayerType(LAYER_TYPE_SOFTWARE, null);

    /*
     * 实例化画笔并设置属性
     */
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setColor(Color.GREEN);
    mPaint.setStrokeWidth(5);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStyle(Paint.Style.STROKE);
    // 绘制的图形添加一个阴影层效果
    mPaint.setShadowLayer(7, 0, 0, Color.GREEN);

    // CornerPathEffect、DiscretePathEffect、DashPathEffect、PathDashPathEffect、ComposePathEffect、SumPathEffect
    mPaint.setPathEffect(new CornerPathEffect(5));

    mPath = new Path();
    transX = 0;
    isCanvasMove = false;
}
 
Example 22
Project: AndroidGeek   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

    mLinePaint = new Paint();
    mLinePaint.setAntiAlias(true);
    mLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mLinePaint.setStyle(Style.FILL);
    mLinePaint.setStrokeWidth(10);

    mDividerLinePaint = new Paint();
    mDividerLinePaint.setAntiAlias(true);
    mDividerLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mDividerLinePaint.setStyle(Style.FILL);
    mDividerLinePaint.setStrokeWidth(5);
}
 
Example 23
Project: ametro   File: SegmentElement.java   Source Code and License 6 votes vote down vote up
private Paint createPaint(int color, float lineWidth, boolean isWorking){
    Paint paint = new Paint();
    paint.setStyle(Style.STROKE);
    paint.setAntiAlias(true);
    paint.setColor(color);

    if (isWorking) {
        paint.setStrokeWidth(lineWidth);
        paint.setPathEffect(
                new CornerPathEffect(lineWidth * 0.2f));
    } else {
        paint.setStrokeWidth(lineWidth * 0.75f);
        paint.setPathEffect(new ComposePathEffect(
                new DashPathEffect(new float[]{lineWidth * 0.8f, lineWidth * 0.2f}, 0),
                new CornerPathEffect(lineWidth * 0.2f)
        ));
    }
    return paint;
}
 
Example 24
Project: Android-ViewPagerIndicator   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获取可见Tab的数量
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.ViewPagerIndicator);

	mTabVisibleCount = a.getInt(
			R.styleable.ViewPagerIndicator_visible_tab_count,
			COUNT_DEFAULT_TAB);
	if (mTabVisibleCount < 0)
	{
		mTabVisibleCount = COUNT_DEFAULT_TAB;
	}
	a.recycle();

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffffffff"));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 25
Project: androidsamples   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);

    // 获得自定义属性,tab的数量
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ViewPagerIndicator);
    mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
            COUNT_DEFAULT_TAB);
    if (mTabVisibleCount < 0)
        mTabVisibleCount = COUNT_DEFAULT_TAB;
    a.recycle();

    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.parseColor("#ffffffff"));
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 26
Project: Analog-Tachometer   File: Tachometer.java   Source Code and License 6 votes vote down vote up
private void drawMainIndicators(Canvas c) {

        mBasePaint.setStrokeWidth(15);
        mBasePaint.setStyle(Paint.Style.FILL);
        mBasePaint.setPathEffect(new CornerPathEffect(4));

        if(mMainIndicatorPath == null) {
            createMainIndicatorPath(c);
        }

        for(int rotation=-128, count=8; rotation <=128; rotation+=32, count--) {

            c.save();
            c.rotate(rotation, c.getWidth() / 2, c.getHeight() / 2);

            if(count<=1) {
                mBasePaint.setColor(COLOR_RED);
            }

            c.drawPath(mMainIndicatorPath, mBasePaint);

            c.restore();
        }

        resetBasePaint();
    }
 
Example 27
Project: miappstore   File: ViewPagerIndicator.java   Source Code and License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获得自定义属性,tab的数量
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.ViewPagerIndicator);
	mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
			COUNT_DEFAULT_TAB);
	if (mTabVisibleCount < 0)
		mTabVisibleCount = COUNT_DEFAULT_TAB;
	a.recycle();

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffffffff"));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example 28
Project: AndroidCommunicationBenchmark   File: AuthenticationView.java   Source Code and License 6 votes vote down vote up
public AuthenticationView(Context context, byte[] key) {
    super(context);
    byte[] digest = new byte[0];
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        messageDigest.update(key);
        digest = messageDigest.digest();
    } catch (NoSuchAlgorithmException e) {
    }
    this.digest = digest;
    this.dotPaint.setColor(Color.BLACK);
    this.dotPaint.setAntiAlias(true);
    this.dotPaint.setStyle(Paint.Style.FILL);

    this.patternPaint.setColor(Color.GREEN);
    this.patternPaint.setAntiAlias(true);
    this.patternPaint.setStyle(Paint.Style.FILL);
    this.patternPaint.setStrokeJoin(Paint.Join.ROUND);    // set the join to round you want
    this.patternPaint.setStrokeCap(Paint.Cap.ROUND);      // set the paint cap to round too
    this.patternPaint.setPathEffect(new CornerPathEffect(10));
    this.patternPaint.setDither(true);
    Log.d("sha",toHex(digest));
}
 
Example 29
Project: itmarry   File: ZLAndroidPaintContext.java   Source Code and License 6 votes vote down vote up
ZLAndroidPaintContext(Canvas canvas, int width, int height, int scrollbarWidth) {
	myCanvas = canvas;
	myWidth = width - scrollbarWidth;
	myHeight = height;
	myScrollbarWidth = scrollbarWidth;

	myTextPaint.setLinearText(false);
	myTextPaint.setAntiAlias(AntiAliasOption.getValue());
	if (DeviceKerningOption.getValue()) {
		myTextPaint.setFlags(myTextPaint.getFlags() | Paint.DEV_KERN_TEXT_FLAG);
	} else {
		myTextPaint.setFlags(myTextPaint.getFlags() & ~Paint.DEV_KERN_TEXT_FLAG);
	}
	myTextPaint.setDither(DitheringOption.getValue());
	myTextPaint.setSubpixelText(SubpixelOption.getValue());

	myLinePaint.setStyle(Paint.Style.STROKE);

	myOutlinePaint.setColor(Color.rgb(255, 127, 0));
	myOutlinePaint.setAntiAlias(true);
	myOutlinePaint.setDither(true);
	myOutlinePaint.setStrokeWidth(4);
	myOutlinePaint.setStyle(Paint.Style.STROKE);
	myOutlinePaint.setPathEffect(new CornerPathEffect(5));
	myOutlinePaint.setMaskFilter(new EmbossMaskFilter(new float[] {1, 1, 1}, .4f, 6f, 3.5f));
}
 
Example 30
Project: -abase-reader   File: ZLAndroidPaintContext.java   Source Code and License 6 votes vote down vote up
ZLAndroidPaintContext(Canvas canvas, int width, int height, int scrollbarWidth) {
	myCanvas = canvas;
	myWidth = width - scrollbarWidth;
	myHeight = height;
	myScrollbarWidth = scrollbarWidth;

	myTextPaint.setLinearText(false);
	myTextPaint.setAntiAlias(AntiAliasOption.getValue());
	if (DeviceKerningOption.getValue()) {
		myTextPaint.setFlags(myTextPaint.getFlags() | Paint.DEV_KERN_TEXT_FLAG);
	} else {
		myTextPaint.setFlags(myTextPaint.getFlags() & ~Paint.DEV_KERN_TEXT_FLAG);
	}
	myTextPaint.setDither(DitheringOption.getValue());
	myTextPaint.setSubpixelText(SubpixelOption.getValue());

	myLinePaint.setStyle(Paint.Style.STROKE);

	myOutlinePaint.setColor(Color.rgb(255, 127, 0));
	myOutlinePaint.setAntiAlias(true);
	myOutlinePaint.setDither(true);
	myOutlinePaint.setStrokeWidth(4);
	myOutlinePaint.setStyle(Paint.Style.STROKE);
	myOutlinePaint.setPathEffect(new CornerPathEffect(5));
	myOutlinePaint.setMaskFilter(new EmbossMaskFilter(new float[] {1, 1, 1}, .4f, 6f, 3.5f));
}
 
Example 31
Project: codeexamples-android   File: CustomButton.java   Source Code and License 6 votes vote down vote up
public CustomButton(Context context) {
	super(context);
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setColor(Color.BLACK);
	paint.setTextSize(40);

	fillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	fillPaint.setStyle(Style.FILL);
	fillPaint.setColor(Color.RED);
	CornerPathEffect effect = new CornerPathEffect(30);
	fillPaint.setPathEffect(effect);
	fillPaint.setStyle(Style.FILL_AND_STROKE);
	fillPaint.setShader(new LinearGradient(0F, 120, getWidth(),
			getHeight(), Color.CYAN, Color.RED, Shader.TileMode.CLAMP));

}
 
Example 32
Project: Mapyst   File: RouteMapOverlay.java   Source Code and License 6 votes vote down vote up
private void setupPaints() {
	paint = new Paint();
	paint.setAntiAlias(true);
	paint.setStrokeWidth(8.0f);
	paint.setStyle(Style.STROKE);
	paint.setPathEffect(new CornerPathEffect(5.0f));
	paint.setColor(OUTSIDE_COLOR);

	bitmapPaint = new Paint();

	shadePaint = new Paint();
	shadePaint.setColor(Color.argb(255 / 3, 89, 89, 89));

	insidePaint = new Paint();
	insidePaint.setAntiAlias(true);
	insidePaint.setStrokeWidth(8.0f);
	insidePaint.setStyle(Style.STROKE);
	insidePaint.setPathEffect(new CornerPathEffect(5.0f));
	insidePaint.setColor(OUTSIDE_COLOR);
}
 
Example 33
Project: GitHub   File: SquareProgressView.java   Source Code and License 5 votes vote down vote up
public void setRoundedCorners(boolean roundedCorners, float radius) {
    this.roundedCorners = roundedCorners;
    this.roundedCornersRadius = radius;
    if (roundedCorners) {
        progressBarPaint.setPathEffect(new CornerPathEffect(roundedCornersRadius));
    } else {
        progressBarPaint.setPathEffect(null);
    }
    this.invalidate();
}
 
Example 34
Project: android_ui   File: ProgressDrawable.java   Source Code and License 5 votes vote down vote up
/**
 * Updates the given <var>paint</var> in the way, that changes its options in order to enable
 * or disable rounded feature for the paint.
 *
 * @param paint   The paint to update.
 * @param rounded {@code True} if the paint should support rounded feature so a graphics drawn
 *                using the paint will have rounded corners, {@code false} to clear the current
 *                rounded feature.
 * @return The specified paint with updated <b>stroke join, stroke cap</b> and <b>path effect</b>.
 */
Paint updatePaintToRounded(Paint paint, boolean rounded) {
	if (rounded) {
		paint.setStrokeJoin(Paint.Join.ROUND);
		paint.setStrokeCap(Paint.Cap.ROUND);
		paint.setPathEffect(new CornerPathEffect(mProgressState.useThickness));
	} else {
		paint.setStrokeJoin(Paint.Join.MITER);
		paint.setStrokeCap(Paint.Cap.BUTT);
		paint.setPathEffect(null);
	}
	return paint;
}
 
Example 35
Project: BubbleAlert   File: AlertDrawable.java   Source Code and License 5 votes vote down vote up
public AlertDrawable(int outerCircleRadiusDP, int textSizeSP, int cornerArc, String drawText, Context context) {
    mContext = context;

    circleRadius = ScreenUtils.unitToPixels(context, TypedValue.COMPLEX_UNIT_DIP, outerCircleRadiusDP);
    textSize = ScreenUtils.unitToPixels(context, TypedValue.COMPLEX_UNIT_SP, textSizeSP);
    mDrawText = TextUtils.isEmpty(drawText) ? " " : drawText;
    initBitmap(mDrawText);
    mBackGroundPaint = new Paint();
    mBackGroundPaint.setAntiAlias(true);
    mBackGroundPaint.setDither(true);
    mBackGroundPaint.setColor(Color.WHITE);
    mBackGroundPaint.setStyle(Paint.Style.FILL);


    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(ContextCompat.getColor(context, R.color.colorMultiArc));
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mOuterCircleFillPaint = new Paint();
    mOuterCircleFillPaint.setAntiAlias(true);
    mOuterCircleFillPaint.setDither(true);
    mOuterCircleFillPaint.setColor(Color.WHITE);
    mOuterCircleFillPaint.setStyle(Paint.Style.FILL);
    mOuterCircleFillPaint.setTextSize(textSize);


    borderPath = new Path();
    borderRect = new Rect();

    CornerPathEffect cornerPathEffect = new CornerPathEffect(cornerArc);
    mBackGroundPaint.setPathEffect(cornerPathEffect);

    outerCircleOffset = context.getResources().getInteger(R.integer.outerCircleOffset);
}
 
Example 36
Project: Sega   File: SimpleRatingBar.java   Source Code and License 5 votes vote down vote up
/**
 * Inits paint objects and default values.
 */
private void initView() {
    starPath = new Path();
    cornerPathEffect = new CornerPathEffect(starCornerRadius);

    paintStarOutline = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarOutline.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarOutline.setAntiAlias(true);
    paintStarOutline.setDither(true);
    paintStarOutline.setStrokeJoin(Paint.Join.ROUND);
    paintStarOutline.setStrokeCap(Paint.Cap.ROUND);
    paintStarOutline.setColor(Color.BLACK);
    paintStarOutline.setPathEffect(cornerPathEffect);

    paintStarBorder = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarBorder.setStyle(Paint.Style.STROKE);
    paintStarBorder.setStrokeJoin(Paint.Join.ROUND);
    paintStarBorder.setStrokeCap(Paint.Cap.ROUND);
    paintStarBorder.setStrokeWidth(starBorderWidth);
    paintStarBorder.setPathEffect(cornerPathEffect);

    paintStarBackground = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarBackground.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarBackground.setAntiAlias(true);
    paintStarBackground.setDither(true);
    paintStarBackground.setStrokeJoin(Paint.Join.ROUND);
    paintStarBackground.setStrokeCap(Paint.Cap.ROUND);

    paintStarFill = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarFill.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarFill.setAntiAlias(true);
    paintStarFill.setDither(true);
    paintStarFill.setStrokeJoin(Paint.Join.ROUND);
    paintStarFill.setStrokeCap(Paint.Cap.ROUND);

    defaultStarSize = applyDimension(COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
}
 
Example 37
Project: Sega   File: SimpleRatingBar.java   Source Code and License 5 votes vote down vote up
/**
 * Sets radius of star corner in pixels.
 * @param starCornerRadius
 */
public void setStarCornerRadius(float starCornerRadius) {
    this.starCornerRadius = starCornerRadius;
    if (starCornerRadius < 0) {
        throw new IllegalArgumentException(String.format("SimpleRatingBar initialized with invalid value for starCornerRadius. Found %f, but should be greater or equal than 0",
                                                         starCornerRadius));
    }
    cornerPathEffect = new CornerPathEffect(starCornerRadius);
    paintStarBorder.setPathEffect(cornerPathEffect);
    paintStarOutline.setPathEffect(cornerPathEffect);
    // request redraw of the view
    invalidate();
}
 
Example 38
Project: Oblique   File: ObliqueView.java   Source Code and License 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    //  super.onDraw(canvas);

    paint.setStyle(Paint.Style.FILL);
    switch (config.getType()) {
        case 0:
            paint.setColor(config.getBaseColor());
            break;
        case 1:
            paint.setShader(config.getLinearGradient(config.getAngle(), width, height));
            break;
        case 2:
            paint.setShader(config.getRadialGradient(width, height));
            break;
        case 3:
            setupBitmap(this, width, height);
            break;
    }
        paint.setStrokeJoin(Paint.Join.ROUND);    // set the join to round you want
        paint.setStrokeCap(Paint.Cap.ROUND);      // set the paint cap to round too
        paint.setPathEffect(new CornerPathEffect(config.getRadius()));
    ViewCompat.setElevation(this, config.getShadow());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && ViewCompat.getElevation(this) > 0f) {

        try {
            setOutlineProvider(getOutlineProvider());
        } catch (Exception e) {
            Log.e("Exception", e.getMessage());
            e.printStackTrace();
        }
    }
    paint.setXfermode(pdMode);
    canvas.drawPath(path, paint);
}
 
Example 39
Project: similarLoadingView   File: SimilarLoadingView.java   Source Code and License 5 votes vote down vote up
private void initPaint() {
    paint.setAlpha(0);
    paint.setPathEffect(new CornerPathEffect(cornerRadius));
    paint.setColor(color);
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);
}
 
Example 40
Project: egma-handwriting-numbers   File: DrawView.java   Source Code and License 5 votes vote down vote up
private void initializePaint() {
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setPathEffect(new CornerPathEffect(50));
    mPaint.setDither(true);
    mPaint.setStrokeWidth(20);
    mPaint.setAntiAlias(true);
}