当前位置: 首页>>代码示例>>Java>>正文


Java Utils.getPosition方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.utils.Utils.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.getPosition方法的具体用法?Java Utils.getPosition怎么用?Java Utils.getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.utils.Utils的用法示例。


在下文中一共展示了Utils.getPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderAxisLabels

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    float factor = mChart.getFactor();

    final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
    final int to = mYAxis.isDrawTopYLabelEntryEnabled()
            ? mYAxis.mEntryCount
            : (mYAxis.mEntryCount - 1);

    for (int j = from; j < to; j++) {

        float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;

        Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);

        String label = mYAxis.getFormattedLabel(j);

        c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
    }
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:YAxisRendererRadarChart.java

示例2: renderAxisLabels

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
        return;

    final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
    final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);

    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
    mAxisLabelPaint.setColor(mXAxis.getTextColor());

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {

        String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis);

        float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;

        Utils.getPosition(center, mChart.getYRange() * factor
                + mXAxis.mLabelRotatedWidth / 2f, angle, pOut);

        drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
                drawLabelAnchor, labelRotationAngleDegrees);
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
    MPPointF.recycleInstance(drawLabelAnchor);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:XAxisRendererRadarChart.java

示例3: renderAxisLabels

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    float factor = mChart.getFactor();

    int labelCount = mYAxis.mEntryCount;

    for (int j = 0; j < labelCount; j++) {

        if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false)
            break;

        float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;

        Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);

        String label = mYAxis.getFormattedLabel(j);

        c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
    }
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:33,代码来源:YAxisRendererRadarChart.java

