Search in sources :

Example 66 with RectF

use of android.graphics.RectF in project EazeGraph by blackfizz.

the class BaseBarChart method onLegendDraw.

@Override
protected void onLegendDraw(Canvas _Canvas) {
    super.onLegendDraw(_Canvas);
    _Canvas.translate(-mCurrentViewport.left, 0);
    for (BaseModel model : getLegendData()) {
        if (model.canShowLabel()) {
            RectF bounds = model.getLegendBounds();
            _Canvas.drawText(model.getLegendLabel(), model.getLegendLabelPosition(), bounds.bottom - mMaxFontHeight, mLegendPaint);
            _Canvas.drawLine(bounds.centerX(), bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding, bounds.centerX(), mLegendTopPadding, mLegendPaint);
        }
    }
}
Also used : RectF(android.graphics.RectF) BaseModel(org.eazegraph.lib.models.BaseModel)

Example 67 with RectF

use of android.graphics.RectF in project EazeGraph by blackfizz.

the class PieChart method onGraphSizeChanged.

@Override
protected void onGraphSizeChanged(int w, int h, int oldw, int oldh) {
    super.onGraphSizeChanged(w, h, oldw, oldh);
    // Figure out how big we can make the pie.
    mPieDiameter = Math.min(w, h);
    mPieRadius = mPieDiameter / 2.f;
    // calculate the left and right space to be center aligned
    float centeredValueWidth = (w - mPieDiameter) / 2f;
    float centeredValueHeight = (h - mPieDiameter) / 2f;
    mGraphBounds = new RectF(0.0f, 0.0f, mPieDiameter, mPieDiameter);
    mGraphBounds.offsetTo(centeredValueWidth, centeredValueHeight);
    mCalculatedInnerPadding = (mPieRadius / 100) * mInnerPadding;
    mCalculatedInnerPaddingOutline = (mPieRadius / 100) * mInnerPaddingOutline;
    mInnerBounds = new RectF(mGraphBounds.centerX() - mCalculatedInnerPadding - mCalculatedInnerPaddingOutline, mGraphBounds.centerY() - mCalculatedInnerPadding - mCalculatedInnerPaddingOutline, mGraphBounds.centerX() + mCalculatedInnerPadding + mCalculatedInnerPaddingOutline, mGraphBounds.centerY() + mCalculatedInnerPadding + mCalculatedInnerPaddingOutline);
    mInnerOutlineBounds = new RectF(mGraphBounds.centerX() - mCalculatedInnerPadding, mGraphBounds.centerY() - mCalculatedInnerPadding, mGraphBounds.centerX() + mCalculatedInnerPadding, mGraphBounds.centerY() + mCalculatedInnerPadding);
}
Also used : RectF(android.graphics.RectF)

Example 68 with RectF

use of android.graphics.RectF in project EazeGraph by blackfizz.

the class StackedBarChart method drawBars.

/**
     * Callback method for drawing the bars in the child classes.
     * @param _Canvas The canvas object of the graph view.
     */
protected void drawBars(Canvas _Canvas) {
    for (StackedBarModel model : mData) {
        float lastTop;
        float lastBottom = mGraphHeight;
        for (int index = 0; index < model.getBars().size(); index++) {
            BarModel barModel = model.getBars().get(index);
            RectF bounds = barModel.getBarBounds();
            mGraphPaint.setColor(barModel.getColor());
            float height = (bounds.height() * mRevealValue);
            lastTop = lastBottom - height;
            _Canvas.drawRect(bounds.left, lastTop, bounds.right, lastBottom, mGraphPaint);
            if (mShowValues && barModel.isShowValue()) {
                _Canvas.drawText(String.valueOf(barModel.getValue()), bounds.centerX(), (lastTop + height / 2) + barModel.getValueBounds().height() / 2, mTextPaint);
            }
            lastBottom = lastTop;
            if (mShowSeparators && index < model.getBars().size() - 1) {
                lastBottom -= mSeparatorWidth;
            }
        }
    }
}
Also used : RectF(android.graphics.RectF) BarModel(org.eazegraph.lib.models.BarModel) StackedBarModel(org.eazegraph.lib.models.StackedBarModel) StackedBarModel(org.eazegraph.lib.models.StackedBarModel) Paint(android.graphics.Paint)

Example 69 with RectF

use of android.graphics.RectF in project fresco by facebook.

the class CircleProgressBarDrawable method drawBar.

private void drawBar(Canvas canvas, int level, int color) {
    Rect bounds = getBounds();
    RectF rectF = new RectF((float) (bounds.right * .4), (float) (bounds.bottom * .4), (float) (bounds.right * .6), (float) (bounds.bottom * .6));
    mPaint.setColor(color);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(6);
    if (level != 0)
        canvas.drawArc(rectF, 0, (float) (level * 360 / maxLevel), false, mPaint);
}
Also used : RectF(android.graphics.RectF) Rect(android.graphics.Rect)

Example 70 with RectF

use of android.graphics.RectF in project fresco by facebook.

the class DefaultZoomableController method limitTranslation.

/**
   * Limits the translation so that there are no empty spaces on the sides if possible.
   *
   * <p> The image is attempted to be centered within the view bounds if the transformed image is
   * smaller. There will be no empty spaces within the view bounds if the transformed image is
   * bigger. This applies to each dimension (horizontal and vertical) independently.
   *
   * @param limitTypes whether to limit translation along the specific axis.
   * @return whether limiting has been applied or not
   */
private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
    if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
        return false;
    }
    RectF b = mTempRect;
    b.set(mImageBounds);
    transform.mapRect(b);
    float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ? getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
    float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ? getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
    if (offsetLeft != 0 || offsetTop != 0) {
        transform.postTranslate(offsetLeft, offsetTop);
        return true;
    }
    return false;
}
Also used : RectF(android.graphics.RectF)

Aggregations

RectF (android.graphics.RectF)1274 Paint (android.graphics.Paint)451 Rect (android.graphics.Rect)178 Matrix (android.graphics.Matrix)155 Bitmap (android.graphics.Bitmap)150 Path (android.graphics.Path)141 Canvas (android.graphics.Canvas)136 Point (android.graphics.Point)86 ImageView (android.widget.ImageView)78 PorterDuffXfermode (android.graphics.PorterDuffXfermode)51 LinearGradient (android.graphics.LinearGradient)41 View (android.view.View)39 SuppressLint (android.annotation.SuppressLint)35 Drawable (android.graphics.drawable.Drawable)27 PointF (android.graphics.PointF)23 RadialGradient (android.graphics.RadialGradient)21 TextPaint (android.text.TextPaint)21 ArrayList (java.util.ArrayList)21 BitmapDrawable (android.graphics.drawable.BitmapDrawable)20 TypedArray (android.content.res.TypedArray)14