导航菜单

页面标题

页面副标题

BetterTogether v3.0.0 - PieChartRenderer.java 源代码

正在查看: BetterTogether v3.0.0 应用的 PieChartRenderer.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.github.mikephil.charting.renderer;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import com.github.mikephil.charting.animation.ChartAnimator;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.datasets.IPieDataSet;
import com.github.mikephil.charting.utils.MPPointF;
import com.github.mikephil.charting.utils.Utils;
import com.github.mikephil.charting.utils.ViewPortHandler;
import java.lang.ref.WeakReference;

public class PieChartRenderer extends DataRenderer {
    protected Canvas mBitmapCanvas;
    private RectF mCenterTextLastBounds;
    private CharSequence mCenterTextLastValue;
    private StaticLayout mCenterTextLayout;
    private TextPaint mCenterTextPaint;
    protected PieChart mChart;
    protected WeakReference<Bitmap> mDrawBitmap;
    protected Path mDrawCenterTextPathBuffer;
    protected RectF mDrawHighlightedRectF;
    private Paint mEntryLabelsPaint;
    private Path mHoleCirclePath;
    protected Paint mHolePaint;
    private RectF mInnerRectBuffer;
    private Path mPathBuffer;
    private RectF[] mRectBuffer;
    protected Paint mTransparentCirclePaint;
    protected Paint mValueLinePaint;

