Java Code Examples for android.graphics.Paint.Cap

The following are top voted examples for showing how to use android.graphics.Paint.Cap. 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: GitHub   File: LineChartRenderer.java   View source code 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
Project: snu-artoon   File: MultiBoxTracker.java   View source code 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 3
Project: open-rmbt   File: SimpleGraph.java   View source code 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 4
Project: open-rmbt   File: StaticGraph.java   View source code 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 5
Project: open-rmbt   File: SmoothGraph.java   View source code 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 6
Project: SmartChart   File: LineChartRenderer.java   View source code 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 7
Project: OSchina_resources_android   File: ToggleButton.java   View source code 6 votes vote down vote up
public void setup(AttributeSet attrs) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paint.setStyle(Style.FILL);
    paint.setStrokeCap(Cap.ROUND);

    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_toggle_border_width, borderWidth);
    typedArray.recycle();
}
 
Example 8
Project: ImageEraser   File: MainActivity.java   View source code 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
Project: MyRepository   File: RoundProgressBarWidthNumber.java   View source code 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 10
Project: TreebolicLib   File: Graphics.java   View source code 6 votes vote down vote up
/**
 * Construct
 *
 * @param canvas0 canvas
 */
public Graphics(final Canvas canvas0)
{
	super();
	this.canvas = canvas0;
	// if (theScale != 1F)
	// this.canvas.scale(theScale, theScale, this.canvas.getWidth() / 2F, this.canvas.getHeight() / 2F);
	// if (Graphics.scale != 1F)
	// this.theCanvas.scale(Graphics.scale, Graphics.scale, this.theCanvas.getWidth() / 2F, this.theCanvas.getHeight() / 2F);

	this.paint = new Paint();
	this.paint.setAntiAlias(true);
	this.paint.setHinting(Paint.HINTING_ON); // font

	this.paint.setStrokeWidth(2);
	this.paint.setStrokeCap(Cap.BUTT);
	this.paint.setStrokeJoin(Join.BEVEL);
	this.paint.setStrokeMiter(1);
	this.paint.setColor(android.graphics.Color.WHITE);
}
 
Example 11
Project: boohee_v5.6   File: LineChartRenderer.java   View source code 6 votes vote down vote up
public LineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    this.touchToleranceMargin = ChartUtils.dp2px(this.density, 4);
    this.linePaint.setAntiAlias(true);
    this.linePaint.setStyle(Style.STROKE);
    this.linePaint.setStrokeCap(Cap.ROUND);
    this.linePaint.setStrokeWidth((float) ChartUtils.dp2px(this.density, 3));
    this.pointPaint.setAntiAlias(true);
    this.pointPaint.setStyle(Style.FILL);
    this.weightStrPaint.setAntiAlias(true);
    this.weightStrPaint.setColor(-1);
    this.weightStrPaint.setTextSize((float) ChartUtils.dp2px(this.density, 12));
    this.weightLinePaint.setAntiAlias(true);
    this.weightLinePaint.setStyle(Style.STROKE);
    this.weightLinePaint.setStrokeWidth((float) ChartUtils.dp2px(this.density, 1));
    this.weightLinePaint.setColor(ChartUtils.DEFAULT_TARGET_COLOR);
    this.checkPrecision = ChartUtils.dp2px(this.density, 2);
}
 
Example 12
Project: boohee_v5.6   File: LineChartRenderer.java   View source code 6 votes vote down vote up
public LineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider, LineChartView lineChartView) {
    super(context, chart);
    this.dataProvider = dataProvider;
    this.lineChartView = lineChartView;
    this.touchToleranceMargin = ChartUtils.dp2px(this.density, 4);
    this.linePaint.setAntiAlias(true);
    this.linePaint.setStyle(Style.STROKE);
    this.linePaint.setStrokeCap(Cap.ROUND);
    this.linePaint.setStrokeWidth((float) ChartUtils.dp2px(this.density, 3));
    this.pointPaint.setAntiAlias(true);
    this.pointPaint.setStyle(Style.FILL);
    this.weightStrPaint.setAntiAlias(true);
    this.weightStrPaint.setColor(-1);
    this.weightStrPaint.setTextSize((float) ChartUtils.dp2px(this.density, 12));
    this.weightLinePaint.setAntiAlias(true);
    this.weightLinePaint.setStyle(Style.STROKE);
    this.weightLinePaint.setStrokeWidth((float) ChartUtils.dp2px(this.density, 1));
    this.weightLinePaint.setColor(ChartUtils.DEFAULT_TARGET_COLOR);
    this.checkPrecision = ChartUtils.dp2px(this.density, 2);
}
 