示例4: renderLimitLines

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void renderLimitLines(Canvas c) {

    List<LimitLine> limitLines = mYAxis.getLimitLines();

    if (limitLines == null)
        return;

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    for (int i = 0; i < limitLines.size(); i++) {

        LimitLine l = limitLines.get(i);

        if (!l.isEnabled())
            continue;

        mLimitLinePaint.setColor(l.getLineColor());
        mLimitLinePaint.setPathEffect(l.getDashPathEffect());
        mLimitLinePaint.setStrokeWidth(l.getLineWidth());

        float r = (l.getLimit() - mChart.getYChartMin()) * factor;

        Path limitPath = mRenderLimitLinesPathBuffer;
        limitPath.reset();


        for (int j = 0; j < mChart.getData().getMaxEntryCountSet().getEntryCount(); j++) {

            Utils.getPosition(center, r, sliceangle * j + mChart.getRotationAngle(), pOut);

            if (j == 0)
                limitPath.moveTo(pOut.x, pOut.y);
            else
                limitPath.lineTo(pOut.x, pOut.y);
        }
        limitPath.close();

        c.drawPath(limitPath, mLimitLinePaint);
    }
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:50,代码来源:YAxisRendererRadarChart.java

示例5: drawDataSet

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * Draws the RadarDataSet
 *
 * @param c
 * @param dataSet
 * @param mostEntries the entry count of the dataset with the most entries
 */
protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) {

    float phaseX = mAnimator.getPhaseX();
    float phaseY = mAnimator.getPhaseY();

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    Path surface = mDrawDataSetSurfacePathBuffer;
    surface.reset();

    boolean hasMovedToPoint = false;

    for (int j = 0; j < dataSet.getEntryCount(); j++) {

        mRenderPaint.setColor(dataSet.getColor(j));

        RadarEntry e = dataSet.getEntryForIndex(j);

        Utils.getPosition(
                center,
                (e.getY() - mChart.getYChartMin()) * factor * phaseY,
                sliceangle * j * phaseX + mChart.getRotationAngle(), pOut);

        if (Float.isNaN(pOut.x))
            continue;

        if (!hasMovedToPoint) {
            surface.moveTo(pOut.x, pOut.y);
            hasMovedToPoint = true;
        } else
            surface.lineTo(pOut.x, pOut.y);
    }

    if (dataSet.getEntryCount() > mostEntries) {
        // if this is not the largest set, draw a line to the center before closing
        surface.lineTo(center.x, center.y);
    }

    surface.close();

    if (dataSet.isDrawFilledEnabled()) {

        final Drawable drawable = dataSet.getFillDrawable();
        if (drawable != null) {

            drawFilledPath(c, surface, drawable);
        } else {

            drawFilledPath(c, surface, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }

    mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
    mRenderPaint.setStyle(Paint.Style.STROKE);

    // draw the line (only if filled is disabled or alpha is below 255)
    if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)
        c.drawPath(surface, mRenderPaint);

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:76,代码来源:RadarChartRenderer.java

示例6: drawWeb

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
protected void drawWeb(Canvas c) {

        float sliceangle = mChart.getSliceAngle();

        // calculate the factor that is needed for transforming the value to
        // pixels
        float factor = mChart.getFactor();
        float rotationangle = mChart.getRotationAngle();

        MPPointF center = mChart.getCenterOffsets();

        // draw the web lines that come from the center
        mWebPaint.setStrokeWidth(mChart.getWebLineWidth());
        mWebPaint.setColor(mChart.getWebColor());
        mWebPaint.setAlpha(mChart.getWebAlpha());

        final int xIncrements = 1 + mChart.getSkipWebLineCount();
        int maxEntryCount = mChart.getData().getMaxEntryCountSet().getEntryCount();

        MPPointF p = MPPointF.getInstance(0,0);
        for (int i = 0; i < maxEntryCount; i += xIncrements) {

            Utils.getPosition(
                    center,
                    mChart.getYRange() * factor,
                    sliceangle * i + rotationangle,
                    p);

            c.drawLine(center.x, center.y, p.x, p.y, mWebPaint);
        }
        MPPointF.recycleInstance(p);

        // draw the inner-web
        mWebPaint.setStrokeWidth(mChart.getWebLineWidthInner());
        mWebPaint.setColor(mChart.getWebColorInner());
        mWebPaint.setAlpha(mChart.getWebAlpha());

        int labelCount = mChart.getYAxis().mEntryCount;

        MPPointF p1out = MPPointF.getInstance(0,0);
        MPPointF p2out = MPPointF.getInstance(0,0);
        for (int j = 0; j < labelCount; j++) {

            for (int i = 0; i < mChart.getData().getEntryCount(); i++) {

                float r = (mChart.getYAxis().mEntries[j] - mChart.getYChartMin()) * factor;

                Utils.getPosition(center, r, sliceangle * i + rotationangle, p1out);
                Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle, p2out);

                c.drawLine(p1out.x, p1out.y, p2out.x, p2out.y, mWebPaint);


            }
        }
        MPPointF.recycleInstance(p1out);
        MPPointF.recycleInstance(p2out);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:59,代码来源:RadarChartRenderer.java

示例7: drawHighlighted

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);

    RadarData radarData = mChart.getData();

    for (Highlight high : indices) {

        IRadarDataSet set = radarData.getDataSetByIndex(high.getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        RadarEntry e = set.getEntryForIndex((int) high.getX());

        if (!isInBoundsX(e, set))
            continue;

        float y = (e.getY() - mChart.getYChartMin());

        Utils.getPosition(center,
                y * factor * mAnimator.getPhaseY(),
                sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
                pOut);

        high.setDraw(pOut.x, pOut.y);

        // draw the lines
        drawHighlightLines(c, pOut.x, pOut.y, set);

        if (set.isDrawHighlightCircleEnabled()) {

            if (!Float.isNaN(pOut.x) && !Float.isNaN(pOut.y)) {

                int strokeColor = set.getHighlightCircleStrokeColor();
                if (strokeColor == ColorTemplate.COLOR_NONE) {
                    strokeColor = set.getColor(0);
                }

                if (set.getHighlightCircleStrokeAlpha() < 255) {
                    strokeColor = ColorTemplate.colorWithAlpha(strokeColor, set.getHighlightCircleStrokeAlpha());
                }

                drawHighlightCircle(c,
                        pOut,
                        set.getHighlightCircleInnerRadius(),
                        set.getHighlightCircleOuterRadius(),
                        set.getHighlightCircleFillColor(),
                        strokeColor,
                        set.getHighlightCircleStrokeWidth());
            }
        }
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:66,代码来源:RadarChartRenderer.java

示例8: drawWeb

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
protected void drawWeb(Canvas c) {

        float sliceangle = mChart.getSliceAngle();

        // calculate the factor that is needed for transforming the value to
        // pixels
        float factor = mChart.getFactor();
        float rotationangle = mChart.getRotationAngle();

        PointF center = mChart.getCenterOffsets();

        // draw the web lines that come from the center
        mWebPaint.setStrokeWidth(mChart.getWebLineWidth());
        mWebPaint.setColor(mChart.getWebColor());
        mWebPaint.setAlpha(mChart.getWebAlpha());

        final int xIncrements = 1 + mChart.getSkipWebLineCount();

        for (int i = 0; i < mChart.getData().getXValCount(); i += xIncrements) {

            PointF p = Utils.getPosition(
                    center,
                    mChart.getYRange() * factor,
                    sliceangle * i + rotationangle);

            c.drawLine(center.x, center.y, p.x, p.y, mWebPaint);
        }

        // draw the inner-web
        mWebPaint.setStrokeWidth(mChart.getWebLineWidthInner());
        mWebPaint.setColor(mChart.getWebColorInner());
        mWebPaint.setAlpha(mChart.getWebAlpha());

        int labelCount = mChart.getYAxis().mEntryCount;

        for (int j = 0; j < labelCount; j++) {

            for (int i = 0; i < mChart.getData().getXValCount(); i++) {

                float r = (mChart.getYAxis().mEntries[j] - mChart.getYChartMin()) * factor;

                PointF p1 = Utils.getPosition(center, r, sliceangle * i + rotationangle);
                PointF p2 = Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle);

                c.drawLine(p1.x, p1.y, p2.x, p2.y, mWebPaint);
            }
        }
    }
 
开发者ID:muyoumumumu,项目名称:QuShuChe,代码行数:49,代码来源:RadarChartRenderer.java

示例9: drawHighlighted

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    float phaseX = mAnimator.getPhaseX();
    float phaseY = mAnimator.getPhaseY();

    float sliceangle = mChart.getSliceAngle();
    float factor = mChart.getFactor();

    PointF center = mChart.getCenterOffsets();

    for (int i = 0; i < indices.length; i++) {

        IRadarDataSet set = mChart.getData()
                .getDataSetByIndex(indices[i]
                        .getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        // get the index to highlight
        int xIndex = indices[i].getXIndex();

        Entry e = set.getEntryForXIndex(xIndex);
        if (e == null || e.getXIndex() != xIndex)
            continue;

        int j = set.getEntryIndex(e);
        float y = (e.getVal() - mChart.getYChartMin());

        if (Float.isNaN(y))
            continue;

        PointF p = Utils.getPosition(
                center,
                y * factor * phaseY,
                sliceangle * j * phaseX + mChart.getRotationAngle());

        float[] pts = new float[]{
                p.x, p.y
        };

        // draw the lines
        drawHighlightLines(c, pts, set);
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:47,代码来源:RadarChartRenderer.java

示例10: drawDataSet

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
     * Draws the RadarDataSet
     *
     * @param c
     * @param dataSet
     * @param mostEntries the entry count of the dataset with the most entries
     */
    protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) {

        float phaseX = mAnimator.getPhaseX();
        float phaseY = mAnimator.getPhaseY();

        float sliceangle = mChart.getSliceAngle();

        // calculate the factor that is needed for transforming the value to
        // pixels
        float factor = mChart.getFactor();

        PointF center = mChart.getCenterOffsets();

        Path surface = new Path();

        boolean hasMovedToPoint = false;

        for (int j = 0; j < dataSet.getEntryCount(); j++) {

            mRenderPaint.setColor(dataSet.getColor(j));

            Entry e = dataSet.getEntryForIndex(j);

            PointF p = Utils.getPosition(
                    center,
                    (e.getVal() - mChart.getYChartMin()) * factor * phaseY,
                    sliceangle * j * phaseX + mChart.getRotationAngle());

            if (Float.isNaN(p.x))
                continue;

            if (!hasMovedToPoint) {
                surface.moveTo(p.x, p.y);
                hasMovedToPoint = true;
            } else
                surface.lineTo(p.x, p.y);
        }

        if (dataSet.getEntryCount() > mostEntries) {
            // if this is not the largest set, draw a line to the center before closing
            surface.lineTo(center.x, center.y);
        }

        surface.close();

        if(dataSet.isDrawFilledEnabled()) {

            final Drawable drawable = dataSet.getFillDrawable();
            if (drawable != null) {

                drawFilledPath(c, surface, drawable);
            } else {

                drawFilledPath(c, surface, dataSet.getFillColor(), dataSet.getFillAlpha());
            }
        }

        mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
        mRenderPaint.setStyle(Paint.Style.STROKE);

        // draw the line (only if filled is disabled or alpha is below 255)
        if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)
            c.drawPath(surface, mRenderPaint);
//
//        // draw filled
//        if (dataSet.isDrawFilledEnabled()) {
//            mRenderPaint.setStyle(Paint.Style.FILL);
//            mRenderPaint.setAlpha(dataSet.getFillAlpha());
//            c.drawPath(surface, mRenderPaint);
//            mRenderPaint.setAlpha(255);
//        }
    }
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:80,代码来源:RadarChartRenderer.java

示例11: drawHighlighted

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);

    RadarData radarData = mChart.getData();

    for (Highlight high : indices) {

        IRadarDataSet set = radarData.getDataSetByIndex(high.getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        RadarEntry e = set.getEntryForIndex((int) high.getX());

        if (!isInBoundsX(e, set))
            continue;

        float y = (e.getY() - mChart.getYChartMin());

        Utils.getPosition(center,
                y * factor * mAnimator.getPhaseY(),
                sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
                pOut);

        high.setDraw(pOut.x, pOut.y);

        // draw the lines
        drawHighlightLines(c, pOut.x, pOut.y, set);

        if (set.isDrawHighlightCircleEnabled()) {

            if (!Float.isNaN(pOut.x) && !Float.isNaN(pOut.y)) {

                int strokeColor = set.getHighlightCircleStrokeColor();
                if (strokeColor == ColorTemplate.COLOR_NONE) {
                    strokeColor = set.getColor(0);
                }

                if (set.getHighlightCircleStrokeAlpha() < 255) {
                    strokeColor = ColorTemplate.getColorWithAlphaComponent(strokeColor, set.getHighlightCircleStrokeAlpha());
                }

                drawHighlightCircle(c,
                        pOut,
                        set.getHighlightCircleInnerRadius(),
                        set.getHighlightCircleOuterRadius(),
                        set.getHighlightCircleFillColor(),
                        strokeColor,
                        set.getHighlightCircleStrokeWidth());
            }
        }
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:66,代码来源:RadarChartRenderer.java

示例12: drawHighlighted

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    float phaseX = mAnimator.getPhaseX();
    float phaseY = mAnimator.getPhaseY();

    float sliceangle = mChart.getSliceAngle();
    float factor = mChart.getFactor();

    PointF center = mChart.getCenterOffsets();

    for (int i = 0; i < indices.length; i++) {

        IRadarDataSet set = mChart.getData()
                .getDataSetByIndex(indices[i]
                        .getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        // get the index to highlight
        int xIndex = indices[i].getXIndex();

        Entry e = set.getEntryForXIndex(xIndex);
        if (e == null || e.getXIndex() != xIndex)
            continue;

        int j = set.getEntryIndex(e);
        float y = (e.getVal() - mChart.getYChartMin());

        if (Float.isNaN(y))
            continue;

        PointF p = Utils.getPosition(
                center,
                y * factor * phaseY,
                sliceangle * j * phaseX + mChart.getRotationAngle());

        float[] pts = new float[]{
                p.x, p.y
        };

        // draw the lines
        drawHighlightLines(c, pts, set);

        if (set.isDrawHighlightCircleEnabled()) {

            if (!Float.isNaN(pts[0]) && !Float.isNaN(pts[1])) {

                int strokeColor = set.getHighlightCircleStrokeColor();
                if (strokeColor == ColorTemplate.COLOR_NONE) {
                    strokeColor = set.getColor(0);
                }

                if (set.getHighlightCircleStrokeAlpha() < 255) {
                    strokeColor = ColorTemplate.getColorWithAlphaComponent(strokeColor, set.getHighlightCircleStrokeAlpha());
                }

                drawHighlightCircle(c,
                        p,
                        set.getHighlightCircleInnerRadius(),
                        set.getHighlightCircleOuterRadius(),
                        set.getHighlightCircleFillColor(),
                        strokeColor,
                        set.getHighlightCircleStrokeWidth());
            }
        }
    }
}
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:70,代码来源:RadarChartRenderer.java

示例13: drawHighlighted

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    float sliceangle = mChart.getSliceAngle();
    float factor = mChart.getFactor();

    PointF center = mChart.getCenterOffsets();

    for (int i = 0; i < indices.length; i++) {

        RadarDataSet set = mChart.getData()
                .getDataSetByIndex(indices[i]
                        .getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        // get the index to highlight
        int xIndex = indices[i].getXIndex();

        Entry e = set.getEntryForXIndex(xIndex);
        if (e == null || e.getXIndex() != xIndex)
            continue;

        int j = set.getEntryPosition(e);
        float y = (e.getVal() - mChart.getYChartMin());

        if (Float.isNaN(y))
            continue;

        PointF p = Utils.getPosition(center, y * factor,
                sliceangle * j + mChart.getRotationAngle());

        float[] pts = new float[]{
                p.x, p.y
        };

        // draw the lines
        drawHighlightLines(c, pts, set);
    }
}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:42,代码来源:RadarChartRenderer.java

示例14: getHighlightsAtIndex

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * Returns an array of Highlight objects for the given index. The Highlight
 * objects give information about the value at the selected index and the
 * DataSet it belongs to. INFORMATION: This method does calculations at
 * runtime. Do not over-use in performance critical situations.
 *
 * @param index
 * @return
 */
protected List<Highlight> getHighlightsAtIndex(int index) {

    mHighlightBuffer.clear();

    float phaseX = mChart.getAnimator().getPhaseX();
    float phaseY = mChart.getAnimator().getPhaseY();
    float sliceangle = mChart.getSliceAngle();
    float factor = mChart.getFactor();

    MPPointF pOut = MPPointF.getInstance(0,0);
    for (int i = 0; i < mChart.getData().getDataSetCount(); i++) {

        IDataSet<?> dataSet = mChart.getData().getDataSetByIndex(i);

        final Entry entry = dataSet.getEntryForIndex(index);

        float y = (entry.getY() - mChart.getYChartMin());

        Utils.getPosition(
                mChart.getCenterOffsets(), y * factor * phaseY,
                sliceangle * index * phaseX + mChart.getRotationAngle(), pOut);

        mHighlightBuffer.add(new Highlight(index, entry.getY(), pOut.x, pOut.y, i, dataSet.getAxisDependency()));
    }

    return mHighlightBuffer;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:RadarHighlighter.java

示例15: renderAxisLabels

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    PointF center = mChart.getCenterOffsets();
    float factor = mChart.getFactor();

    int labelCount = mYAxis.mEntryCount;

    for (int j = 0; j < labelCount; j++) {

        if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false)
            break;

        float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;

        PointF p = Utils.getPosition(center, r, mChart.getRotationAngle());

        String label = mYAxis.getFormattedLabel(j);

        c.drawText(label, p.x + 10, p.y, mAxisLabelPaint);
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:30,代码来源:YAxisRendererRadarChart.java


注:本文中的com.github.mikephil.charting.utils.Utils.getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。