Search in sources :

Example 16 with Paint

use of android.graphics.Paint in project NumberProgressBar by daimajia.

the class NumberProgressBar method initializePainters.

private void initializePainters() {
    mReachedBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mReachedBarPaint.setColor(mReachedBarColor);
    mUnreachedBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mUnreachedBarPaint.setColor(mUnreachedBarColor);
    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
}
Also used : Paint(android.graphics.Paint)

Example 17 with Paint

use of android.graphics.Paint in project barcodescanner by dm77.

the class ViewFinderView method init.

private void init() {
    //set up laser paint
    mLaserPaint = new Paint();
    mLaserPaint.setColor(mDefaultLaserColor);
    mLaserPaint.setStyle(Paint.Style.FILL);
    //finder mask paint
    mFinderMaskPaint = new Paint();
    mFinderMaskPaint.setColor(mDefaultMaskColor);
    //border paint
    mBorderPaint = new Paint();
    mBorderPaint.setColor(mDefaultBorderColor);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setStrokeWidth(mDefaultBorderStrokeWidth);
    mBorderLineLength = mDefaultBorderLineLength;
}
Also used : Paint(android.graphics.Paint)

Example 18 with Paint

use of android.graphics.Paint in project UltimateRecyclerView by cymcsg.

the class CircularImageView method onDraw.

@Override
public void onDraw(Canvas canvas) {
    // Don't draw anything without an image
    if (image == null)
        return;
    // Nothing to draw (Empty bounds)
    if (image.getHeight() == 0 || image.getWidth() == 0)
        return;
    // Update shader if canvas size has changed
    int oldCanvasSize = canvasSize;
    canvasSize = getWidth() < getHeight() ? getWidth() : getHeight();
    if (oldCanvasSize != canvasSize)
        updateBitmapShader();
    // Apply shader to paint
    paint.setShader(shader);
    // Keep track of selectorStroke/border width
    int outerWidth = 0;
    // Get the exact X/Y axis of the view
    int center = canvasSize / 2;
    if (hasSelector && isSelected) {
        // Draw the selector stroke & apply the selector filter, if applicable
        outerWidth = selectorStrokeWidth;
        center = (canvasSize - (outerWidth * 2)) / 2;
        paint.setColorFilter(selectorFilter);
        canvas.drawCircle(center + outerWidth, center + outerWidth, ((canvasSize - (outerWidth * 2)) / 2) + outerWidth - 4.0f, paintSelectorBorder);
    } else if (hasBorder) {
        // If no selector was drawn, draw a border and clear the filter instead... if enabled
        outerWidth = borderWidth;
        center = (canvasSize - (outerWidth * 2)) / 2;
        paint.setColorFilter(null);
        RectF rekt = new RectF(0 + outerWidth / 2, 0 + outerWidth / 2, canvasSize - outerWidth / 2, canvasSize - outerWidth / 2);
        canvas.drawArc(rekt, 360, 360, false, paintBorder);
    //canvas.drawCircle(center + outerWidth, center + outerWidth, ((canvasSize - (outerWidth * 2)) / 2) + outerWidth - 4.0f, paintBorder);
    } else
        // Clear the color filter if no selector nor border were drawn
        paint.setColorFilter(null);
    // Draw the circular image itself
    canvas.drawCircle(center + outerWidth, center + outerWidth, ((canvasSize - (outerWidth * 2)) / 2), paint);
}
Also used : RectF(android.graphics.RectF) Paint(android.graphics.Paint)

Example 19 with Paint

use of android.graphics.Paint in project UltimateRecyclerView by cymcsg.

the class CircularImageView method init.

/**
	 * Initializes paint objects and sets desired attributes.
	 * @param context Context
	 * @param attrs Attributes
	 * @param defStyle Default Style
	 */
