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

The following examples show how to use android.graphics.Paint#set() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: CreditCardView   File: FontFitTextView.java    License: MIT License 6 votes vote down vote up
private void initialise(Context context, AttributeSet attributeSet)
{
    if(attributeSet!=null)
    {
        TypedArray styledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.FontFitTextView);
        maxFontSize = styledAttributes.getDimension(R.styleable.FontFitTextView_maxFontSize, MAX_FONT_SIZE_DEFAULT_VALUE);
        styledAttributes.recycle();
    }
    else
    {
        maxFontSize = MAX_FONT_SIZE_DEFAULT_VALUE;
    }

    mTestPaint = new Paint();
    mTestPaint.set(this.getPaint());
    //max size defaults to the initially specified text size unless it is too small
}
 
Example 2
private void initialise() {
    testPaint = new Paint();
    testPaint.set(this.getPaint());
    //max size defaults to the intially specified text size unless it is too small
    maxTextSize = this.getTextSize();
    if (maxTextSize < 9) {
        maxTextSize = 23;
    }
    minTextSize = 8;
}
 
Example 3
protected void drawLabeles(int idx, Canvas c, Paint p)
{
    final Label[] labels = (idx == FunctionIf.X) ? xLabels : yLabels;
    if (labels == null)
    {
        return;
    }
    p.set(getPaint());
    p.setColor(getPaint().getColor());
    p.setTextSize(axisParameters.getLabelTextSize());
    final int labelLineSize = axisParameters.getLabelLineSize();
    for (int i = 0; i < labels.length; i++)
    {
        area.toScreenPoint(labels[i].point, rect, p1);
        String label = labels[i].name;
        p.getTextBounds(label, 0, label.length(), tmpRect);
        p.setStrokeWidth(labelLineSize);
        if (idx == FunctionIf.X)
        {
            c.drawLine(p1.x, p1.y - labelLineSize, p1.x, p1.y + labelLineSize, p);
            tmpRect.offset(p1.x + axisParameters.getGridLineWidth() + 1, p1.y - labelLineSize - 2);
        }
        else
        {
            c.drawLine(p1.x - labelLineSize, p1.y, p1.x + labelLineSize, p1.y, p);
            tmpRect.offset(p1.x + labelLineSize + 2, p1.y - axisParameters.getGridLineWidth() - 2);
        }
        p.setStrokeWidth(1);
        c.drawText(label, tmpRect.left, tmpRect.bottom, p);
    }
}
 
Example 4
Source Project: SprintNBA   File: AdaptiveTextView.java    License: Apache License 2.0 5 votes vote down vote up
private void initialise() {
    testPaint = new Paint();
    testPaint.set(this.getPaint()); // 获取模拟的paint

    maxTextSize = this.getTextSize();// 获取单个字体的像素
    if (maxTextSize <= DEFAULT_MIN_TEXT_SIZE) {
        maxTextSize = DEFAULT_MAX_TEXT_SIZE;
    }
    minTextSize = DEFAULT_MIN_TEXT_SIZE;
}
 
Example 5
private void initPaint() {
    bgPaint = getPaint();
    bgPaint.setAntiAlias(true);
    bgPaint.setTextSize(getTextSize());
    
    paint=new Paint();
    paint.set(bgPaint);
}
 
Example 6
public AddressText(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTestPaint = new Paint();
    mTestPaint.set(this.getPaint());
    mAddressListener = null;
}
 
Example 7
public ExtendedTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.ExtendedTextView, 0, 0);

    fitText = attributes.getBoolean(R.styleable.ExtendedTextView_pro_aaverin_fitText, false);
    attributes.recycle();

    textPaint = new Paint();
    textPaint.set(this.getPaint());
}
 
Example 8
public EditTextLabelFloat(Context context, AttributeSet attrs) {
    super(context, attrs);

    mFloatingHintPaint = new Paint();
    mAnimation = Animation.NONE;
    mHintColors = getHintTextColors();
    mWasEmpty = true;

    mFloatingHintPaint.set(getPaint());
    mFloatingHintPaint.setColor(mHintColors.getColorForState(getDrawableState(), mHintColors.getDefaultColor()));

    TypedValue typedValue = new TypedValue();
    getResources().getValue(R.dimen.floatinghintedittext_hint_scale, typedValue, true);
    mHintScale = typedValue.getFloat();
}
 
Example 9
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
private void initPaints() {
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleProgressGlowPaint = new Paint();
    mCircleProgressGlowPaint.set(mCircleProgressPaint);
    mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setStyle(Paint.Style.FILL);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerRadius);

    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);
}
 
Example 10
public AddressText(Context context, AttributeSet attrs) {
	super(context, attrs);

	mTestPaint = new Paint();
	mTestPaint.set(this.getPaint());
}
 
