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


Java Transformer.pathValueToPixel方法代码示例

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


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

示例1: drawCubicFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {

        float fillMin = dataSet.getFillFormatter()
                .getFillLinePosition(dataSet, mChart);

        spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin);
        spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin);
        spline.close();

        trans.pathValueToPixel(spline);

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

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

            drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:LineChartRenderer.java

示例2: drawLinearFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, int minx,
                              int maxx,
                              Transformer trans) {

    Path filled = generateFilledPath(
            dataSet, minx, maxx);

    trans.pathValueToPixel(filled);

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

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

        drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha());
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:19,代码来源:LineChartRenderer.java

示例3: drawCubicFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicFill(LineDataSet dataSet, Path spline, Transformer trans,
        int from, int to) {

    if (to - from <= 1)
        return;
    
    float fillMin = dataSet.getFillFormatter()
            .getFillLinePosition(dataSet, mChart);

    spline.lineTo(to - 1, fillMin);
    spline.lineTo(from, fillMin);
    spline.close();

    mRenderPaint.setStyle(Paint.Style.FILL);

    mRenderPaint.setColor(dataSet.getFillColor());
    // filled is drawn with less alpha
    mRenderPaint.setAlpha(dataSet.getFillAlpha());

    trans.pathValueToPixel(spline);
    mBitmapCanvas.drawPath(spline, mRenderPaint);

    mRenderPaint.setAlpha(255);
}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:25,代码来源:LineChartRenderer.java

示例4: drawLinearFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawLinearFill(Canvas c, LineDataSet dataSet, List<Entry> entries, int minx,
        int maxx,
        Transformer trans) {

    mRenderPaint.setStyle(Paint.Style.FILL);

    mRenderPaint.setColor(dataSet.getFillColor());
    // filled is drawn with less alpha
    mRenderPaint.setAlpha(dataSet.getFillAlpha());

    Path filled = generateFilledPath(
            entries,
            dataSet.getFillFormatter().getFillLinePosition(dataSet, mChart), minx, maxx);

    trans.pathValueToPixel(filled);

    c.drawPath(filled, mRenderPaint);

    // restore alpha
    mRenderPaint.setAlpha(255);
}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:22,代码来源:LineChartRenderer.java

示例5: drawCubicFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) {

        float fillMin = dataSet.getFillFormatter()
                .getFillLinePosition(dataSet, mChart);

        spline.lineTo(bounds.min + bounds.range, fillMin);
        spline.lineTo(bounds.min, fillMin);
        spline.close();

        trans.pathValueToPixel(spline);

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

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

            drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
        }
    }
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:21,代码来源:LineChartRenderer.java

示例6: drawLinearFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
/**
 * Draws a filled linear path on the canvas.
 *
 * @param c
 * @param dataSet
 * @param trans
 * @param bounds
 */
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) {

    final Path filled = mGenerateFilledPathBuffer;

    final int startingIndex = bounds.min;
    final int endingIndex = bounds.range + bounds.min;
    final int indexInterval = 128;

    int currentStartIndex = 0;
    int currentEndIndex = indexInterval;
    int iterations = 0;

    // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets.
    do {
        currentStartIndex = startingIndex + (iterations * indexInterval);
        currentEndIndex = currentStartIndex + indexInterval;
        currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex;

        if (currentStartIndex <= currentEndIndex) {
            generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled);

            trans.pathValueToPixel(filled);

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

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

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

        iterations++;

    } while (currentStartIndex <= currentEndIndex);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:47,代码来源:LineChartRenderer.java

示例7: drawCubicFill

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans,
                             int from, int to) {

    if (to - from <= 1)
        return;

    float fillMin = dataSet.getFillFormatter()
            .getFillLinePosition(dataSet, mChart);
    
    // Take the from/to xIndex from the entries themselves,
    // so missing entries won't screw up the filling.
    // What we need to draw is line from points of the xIndexes - not arbitrary entry indexes!

    final Entry toEntry = dataSet.getEntryForIndex(to - 1);
    final Entry fromEntry = dataSet.getEntryForIndex(from);
    final float xTo = toEntry == null ? 0 : toEntry.getXIndex();
    final float xFrom = fromEntry == null ? 0 : fromEntry.getXIndex();

    spline.lineTo(xTo, fillMin);
    spline.lineTo(xFrom, fillMin);
    spline.close();

    trans.pathValueToPixel(spline);

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

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

        drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha());
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:34,代码来源:LineChartRenderer.java