Example 13
Project: boohee_v5.6   File: PieChartRenderer.java   View source code 6 votes vote down vote up
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    this.touchAdditional = ChartUtils.dp2px(this.density, 8);
    this.slicePaint.setAntiAlias(true);
    this.slicePaint.setStyle(Style.FILL);
    this.centerCirclePaint.setAntiAlias(true);
    this.centerCirclePaint.setStyle(Style.FILL);
    this.centerCirclePaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    this.centerCircleText1Paint.setAntiAlias(true);
    this.centerCircleText1Paint.setTextAlign(Align.CENTER);
    this.centerCircleText2Paint.setAntiAlias(true);
    this.centerCircleText2Paint.setTextAlign(Align.CENTER);
    this.separationLinesPaint.setAntiAlias(true);
    this.separationLinesPaint.setStyle(Style.STROKE);
    this.separationLinesPaint.setStrokeCap(Cap.ROUND);
    this.separationLinesPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
    this.separationLinesPaint.setColor(0);
}
 
Example 14
Project: boohee_v5.6   File: ColumnChartRenderer.java   View source code 6 votes vote down vote up
public ColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    this.subcolumnSpacing = ChartUtils.dp2px(this.density, 1);
    this.touchAdditionalWidth = ChartUtils.dp2px(this.density, 4);
    this.columnPaint.setAntiAlias(true);
    this.columnPaint.setStyle(Style.FILL);
    this.columnPaint.setStrokeCap(Cap.SQUARE);
    this.caloryLinePaint.setAntiAlias(true);
    this.caloryLinePaint.setStyle(Style.STROKE);
    this.caloryLinePaint.setStrokeWidth((float) ChartUtils.dp2px(this.density, 1));
    this.caloryLinePaint.setColor(ChartUtils.DEFAULT_TARGET_COLOR);
    this.caloryTextPaint.setAntiAlias(true);
    this.caloryTextPaint.setStyle(Style.FILL);
    this.caloryTextPaint.setTextSize((float) ChartUtils.dp2px(this.density, 12));
    this.caloryTextPaint.setColor(ChartUtils.COLOR_BACKGROUND);
}
 
Example 15
Project: boohee_v5.6   File: LineGraph.java   View source code 6 votes vote down vote up
private void init(Context context) {
    setLayerType(1, null);
    this.LINE_WIDTH = DensityUtil.dip2px(context, (float) this.LINE_WIDTH);
    this.POINT_WIDTH = DensityUtil.dip2px(context, (float) this.POINT_WIDTH);
    this.linePaint = new Paint();
    this.linePaint.setAntiAlias(true);
    this.linePaint.setColor(-2826241);
    this.linePaint.setStyle(Style.STROKE);
    this.linePaint.setStrokeWidth((float) this.LINE_WIDTH);
    this.pointPaint = new Paint();
    this.pointPaint.setAntiAlias(true);
    this.pointPaint.setColor(-8874003);
    this.pointPaint.setStrokeCap(Cap.ROUND);
    this.pointPaint.setStyle(Style.STROKE);
    this.pointPaint.setStrokeWidth((float) this.POINT_WIDTH);
}
 
