android.graphics.Paint.Style Java Examples

The following examples show how to use android.graphics.Paint.Style. 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: SimpleHeader.java    From ZrcListView with MIT License 6 votes vote down vote up
public SimpleHeader(Context context) {
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Style.FILL);
    int fontSize = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, context.getResources()
                    .getDisplayMetrics());
    mPaint.setTextSize(fontSize);
    mPaint.setTextAlign(Align.CENTER);
    mTextColor = 0xffffffff;
    mPointColor = 0xffffffff;
    mFontOffset = -(mPaint.getFontMetrics().top + mPaint.getFontMetrics().bottom) / 2;
    mHeight = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 45, context.getResources()
                    .getDisplayMetrics());
    mPointRadius =
            TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2.5f, context.getResources()
                    .getDisplayMetrics());
    mCircleRadius = mPointRadius * 3.5f;
}
 
Example #2
Source File: X8DoubleWaySeekBar.java    From FimiX8-RE with MIT License 6 votes vote down vote up
private void init(AttributeSet attrs) {
    int progressColor = Color.parseColor("#FF4081");
    int backgroundColor = Color.parseColor("#BBBBBB");
    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.doubleWaySeekBar);
        this.mPointerDrawable = a.getDrawable(R.styleable.doubleWaySeekBar_pointerBackground);
        this.mHalfDrawableWidth = this.mPointerDrawable.getIntrinsicWidth() / 2;
        progressColor = a.getColor(R.styleable.doubleWaySeekBar_progressColor, Color.parseColor("#FF4081"));
        backgroundColor = a.getColor(R.styleable.doubleWaySeekBar_backgroundColor, Color.parseColor("#BBBBBB"));
        a.recycle();
    }
    this.mNormalPaint = new Paint();
    this.mNormalPaint.setColor(backgroundColor);
    this.mPointerPaint = new Paint();
    this.mPointerPaint.setColor(SupportMenu.CATEGORY_MASK);
    this.mProgressPaint = new Paint();
    this.mProgressPaint.setColor(progressColor);
    this.mCenterPaint = new Paint();
    this.mCenterPaint.setColor(-1);
    this.mCenterPaint.setStyle(Style.FILL);
}
 
Example #3
Source File: LinearGradientFillBitmapTextureAtlasSourceDecorator.java    From tilt-game-android with MIT License 6 votes vote down vote up
public LinearGradientFillBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int[] pColors, final float[] pPositions, final LinearGradientDirection pLinearGradientDirection, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
	super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
	this.mColors = pColors;
	this.mPositions = pPositions;
	this.mLinearGradientDirection = pLinearGradientDirection;

	this.mPaint.setStyle(Style.FILL);

	final int right = pBitmapTextureAtlasSource.getTextureWidth() - 1;
	final int bottom = pBitmapTextureAtlasSource.getTextureHeight() - 1;

	final float fromX = pLinearGradientDirection.getFromX(right);
	final float fromY = pLinearGradientDirection.getFromY(bottom);
	final float toX = pLinearGradientDirection.getToX(right);
	final float toY = pLinearGradientDirection.getToY(bottom);

	this.mPaint.setShader(new LinearGradient(fromX, fromY, toX, toY, pColors, pPositions, TileMode.CLAMP));
}
 
Example #4
Source File: PieChartRenderer.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
public PieChartRenderer(PieChart chart, ChartAnimator animator,
                        ViewPortHandler viewPortHandler) {
    super(animator, viewPortHandler);
    mChart = chart;

    mHolePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHolePaint.setColor(Color.WHITE);
    mHolePaint.setStyle(Style.FILL);

    mTransparentCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTransparentCirclePaint.setColor(Color.WHITE);
    mTransparentCirclePaint.setStyle(Style.FILL);
    mTransparentCirclePaint.setAlpha(105);

    mCenterTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mCenterTextPaint.setColor(Color.BLACK);
    mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12f));

    mValuePaint.setTextSize(Utils.convertDpToPixel(13f));
    mValuePaint.setColor(Color.WHITE);
    mValuePaint.setTextAlign(Align.CENTER);
}
 
