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

The following examples show how to use android.graphics.Paint#set() . 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: FontFitTextView.java    From CreditCardView with 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
Source File: FitTextView.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: PlanePlotView.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
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 File: EditTextLabelFloat.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
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 5
Source File: AdaptiveTextView.java    From SprintNBA with 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 6
Source File: ExtendedTextView.java    From android-skeleton-project with MIT License 5 votes vote down vote up
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 7
Source File: GradientTextProgress.java    From SweetMusicPlayer with Apache License 2.0 5 votes vote down vote up
private void initPaint() {
    bgPaint = getPaint();
    bgPaint.setAntiAlias(true);
    bgPaint.setTextSize(getTextSize());
    
    paint=new Paint();
    paint.set(bgPaint);
}
 
Example 8
Source File: AddressText.java    From linphone-android with GNU General Public License v3.0 5 votes vote down vote up
public AddressText(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTestPaint = new Paint();
    mTestPaint.set(this.getPaint());
    mAddressListener = null;
}
 
Example 9
Source File: FontFitEditText.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
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 10
Source File: CircularSeekBar.java    From circularseekbar with 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);

}
 
Example 11
Source File: CircularSeekBar.java    From Kernel-Tuner with GNU General Public License v3.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
Source File: ObjectPool.java    From pixate-freestyle-android with Apache License 2.0 4 votes vote down vote up
public void initializeInstance(Paint toInitialize, Paint initializerObject) {
    toInitialize.set(initializerObject);
}
 
Example 13
Source File: CircularSeekBar.java    From CircularSeekBar with 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 14
Source File: CircularSeekBar.java    From OmniList with GNU Affero General Public License v3.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 15
Source File: CircularSeekBar.java    From Muzesto with GNU General Public License v3.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 16
Source File: CircularSeekBar.java    From Melophile with 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 17
Source File: AddressText.java    From Linphone4Android with GNU General Public License v3.0 4 votes vote down vote up
public AddressText(Context context, AttributeSet attrs) {
	super(context, attrs);

	mTestPaint = new Paint();
	mTestPaint.set(this.getPaint());
}