Example 16
Project: boohee_v5.6   File: ScaleIndexView.java   View source code 6 votes vote down vote up
private void init(Context context) {
    setLayerType(1, null);
    this.mContext = context;
    this.lineHeight = DensityUtil.dip2px(context, (float) this.lineHeight);
    this.textSize = DensityUtil.dip2px(context, (float) this.textSize);
    this.textPaint = new Paint();
    this.textPaint.setAntiAlias(true);
    this.textPaint.setTextSize((float) this.textSize);
    this.textPaint.setTextAlign(Align.LEFT);
    this.textPaint.setColor(AbstractWheelTextAdapter.DEFAULT_TEXT_COLOR);
    this.dividerPaint = new Paint();
    this.dividerPaint.setAntiAlias(true);
    this.dividerPaint.setTextSize((float) this.textSize);
    this.dividerPaint.setTextAlign(Align.LEFT);
    this.dividerPaint.setColor(-1);
    this.dividerPaint.setStrokeWidth(2.0f);
    this.backgroundPaint = new Paint();
    this.backgroundPaint.setAntiAlias(true);
    this.backgroundPaint.setStyle(Style.FILL_AND_STROKE);
    this.backgroundPaint.setStrokeCap(Cap.ROUND);
}
 
Example 17
Project: boohee_v5.6   File: ArcProgressView.java   View source code 6 votes vote down vote up
private void init(Context context) {
    setLayerType(1, null);
    this.ARC_WIDTH = DensityUtil.dip2px(context, (float) this.ARC_WIDTH);
    this.SMALL_CIRCLE_WIDTH = DensityUtil.dip2px(context, (float) this.SMALL_CIRCLE_WIDTH);
    this.mBackgroundPaint = new Paint();
    this.mBackgroundPaint.setAntiAlias(true);
    this.mBackgroundPaint.setStrokeWidth((float) this.ARC_WIDTH);
    this.mBackgroundPaint.setStyle(Style.STROKE);
    this.mBackgroundPaint.setStrokeCap(Cap.ROUND);
    this.mCirclePaint = new Paint();
    this.mCirclePaint.setAntiAlias(true);
    this.mCirclePaint.setColor(-1);
    this.mCirclePaint.setStrokeWidth((float) this.SMALL_CIRCLE_WIDTH);
    this.mCirclePaint.setStyle(Style.STROKE);
    this.mCirclePaint.setStrokeCap(Cap.ROUND);
}
 
Example 18
Project: boohee_v5.6   File: CircleProgress.java   View source code 6 votes vote down vote up
private void drawCircle(Canvas canvas) {
    int radius = (int) (((float) getViewRadius()) - (2.6f * ((float) this.mDividerWidth)));
    RectF oval = new RectF((float) (getCenterX() - radius), (float) (getCenterY() - radius),
            (float) (getCenterX() + radius), (float) (getCenterY() + radius));
    Paint circlePaint = new Paint();
    circlePaint.setAntiAlias(true);
    circlePaint.setStrokeWidth(56.0f);
    circlePaint.setStyle(Style.STROKE);
    circlePaint.setStrokeCap(Cap.ROUND);
    circlePaint.setColor(this.mCircleGray);
    canvas.drawArc(oval, 135.0f, 270.0f, false, circlePaint);
    if (this.mEndIndicator > this.mStartIndicator && this.mProgress >= this.mStartIndicator) {
        circlePaint.setColor(this.mCircleGreen);
        float angle = ((this.mProgress - this.mStartIndicator) * 270.0f) / (this
                .mEndIndicator - this.mStartIndicator);
        canvas.drawArc(oval, 135.0f, angle, false, circlePaint);
        if (!TextUtils.isEmpty(this.mProgressAlert)) {
            drawAlert(canvas, radius, angle);
        }
    }
}
 
Example 19
Project: boohee_v5.6   File: DrawerArrowDrawable.java   View source code 6 votes vote down vote up
public DrawerArrowDrawable(Context context) {
    this.mPaint.setStyle(Style.STROKE);
    this.mPaint.setStrokeJoin(Join.MITER);
    this.mPaint.setStrokeCap(Cap.BUTT);
    this.mPaint.setAntiAlias(true);
    TypedArray a = context.getTheme().obtainStyledAttributes(null, R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle, R.style.Base_Widget_AppCompat_DrawerArrowToggle);
    setColor(a.getColor(R.styleable.DrawerArrowToggle_color, 0));
    setBarThickness(a.getDimension(R.styleable.DrawerArrowToggle_thickness, 0.0f));
    setSpinEnabled(a.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true));
    setGapSize((float) Math.round(a.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0.0f)));
    this.mSize = a.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
    this.mBarLength = (float) Math.round(a.getDimension(R.styleable.DrawerArrowToggle_barLength, 0.0f));
    this.mArrowHeadLength = (float) Math.round(a.getDimension(R.styleable.DrawerArrowToggle_arrowHeadLength, 0.0f));
    this.mArrowShaftLength = a.getDimension(R.styleable.DrawerArrowToggle_arrowShaftLength, 0.0f);
    a.recycle();
}
 
