android.graphics.Paint.Cap Java Examples

The following examples show how to use android.graphics.Paint.Cap. 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: LineChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
public LineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;

    touchToleranceMargin = ChartUtils.dp2px(density, DEFAULT_TOUCH_TOLERANCE_MARGIN_DP);

    linePaint.setAntiAlias(true);
    linePaint.setStyle(Paint.Style.STROKE);
    linePaint.setStrokeCap(Cap.ROUND);
    linePaint.setStrokeWidth(ChartUtils.dp2px(density, DEFAULT_LINE_STROKE_WIDTH_DP));

    pointPaint.setAntiAlias(true);
    pointPaint.setStyle(Paint.Style.FILL);

    checkPrecision = ChartUtils.dp2px(density, 2);

}
 
Example #2
Source File: RoundProgressBarWidthNumber.java    From Android-ProgressBarWidthNumber with Apache License 2.0 6 votes vote down vote up
public RoundProgressBarWidthNumber(Context context, AttributeSet attrs)
{
	super(context, attrs);

	mReachedProgressBarHeight = (int) (mUnReachedProgressBarHeight * 2.5f);
	TypedArray ta = context.obtainStyledAttributes(attrs,
			R.styleable.RoundProgressBarWidthNumber);
	mRadius = (int) ta.getDimension(
			R.styleable.RoundProgressBarWidthNumber_radius, mRadius);
	ta.recycle();

	mPaint.setStyle(Style.STROKE);
	mPaint.setAntiAlias(true);
	mPaint.setDither(true);
	mPaint.setStrokeCap(Cap.ROUND);

}
 
Example #3
Source File: RoundProgressBarWidthNumber.java    From quickmark with MIT License 6 votes vote down vote up
public RoundProgressBarWidthNumber(Context context, AttributeSet attrs)
{
	super(context, attrs);

	mReachedProgressBarHeight = (int) (mUnReachedProgressBarHeight * 2.5f);
	TypedArray ta = context.obtainStyledAttributes(attrs,
			R.styleable.RoundProgressBarWidthNumber);
	mRadius = (int) ta.getDimension(
			R.styleable.RoundProgressBarWidthNumber_radius, mRadius);
	ta.recycle();

	mPaint.setStyle(Style.STROKE);
	mPaint.setAntiAlias(true);
	mPaint.setDither(true);
	mPaint.setStrokeCap(Cap.ROUND);

}
 
Example #4
Source File: PainterThreadControl.java    From whiteboard with Apache License 2.0 6 votes vote down vote up
/**
 * @param surfaceHolder
 * @param painterCanvas
 */
public PainterThreadControl(SurfaceHolder surfaceHolder,
		PainterCanvasControl painterCanvas) {
	// base data
	mHolder = surfaceHolder;
	this.mPainterCanvas = painterCanvas;

	// defaults brush settings
	mBrushSize = 2;
	mBrush = new Paint();
	mBrush.setAntiAlias(true);
	mBrush.setColor(Color.rgb(0, 0, 0));
	mBrush.setStrokeWidth(mBrushSize);
	mBrush.setStrokeCap(Cap.ROUND);

	Commons.currentColor = Color.rgb(0, 0, 0);
	Commons.currentSize = 2;

	// default canvas settings
	mCanvasBgColor = Color.WHITE;

	// set negative coordinates for reset last point
	mLastBrushPointX = -1;
	mLastBrushPointY = -1;
}
 