Example 11
Source Project: Melophile   File: CircularSeekBar.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
private void initPaints() {
  mCirclePaint = new Paint();
  mCirclePaint.setAntiAlias(true);
  mCirclePaint.setDither(true);
  mCirclePaint.setColor(mCircleColor);
  mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
  mCirclePaint.setStyle(Paint.Style.STROKE);
  mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
  mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

  mCircleFillPaint = new Paint();
  mCircleFillPaint.setAntiAlias(true);
  mCircleFillPaint.setDither(true);
  mCircleFillPaint.setColor(mCircleFillColor);
  mCircleFillPaint.setStyle(Paint.Style.FILL);

  mCircleProgressPaint = new Paint();
  mCircleProgressPaint.setAntiAlias(true);
  mCircleProgressPaint.setDither(true);
  mCircleProgressPaint.setColor(mCircleProgressColor);
  mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
  mCircleProgressPaint.setStyle(Paint.Style.STROKE);
  mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
  mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

  mCircleProgressGlowPaint = new Paint();
  mCircleProgressGlowPaint.set(mCircleProgressPaint);
  mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

  mPointerPaint = new Paint();
  mPointerPaint.setAntiAlias(true);
  mPointerPaint.setDither(true);
  mPointerPaint.setStyle(Paint.Style.FILL);
  mPointerPaint.setColor(mPointerColor);
  mPointerPaint.setStrokeWidth(mPointerRadius);

  mPointerHaloPaint = new Paint();
  mPointerHaloPaint.set(mPointerPaint);
  mPointerHaloPaint.setColor(mPointerHaloColor);
  mPointerHaloPaint.setAlpha(mPointerAlpha);
  mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

  mPointerHaloBorderPaint = new Paint();
  mPointerHaloBorderPaint.set(mPointerPaint);
  mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
  mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
Example 12
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
private void initPaints() {
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleProgressGlowPaint = new Paint();
    mCircleProgressGlowPaint.set(mCircleProgressPaint);
    mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setStyle(Paint.Style.FILL);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerRadius);

    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
Example 13
private void initialise() {
    mTestPaint = new Paint();
    mTestPaint.set(this.getPaint());
    //max size defaults to the initially specified text size unless it is too small
}
 
Example 14
Source Project: CircularSeekBar   File: CircularSeekBar.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
private void initPaints() {
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(mCircleStyle);

    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(mCircleStyle);

    if (!mDisableProgressGlow) {
        mCircleProgressGlowPaint = new Paint();
        mCircleProgressGlowPaint.set(mCircleProgressPaint);
        mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((PROGRESS_GLOW_RADIUS_DP * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));
    }

    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerStrokeWidth);
    mPointerPaint.setStyle(Paint.Style.STROKE);
    mPointerPaint.setStrokeJoin(Paint.Join.ROUND);
    mPointerPaint.setStrokeCap(mCircleStyle);

    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerStrokeWidth + mPointerHaloWidth * 2f);

    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
Example 15
public void initializeInstance(Paint toInitialize, Paint initializerObject) {
    toInitialize.set(initializerObject);
}
 
Example 16
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
private void initPaints()
{
    mCirclePaint = new Paint();
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setDither(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
    mCirclePaint.setStyle(Paint.Style.STROKE);
    mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
    mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleFillPaint = new Paint();
    mCircleFillPaint.setAntiAlias(true);
    mCircleFillPaint.setDither(true);
    mCircleFillPaint.setColor(mCircleFillColor);
    mCircleFillPaint.setStyle(Paint.Style.FILL);

    mCircleProgressPaint = new Paint();
    mCircleProgressPaint.setAntiAlias(true);
    mCircleProgressPaint.setDither(true);
    mCircleProgressPaint.setColor(mCircleProgressColor);
    mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
    mCircleProgressPaint.setStyle(Paint.Style.STROKE);
    mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
    mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

    mCircleProgressGlowPaint = new Paint();
    mCircleProgressGlowPaint.set(mCircleProgressPaint);
    mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

    mPointerPaint = new Paint();
    mPointerPaint.setAntiAlias(true);
    mPointerPaint.setDither(true);
    mPointerPaint.setStyle(Paint.Style.FILL);
    mPointerPaint.setColor(mPointerColor);
    mPointerPaint.setStrokeWidth(mPointerRadius);

    mPointerHaloPaint = new Paint();
    mPointerHaloPaint.set(mPointerPaint);
    mPointerHaloPaint.setColor(mPointerHaloColor);
    mPointerHaloPaint.setAlpha(mPointerAlpha);
    mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

    mPointerHaloBorderPaint = new Paint();
    mPointerHaloBorderPaint.set(mPointerPaint);
    mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
    mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}
 
Example 17
Source Project: circularseekbar   File: CircularSeekBar.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the {@code Paint} objects with the appropriate styles.
 */
protected void initPaints() {
	mCirclePaint = new Paint();
	mCirclePaint.setAntiAlias(true);
	mCirclePaint.setDither(true);
	mCirclePaint.setColor(mCircleColor);
	mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
	mCirclePaint.setStyle(Paint.Style.STROKE);
	mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
	mCirclePaint.setStrokeCap(Paint.Cap.ROUND);

	mCircleFillPaint = new Paint();
	mCircleFillPaint.setAntiAlias(true);
	mCircleFillPaint.setDither(true);
	mCircleFillPaint.setColor(mCircleFillColor);
	mCircleFillPaint.setStyle(Paint.Style.FILL);

	mCircleProgressPaint = new Paint();
	mCircleProgressPaint.setAntiAlias(true);
	mCircleProgressPaint.setDither(true);
	mCircleProgressPaint.setColor(mCircleProgressColor);
	mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
	mCircleProgressPaint.setStyle(Paint.Style.STROKE);
	mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
	mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);

	mCircleProgressGlowPaint = new Paint();
	mCircleProgressGlowPaint.set(mCircleProgressPaint);
	mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));

	mPointerPaint = new Paint();
	mPointerPaint.setAntiAlias(true);
	mPointerPaint.setDither(true);
	mPointerPaint.setStyle(Paint.Style.FILL);
	mPointerPaint.setColor(mPointerColor);
	mPointerPaint.setStrokeWidth(mPointerRadius);

	mPointerHaloPaint = new Paint();
	mPointerHaloPaint.set(mPointerPaint);
	mPointerHaloPaint.setColor(mPointerHaloColor);
	mPointerHaloPaint.setAlpha(mPointerAlpha);
	mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);

	mPointerHaloBorderPaint = new Paint();
	mPointerHaloBorderPaint.set(mPointerPaint);
	mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
	mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);

}