Example #5
Source File: AxisRenderer.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
public AxisRenderer(ViewPortHandler viewPortHandler, Transformer trans) {
       super(viewPortHandler);

       this.mTrans = trans;

       mAxisLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

       mGridPaint = new Paint();
       mGridPaint.setColor(Color.GRAY);
       mGridPaint.setStrokeWidth(1f);
       mGridPaint.setStyle(Style.STROKE);
       mGridPaint.setAlpha(90);

       mAxisLinePaint = new Paint();
       mAxisLinePaint.setColor(Color.BLACK);
       mAxisLinePaint.setStrokeWidth(1f);
       mAxisLinePaint.setStyle(Style.STROKE);

	mLimitLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mLimitLinePaint.setStyle(Paint.Style.STROKE);
}
 
Example #6
Source File: SimpleGraph.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
private SimpleGraph(final int color, final long maxNsecs, final float width, final float height, final float strokeWidth)
{
    this.maxNsecs = maxNsecs;
    // this.width = width;
    this.height = height;
    nsecWidth = width / maxNsecs;
    
    paintStroke = new Paint();
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);
    
    paintFill = new Paint();
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
    
    pathStroke = new Path();
    pathFill = new Path();
}
 
Example #7
Source File: ColorsHelper.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
public void drawTextCenter(Canvas canvas, String text, int color, int size,
                           int min) {
    Paint innerPaint = new Paint();
    innerPaint.setAntiAlias(true);
    innerPaint.setStyle(Style.FILL);
    innerPaint.setColor(color);
    innerPaint.setTextSize(size);
    // int cHeight = canvas.getClipBounds().height();
    // int cWidth = canvas.getClipBounds().width();
    Rect r = new Rect();
    // setTextMatchParent(text,innerPaint,width-strokeWidth*2-25);
    innerPaint.setTextAlign(Paint.Align.LEFT);
    innerPaint.getTextBounds(text, 0, text.length(), r);
    float x = min / 2f - r.width() / 2f - r.left;
    float y = min / 2f + r.height() / 2f - r.bottom;

    canvas.drawText(text, x, y, innerPaint);
}
 
Example #8
Source File: DataRenderer.java    From android-kline with Apache License 2.0 6 votes vote down vote up
public DataRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(viewPortHandler);
    this.mAnimator = animator;

    mRenderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mRenderPaint.setStyle(Style.FILL);

    mDrawPaint = new Paint(Paint.DITHER_FLAG);

    mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValuePaint.setColor(Color.rgb(63, 63, 63));
    mValuePaint.setTextAlign(Align.CENTER);
    mValuePaint.setTextSize(Utils.convertDpToPixel(9f));

    mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHighlightPaint.setStyle(Paint.Style.STROKE);
    mHighlightPaint.setStrokeWidth(2f);
    mHighlightPaint.setColor(Color.rgb(255, 187, 115));
}
 
Example #9
Source File: SmoothGraph.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
private SmoothGraph(final int color, final float width, final float height, final float strokeWidth)
{
    this.height = height;
    this.width = width;
    
    paintStroke = new Paint();
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);
    
    paintFill = new Paint();
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);

    pathStroke = new Path();
    pathFill = new Path();
}
 