Example #5
Source File: GUIFallingOsuSliderEnd.java    From Beats with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public GUIFallingOsuSliderEnd(DataNote n) {
	super(n);
	focusRadius = (int)(Tools.button_w * 1.3 / 2);
	focusPaint = new Paint();
	focusPaint.setAntiAlias(true);
	focusPaint.setAlpha(0);
	focusPaint.setColor(Color.WHITE);
	focusPaint.setStyle(Paint.Style.STROKE);
	focusPaint.setStrokeWidth(RING_STROKE_WIDTH);
	
	curvePath = new Path();
	curvePaint = new Paint();
	curvePaint.setAntiAlias(true);
	curvePaint.setColor(lighten(GUINoteImage.osu_circle(fraction)));
	curvePaint.setStyle(Paint.Style.STROKE);
	//curvePaint.setStrokeWidth(Tools.button_w * 2 / 3);
	curvePaint.setStrokeWidth(Tools.button_w - RING_STROKE_WIDTH * 4);
	curvePaint.setStrokeCap(Cap.ROUND);
	curvePaintOutline = new Paint();
	curvePaintOutline.setAntiAlias(true);
	curvePaintOutline.setColor(Color.WHITE);
	curvePaintOutline.setStyle(Paint.Style.STROKE);
	//curvePaintOutline.setStrokeWidth(Tools.button_w * 2 / 3 + RING_STROKE_WIDTH * 2);
	curvePaintOutline.setStrokeWidth(Tools.button_w - RING_STROKE_WIDTH * 2);
	curvePaintOutline.setStrokeCap(Cap.ROUND);
}
 
Example #6
Source File: SwitchButton.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
public void init(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SwitchButton);
    offBorderColor = typedArray.getColor(R.styleable.SwitchButton_offBorderColor, offBorderColor);
    onColor = typedArray.getColor(R.styleable.SwitchButton_onColor, onColor);
    spotColor = typedArray.getColor(R.styleable.SwitchButton_spotColor, spotColor);
    offColor = typedArray.getColor(R.styleable.SwitchButton_offColor, offColor);
    borderWidth = typedArray.getDimensionPixelSize(R.styleable.SwitchButton_swBorderWidth, borderWidth);
    defaultAnimate = typedArray.getBoolean(R.styleable.SwitchButton_animate, defaultAnimate);
    is_rect = typedArray.getBoolean(R.styleable.SwitchButton_isRect, is_rect);
    typedArray.recycle();

    borderColor = offBorderColor;
}
 
Example #7
Source File: ToggleButton.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
public void setup(AttributeSet attrs) {
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setStrokeCap(Cap.ROUND);
	
	springSystem = SpringSystem.create();
	spring = springSystem.createSpring();
	spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));
	
	this.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			toggle();
		}
	});
	
	TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
	spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth, borderWidth);
	typedArray.recycle();
}
 
Example #8
Source File: MainActivity.java    From ImageEraser with GNU General Public License v3.0 6 votes vote down vote up
public void UpdateCanvas() {
    canvasMaster.drawColor(0, Mode.CLEAR);
    canvasMaster.drawBitmap(lastEditedBitmap, 0.0f, 0.0f, null);
    int i = 0;
    while (true) {
        if (i >= paths.size()) {
            break;
        }
        int brushSize = brushSizes.get(i);
        Paint paint = new Paint();
        paint.setColor(0);
        paint.setStyle(Style.STROKE);
        paint.setAntiAlias(true);
        paint.setStrokeJoin(Join.ROUND);
        paint.setStrokeCap(Cap.ROUND);
        paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
        paint.setStrokeWidth((float) brushSize);
        canvasMaster.drawPath(paths.get(i), paint);
        i += 1;
    }
    touchImageView.invalidate();
}
 
Example #9
Source File: LineChartRenderer.java    From SmartChart with Apache License 2.0 6 votes vote down vote up
public LineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;

    touchToleranceMargin = ChartUtils.dp2px(density, DEFAULT_TOUCH_TOLERANCE_MARGIN_DP);

    linePaint.setAntiAlias(true);
    linePaint.setStyle(Paint.Style.STROKE);
    linePaint.setStrokeCap(Cap.ROUND);
    linePaint.setStrokeWidth(ChartUtils.dp2px(density, DEFAULT_LINE_STROKE_WIDTH_DP));

    pointPaint.setAntiAlias(true);
    pointPaint.setStyle(Paint.Style.FILL);

    checkPrecision = ChartUtils.dp2px(density, 2);

}
 