Example 20
Project: ForeverLibrary   File: RoundProgressBarWidthNumber.java   View source code 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 21
Project: PDR   File: BackgroundView.java   View source code 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);

	// ����ͼ��ı���ɫ
	canvas.drawColor(Color.TRANSPARENT);
	// ��ӻ���
	Paint paint_Line = new Paint();
	paint_Line.setAntiAlias(true); // �����
	paint_Line.setStrokeWidth(2); // ���û��ʿ��
	paint_Line.setStyle(Style.STROKE);
	paint_Line.setColor(Color.BLACK); // ���ʵ���ɫ

	Paint paint_Point = new Paint();
	paint_Point.setAntiAlias(true); // �����
	paint_Point.setStrokeWidth(4); // ���û��ʿ��
	paint_Point.setStyle(Style.STROKE);
	paint_Point.setColor(Color.RED); // ���ʵ���ɫ
	paint_Point.setStrokeCap(Cap.ROUND);//Բͷ�Ļ���ͷ
	
	drawDpLine(canvas, line_point, paint_Line);
}
 
Example 22
Project: AstroSmash   File: AstroSmashView.java   View source code 6 votes vote down vote up
private void drawTouchArrow(Canvas canvas, Paint paint) {
	paint.setColor(Version.GREENCOLOR_DARK);
	canvas.drawRect(0, 0, screenWidth, screenHeightPercent, paint);
	paint.setStrokeCap(Cap.ROUND);
	paint.setAntiAlias(true);
	for (int i = 0; i < 2; ++i) {
		if (i == 0) {
			paint.setColor(Version.GRAYCOLOR);
			paint.setStrokeWidth(px5);
		} else {
			paint.setColor(Version.DARKCOLOR);
			paint.setStrokeWidth(px1);
		}
		canvas.drawLine(px25, arrow_Y0, arrow_X0, arrow_Y0, paint);
		canvas.drawLine(px25, arrow_Y0, px25double, arrow_Y1, paint);
		canvas.drawLine(px25, arrow_Y0, px25double, arrow_Y2, paint);
		canvas.drawLine(arrow_X0, arrow_Y0, arrow_X1, arrow_Y1, paint);
		canvas.drawLine(arrow_X0, arrow_Y0, arrow_X1, arrow_Y2, paint);
	}
}
 
Example 23
Project: Incubators   File: IOSToggleButton.java   View source code 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.IOSToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.IOSToggleButton_btnOffBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.IOSToggleButton_btnOnColor, onColor);
	spotColor = typedArray.getColor(R.styleable.IOSToggleButton_btnSpotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.IOSToggleButton_btnOffColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.IOSToggleButton_btnBorderWidth, borderWidth);
	typedArray.recycle();
}
 
Example 24
Project: YingBeautyNote   File: ToggleButton.java   View source code 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);

    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_toggle_border_width, borderWidth);
    typedArray.recycle();
}
 
Example 25
Project: SprintNBA   File: SwitchButton.java   View source code 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 26
Project: Tower-develop   File: AttitudeIndicator.java   View source code 6 votes vote down vote up
private void initialize() {

		Paint fillPaint = new Paint();
		fillPaint.setAntiAlias(true);
		fillPaint.setStyle(Style.FILL);

		yawPaint = new Paint(fillPaint);
		yawPaint.setColor(Color.GRAY);

		skyPaint = new Paint(fillPaint);

		groundPaint = new Paint(fillPaint);

		planePaint = new Paint(fillPaint);
		planePaint.setColor(Color.WHITE);
		planePaint.setStrokeWidth(PLANE_WING_WIDTH);
		planePaint.setStrokeCap(Cap.ROUND);
		planeCenterPaint = new Paint(planePaint);
		planeCenterPaint.setColor(Color.RED);
		planeFinPaint = new Paint(planePaint);
		planeFinPaint.setStrokeWidth(PLANE_WING_WIDTH / 2f);

		tickPaint = new Paint(fillPaint);
		tickPaint.setColor(Color.parseColor("#44ffffff"));
		tickPaint.setStrokeWidth(2);
	}
 