Example #10
Source File: StickMole.java    From Android-Charts with Apache License 2.0 6 votes vote down vote up
public void draw(Canvas canvas) {	
	Paint mPaintFill = new Paint();
	mPaintFill.setStyle(Style.FILL);
	mPaintFill.setColor(stickFillColor);
	
	if (width() >= 2f && width() >= 2 * stickStrokeWidth) {
		if (stickStrokeWidth  > 0) {
			Paint mPaintBorder = new Paint();
			mPaintBorder.setStyle(Style.STROKE);
			mPaintBorder.setStrokeWidth(stickStrokeWidth);
			mPaintBorder.setColor(stickBorderColor);
			
			canvas.drawRect(left + stickStrokeWidth, top + stickStrokeWidth, right - stickStrokeWidth, bottom - stickStrokeWidth, mPaintFill);
			canvas.drawRect(left + stickStrokeWidth, top + stickStrokeWidth, right - stickStrokeWidth, bottom - stickStrokeWidth, mPaintBorder);
		}else{
			canvas.drawRect(left, top, right, bottom, mPaintFill);
		}
	} else {
		canvas.drawLine(left, top, left, bottom, mPaintFill);	
	}
}
 
Example #11
Source File: X8TabItem.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    Log.i("zdy", "......" + getWidth() + " " + getHeight());
    if (getWidth() != 0) {
        int count = this.textArr.length;
        Paint p = new Paint();
        p.setColor(this.lineColor);
        p.setStyle(Style.FILL);
        float with = (((float) getWidth()) * 1.0f) / ((float) this.textArr.length);
        for (int i = 1; i < count; i++) {
            RectF r1 = new RectF();
            float nPos = with * ((float) i);
            r1.left = nPos - (((float) this.space) / 2.0f);
            r1.right = (((float) this.space) / 2.0f) + nPos;
            r1.top = (float) (this.lineStroke + 0);
            r1.bottom = (float) (getHeight() - this.lineStroke);
            canvas.drawRect(r1, p);
        }
    }
}
 
Example #12
Source File: ProgressWheel.java    From pandroid with Apache License 2.0 6 votes vote down vote up
/**
 * Set the properties of the paints we're using to
 * draw the progress wheel
 */
private void setupPaints() {
    if (roundStroke) {
        barPaint.setDither(true);
        barPaint.setStrokeCap(Paint.Cap.ROUND);
        barPaint.setPathEffect(new CornerPathEffect(10) );
    }

    barPaint.setColor(barColor);
    barPaint.setAntiAlias(true);
    barPaint.setStyle(Style.STROKE);
    barPaint.setStrokeWidth(barWidth);

    rimPaint.setColor(rimColor);
    rimPaint.setAntiAlias(true);
    rimPaint.setStyle(Style.STROKE);
    rimPaint.setStrokeWidth(rimWidth);
}
 
Example #13
Source File: CircleDisplay.java    From itracing2 with GNU General Public License v2.0 6 votes vote down vote up
private void init()
{

    mBoxSetup = false;

    mArcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mArcPaint.setStyle(Style.FILL);
    mArcPaint.setColor(Color.rgb(192, 255, 140));

    mInnerCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mInnerCirclePaint.setStyle(Style.FILL);
    mInnerCirclePaint.setColor(Color.WHITE);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setStyle(Style.STROKE);
    mTextPaint.setTextAlign(Align.CENTER);
    mTextPaint.setColor(Color.BLACK);
    mTextPaint.setTextSize(Utils.convertDpToPixel(getResources(), 24f));

    mDrawAnimator = ObjectAnimator.ofFloat(this, "phase", mPhase, 1.0f).setDuration(3000);
    mDrawAnimator.setInterpolator(new AccelerateDecelerateInterpolator());

    mGestureDetector = new GestureDetector(getContext(), this);
}
 
Example #14
Source File: SquareProgressView.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
public SquareProgressView(Context context, AttributeSet attrs) {
	super(context, attrs);
	progressBarPaint = new Paint();
	progressBarPaint.setColor(context.getResources().getColor(
			android.R.color.holo_green_dark));
	progressBarPaint.setStrokeWidth(CalculationUtil.convertDpToPx(
			widthInDp, getContext()));
	progressBarPaint.setAntiAlias(true);
	progressBarPaint.setStyle(Style.STROKE);

	outlinePaint = new Paint();
	outlinePaint.setColor(context.getResources().getColor(
			android.R.color.black));
	outlinePaint.setStrokeWidth(1);
	outlinePaint.setAntiAlias(true);
	outlinePaint.setStyle(Style.STROKE);

	textPaint = new Paint();
	textPaint.setColor(context.getResources().getColor(
			android.R.color.black));
	textPaint.setAntiAlias(true);
	textPaint.setStyle(Style.STROKE);
}
 