Example #10
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 #11
Source File: StaticGraph.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
private StaticGraph(final int color, final float width, final float height, final float strokeWidth)
{
    this.height = height;
    this.width = width;
    
    pathStroke = new Path();
    pathFill = new Path();
    paintStroke = new Paint();
    paintFill = 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.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
}
 
Example #12
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 #13
Source File: CircleView.java    From subsampling-scale-image-view with Apache License 2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Don't draw pin before image is ready so it doesn't move around during setup.
    if (!isReady()) {
        return;
    }

    sCenter.set(getSWidth()/2, getSHeight()/2);
    sourceToViewCoord(sCenter, vCenter);
    float radius = (getScale() * getSWidth()) * 0.25f;

    paint.setAntiAlias(true);
    paint.setStyle(Style.STROKE);
    paint.setStrokeCap(Cap.ROUND);
    paint.setStrokeWidth(strokeWidth * 2);
    paint.setColor(Color.BLACK);
    canvas.drawCircle(vCenter.x, vCenter.y, radius, paint);
    paint.setStrokeWidth(strokeWidth);
    paint.setColor(Color.argb(255, 51, 181, 229));
    canvas.drawCircle(vCenter.x, vCenter.y, radius, paint);
}
 
Example #14
Source File: MultiBoxTracker.java    From tfliteSSDminimalWorkingExample with Apache License 2.0 6 votes vote down vote up
public MultiBoxTracker(final Context context) {
	this.context = context;
	for (final int color : COLORS) {
		availableColors.add(color);
	}

	boxPaint.setColor(Color.RED);
	boxPaint.setStyle(Style.STROKE);
	boxPaint.setStrokeWidth(12.0f);
	boxPaint.setStrokeCap(Cap.ROUND);
	boxPaint.setStrokeJoin(Join.ROUND);
	boxPaint.setStrokeMiter(100);

	textSizePx =
			TypedValue.applyDimension(
					TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_DIP, context.getResources().getDisplayMetrics());
	borderedText = new BorderedText(textSizePx);
}
 
Example #15
Source File: SwitchButton.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void setup(AttributeSet attrs) {
    this.paint = new Paint(1);
    this.paint.setStyle(Style.STROKE);
    this.paint.setStrokeCap(Cap.ROUND);
    this.springSystem = SpringSystem.create();
    this.spring = this.springSystem.createSpring();
    this.spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50.0d, 7.0d));
    setOnClickListener(new OnClickListener() {
        public void onClick(View arg0) {
            SwitchButton.this.onViewSwitch();
        }
    });
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SwitchButton);
    this.onSpotColor = typedArray.getColor(R.styleable.SwitchButton_onColor, this.onSpotColor);
    this.offSpotColor = typedArray.getColor(R.styleable.SwitchButton_spotColor, this.offSpotColor);
    this.toggleOn = typedArray.getBoolean(R.styleable.SwitchButton_onToggle, this.toggleOn);
    this.spotColor = this.offSpotColor;
    this.borderWidth = typedArray.getDimensionPixelSize(R.styleable.SwitchButton_borderWidth, (int) AbViewUtil.dip2px(getContext(), (float) this.borderWidth));
    this.defaultAnimate = typedArray.getBoolean(R.styleable.SwitchButton_animate, this.defaultAnimate);
    typedArray.recycle();
}
 