Example 27
Project: UAFClient   File: CircularProgress.java   View source code 6 votes vote down vote up
public CircularProgress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    float density = context.getResources().getDisplayMetrics().density;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircularProgress, defStyleAttr, 0);
    mBorderWidth = a.getDimension(R.styleable.CircularProgress_borderWidth1,
            DEFAULT_BORDER_WIDTH * density);
    a.recycle();
    mColors = new int[4];
    mColors[0] = context.getResources().getColor(R.color.red);
    mColors[1] = context.getResources().getColor(R.color.yellow);
    mColors[2] = context.getResources().getColor(R.color.green);
    mColors[3] = context.getResources().getColor(R.color.blue);
    mCurrentColorIndex = 0;
    mNextColorIndex = 1;

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

    setupAnimations();
}
 
Example 28
Project: droidplanner-master   File: AttitudeIndicator.java   View source code 6 votes vote down vote up
private void initialize() {

		Paint fillPaint = new Paint();
		fillPaint.setAntiAlias(true);
		fillPaint.setStyle(Style.FILL);

		yawPaint = new Paint(fillPaint);
		yawPaint.setColor(Color.WHITE);

		skyPaint = new Paint(fillPaint);

		groundPaint = new Paint(fillPaint);

		planePaint = new Paint(fillPaint);
		planePaint.setColor(Color.WHITE);
		planePaint.setStrokeWidth(PLANE_WING_WIDTH);
		planePaint.setStrokeCap(Cap.ROUND);
		planeCenterPaint = new Paint(planePaint);
		planeCenterPaint.setColor(Color.RED);
		planeFinPaint = new Paint(planePaint);
		planeFinPaint.setStrokeWidth(PLANE_WING_WIDTH / 2f);

		tickPaint = new Paint(fillPaint);
		tickPaint.setColor(Color.parseColor("#44ffffff"));
		tickPaint.setStrokeWidth(2);
	}
 
Example 29
Project: EveryXDay   File: ToggleButton.java   View source code 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 30
Project: nongfei-missionplane   File: AttitudeIndicator.java   View source code 6 votes vote down vote up
private void initialize() {

		Paint fillPaint = new Paint();
		fillPaint.setAntiAlias(true);
		fillPaint.setStyle(Style.FILL);

		yawPaint = new Paint(fillPaint);
		yawPaint.setColor(Color.WHITE);

		skyPaint = new Paint(fillPaint);

		groundPaint = new Paint(fillPaint);

		planePaint = new Paint(fillPaint);
		planePaint.setColor(Color.WHITE);
		planePaint.setStrokeWidth(PLANE_WING_WIDTH);
		planePaint.setStrokeCap(Cap.ROUND);
		planeCenterPaint = new Paint(planePaint);
		planeCenterPaint.setColor(Color.RED);
		planeFinPaint = new Paint(planePaint);
		planeFinPaint.setStrokeWidth(PLANE_WING_WIDTH / 2f);

		tickPaint = new Paint(fillPaint);
		tickPaint.setColor(Color.parseColor("#44ffffff"));
		tickPaint.setStrokeWidth(2);
	}
 
Example 31
Project: yuedong-app   File: ToggleButton.java   View source code 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_borderWidthTB, borderWidth);
	typedArray.recycle();
}
 
Example 32
Project: quickmark   File: RoundProgressBarWidthNumber.java   View source code 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 33
Project: Android-ProgressBarWidthNumber   File: RoundProgressBarWidthNumber.java   View source code 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 34
Project: iLocker   File: CircularProgress.java   View source code 6 votes vote down vote up
public CircularProgress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    float density = context.getResources().getDisplayMetrics().density;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircularProgress, defStyleAttr, 0);
    mBorderWidth = a.getDimension(R.styleable.CircularProgress_borderWidth, DEFAULT_BORDER_WIDTH * density);
    a.recycle();
    mColors = new int[4];
    mColors[0] = context.getResources().getColor(R.color.progress_red);
    mColors[1] = context.getResources().getColor(R.color.progress_yellow);
    mColors[2] = context.getResources().getColor(R.color.progress_green);
    mColors[3] = context.getResources().getColor(R.color.progress_blue);
    mCurrentColorIndex = 0;
    mNextColorIndex = 1;

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

    setupAnimations();
}
 