Example #15
Source File: HorizontalRule.java    From FlexibleRichTextView with Apache License 2.0 6 votes vote down vote up
public void draw(Canvas g2, float x, float y) {
Paint st = AjLatexMath.getPaint();
Style s = st.getStyle();
float w = st.getStrokeWidth();
st.setStyle(Style.FILL);
st.setStrokeWidth(0);
int c = st.getColor();
if (color != null)
    st.setColor(color);
if (speShift == 0) {
	g2.drawRect(x, y - height, x + width, y, st);
} else {
    g2.drawRect(x, y - height + speShift, x + width, y + speShift, st);
}
	st.setColor(c);
	st.setStyle(s);
st.setStrokeWidth(w);
   }
 
Example #16
Source File: Ripple.java    From Mover with Apache License 2.0 6 votes vote down vote up
private boolean drawSoftware(Canvas c, Paint p) {
    boolean hasContent = false;

    p.setColor(mColorOpaque);
    final int alpha = (int) (mColorAlpha * mOpacity + 0.5f);
    final float radius = lerp(0, mOuterRadius, mTweenRadius);
    if (alpha > 0 && radius > 0) {
        final float x = lerp(
                mClampedStartingX - mBounds.exactCenterX(), mOuterX, mTweenX);
        final float y = lerp(
                mClampedStartingY - mBounds.exactCenterY(), mOuterY, mTweenY);
        p.setAlpha(alpha);
        p.setStyle(Style.FILL);
        c.drawCircle(x, y, radius, p);
        hasContent = true;
    }

    return hasContent;
}
 
Example #17
Source File: AxisRenderer.java    From JNChartDemo with Apache License 2.0 6 votes vote down vote up
public AxisRenderer(ViewPortHandler viewPortHandler, Transformer trans) {
       super(viewPortHandler);

       this.mTrans = trans;

       mAxisLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

       mGridPaint = new Paint();
       mGridPaint.setColor(Color.GRAY);
       mGridPaint.setStrokeWidth(1f);
       mGridPaint.setStyle(Style.STROKE);
       mGridPaint.setAlpha(90);

       mAxisLinePaint = new Paint();
       mAxisLinePaint.setColor(Color.BLACK);
       mAxisLinePaint.setStrokeWidth(1f);
       mAxisLinePaint.setStyle(Style.STROKE);

	mLimitLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mLimitLinePaint.setStyle(Paint.Style.STROKE);
}
 
Example #18
Source File: FlipView.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void init() {
	final Context context = getContext();
	final ViewConfiguration configuration = ViewConfiguration.get(context);

	mScroller = new Scroller(context, flipInterpolator);
	mTouchSlop = configuration.getScaledPagingTouchSlop();
	mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
	mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

	mShadowPaint.setColor(Color.BLACK);
	mShadowPaint.setStyle(Style.FILL);
	mShadePaint.setColor(Color.BLACK);
	mShadePaint.setStyle(Style.FILL);
	mShinePaint.setColor(Color.WHITE);
	mShinePaint.setStyle(Style.FILL);
}
 
Example #19
Source File: ProgressWheel.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
/**
 * Set the properties of the paints we're using to
 * draw the progress wheel
 */