示例8: drawCubicBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicBezier(ILineDataSet dataSet) {

        float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
        float phaseY = mAnimator.getPhaseY();

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        mXBounds.set(mChart, dataSet);

        float intensity = dataSet.getCubicIntensity();

        cubicPath.reset();

        if (mXBounds.range >= 1) {

            float prevDx = 0f;
            float prevDy = 0f;
            float curDx = 0f;
            float curDy = 0f;

            // Take an extra point from the left, and an extra from the right.
            // That's because we need 4 points for a cubic bezier (cubic=4), otherwise we get lines moving and doing weird stuff on the edges of the chart.
            // So in the starting `prev` and `cur`, go -2, -1
            // And in the `lastIndex`, add +1

            final int firstIndex = mXBounds.min + 1;
            final int lastIndex = mXBounds.min + mXBounds.range;

            Entry prevPrev;
            Entry prev = dataSet.getEntryForIndex(Math.max(firstIndex - 2, 0));
            Entry cur = dataSet.getEntryForIndex(Math.max(firstIndex - 1, 0));
            Entry next = cur;
            int nextIndex = -1;

            if (cur == null) return;

            // let the spline start
            cubicPath.moveTo(cur.getX(), cur.getY() * phaseY);

            for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) {

                prevPrev = prev;
                prev = cur;
                cur = nextIndex == j ? next : dataSet.getEntryForIndex(j);

                nextIndex = j + 1 < dataSet.getEntryCount() ? j + 1 : j;
                next = dataSet.getEntryForIndex(nextIndex);

                prevDx = (cur.getX() - prevPrev.getX()) * intensity;
                prevDy = (cur.getY() - prevPrev.getY()) * intensity;
                curDx = (next.getX() - prev.getX()) * intensity;
                curDy = (next.getY() - prev.getY()) * intensity;

                cubicPath.cubicTo(prev.getX() + prevDx, (prev.getY() + prevDy) * phaseY,
                        cur.getX() - curDx,
                        (cur.getY() - curDy) * phaseY, cur.getX(), cur.getY() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);

            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:LineChartRenderer.java

示例9: drawHighlighted

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

    int setCount = mChart.getBarData().getDataSetCount();

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

        Highlight h = indices[i];
        int index = h.getXIndex();

        int dataSetIndex = h.getDataSetIndex();
        IBarDataSet set = mChart.getBarData().getDataSetByIndex(dataSetIndex);

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

        float barspaceHalf = set.getBarSpace() / 2f;
        
        Transformer trans = mChart.getTransformer(set.getAxisDependency());

        mHighlightPaint.setColor(set.getHighLightColor());
        mHighlightPaint.setAlpha(set.getHighLightAlpha());

        // check outofbounds
        if (index >= 0
                && index < (mChart.getXChartMax() * mAnimator.getPhaseX()) / setCount) {

            BarEntry e = set.getEntryForXIndex(index);

            if (e == null || e.getXIndex() != index)
                continue;

            float groupspace = mChart.getBarData().getGroupSpace();
            boolean isStack = h.getStackIndex() < 0 ? false : true;

            // calculate the correct x-position
            float x = index * setCount + dataSetIndex + groupspace / 2f
                    + groupspace * index;

            final float y1;
            final float y2;

            if (isStack) {
                y1 = h.getRange().from;
                y2 = h.getRange().to;
            } else {
                y1 = e.getVal();
                y2 = 0.f;
            }

            prepareBarHighlight(x, y1, y2, barspaceHalf, trans);

            c.drawRect(mBarRect, mHighlightPaint);

            if (mChart.isDrawHighlightArrowEnabled()) {

                mHighlightPaint.setAlpha(255);

                // distance between highlight arrow and bar
                float offsetY = mAnimator.getPhaseY() * 0.07f;

                float[] values = new float[9];
                trans.getPixelToValueMatrix().getValues(values);
                final float xToYRel = Math.abs(values[Matrix.MSCALE_Y] / values[Matrix.MSCALE_X]);

                final float arrowWidth = set.getBarSpace() / 2.f;
                final float arrowHeight = arrowWidth * xToYRel;

                final float yArrow = (y1 > -y2 ? y1 : y1) * mAnimator.getPhaseY();

                Path arrow = new Path();
                arrow.moveTo(x + 0.4f, yArrow + offsetY);
                arrow.lineTo(x + 0.4f + arrowWidth, yArrow + offsetY - arrowHeight);
                arrow.lineTo(x + 0.4f + arrowWidth, yArrow + offsetY + arrowHeight);

                trans.pathValueToPixel(arrow);
                c.drawPath(arrow, mHighlightPaint);
            }
        }
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:82,代码来源:BarChartRenderer.java

示例10: drawCubicBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicBezier(Canvas c, ILineDataSet dataSet) {

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        int entryCount = dataSet.getEntryCount();

        Entry entryFrom = dataSet.getEntryForXIndex((mMinX < 0) ? 0 : mMinX, DataSet.Rounding.DOWN);
        Entry entryTo = dataSet.getEntryForXIndex(mMaxX, DataSet.Rounding.UP);

        int diff = (entryFrom == entryTo) ? 1 : 0;
        int minx = Math.max(dataSet.getEntryIndex(entryFrom) - diff - 1, 0);
        int maxx = Math.min(Math.max(minx + 2, dataSet.getEntryIndex(entryTo) + 1), entryCount);

        float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
        float phaseY = mAnimator.getPhaseY();

        float intensity = dataSet.getCubicIntensity();

        cubicPath.reset();

        int size = (int) Math.ceil((maxx - minx) * phaseX + minx);

        if (size - minx >= 2) {

            float prevDx = 0f;
            float prevDy = 0f;
            float curDx = 0f;
            float curDy = 0f;

            Entry prevPrev = dataSet.getEntryForIndex(minx);
            Entry prev = prevPrev;
            Entry cur = prev;
            Entry next = dataSet.getEntryForIndex(minx + 1);

            // let the spline start
            cubicPath.moveTo(cur.getXIndex(), cur.getVal() * phaseY);

            for (int j = minx + 1, count = Math.min(size, entryCount); j < count; j++) {

                prevPrev = dataSet.getEntryForIndex(j == 1 ? 0 : j - 2);
                prev = dataSet.getEntryForIndex(j - 1);
                cur = dataSet.getEntryForIndex(j);
                next = entryCount > j + 1 ? dataSet.getEntryForIndex(j + 1) : cur;

                prevDx = (cur.getXIndex() - prevPrev.getXIndex()) * intensity;
                prevDy = (cur.getVal() - prevPrev.getVal()) * intensity;
                curDx = (next.getXIndex() - prev.getXIndex()) * intensity;
                curDy = (next.getVal() - prev.getVal()) * intensity;

                cubicPath.cubicTo(prev.getXIndex() + prevDx, (prev.getVal() + prevDy) * phaseY,
                        cur.getXIndex() - curDx,
                        (cur.getVal() - curDy) * phaseY, cur.getXIndex(), cur.getVal() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);
            // create a new path, this is bad for performance
            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans,
                    minx, size);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:76,代码来源:LineChartRenderer.java

示例11: drawCubicBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicBezier(ILineDataSet dataSet) {

        float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
        float phaseY = mAnimator.getPhaseY();

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        mXBounds.set(mChart, dataSet);

        float intensity = dataSet.getCubicIntensity();

        cubicPath.reset();

        if (mXBounds.range >= 1) {

            float prevDx = 0f;
            float prevDy = 0f;
            float curDx = 0f;
            float curDy = 0f;

            Entry prevPrev = dataSet.getEntryForIndex(mXBounds.min);
            Entry prev = prevPrev;
            Entry cur = prev;
            Entry next = dataSet.getEntryForIndex(mXBounds.min + 1);

            // let the spline start
            cubicPath.moveTo(cur.getX(), cur.getY() * phaseY);

            for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) {

                prevPrev = dataSet.getEntryForIndex(j == 1 ? 0 : j - 2);
                prev = dataSet.getEntryForIndex(j - 1);
                cur = dataSet.getEntryForIndex(j);
                next = mXBounds.max > j + 1 ? dataSet.getEntryForIndex(j + 1) : cur;

                prevDx = (cur.getX() - prevPrev.getX()) * intensity;
                prevDy = (cur.getY() - prevPrev.getY()) * intensity;
                curDx = (next.getX() - prev.getX()) * intensity;
                curDy = (next.getY() - prev.getY()) * intensity;

                cubicPath.cubicTo(prev.getX() + prevDx, (prev.getY() + prevDy) * phaseY,
                        cur.getX() - curDx,
                        (cur.getY() - curDy) * phaseY, cur.getX(), cur.getY() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);
            // create a new path, this is bad for performance
            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:66,代码来源:LineChartRenderer.java

示例12: drawCubicBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawCubicBezier(Canvas c, ILineDataSet dataSet) {

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        int entryCount = dataSet.getEntryCount();

        Entry entryFrom = dataSet.getEntryForXIndex((mMinX < 0) ? 0 : mMinX, DataSet.Rounding.DOWN);
        Entry entryTo = dataSet.getEntryForXIndex(mMaxX, DataSet.Rounding.UP);

        int diff = (entryFrom == entryTo) ? 1 : 0;
        int minx = Math.max(dataSet.getEntryIndex(entryFrom) - diff, 0);
        int maxx = Math.min(Math.max(minx + 2, dataSet.getEntryIndex(entryTo) + 1), entryCount);

        float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
        float phaseY = mAnimator.getPhaseY();

        float intensity = dataSet.getCubicIntensity();

        cubicPath.reset();

        int size = (int) Math.ceil((maxx - minx) * phaseX + minx);

        if (size - minx >= 2) {

            float prevDx = 0f;
            float prevDy = 0f;
            float curDx = 0f;
            float curDy = 0f;

            Entry prevPrev = dataSet.getEntryForIndex(minx);
            Entry prev = prevPrev;
            Entry cur = prev;
            Entry next = dataSet.getEntryForIndex(minx + 1);

            // let the spline start
            cubicPath.moveTo(cur.getXIndex(), cur.getVal() * phaseY);

            for (int j = minx + 1, count = Math.min(size, entryCount); j < count; j++) {

                prevPrev = dataSet.getEntryForIndex(j == 1 ? 0 : j - 2);
                prev = dataSet.getEntryForIndex(j - 1);
                cur = dataSet.getEntryForIndex(j);
                next = entryCount > j + 1 ? dataSet.getEntryForIndex(j + 1) : cur;

                prevDx = (cur.getXIndex() - prevPrev.getXIndex()) * intensity;
                prevDy = (cur.getVal() - prevPrev.getVal()) * intensity;
                curDx = (next.getXIndex() - prev.getXIndex()) * intensity;
                curDy = (next.getVal() - prev.getVal()) * intensity;

                cubicPath.cubicTo(prev.getXIndex() + prevDx, (prev.getVal() + prevDy) * phaseY,
                        cur.getXIndex() - curDx,
                        (cur.getVal() - curDy) * phaseY, cur.getXIndex(), cur.getVal() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);
            // create a new path, this is bad for performance
            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans,
                    minx, size);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:muyoumumumu,项目名称:QuShuChe,代码行数:76,代码来源:LineChartRenderer.java

示例13: drawHorizontalBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawHorizontalBezier(ILineDataSet dataSet) {

        float phaseY = mAnimator.getPhaseY();

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        mXBounds.set(mChart, dataSet);

        cubicPath.reset();

        if (mXBounds.range >= 1) {

            Entry prev = dataSet.getEntryForIndex(mXBounds.min);
            Entry cur = prev;

            // let the spline start
            cubicPath.moveTo(cur.getX(), cur.getY() * phaseY);

            for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) {

                prev = cur;
                cur = dataSet.getEntryForIndex(j);

                final float cpx = (prev.getX())
                        + (cur.getX() - prev.getX()) / 2.0f;

                cubicPath.cubicTo(
                        cpx, prev.getY() * phaseY,
                        cpx, cur.getY() * phaseY,
                        cur.getX(), cur.getY() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);
            // create a new path, this is bad for performance
            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:53,代码来源:LineChartRenderer.java

示例14: drawHorizontalBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
/**
 * Draws a cubic line.
 *
 * @param c
 * @param dataSet
 */
protected void drawHorizontalBezier(Canvas c, ILineDataSet dataSet) {

    Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

    int entryCount = dataSet.getEntryCount();

    Entry entryFrom = dataSet.getEntryForXIndex((mMinX < 0) ? 0 : mMinX, DataSet.Rounding.DOWN);
    Entry entryTo = dataSet.getEntryForXIndex(mMaxX, DataSet.Rounding.UP);

    int diff = (entryFrom == entryTo) ? 1 : 0;
    int minx = Math.max(dataSet.getEntryIndex(entryFrom) - diff, 0);
    int maxx = Math.min(Math.max(minx + 2, dataSet.getEntryIndex(entryTo) + 1), entryCount);

    float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
    float phaseY = mAnimator.getPhaseY();

    cubicPath.reset();

    int size = (int) Math.ceil((maxx - minx) * phaseX + minx);

    if (size - minx >= 2) {

        Entry prev = dataSet.getEntryForIndex(minx);
        Entry cur = prev;

        // let the spline start
        cubicPath.moveTo(cur.getXIndex(), cur.getVal() * phaseY);

        for (int j = minx + 1, count = Math.min(size, entryCount); j < count; j++) {

            prev = dataSet.getEntryForIndex(j - 1);
            cur = dataSet.getEntryForIndex(j);

            final float cpx = (float)(prev.getXIndex())
                    + (float)(cur.getXIndex() - prev.getXIndex()) / 2.0f;

            cubicPath.cubicTo(
                    cpx, prev.getVal() * phaseY,
                    cpx, cur.getVal() * phaseY,
                    cur.getXIndex(), cur.getVal() * phaseY);
        }
    }

    // if filled is enabled, close the path
    if (dataSet.isDrawFilledEnabled()) {

        cubicFillPath.reset();
        cubicFillPath.addPath(cubicPath);
        // create a new path, this is bad for performance
        drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans,
                minx, size);
    }

    mRenderPaint.setColor(dataSet.getColor());

    mRenderPaint.setStyle(Paint.Style.STROKE);

    trans.pathValueToPixel(cubicPath);

    mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

    mRenderPaint.setPathEffect(null);
}
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:70,代码来源:LineChartRenderer.java

示例15: drawHorizontalBezier

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
protected void drawHorizontalBezier(ILineDataSet dataSet) {

        float phaseY = mAnimator.getPhaseY();

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        mXBounds.set(mChart, dataSet);

        cubicPath.reset();

        if (mXBounds.range >= 1) {

            Entry prev = dataSet.getEntryForIndex(mXBounds.min);
            Entry cur = prev;

            // let the spline start
            cubicPath.moveTo(cur.getX(), cur.getY() * phaseY);

            for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) {

                prev = dataSet.getEntryForIndex(j - 1);
                cur = dataSet.getEntryForIndex(j);

                final float cpx = (prev.getX())
                        + (cur.getX() - prev.getX()) / 2.0f;

                cubicPath.cubicTo(
                        cpx, prev.getY() * phaseY,
                        cpx, cur.getY() * phaseY,
                        cur.getX(), cur.getY() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);
            // create a new path, this is bad for performance
            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:53,代码来源:LineChartRenderer.java


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