private void init(Context context, AttributeSet attrs, int defStyle) {
    // Initialize paint objects
    paint = new Paint();
    paint.setAntiAlias(true);
    paintBorder = new Paint();
    paintBorder.setAntiAlias(true);
    paintBorder.setStyle(Paint.Style.STROKE);
    paintSelectorBorder = new Paint();
    paintSelectorBorder.setAntiAlias(true);
    // Enable software rendering on HoneyComb and up. (needed for shadow)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    // Load the styled attributes and set their properties
    TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.CircularImageView, defStyle, 0);
    // Check for extra features being enabled
    hasBorder = attributes.getBoolean(R.styleable.CircularImageView_civ_border, false);
    hasSelector = attributes.getBoolean(R.styleable.CircularImageView_civ_selector, false);
    shadowEnabled = attributes.getBoolean(R.styleable.CircularImageView_civ_shadow, SHADOW_ENABLED);
    // Set border properties, if enabled
    if (hasBorder) {
        int defaultBorderSize = (int) (2 * context.getResources().getDisplayMetrics().density + 0.5f);
        setBorderWidth(attributes.getDimensionPixelOffset(R.styleable.CircularImageView_civ_borderWidth, defaultBorderSize));
        setBorderColor(attributes.getColor(R.styleable.CircularImageView_civ_borderColor, Color.WHITE));
    }
    // Set selector properties, if enabled
    if (hasSelector) {
        int defaultSelectorSize = (int) (2 * context.getResources().getDisplayMetrics().density + 0.5f);
        setSelectorColor(attributes.getColor(R.styleable.CircularImageView_civ_selectorColor, Color.TRANSPARENT));
        setSelectorStrokeWidth(attributes.getDimensionPixelOffset(R.styleable.CircularImageView_civ_selectorStrokeWidth, defaultSelectorSize));
        setSelectorStrokeColor(attributes.getColor(R.styleable.CircularImageView_civ_selectorStrokeColor, Color.BLUE));
    }
    // Set shadow properties, if enabled
    if (shadowEnabled) {
        shadowRadius = attributes.getFloat(R.styleable.CircularImageView_civ_shadowRadius, SHADOW_RADIUS);
        shadowDx = attributes.getFloat(R.styleable.CircularImageView_civ_shadowDx, SHADOW_DX);
        shadowDy = attributes.getFloat(R.styleable.CircularImageView_civ_shadowDy, SHADOW_DY);
        shadowColor = attributes.getColor(R.styleable.CircularImageView_civ_shadowColor, SHADOW_COLOR);
        setShadowEnabled(true);
    }
    // We no longer need our attributes TypedArray, give it back to cache
    attributes.recycle();
}
Also used : TypedArray(android.content.res.TypedArray) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 20 with Paint

use of android.graphics.Paint in project WilliamChart by diogobernardino.

the class ChartView method setLabelThreshold.

/**
	 * Display a label threshold either in a form of line or band.
	 * In order to produce a line, the start and end label will be equal.
	 *
	 * @param startLabels Threshold start label index.
	 * @param endLabels Threshold end label index.
	 * @param paint The Paint instance that will be used to draw the grid
	 * If null the grid won't be drawn
	 *
	 * @return {@link com.db.chart.view.ChartView} self-reference.
	 */
public ChartView setLabelThreshold(int[] startLabels, int[] endLabels, Paint paint) {
    mThresholdStartLabels.clear();
    mThresholdEndLabels.clear();
    for (int i = 0; i < startLabels.length; i++) {
        mThresholdStartLabels.add(startLabels[i]);
        mThresholdEndLabels.add(endLabels[i]);
    }
    style.labelThresPaint = paint;
    return this;
}
Also used : SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)2191 Canvas (android.graphics.Canvas)461 Bitmap (android.graphics.Bitmap)412 Rect (android.graphics.Rect)266 RectF (android.graphics.RectF)225 TextPaint (android.text.TextPaint)177 PorterDuffXfermode (android.graphics.PorterDuffXfermode)121 Path (android.graphics.Path)116 Matrix (android.graphics.Matrix)102 TypedArray (android.content.res.TypedArray)80 BitmapDrawable (android.graphics.drawable.BitmapDrawable)75 Drawable (android.graphics.drawable.Drawable)64 BitmapShader (android.graphics.BitmapShader)63 Point (android.graphics.Point)58 SuppressLint (android.annotation.SuppressLint)55 View (android.view.View)54 Resources (android.content.res.Resources)42 Test (org.junit.Test)40 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)39 Typeface (android.graphics.Typeface)39