private void setupPaints() {
    barPaint.setColor(barColor);
    barPaint.setAntiAlias(true);
    barPaint.setStyle(Style.STROKE);
    barPaint.setStrokeWidth(barWidth);

    rimPaint.setColor(rimColor);
    rimPaint.setAntiAlias(true);
    rimPaint.setStyle(Style.STROKE);
    rimPaint.setStrokeWidth(rimWidth);

    circlePaint.setColor(circleColor);
    circlePaint.setAntiAlias(true);
    circlePaint.setStyle(Style.FILL);

    textPaint.setColor(textColor);
    textPaint.setStyle(Style.FILL);
    textPaint.setAntiAlias(true);
    textPaint.setTextSize(textSize);

    contourPaint.setColor(contourColor);
    contourPaint.setAntiAlias(true);
    contourPaint.setStyle(Style.STROKE);
    contourPaint.setStrokeWidth(contourSize);
}
 
Example #20
Source File: RefreshView.java    From WidgetCase with Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
        mContext = context;

        DisplayMetrics dm = getResources().getDisplayMetrics();
        mScreenW = dm.widthPixels;
        mHeadBmp = BitmapFactory.decodeResource(getResources(), R.drawable.load_more_1);

//		mScrDistance = mScreenH / 3 - 46;
        mHeadW = mHeadBmp.getWidth();
        mHeadH = mHeadBmp.getHeight();
        mInitLeftPX = mScreenW / 2 - mHeadW;
        mInitRightPX = mScreenW / 2 + mHeadW;
        mBmpL = mScreenW / 2 - mHeadBmp.getWidth() / 2;
        mBmpT = 0;

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Style.FILL);//设置非填充
        mScroller = new Scroller(mContext, new DecelerateInterpolator());
        mScroller1 = new Scroller(mContext, new DecelerateInterpolator());

        mAniDraw = (AnimationDrawable) mAnimList.getDrawable();
    }
 
Example #21
Source File: Ripple.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
private boolean drawSoftware(Canvas c, Paint p) {
    boolean hasContent = false;

    p.setColor(mColorOpaque);
    final int alpha = (int) (255 * mOpacity + 0.5f);
    final float radius = lerp(0, mOuterRadius, mTweenRadius);
    if (alpha > 0 && radius > 0) {
        final float x = lerp(
                mClampedStartingX - mBounds.exactCenterX(), mOuterX, mTweenX);
        final float y = lerp(
                mClampedStartingY - mBounds.exactCenterY(), mOuterY, mTweenY);
        p.setAlpha(alpha);
        p.setStyle(Style.FILL);
        c.drawCircle(x, y, radius, p);
        hasContent = true;
    }

    return hasContent;
}
 
Example #22
Source File: Box.java    From FlexibleRichTextView with Apache License 2.0 6 votes vote down vote up
protected void drawDebug(Canvas g2, float x, float y, boolean showDepth) {
	if (DEBUG) {
		Paint st = AjLatexMath.getPaint();
		int c = st.getColor();
		st.setColor(markForDEBUG);
		st.setStyle(Style.FILL_AND_STROKE);
		if (markForDEBUG != null) {
			g2.drawRect(x, y - height, width, height + depth, st);
		}
		if (width < 0) {
			x += width;
			width = -width;
		}
		g2.drawRect(x, y - height, width, height + depth, st);
		if (showDepth) {
			st.setColor(Color.RED);
			if (depth > 0) {
				g2.drawRect(x, y, width, depth, st);
			} else if (depth < 0) {
				g2.drawRect(x, y + depth, width, -depth, st);
			} else {
			}
		}
		st.setColor(c);
	}
}
 
Example #23
Source File: ColorsHelper.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Deprecated
private void drawText(String text, Canvas canvas) {
    Paint innerPaint = new Paint();
    innerPaint.setAntiAlias(true);
    innerPaint.setStyle(Style.FILL);
    innerPaint.setColor(Color.BLACK);
    int xPos = (canvas.getWidth() / 2);
    int yPos = (int) ((canvas.getHeight() / 2) - ((innerPaint.descent() + innerPaint
            .ascent()) / 2));

    canvas.drawText(text, xPos, yPos, innerPaint);
}
 