Example #16
Source File: ModifierRenderer.java    From mil-sym-android with Apache License 2.0 5 votes vote down vote up
private static void drawDOMArrow(Canvas ctx, Point[] domPoints, int alpha, Color lineColor)
{
    Paint domPaint = new Paint();
    domPaint.setStrokeCap(Cap.BUTT);
    domPaint.setStrokeJoin(Join.MITER);
    domPaint.setStrokeWidth(3);
    domPaint.setColor(lineColor.toInt());
    domPaint.setStyle(Style.STROKE);
    if(alpha > -1)
        domPaint.setAlpha(alpha);

    Path domPath = new Path();
    domPath.moveTo(domPoints[0].x, domPoints[0].y);
    if (domPoints[1] != null)
    {
        domPath.lineTo(domPoints[1].x, domPoints[1].y);
    }
    if (domPoints[2] != null)
    {
        domPath.lineTo(domPoints[2].x, domPoints[2].y);
    }
    ctx.drawPath(domPath, domPaint);

    domPath.reset();
    domPaint.setStyle(Style.FILL);
    domPath.moveTo(domPoints[3].x, domPoints[3].y);
    domPath.lineTo(domPoints[4].x, domPoints[4].y);
    domPath.lineTo(domPoints[5].x, domPoints[5].y);
    ctx.drawPath(domPath, domPaint);
}
 
Example #17
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public ColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    subcolumnSpacing = ChartUtils.dp2px(density, DEFAULT_SUBCOLUMN_SPACING_DP);
    touchAdditionalWidth = ChartUtils.dp2px(density, DEFAULT_COLUMN_TOUCH_ADDITIONAL_WIDTH_DP);

    columnPaint.setAntiAlias(true);
    columnPaint.setStyle(Paint.Style.FILL);
    columnPaint.setStrokeCap(Cap.SQUARE);
}
 
Example #18
Source File: FreehandView.java    From subsampling-scale-image-view with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Don't draw anything before image is ready.
    if (!isReady()) {
        return;
    }

    paint.setAntiAlias(true);

    if (sPoints != null && sPoints.size() >= 2) {
        vPath.reset();
        sourceToViewCoord(sPoints.get(0).x, sPoints.get(0).y, vPrev);
        vPath.moveTo(vPrev.x, vPrev.y);
        for (int i = 1; i < sPoints.size(); i++) {
            sourceToViewCoord(sPoints.get(i).x, sPoints.get(i).y, vPoint);
            vPath.quadTo(vPrev.x, vPrev.y, (vPoint.x + vPrev.x) / 2, (vPoint.y + vPrev.y) / 2);
            vPrev = vPoint;
        }
        paint.setStyle(Style.STROKE);
        paint.setStrokeCap(Cap.ROUND);
        paint.setStrokeWidth(strokeWidth * 2);
        paint.setColor(Color.BLACK);
        canvas.drawPath(vPath, paint);
        paint.setStrokeWidth(strokeWidth);
        paint.setColor(Color.argb(255, 51, 181, 229));
        canvas.drawPath(vPath, paint);
    }

}
 
Example #19
Source File: ToggleButton.java    From ToggleButton with MIT License 5 votes vote down vote up
public void setup(AttributeSet attrs) {
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setStrokeCap(Cap.ROUND);
	
	springSystem = SpringSystem.create();
	spring = springSystem.createSpring();
	spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));
	
	this.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			toggle(defaultAnimate);
		}
	});
	
	TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.ToggleButton_tbOffBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.ToggleButton_tbOnColor, onColor);
	spotColor = typedArray.getColor(R.styleable.ToggleButton_tbSpotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.ToggleButton_tbOffColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_tbBorderWidth, borderWidth);
	defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_tbAnimate, defaultAnimate);
	isDefaultOn = typedArray.getBoolean(R.styleable.ToggleButton_tbAsDefaultOn, isDefaultOn);
	typedArray.recycle();
	
	borderColor = offBorderColor;

	if (isDefaultOn) {
		toggleOn();
	}
}
 
Example #20
Source File: PXSVGLoader.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
private static Cap lineCapFromString(String value) {
    if (value == null) {
        return Cap.BUTT;
    }
    Cap cap = Cap.valueOf(value.toUpperCase(Locale.US));
    if (cap == null) {
        PXLog.e(TAG, "Unrecognized line cap: " + value);
    }
    return cap;
}
 
Example #21
Source File: PXStroke.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new PX stroke.
 */