    public PieChartRenderer(PieChart pieChart, ChartAnimator chartAnimator, ViewPortHandler viewPortHandler) {
        super(chartAnimator, viewPortHandler);
        this.mCenterTextLastBounds = new RectF();
        this.mRectBuffer = new RectF[]{new RectF(), new RectF(), new RectF()};
        this.mPathBuffer = new Path();
        this.mInnerRectBuffer = new RectF();
        this.mHoleCirclePath = new Path();
        this.mDrawCenterTextPathBuffer = new Path();
        this.mDrawHighlightedRectF = new RectF();
        this.mChart = pieChart;
        Paint paint = new Paint(1);
        this.mHolePaint = paint;
        paint.setColor(-1);
        this.mHolePaint.setStyle(Paint.Style.FILL);
        Paint paint2 = new Paint(1);
        this.mTransparentCirclePaint = paint2;
        paint2.setColor(-1);
        this.mTransparentCirclePaint.setStyle(Paint.Style.FILL);
        this.mTransparentCirclePaint.setAlpha(105);
        TextPaint textPaint = new TextPaint(1);
        this.mCenterTextPaint = textPaint;
        textPaint.setColor(-16777216);
        this.mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12.0f));
        this.mValuePaint.setTextSize(Utils.convertDpToPixel(13.0f));
        this.mValuePaint.setColor(-1);
        this.mValuePaint.setTextAlign(Paint.Align.CENTER);
        Paint paint3 = new Paint(1);
        this.mEntryLabelsPaint = paint3;
        paint3.setColor(-1);
        this.mEntryLabelsPaint.setTextAlign(Paint.Align.CENTER);
        this.mEntryLabelsPaint.setTextSize(Utils.convertDpToPixel(13.0f));
        Paint paint4 = new Paint(1);
        this.mValueLinePaint = paint4;
        paint4.setStyle(Paint.Style.STROKE);
    }

    public float calculateMinimumRadiusForSpacedSlice(MPPointF mPPointF, float f10, float f11, float f12, float f13, float f14, float f15) {
        double d10 = (f14 + f15) * 0.017453292f;
        float cos = (((float) Math.cos(d10)) * f10) + mPPointF.f5312x;
        float sin = (((float) Math.sin(d10)) * f10) + mPPointF.f5313y;
        double d11 = ((f15 / 2.0f) + f14) * 0.017453292f;
        float cos2 = (((float) Math.cos(d11)) * f10) + mPPointF.f5312x;
        float sin2 = (((float) Math.sin(d11)) * f10) + mPPointF.f5313y;
        return (float) ((f10 - ((float) (Math.tan(((180.0d - f11) / 2.0d) * 0.017453292519943295d) * (Math.sqrt(Math.pow(sin - f13, 2.0d) + Math.pow(cos - f12, 2.0d)) / 2.0d)))) - Math.sqrt(Math.pow(sin2 - ((sin + f13) / 2.0f), 2.0d) + Math.pow(cos2 - ((cos + f12) / 2.0f), 2.0d)));
    }

    public void drawCenterText(Canvas canvas) {
        float radius;
        MPPointF mPPointF;
        CharSequence centerText = this.mChart.getCenterText();
        if (!this.mChart.isDrawCenterTextEnabled() || centerText == null) {
            return;
        }
        MPPointF centerCircleBox = this.mChart.getCenterCircleBox();
        MPPointF centerTextOffset = this.mChart.getCenterTextOffset();
        float f10 = centerCircleBox.f5312x + centerTextOffset.f5312x;
        float f11 = centerCircleBox.f5313y + centerTextOffset.f5313y;
        if (!this.mChart.isDrawHoleEnabled() || this.mChart.isDrawSlicesUnderHoleEnabled()) {
            radius = this.mChart.getRadius();
        } else {
            radius = (this.mChart.getHoleRadius() / 100.0f) * this.mChart.getRadius();
        }
        RectF[] rectFArr = this.mRectBuffer;
        RectF rectF = rectFArr[0];
        rectF.left = f10 - radius;
        rectF.top = f11 - radius;
        rectF.right = f10 + radius;
        rectF.bottom = f11 + radius;
        RectF rectF2 = rectFArr[1];
        rectF2.set(rectF);
        float centerTextRadiusPercent = this.mChart.getCenterTextRadiusPercent() / 100.0f;
        if (centerTextRadiusPercent > Utils.DOUBLE_EPSILON) {
            rectF2.inset((rectF2.width() - (rectF2.width() * centerTextRadiusPercent)) / 2.0f, (rectF2.height() - (rectF2.height() * centerTextRadiusPercent)) / 2.0f);
        }
        if (centerText.equals(this.mCenterTextLastValue) && rectF2.equals(this.mCenterTextLastBounds)) {
            mPPointF = centerTextOffset;
        } else {
            this.mCenterTextLastBounds.set(rectF2);
            this.mCenterTextLastValue = centerText;
            mPPointF = centerTextOffset;
            this.mCenterTextLayout = new StaticLayout(centerText, 0, centerText.length(), this.mCenterTextPaint, (int) Math.max(Math.ceil(this.mCenterTextLastBounds.width()), 1.0d), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
        }
        float height = this.mCenterTextLayout.getHeight();
        canvas.save();
        Path path = this.mDrawCenterTextPathBuffer;
        path.reset();
        path.addOval(rectF, Path.Direction.CW);
        canvas.clipPath(path);
        canvas.translate(rectF2.left, ((rectF2.height() - height) / 2.0f) + rectF2.top);
        this.mCenterTextLayout.draw(canvas);
        canvas.restore();
        MPPointF.recycleInstance(centerCircleBox);
        MPPointF.recycleInstance(mPPointF);
    }

    @Override
    public void drawData(Canvas canvas) {
        int chartWidth = (int) this.mViewPortHandler.getChartWidth();
        int chartHeight = (int) this.mViewPortHandler.getChartHeight();
        WeakReference<Bitmap> weakReference = this.mDrawBitmap;
        Bitmap bitmap = weakReference == null ? null : weakReference.get();
        if (bitmap == null || bitmap.getWidth() != chartWidth || bitmap.getHeight() != chartHeight) {
            if (chartWidth <= 0 || chartHeight <= 0) {
                return;
            }
            bitmap = Bitmap.createBitmap(chartWidth, chartHeight, Bitmap.Config.ARGB_4444);
            this.mDrawBitmap = new WeakReference<>(bitmap);
            this.mBitmapCanvas = new Canvas(bitmap);
        }
        bitmap.eraseColor(0);
        for (IPieDataSet iPieDataSet : ((PieData) this.mChart.getData()).getDataSets()) {
            if (iPieDataSet.isVisible() && iPieDataSet.getEntryCount() > 0) {
                drawDataSet(canvas, iPieDataSet);
            }
        }
    }

    public void drawDataSet(Canvas canvas, IPieDataSet iPieDataSet) {
        int i10;
        int i11;
        int i12;
        float f10;
        float f11;
        float[] fArr;
        float f12;
        float f13;
        int i13;
        RectF rectF;
        RectF rectF2;
        MPPointF mPPointF;
        float f14;
        MPPointF mPPointF2;
        int i14;
        float f15;
        MPPointF mPPointF3;
        IPieDataSet iPieDataSet2 = iPieDataSet;
        float rotationAngle = this.mChart.getRotationAngle();
        float phaseX = this.mAnimator.getPhaseX();
        float phaseY = this.mAnimator.getPhaseY();
        RectF circleBox = this.mChart.getCircleBox();
        int entryCount = iPieDataSet.getEntryCount();
        float[] drawAngles = this.mChart.getDrawAngles();
        MPPointF centerCircleBox = this.mChart.getCenterCircleBox();
        float radius = this.mChart.getRadius();
        boolean z4 = this.mChart.isDrawHoleEnabled() && !this.mChart.isDrawSlicesUnderHoleEnabled();
        float holeRadius = z4 ? (this.mChart.getHoleRadius() / 100.0f) * radius : 0.0f;
        float holeRadius2 = (radius - ((this.mChart.getHoleRadius() * radius) / 100.0f)) / 2.0f;
        RectF rectF3 = new RectF();
        boolean z10 = z4 && this.mChart.isDrawRoundedSlicesEnabled();
        int i15 = 0;
        for (int i16 = 0; i16 < entryCount; i16++) {
            if (Math.abs(iPieDataSet2.getEntryForIndex(i16).getY()) > Utils.FLOAT_EPSILON) {
                i15++;
            }
        }
        float sliceSpace = i15 <= 1 ? 0.0f : getSliceSpace(iPieDataSet2);
        int i17 = 0;
        float f16 = 0.0f;
        while (i17 < entryCount) {
            float f17 = drawAngles[i17];
            float abs = Math.abs(iPieDataSet2.getEntryForIndex(i17).getY());
            float f18 = Utils.FLOAT_EPSILON;
            if (abs > f18 && (!this.mChart.needsHighlight(i17) || z10)) {
                boolean z11 = sliceSpace > 0.0f && f17 <= 180.0f;
                i10 = entryCount;
                this.mRenderPaint.setColor(iPieDataSet2.getColor(i17));
                float f19 = i15 == 1 ? 0.0f : sliceSpace / (radius * 0.017453292f);
                float f20 = (((f19 / 2.0f) + f16) * phaseY) + rotationAngle;
                float f21 = (f17 - f19) * phaseY;
                float f22 = f21 < 0.0f ? 0.0f : f21;
                this.mPathBuffer.reset();
                if (z10) {
                    float f23 = radius - holeRadius2;
                    i11 = i17;
                    i12 = i15;
                    double d10 = f20 * 0.017453292f;
                    f10 = rotationAngle;
                    f11 = phaseX;
                    float cos = (((float) Math.cos(d10)) * f23) + centerCircleBox.f5312x;
                    float sin = (f23 * ((float) Math.sin(d10))) + centerCircleBox.f5313y;
                    rectF3.set(cos - holeRadius2, sin - holeRadius2, cos + holeRadius2, sin + holeRadius2);
                } else {
                    i11 = i17;
                    i12 = i15;
                    f10 = rotationAngle;
                    f11 = phaseX;
                }
                double d11 = f20 * 0.017453292f;
                float f24 = holeRadius;
                float cos2 = (((float) Math.cos(d11)) * radius) + centerCircleBox.f5312x;
                float sin2 = (((float) Math.sin(d11)) * radius) + centerCircleBox.f5313y;
                if (f22 < 360.0f || f22 % 360.0f > f18) {
                    fArr = drawAngles;
                    if (z10) {
                        this.mPathBuffer.arcTo(rectF3, f20 + 180.0f, -180.0f);
                    }
                    this.mPathBuffer.arcTo(circleBox, f20, f22);
                } else {
                    fArr = drawAngles;
                    this.mPathBuffer.addCircle(centerCircleBox.f5312x, centerCircleBox.f5313y, radius, Path.Direction.CW);
                }
                RectF rectF4 = this.mInnerRectBuffer;
                float f25 = centerCircleBox.f5312x;
                float f26 = centerCircleBox.f5313y;
                RectF rectF5 = rectF3;
                rectF4.set(f25 - f24, f26 - f24, f25 + f24, f26 + f24);
                if (!z4) {
                    f12 = radius;
                    f13 = f24;
                    i13 = i12;
                    rectF = rectF5;
                    rectF2 = circleBox;
                    mPPointF = centerCircleBox;
                    f14 = 360.0f;
                } else if (f24 > 0.0f || z11) {
                    if (z11) {
                        i13 = i12;
                        rectF2 = circleBox;
                        f13 = f24;
                        i14 = 1;
                        f12 = radius;
                        mPPointF2 = centerCircleBox;
                        float calculateMinimumRadiusForSpacedSlice = calculateMinimumRadiusForSpacedSlice(centerCircleBox, radius, f17 * phaseY, cos2, sin2, f20, f22);
                        if (calculateMinimumRadiusForSpacedSlice < 0.0f) {
                            calculateMinimumRadiusForSpacedSlice = -calculateMinimumRadiusForSpacedSlice;
                        }
                        f15 = Math.max(f13, calculateMinimumRadiusForSpacedSlice);
                    } else {
                        f12 = radius;
                        mPPointF2 = centerCircleBox;
                        f13 = f24;
                        i13 = i12;
                        rectF2 = circleBox;
                        i14 = 1;
                        f15 = f13;
                    }
                    float f27 = (i13 == i14 || f15 == 0.0f) ? 0.0f : sliceSpace / (f15 * 0.017453292f);
                    float f28 = (((f27 / 2.0f) + f16) * phaseY) + f10;
                    float f29 = (f17 - f27) * phaseY;
                    if (f29 < 0.0f) {
                        f29 = 0.0f;
                    }
                    float f30 = f28 + f29;
                    if (f22 < 360.0f || f22 % 360.0f > f18) {
                        if (z10) {
                            float f31 = f12 - holeRadius2;
                            double d12 = 0.017453292f * f30;
                            mPPointF3 = mPPointF2;
                            float cos3 = (((float) Math.cos(d12)) * f31) + mPPointF2.f5312x;
                            float sin3 = (f31 * ((float) Math.sin(d12))) + mPPointF3.f5313y;
                            rectF = rectF5;
                            rectF.set(cos3 - holeRadius2, sin3 - holeRadius2, cos3 + holeRadius2, sin3 + holeRadius2);
                            this.mPathBuffer.arcTo(rectF, f30, 180.0f);
                        } else {
                            mPPointF3 = mPPointF2;
                            rectF = rectF5;
                            double d13 = f30 * 0.017453292f;
                            this.mPathBuffer.lineTo((((float) Math.cos(d13)) * f15) + mPPointF3.f5312x, (f15 * ((float) Math.sin(d13))) + mPPointF3.f5313y);
                        }
                        this.mPathBuffer.arcTo(this.mInnerRectBuffer, f30, -f29);
                    } else {
                        this.mPathBuffer.addCircle(mPPointF2.f5312x, mPPointF2.f5313y, f15, Path.Direction.CCW);
                        mPPointF3 = mPPointF2;
                        rectF = rectF5;
                    }
                    mPPointF = mPPointF3;
                    this.mPathBuffer.close();
                    this.mBitmapCanvas.drawPath(this.mPathBuffer, this.mRenderPaint);
                    f16 = (f17 * f11) + f16;
                } else {
                    f12 = radius;
                    f13 = f24;
                    i13 = i12;
                    rectF = rectF5;
                    f14 = 360.0f;
                    rectF2 = circleBox;
                    mPPointF = centerCircleBox;
                }
                if (f22 % f14 > f18) {
                    if (z11) {
                        float calculateMinimumRadiusForSpacedSlice2 = calculateMinimumRadiusForSpacedSlice(mPPointF, f12, f17 * phaseY, cos2, sin2, f20, f22);
                        double d14 = 0.017453292f * ((f22 / 2.0f) + f20);
                        this.mPathBuffer.lineTo((((float) Math.cos(d14)) * calculateMinimumRadiusForSpacedSlice2) + mPPointF.f5312x, (calculateMinimumRadiusForSpacedSlice2 * ((float) Math.sin(d14))) + mPPointF.f5313y);
                    } else {
                        this.mPathBuffer.lineTo(mPPointF.f5312x, mPPointF.f5313y);
                    }
                }
                this.mPathBuffer.close();
                this.mBitmapCanvas.drawPath(this.mPathBuffer, this.mRenderPaint);
                f16 = (f17 * f11) + f16;
            } else {
                i11 = i17;
                f12 = radius;
                f10 = rotationAngle;
                f11 = phaseX;
                rectF2 = circleBox;
                i10 = entryCount;
                fArr = drawAngles;
                f16 = (f17 * phaseX) + f16;
                i13 = i15;
                rectF = rectF3;
                f13 = holeRadius;
                mPPointF = centerCircleBox;
            }
            i17 = i11 + 1;
            iPieDataSet2 = iPieDataSet;
            holeRadius = f13;
            rectF3 = rectF;
            centerCircleBox = mPPointF;
            i15 = i13;
            radius = f12;
            entryCount = i10;
            circleBox = rectF2;
            rotationAngle = f10;
            phaseX = f11;
            drawAngles = fArr;
        }
        MPPointF.recycleInstance(centerCircleBox);
    }

    public void drawEntryLabel(Canvas canvas, String str, float f10, float f11) {
        canvas.drawText(str, f10, f11, this.mEntryLabelsPaint);
    }

    @Override
    public void drawExtras(Canvas canvas) {
        drawHole(canvas);
        canvas.drawBitmap(this.mDrawBitmap.get(), 0.0f, 0.0f, (Paint) null);
        drawCenterText(canvas);
    }

    @Override
    public void drawHighlighted(Canvas canvas, Highlight[] highlightArr) {
        int i10;
        RectF rectF;
        float f10;
        float[] fArr;
        boolean z4;
        float f11;
        float f12;
        MPPointF mPPointF;
        IPieDataSet dataSetByIndex;
        float f13;
        int i11;
        float[] fArr2;
        float f14;
        int i12;
        float f15;
        float f16;
        Highlight[] highlightArr2 = highlightArr;
        boolean z10 = this.mChart.isDrawHoleEnabled() && !this.mChart.isDrawSlicesUnderHoleEnabled();
        if (z10 && this.mChart.isDrawRoundedSlicesEnabled()) {
            return;
        }
        float phaseX = this.mAnimator.getPhaseX();
        float phaseY = this.mAnimator.getPhaseY();
        float rotationAngle = this.mChart.getRotationAngle();
        float[] drawAngles = this.mChart.getDrawAngles();
        float[] absoluteAngles = this.mChart.getAbsoluteAngles();
        MPPointF centerCircleBox = this.mChart.getCenterCircleBox();
        float radius = this.mChart.getRadius();
        float holeRadius = z10 ? (this.mChart.getHoleRadius() / 100.0f) * radius : 0.0f;
        RectF rectF2 = this.mDrawHighlightedRectF;
        rectF2.set(0.0f, 0.0f, 0.0f, 0.0f);
        int i13 = 0;
        while (i13 < highlightArr2.length) {
            int x10 = (int) highlightArr2[i13].getX();
            if (x10 < drawAngles.length && (dataSetByIndex = ((PieData) this.mChart.getData()).getDataSetByIndex(highlightArr2[i13].getDataSetIndex())) != null && dataSetByIndex.isHighlightEnabled()) {
                int entryCount = dataSetByIndex.getEntryCount();
                int i14 = 0;
                for (int i15 = 0; i15 < entryCount; i15++) {
                    if (Math.abs(dataSetByIndex.getEntryForIndex(i15).getY()) > Utils.FLOAT_EPSILON) {
                        i14++;
                    }
                }
                if (x10 == 0) {
                    i11 = 1;
                    f13 = 0.0f;
                } else {
                    f13 = absoluteAngles[x10 - 1] * phaseX;
                    i11 = 1;
                }
                float sliceSpace = i14 <= i11 ? 0.0f : dataSetByIndex.getSliceSpace();
                float f17 = drawAngles[x10];
                float selectionShift = dataSetByIndex.getSelectionShift();
                int i16 = i13;
                float f18 = radius + selectionShift;
                float f19 = holeRadius;
                rectF2.set(this.mChart.getCircleBox());
                float f20 = -selectionShift;
                rectF2.inset(f20, f20);
                boolean z11 = sliceSpace > 0.0f && f17 <= 180.0f;
                this.mRenderPaint.setColor(dataSetByIndex.getColor(x10));
                float f21 = i14 == 1 ? 0.0f : sliceSpace / (radius * 0.017453292f);
                float f22 = i14 == 1 ? 0.0f : sliceSpace / (f18 * 0.017453292f);
                float f23 = (((f21 / 2.0f) + f13) * phaseY) + rotationAngle;
                float f24 = (f17 - f21) * phaseY;
                float f25 = f24 < 0.0f ? 0.0f : f24;
                float f26 = (((f22 / 2.0f) + f13) * phaseY) + rotationAngle;
                float f27 = (f17 - f22) * phaseY;
                if (f27 < 0.0f) {
                    f27 = 0.0f;
                }
                this.mPathBuffer.reset();
                if (f25 < 360.0f || f25 % 360.0f > Utils.FLOAT_EPSILON) {
                    fArr2 = drawAngles;
                    f14 = f13;
                    double d10 = f26 * 0.017453292f;
                    i12 = i14;
                    z4 = z10;
                    this.mPathBuffer.moveTo((((float) Math.cos(d10)) * f18) + centerCircleBox.f5312x, (f18 * ((float) Math.sin(d10))) + centerCircleBox.f5313y);
                    this.mPathBuffer.arcTo(rectF2, f26, f27);
                } else {
                    this.mPathBuffer.addCircle(centerCircleBox.f5312x, centerCircleBox.f5313y, f18, Path.Direction.CW);
                    fArr2 = drawAngles;
                    f14 = f13;
                    i12 = i14;
                    z4 = z10;
                }
                if (z11) {
                    double d11 = f23 * 0.017453292f;
                    i10 = i16;
                    rectF = rectF2;
                    f10 = f19;
                    mPPointF = centerCircleBox;
                    fArr = fArr2;
                    f15 = calculateMinimumRadiusForSpacedSlice(centerCircleBox, radius, f17 * phaseY, (((float) Math.cos(d11)) * radius) + centerCircleBox.f5312x, (((float) Math.sin(d11)) * radius) + centerCircleBox.f5313y, f23, f25);
                } else {
                    rectF = rectF2;
                    mPPointF = centerCircleBox;
                    i10 = i16;
                    f10 = f19;
                    fArr = fArr2;
                    f15 = 0.0f;
                }
                RectF rectF3 = this.mInnerRectBuffer;
                float f28 = mPPointF.f5312x;
                float f29 = mPPointF.f5313y;
                rectF3.set(f28 - f10, f29 - f10, f28 + f10, f29 + f10);
                if (!z4 || (f10 <= 0.0f && !z11)) {
                    f11 = phaseX;
                    f12 = phaseY;
                    if (f25 % 360.0f > Utils.FLOAT_EPSILON) {
                        if (z11) {
                            double d12 = ((f25 / 2.0f) + f23) * 0.017453292f;
                            this.mPathBuffer.lineTo((((float) Math.cos(d12)) * f15) + mPPointF.f5312x, (f15 * ((float) Math.sin(d12))) + mPPointF.f5313y);
                        } else {
                            this.mPathBuffer.lineTo(mPPointF.f5312x, mPPointF.f5313y);
                        }
                    }
                } else {
                    if (z11) {
                        if (f15 < 0.0f) {
                            f15 = -f15;
                        }
                        f16 = Math.max(f10, f15);
                    } else {
                        f16 = f10;
                    }
                    float f30 = (i12 == 1 || f16 == 0.0f) ? 0.0f : sliceSpace / (f16 * 0.017453292f);
                    float f31 = (((f30 / 2.0f) + f14) * phaseY) + rotationAngle;
                    float f32 = (f17 - f30) * phaseY;
                    if (f32 < 0.0f) {
                        f32 = 0.0f;
                    }
                    float f33 = f31 + f32;
                    if (f25 < 360.0f || f25 % 360.0f > Utils.FLOAT_EPSILON) {
                        double d13 = f33 * 0.017453292f;
                        f11 = phaseX;
                        f12 = phaseY;
                        this.mPathBuffer.lineTo((((float) Math.cos(d13)) * f16) + mPPointF.f5312x, (f16 * ((float) Math.sin(d13))) + mPPointF.f5313y);
                        this.mPathBuffer.arcTo(this.mInnerRectBuffer, f33, -f32);
                    } else {
                        this.mPathBuffer.addCircle(mPPointF.f5312x, mPPointF.f5313y, f16, Path.Direction.CCW);
                        f11 = phaseX;
                        f12 = phaseY;
                    }
                }
                this.mPathBuffer.close();
                this.mBitmapCanvas.drawPath(this.mPathBuffer, this.mRenderPaint);
            } else {
                i10 = i13;
                rectF = rectF2;
                f10 = holeRadius;
                fArr = drawAngles;
                z4 = z10;
                f11 = phaseX;
                f12 = phaseY;
                mPPointF = centerCircleBox;
            }
            i13 = i10 + 1;
            phaseX = f11;
            rectF2 = rectF;
            holeRadius = f10;
            centerCircleBox = mPPointF;
            phaseY = f12;
            drawAngles = fArr;
            z10 = z4;
            highlightArr2 = highlightArr;
        }
        MPPointF.recycleInstance(centerCircleBox);
    }

    public void drawHole(Canvas canvas) {
        if (!this.mChart.isDrawHoleEnabled() || this.mBitmapCanvas == null) {
            return;
        }
        float radius = this.mChart.getRadius();
        float holeRadius = (this.mChart.getHoleRadius() / 100.0f) * radius;
        MPPointF centerCircleBox = this.mChart.getCenterCircleBox();
        if (Color.alpha(this.mHolePaint.getColor()) > 0) {
            this.mBitmapCanvas.drawCircle(centerCircleBox.f5312x, centerCircleBox.f5313y, holeRadius, this.mHolePaint);
        }
        if (Color.alpha(this.mTransparentCirclePaint.getColor()) > 0 && this.mChart.getTransparentCircleRadius() > this.mChart.getHoleRadius()) {
            int alpha = this.mTransparentCirclePaint.getAlpha();
            float transparentCircleRadius = (this.mChart.getTransparentCircleRadius() / 100.0f) * radius;
            this.mTransparentCirclePaint.setAlpha((int) (this.mAnimator.getPhaseY() * this.mAnimator.getPhaseX() * alpha));
            this.mHoleCirclePath.reset();
            this.mHoleCirclePath.addCircle(centerCircleBox.f5312x, centerCircleBox.f5313y, transparentCircleRadius, Path.Direction.CW);
            this.mHoleCirclePath.addCircle(centerCircleBox.f5312x, centerCircleBox.f5313y, holeRadius, Path.Direction.CCW);
            this.mBitmapCanvas.drawPath(this.mHoleCirclePath, this.mTransparentCirclePaint);
            this.mTransparentCirclePaint.setAlpha(alpha);
        }
        MPPointF.recycleInstance(centerCircleBox);
    }

    public void drawRoundedSlices(Canvas canvas) {
        float f10;
        float[] fArr;
        float f11;
        if (this.mChart.isDrawRoundedSlicesEnabled()) {
            IPieDataSet dataSet = ((PieData) this.mChart.getData()).getDataSet();
            if (dataSet.isVisible()) {
                float phaseX = this.mAnimator.getPhaseX();
                float phaseY = this.mAnimator.getPhaseY();
                MPPointF centerCircleBox = this.mChart.getCenterCircleBox();
                float radius = this.mChart.getRadius();
                float holeRadius = (radius - ((this.mChart.getHoleRadius() * radius) / 100.0f)) / 2.0f;
                float[] drawAngles = this.mChart.getDrawAngles();
                float rotationAngle = this.mChart.getRotationAngle();
                int i10 = 0;
                while (i10 < dataSet.getEntryCount()) {
                    float f12 = drawAngles[i10];
                    if (Math.abs(dataSet.getEntryForIndex(i10).getY()) > Utils.FLOAT_EPSILON) {
                        double d10 = radius - holeRadius;
                        double d11 = (rotationAngle + f12) * phaseY;
                        f10 = phaseY;
                        fArr = drawAngles;
                        f11 = rotationAngle;
                        float cos = (float) (centerCircleBox.f5312x + (Math.cos(Math.toRadians(d11)) * d10));
                        float sin = (float) ((Math.sin(Math.toRadians(d11)) * d10) + centerCircleBox.f5313y);
                        this.mRenderPaint.setColor(dataSet.getColor(i10));
                        this.mBitmapCanvas.drawCircle(cos, sin, holeRadius, this.mRenderPaint);
                    } else {
                        f10 = phaseY;
                        fArr = drawAngles;
                        f11 = rotationAngle;
                    }
                    rotationAngle = (f12 * phaseX) + f11;
                    i10++;
                    phaseY = f10;
                    drawAngles = fArr;
                }
                MPPointF.recycleInstance(centerCircleBox);
            }
        }
    }

    @Override
    public void drawValue(Canvas canvas, String str, float f10, float f11, int i10) {
        this.mValuePaint.setColor(i10);
        canvas.drawText(str, f10, f11, this.mValuePaint);
    }

    @Override
    public void drawValues(android.graphics.Canvas r50) {
        throw new UnsupportedOperationException("Method not decompiled: com.github.mikephil.charting.renderer.PieChartRenderer.drawValues(android.graphics.Canvas):void");
    }

    public TextPaint getPaintCenterText() {
        return this.mCenterTextPaint;
    }

    public Paint getPaintEntryLabels() {
        return this.mEntryLabelsPaint;
    }

    public Paint getPaintHole() {
        return this.mHolePaint;
    }

    public Paint getPaintTransparentCircle() {
        return this.mTransparentCirclePaint;
    }

    public float getSliceSpace(IPieDataSet iPieDataSet) {
        if (iPieDataSet.isAutomaticallyDisableSliceSpacingEnabled() && iPieDataSet.getSliceSpace() / this.mViewPortHandler.getSmallestContentExtension() > (iPieDataSet.getYMin() / ((PieData) this.mChart.getData()).getYValueSum()) * 2.0f) {
            return 0.0f;
        }
        return iPieDataSet.getSliceSpace();
    }

    @Override
    public void initBuffers() {
    }

    public void releaseBitmap() {
        Canvas canvas = this.mBitmapCanvas;
        if (canvas != null) {
            canvas.setBitmap(null);
            this.mBitmapCanvas = null;
        }
        WeakReference<Bitmap> weakReference = this.mDrawBitmap;
        if (weakReference != null) {
            Bitmap bitmap = weakReference.get();
            if (bitmap != null) {
                bitmap.recycle();
            }
            this.mDrawBitmap.clear();
            this.mDrawBitmap = null;
        }
    }
}