Example #24
Source File: MaterialProgressDrawable.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
public Ring(Callback callback) {
    mRingCallback = callback;
    mArcPaint.setStrokeCap(Paint.Cap.SQUARE);
    mArcPaint.setAntiAlias(true);
    mArcPaint.setStyle(Style.STROKE);
    mArrowPaint.setStyle(Style.FILL);
    mArrowPaint.setAntiAlias(true);

    mCirclePaint.setAntiAlias(true);
}
 
Example #25
Source File: FloatingActionButton.java    From FloatingActionButton with Apache License 2.0 5 votes vote down vote up
private Drawable createOuterStrokeDrawable(float strokeWidth) {
  ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

  final Paint paint = shapeDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setStrokeWidth(strokeWidth);
  paint.setStyle(Style.STROKE);
  paint.setColor(Color.BLACK);
  paint.setAlpha(opacityToAlpha(0.02f));

  return shapeDrawable;
}
 
Example #26
Source File: ObjectReticleGraphic.java    From mlkit-material-android with Apache License 2.0 5 votes vote down vote up
ObjectReticleGraphic(GraphicOverlay overlay, CameraReticleAnimator animator) {
  super(overlay);
  this.animator = animator;

  Resources resources = overlay.getResources();
  outerRingFillPaint = new Paint();
  outerRingFillPaint.setStyle(Style.FILL);
  outerRingFillPaint.setColor(
      ContextCompat.getColor(context, R.color.object_reticle_outer_ring_fill));

  outerRingStrokePaint = new Paint();
  outerRingStrokePaint.setStyle(Style.STROKE);
  outerRingStrokePaint.setStrokeWidth(
      resources.getDimensionPixelOffset(R.dimen.object_reticle_outer_ring_stroke_width));
  outerRingStrokePaint.setStrokeCap(Cap.ROUND);
  outerRingStrokePaint.setColor(
      ContextCompat.getColor(context, R.color.object_reticle_outer_ring_stroke));

  innerRingStrokePaint = new Paint();
  innerRingStrokePaint.setStyle(Style.STROKE);
  innerRingStrokePaint.setStrokeWidth(
      resources.getDimensionPixelOffset(R.dimen.object_reticle_inner_ring_stroke_width));
  innerRingStrokePaint.setStrokeCap(Cap.ROUND);
  innerRingStrokePaint.setColor(ContextCompat.getColor(context, R.color.white));

  ripplePaint = new Paint();
  ripplePaint.setStyle(Style.STROKE);
  ripplePaint.setColor(ContextCompat.getColor(context, R.color.reticle_ripple));

  outerRingFillRadius =
      resources.getDimensionPixelOffset(R.dimen.object_reticle_outer_ring_fill_radius);
  outerRingStrokeRadius =
      resources.getDimensionPixelOffset(R.dimen.object_reticle_outer_ring_stroke_radius);
  innerRingStrokeRadius =
      resources.getDimensionPixelOffset(R.dimen.object_reticle_inner_ring_stroke_radius);
  rippleSizeOffset = resources.getDimensionPixelOffset(R.dimen.object_reticle_ripple_size_offset);
  rippleStrokeWidth =
      resources.getDimensionPixelOffset(R.dimen.object_reticle_ripple_stroke_width);
  rippleAlpha = ripplePaint.getAlpha();
}
 