public PXStroke() {
    this.type = PXStrokeType.CENTER;
    this.width = 1.0f;
    this.dashOffset = 0;
    this.lineCap = Cap.BUTT;
    this.lineJoin = Join.MITER;
    this.miterLimit = 4.0f; // What is a reasonable default here?
}
 
Example #22
Source File: RoundProgressBar.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int centre = getWidth() / 2;
    int radius = (int) (((float) centre) - (this.roundWidth / 2.0f));
    this.paint.setColor(this.roundColor);
    this.paint.setStyle(Style.STROKE);
    this.paint.setStrokeWidth(this.roundWidth);
    this.paint.setAntiAlias(true);
    canvas.drawCircle((float) centre, (float) centre, (float) radius, this.paint);
    this.paint.setStrokeWidth(0.0f);
    this.paint.setColor(this.textColor);
    this.paint.setTextSize(this.textSize);
    this.paint.setStrokeCap(Cap.ROUND);
    this.paint.setTypeface(Typeface.DEFAULT_BOLD);
    int percent = (int) ((((float) this.progress) / ((float) this.max)) * 100.0f);
    float textWidth = this.paint.measureText(percent + "%");
    if (this.textIsDisplayable && this.style == 0) {
        canvas.drawText(percent + "%", ((float) centre) - (textWidth / 2.0f), ((float) centre) + (this.textSize / 2.0f), this.paint);
    }
    this.paint.setStrokeWidth(this.roundWidthPlan);
    this.paint.setColor(this.roundProgressColor);
    RectF oval = new RectF((float) (centre - radius), (float) (centre - radius), (float) (centre + radius), (float) (centre + radius));
    switch (this.style) {
        case 0:
            this.paint.setStyle(Style.STROKE);
            canvas.drawArc(oval, 270.0f, (float) ((this.progress * 360) / this.max), false, this.paint);
            return;
        case 1:
            this.paint.setStyle(Style.FILL_AND_STROKE);
            if (this.progress != 0) {
                canvas.drawArc(oval, 270.0f, (float) ((this.progress * 360) / this.max), true, this.paint);
                return;
            }
            return;
        default:
            return;
    }
}
 
Example #23
Source File: RadialMenuView.java    From talkback with Apache License 2.0 5 votes vote down vote up
private void drawCancel(Canvas canvas) {
  final float centerX = center.x;
  final float centerY = center.y;
  final float radius = innerRadius;
  final float iconRadius = (radius / 4.0f);

  final RectF dotBounds =
      new RectF((centerX - radius), (centerY - radius), (centerX + radius), (centerY + radius));

  // Apply the appropriate color filters.
  final boolean selected = (focusedItem == null);

  paint.setStyle(Style.FILL);
  paint.setColor(selected ? selectionColor : centerFillColor);
  paint.setShadowLayer(shadowRadius, 0, 0, (selected ? selectionShadowColor : textShadowColor));
  canvas.drawOval(dotBounds, paint);
  paint.setShadowLayer(0, 0, 0, 0);

  paint.setStyle(Style.STROKE);
  paint.setColor(selected ? selectionTextFillColor : centerTextFillColor);
  paint.setStrokeCap(Cap.SQUARE);
  paint.setStrokeWidth(10.0f);
  canvas.drawLine(
      (centerX - iconRadius),
      (centerY - iconRadius),
      (centerX + iconRadius),
      (centerY + iconRadius),
      paint);
  canvas.drawLine(
      (centerX + iconRadius),
      (centerY - iconRadius),
      (centerX - iconRadius),
      (centerY + iconRadius),
      paint);
}
 
Example #24
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 #25
Source File: MaterialProgressDrawable.java    From letv with Apache License 2.0 5 votes vote down vote up
public Ring(Callback callback) {
    this.mCallback = callback;
    this.mPaint.setStrokeCap(Cap.SQUARE);
    this.mPaint.setAntiAlias(true);
    this.mPaint.setStyle(Style.STROKE);
    this.mArrowPaint.setStyle(Style.FILL);
    this.mArrowPaint.setAntiAlias(true);
}
 