Example 35
Project: iLocker   File: CircularProgress.java   View source code 6 votes vote down vote up
public CircularProgress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    float density = context.getResources().getDisplayMetrics().density;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircularProgress, defStyleAttr, 0);
    mBorderWidth = a.getDimension(R.styleable.CircularProgress_borderWidth,
            DEFAULT_BORDER_WIDTH * density);
    a.recycle();
    mColors = new int[4];
    mColors[0] = context.getResources().getColor(R.color.progress_red);
    mColors[1] = context.getResources().getColor(R.color.progress_yellow);
    mColors[2] = context.getResources().getColor(R.color.progress_green);
    mColors[3] = context.getResources().getColor(R.color.progress_blue);
    mCurrentColorIndex = 0;
    mNextColorIndex = 1;

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

    setupAnimations();
}
 
Example 36
Project: DroidPlanner-Tower   File: AttitudeIndicator.java   View source code 6 votes vote down vote up
private void initialize() {

		Paint fillPaint = new Paint();
		fillPaint.setAntiAlias(true);
		fillPaint.setStyle(Style.FILL);

		yawPaint = new Paint(fillPaint);
		yawPaint.setColor(Color.WHITE);

		skyPaint = new Paint(fillPaint);

		groundPaint = new Paint(fillPaint);

		planePaint = new Paint(fillPaint);
		planePaint.setColor(Color.WHITE);
		planePaint.setStrokeWidth(PLANE_WING_WIDTH);
		planePaint.setStrokeCap(Cap.ROUND);
		planeCenterPaint = new Paint(planePaint);
		planeCenterPaint.setColor(Color.RED);
		planeFinPaint = new Paint(planePaint);
		planeFinPaint.setStrokeWidth(PLANE_WING_WIDTH / 2f);

		tickPaint = new Paint(fillPaint);
		tickPaint.setColor(Color.parseColor("#44ffffff"));
		tickPaint.setStrokeWidth(2);
	}
 
Example 37
Project: Gprs_droidplanner   File: AttitudeIndicator.java   View source code 6 votes vote down vote up
private void initialize() {

		Paint fillPaint = new Paint();
		fillPaint.setAntiAlias(true);
		fillPaint.setStyle(Style.FILL);

		yawPaint = new Paint(fillPaint);
		yawPaint.setColor(Color.WHITE);

		skyPaint = new Paint(fillPaint);

		groundPaint = new Paint(fillPaint);

		planePaint = new Paint(fillPaint);
		planePaint.setColor(Color.WHITE);
		planePaint.setStrokeWidth(PLANE_WING_WIDTH);
		planePaint.setStrokeCap(Cap.ROUND);
		planeCenterPaint = new Paint(planePaint);
		planeCenterPaint.setColor(Color.RED);
		planeFinPaint = new Paint(planePaint);
		planeFinPaint.setStrokeWidth(PLANE_WING_WIDTH / 2f);

		tickPaint = new Paint(fillPaint);
		tickPaint.setColor(Color.parseColor("#44ffffff"));
		tickPaint.setStrokeWidth(2);
	}
 
Example 38
Project: Play2   File: BarItem.java   View source code 6 votes vote down vote up
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);
	Paint paint = new Paint();  
    paint.setAntiAlias(true);
    paint.setColor(lineColor);  
    paint.setStrokeWidth(lineWidth);
    paint.setStrokeCap(Cap.ROUND);
    paint.setStrokeJoin(Join.ROUND);
    paint.setStyle(Style.STROKE);
    Path path = new Path();
    path.moveTo(startPoint.x, startPoint.y);
    path.lineTo(endPoint.x, endPoint.y);
    canvas.setMatrix(mMatrix);
    canvas.drawPath(path, paint);
}
 
Example 39
Project: whiteboard   File: PainterThreadControl.java   View source code 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 40
Project: oschina-app   File: ToggleButton.java   View source code 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();
}