Example #27
Source File: BarLineChartBase.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
@Override
    protected void init() {
        super.init();

        mAxisLeft = new YAxis(AxisDependency.LEFT);
        mAxisRight = new YAxis(AxisDependency.RIGHT);

        mLeftAxisTransformer = new Transformer(mViewPortHandler);
        mRightAxisTransformer = new Transformer(mViewPortHandler);

        mAxisRendererLeft = new YAxisRenderer(mViewPortHandler, mAxisLeft, mLeftAxisTransformer);
        mAxisRendererRight = new YAxisRenderer(mViewPortHandler, mAxisRight, mRightAxisTransformer);

        initXAxisRenderer();
//        mXAxisRenderer = new XAxisRenderer(mViewPortHandler, mXAxis, mLeftAxisTransformer);

        setHighlighter(new ChartHighlighter(this));

        mChartTouchListener = new BarLineChartTouchListener(this, mViewPortHandler.getMatrixTouch(), 3f);

        mGridBackgroundPaint = new Paint();
        mGridBackgroundPaint.setStyle(Style.FILL);
        // mGridBackgroundPaint.setColor(Color.WHITE);
        mGridBackgroundPaint.setColor(Color.rgb(240, 240, 240)); // light
        // grey

        mBorderPaint = new Paint();
        mBorderPaint.setStyle(Style.STROKE);
        mBorderPaint.setColor(Color.BLACK);
        mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
    }
 
Example #28
Source File: FloatingActionButton.java    From FloatingActionButton with Apache License 2.0 5 votes vote down vote up
private Drawable createInnerStrokesDrawable(final int color, float strokeWidth) {
  if (!mStrokeVisible) {
    return new ColorDrawable(Color.TRANSPARENT);
  }

  ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

  final int bottomStrokeColor = darkenColor(color);
  final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
  final int topStrokeColor = lightenColor(color);
  final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);

  final Paint paint = shapeDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setStrokeWidth(strokeWidth);
  paint.setStyle(Style.STROKE);
  shapeDrawable.setShaderFactory(new ShaderFactory() {
    @Override
    public Shader resize(int width, int height) {
      return new LinearGradient(width / 2, 0, width / 2, height,
          new int[] { topStrokeColor, topStrokeColorHalfTransparent, color, bottomStrokeColorHalfTransparent, bottomStrokeColor },
          new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f },
          TileMode.CLAMP
      );
    }
  });

  return shapeDrawable;
}
 
Example #29
Source File: BarcodeGraphicBase.java    From mlkit-material-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void draw(Canvas canvas) {
  // Draws the dark background scrim and leaves the box area clear.
  canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), scrimPaint);
  // As the stroke is always centered, so erase twice with FILL and STROKE respectively to clear
  // all area that the box rect would occupy.
  eraserPaint.setStyle(Style.FILL);
  canvas.drawRoundRect(boxRect, boxCornerRadius, boxCornerRadius, eraserPaint);
  eraserPaint.setStyle(Style.STROKE);
  canvas.drawRoundRect(boxRect, boxCornerRadius, boxCornerRadius, eraserPaint);

  // Draws the box.
  canvas.drawRoundRect(boxRect, boxCornerRadius, boxCornerRadius, boxPaint);
}
 
Example #30
Source File: CircleProgressView.java    From AndroidHeros with MIT License 5 votes vote down vote up
private void initView() {
    float length = 0;
    if (mMeasureHeight >= mMeasureWidth){
        length = mMeasureWidth;
    }else {
        length = mMeasureHeight;
    }

    mCircleXY = length / 2;
    mRadius = (float) (length * 0.5 / 2);
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setColor(getResources().getColor(android.R.color.holo_blue_bright));
    mArcRectF = new RectF(
            (float) (length * 0.1),
            (float) (length * 0.1),
            (float) (length * 0.9),
            (float) (length * 0.9));
    mSweepAngle = (mSweepValue / 100f) * 360f;
    mArcPaint = new Paint();
    mArcPaint.setAntiAlias(true);
    mArcPaint.setColor(getResources().getColor(
            android.R.color.holo_blue_bright));
    mArcPaint.setStrokeWidth((float) (length * 0.1));
    mArcPaint.setStyle(Style.STROKE);

    mShowText= setShowText();
    mShowTextSize = setShowTextSize();
    mTextPaint = new Paint();
    mTextPaint.setTextSize(mShowTextSize);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
}