Example #26
Source File: ColumnChartRenderer.java    From SmartChart with Apache License 2.0 5 votes vote down vote up
public ColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    subcolumnSpacing = ChartUtils.dp2px(density, DEFAULT_SUBCOLUMN_SPACING_DP);
    touchAdditionalWidth = ChartUtils.dp2px(density, DEFAULT_COLUMN_TOUCH_ADDITIONAL_WIDTH_DP);

    columnPaint.setAntiAlias(true);
    columnPaint.setStyle(Paint.Style.FILL);
    columnPaint.setStrokeCap(Cap.SQUARE);

}
 
Example #27
Source File: MainActivity.java    From ImageEraser with GNU General Public License v3.0 5 votes vote down vote up
private void drawOnTouchMove() {
    Paint paint = new Paint();
    paint.setStrokeWidth((float) updatedBrushSize);
    paint.setColor(0);
    paint.setStyle(Style.STROKE);
    paint.setAntiAlias(true);
    paint.setStrokeJoin(Join.ROUND);
    paint.setStrokeCap(Cap.ROUND);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    canvasMaster.drawPath(drawingPath, paint);
    touchImageView.invalidate();
}
 
Example #28
Source File: MainActivity.java    From ImageEraser with GNU General Public License v3.0 5 votes vote down vote up
public void UpdateLastEiditedBitmapForUndoLimit() {
    Canvas canvas = new Canvas(lastEditedBitmap);
    for (int i = 0; i < 1; i += 1) {
        int brushSize = brushSizes.get(i);
        Paint paint = new Paint();
        paint.setColor(0);
        paint.setStyle(Style.STROKE);
        paint.setAntiAlias(true);
        paint.setStrokeJoin(Join.ROUND);
        paint.setStrokeCap(Cap.ROUND);
        paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
        paint.setStrokeWidth((float) brushSize);
        canvas.drawPath(paths.get(i), paint);
    }
}
 
Example #29
Source File: ToggleButton.java    From Viewer with Apache License 2.0 5 votes vote down vote up
public void setup(AttributeSet attrs) {
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setStrokeCap(Cap.ROUND);
	
	springSystem = SpringSystem.create();
	spring = springSystem.createSpring();
	spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));
	
	this.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			toggle(defaultAnimate);
		}
	});
	
	TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
	spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth1, borderWidth);
	defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_animate, defaultAnimate);
	isDefaultOn = typedArray.getBoolean(R.styleable.ToggleButton_isDefaultOn, isDefaultOn);
	typedArray.recycle();
	
	borderColor = offBorderColor;

	if (isDefaultOn) {
		toggleOn();
	}
}
 
Example #30
Source File: CustomerProgress.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
public CustomerProgress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    float density = context.getResources().getDisplayMetrics().density;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomerProgress, defStyleAttr, 0);
    mBorderWidth = a.getDimension(R.styleable.CustomerProgress_progressBorderWidth,
            DEFAULT_BORDER_WIDTH * density);
    a.recycle();
    ARROW_WIDTH = (int) (mBorderWidth * 2);
    ARROW_HEIGHT = (int) mBorderWidth;
    mColors = new int[4];
    mColors[0] = Color.RED;//context.getResources().getColor(R.color.white);
    mColors[1] = Color.BLUE;//context.getResources().getColor(R.color.white);
    mColors[2] = Color.GREEN;//context.getResources().getColor(R.color.white);
    mColors[3] = Color.GRAY;//context.getResources().getColor(R.color.white);
    mCurrentColorIndex = 0;
    mNextColorIndex = 1;

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeCap(Cap.ROUND);
    mPaint.setStrokeWidth(mBorderWidth);
    mPaint.setColor(mColors[mCurrentColorIndex]);

    mHookPaint = new Paint(mPaint);
    mArrowPaint = new Paint(mPaint);

    mHook = new Path();
    mError = new Path();

    setupAnimations();
}