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


Java Transformer.pointValuesToPixel方法代码示例

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


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

示例1: drawDataSet

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

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

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

        final float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());

        ScatterBuffer buffer = mScatterBuffers[mChart.getScatterData().getIndexOfDataSet(
                dataSet)];
        buffer.setPhases(phaseX, phaseY);
        buffer.feed(dataSet);

        trans.pointValuesToPixel(buffer.buffer);

        String shape = dataSet.getScatterShape();
        ShapeRenderer renderer = mChart.getShapeRenderer(shape);

        if (renderer != null) {
            renderer.renderShape(c, dataSet, mViewPortHandler, buffer, mRenderPaint, shapeSize);
        } else {
            throw new RuntimeException("No ShapeRenderer found for provided identifier. Please make sure to add a ShapeRenderer" +
                    " capable of rendering the provided shape.");
        }
    }
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:27,代码来源:ScatterChartRenderer.java

示例2: drawDataSet

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

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

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

        final float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());

        ScatterBuffer buffer = mScatterBuffers[mChart.getScatterData().getIndexOfDataSet(dataSet)];
        buffer.setPhases(phaseX, phaseY);
        buffer.feed(dataSet);

        trans.pointValuesToPixel(buffer.buffer);

        ShapeRenderer renderer = dataSet.getShapeRenderer();

        if (renderer != null) {
            renderer.renderShape(c, dataSet, mViewPortHandler, buffer, mRenderPaint, shapeSize);
        } else {
            throw new RuntimeException("No ShapeRenderer found for provided identifier. Please make sure to add a ShapeRenderer" +
                    " capable of rendering the provided shape.");
        }
    }
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:25,代码来源:ScatterChartRenderer.java

示例3: drawHighlighted

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

    BubbleData bubbleData = mChart.getBubbleData();

    float phaseY = mAnimator.getPhaseY();

    for (Highlight high : indices) {

        IBubbleDataSet set = bubbleData.getDataSetByIndex(high.getDataSetIndex());

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

        final BubbleEntry entry = set.getEntryForXValue(high.getX(), high.getY());

        if (entry.getY() != high.getY())
            continue;

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

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

        sizeBuffer[0] = 0f;
        sizeBuffer[2] = 1f;

        trans.pointValuesToPixel(sizeBuffer);

        boolean normalizeSize = set.isNormalizeSizeEnabled();

        // calcualte the full width of 1 step on the x-axis
        final float maxBubbleWidth = Math.abs(sizeBuffer[2] - sizeBuffer[0]);
        final float maxBubbleHeight = Math.abs(
                mViewPortHandler.contentBottom() - mViewPortHandler.contentTop());
        final float referenceSize = Math.min(maxBubbleHeight, maxBubbleWidth);

        pointBuffer[0] = entry.getX();
        pointBuffer[1] = (entry.getY()) * phaseY;
        trans.pointValuesToPixel(pointBuffer);

        high.setDraw(pointBuffer[0], pointBuffer[1]);

        float shapeHalf = getShapeSize(entry.getSize(),
                set.getMaxSize(),
                referenceSize,
                normalizeSize) / 2f;

        if (!mViewPortHandler.isInBoundsTop(pointBuffer[1] + shapeHalf)
                || !mViewPortHandler.isInBoundsBottom(pointBuffer[1] - shapeHalf))
            continue;

        if (!mViewPortHandler.isInBoundsLeft(pointBuffer[0] + shapeHalf))
            continue;

        if (!mViewPortHandler.isInBoundsRight(pointBuffer[0] - shapeHalf))
            break;

        final int originalColor = set.getColor((int) entry.getX());

        Color.RGBToHSV(Color.red(originalColor), Color.green(originalColor),
                Color.blue(originalColor), _hsvBuffer);
        _hsvBuffer[2] *= 0.5f;
        final int color = Color.HSVToColor(Color.alpha(originalColor), _hsvBuffer);

        mHighlightPaint.setColor(color);
        mHighlightPaint.setStrokeWidth(set.getHighlightCircleWidth());
        c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mHighlightPaint);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:71,代码来源:BubbleChartRenderer.java

示例4: drawCircles

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

        mRenderPaint.setStyle(Paint.Style.FILL);

        float phaseY = mAnimator.getPhaseY();

        mCirclesBuffer[0] = 0;
        mCirclesBuffer[1] = 0;

        List<ILineDataSet> dataSets = mChart.getLineData().getDataSets();

        for (int i = 0; i < dataSets.size(); i++) {

            ILineDataSet dataSet = dataSets.get(i);

            if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled() ||
                    dataSet.getEntryCount() == 0)
                continue;

            mCirclePaintInner.setColor(dataSet.getCircleHoleColor());

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

            mXBounds.set(mChart, dataSet);

            float circleRadius = dataSet.getCircleRadius();
            float circleHoleRadius = dataSet.getCircleHoleRadius();
            boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() &&
                    circleHoleRadius < circleRadius &&
                    circleHoleRadius > 0.f;
            boolean drawTransparentCircleHole = drawCircleHole &&
                    dataSet.getCircleHoleColor() == ColorTemplate.COLOR_NONE;

            DataSetImageCache imageCache;

            if (mImageCaches.containsKey(dataSet)) {
                imageCache = mImageCaches.get(dataSet);
            } else {
                imageCache = new DataSetImageCache();
                mImageCaches.put(dataSet, imageCache);
            }

            boolean changeRequired = imageCache.init(dataSet);

            // only fill the cache with new bitmaps if a change is required
            if (changeRequired) {
                imageCache.fill(dataSet, drawCircleHole, drawTransparentCircleHole);
            }

            int boundsRangeCount = mXBounds.range + mXBounds.min;

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

                Entry e = dataSet.getEntryForIndex(j);

                if (e == null) break;

                mCirclesBuffer[0] = e.getX();
                mCirclesBuffer[1] = e.getY() * phaseY;

                trans.pointValuesToPixel(mCirclesBuffer);

                if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0]))
                    break;

                if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) ||
                        !mViewPortHandler.isInBoundsY(mCirclesBuffer[1]))
                    continue;

                Bitmap circleBitmap = imageCache.getBitmap(j);

                if (circleBitmap != null) {
                    c.drawBitmap(circleBitmap, mCirclesBuffer[0] - circleRadius, mCirclesBuffer[1] - circleRadius, null);
                }
            }
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:78,代码来源:LineChartRenderer.java

示例5: drawDataSet

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

        ViewPortHandler viewPortHandler = mViewPortHandler;

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

        float phaseY = mAnimator.getPhaseY();

        IShapeRenderer renderer = dataSet.getShapeRenderer();
        if (renderer == null) {
            Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet");
            return;
        }

        int max = (int)(Math.min(
                Math.ceil((float)dataSet.getEntryCount() * mAnimator.getPhaseX()),
                (float)dataSet.getEntryCount()));

        for (int i = 0; i < max; i++) {

            Entry e = dataSet.getEntryForIndex(i);

            mPixelBuffer[0] = e.getX();
            mPixelBuffer[1] = e.getY() * phaseY;

            trans.pointValuesToPixel(mPixelBuffer);

            if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0]))
                break;

            if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0])
                    || !viewPortHandler.isInBoundsY(mPixelBuffer[1]))
                continue;

            mRenderPaint.setColor(dataSet.getColor(i / 2));
            renderer.renderShape(
                    c, dataSet, mViewPortHandler,
                    mPixelBuffer[0], mPixelBuffer[1],
                    mRenderPaint);
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:ScatterChartRenderer.java

示例6: drawHighlighted

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

    BubbleData bubbleData = mChart.getBubbleData();

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

    for (Highlight indice : indices) {

        IBubbleDataSet dataSet = bubbleData.getDataSetByIndex(indice.getDataSetIndex());

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

        BubbleEntry entryFrom = dataSet.getEntryForXIndex(mMinX);
        BubbleEntry entryTo = dataSet.getEntryForXIndex(mMaxX);

        int minx = dataSet.getEntryIndex(entryFrom);
        int maxx = Math.min(dataSet.getEntryIndex(entryTo) + 1, dataSet.getEntryCount());

        final BubbleEntry entry = (BubbleEntry) bubbleData.getEntryForHighlight(indice);
        if (entry == null || entry.getXIndex() != indice.getXIndex())
            continue;

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

        sizeBuffer[0] = 0f;
        sizeBuffer[2] = 1f;

        trans.pointValuesToPixel(sizeBuffer);

        // calcualte the full width of 1 step on the x-axis
        final float maxBubbleWidth = Math.abs(sizeBuffer[2] - sizeBuffer[0]);
        final float maxBubbleHeight = Math.abs(mViewPortHandler.contentBottom() - mViewPortHandler.contentTop());
        final float referenceSize = Math.min(maxBubbleHeight, maxBubbleWidth);

        pointBuffer[0] = (float) (entry.getXIndex() - minx) * phaseX + (float) minx;
        pointBuffer[1] = (float) (entry.getVal()) * phaseY;
        trans.pointValuesToPixel(pointBuffer);

        float shapeHalf = getShapeSize(entry.getSize(), dataSet.getMaxSize(), referenceSize) / 2f;

        if (!mViewPortHandler.isInBoundsTop(pointBuffer[1] + shapeHalf)
                || !mViewPortHandler.isInBoundsBottom(pointBuffer[1] - shapeHalf))
            continue;

        if (!mViewPortHandler.isInBoundsLeft(pointBuffer[0] + shapeHalf))
            continue;

        if (!mViewPortHandler.isInBoundsRight(pointBuffer[0] - shapeHalf))
            break;

        if (indice.getXIndex() < minx || indice.getXIndex() >= maxx)
            continue;

        final int originalColor = dataSet.getColor(entry.getXIndex());

        Color.RGBToHSV(Color.red(originalColor), Color.green(originalColor),
                Color.blue(originalColor), _hsvBuffer);
        _hsvBuffer[2] *= 0.5f;
        final int color = Color.HSVToColor(Color.alpha(originalColor), _hsvBuffer);

        mHighlightPaint.setColor(color);
        mHighlightPaint.setStrokeWidth(dataSet.getHighlightCircleWidth());
        c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mHighlightPaint);
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:69,代码来源:BubbleChartRenderer.java

示例7: drawDataSet

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

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

        mShadowPaint.setColor(dataSet.getBarShadowColor());

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

        // initialize the buffer
        BarBuffer buffer = mBarBuffers[index];
        buffer.setPhases(phaseX, phaseY);
        buffer.setBarSpace(dataSet.getBarSpace());
        buffer.setDataSet(index);
        buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));

        buffer.feed(dataSet);

        trans.pointValuesToPixel(buffer.buffer);

        // if multiple colors
        if (dataSet.getColors().size() > 1) {

            for (int j = 0; j < buffer.size(); j += 4) {

                if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2]))
                    continue;

                if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j]))
                    break;

                if (mChart.isDrawBarShadowEnabled()) {
                    c.drawRect(buffer.buffer[j], mViewPortHandler.contentTop(),
                            buffer.buffer[j + 2],
                            mViewPortHandler.contentBottom(), mShadowPaint);
                }

                // Set the color for the currently drawn value. If the index
                // is
                // out of bounds, reuse colors.
                mRenderPaint.setColor(dataSet.getColor(j / 4));
                c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                        buffer.buffer[j + 3], mRenderPaint);
            }
        } else {

            mRenderPaint.setColor(dataSet.getColor());

            for (int j = 0; j < buffer.size(); j += 4) {

                if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2]))
                    continue;

                if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j]))
                    break;

                if (mChart.isDrawBarShadowEnabled()) {
                    c.drawRect(buffer.buffer[j], mViewPortHandler.contentTop(),
                            buffer.buffer[j + 2],
                            mViewPortHandler.contentBottom(), mShadowPaint);
                }

                c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                        buffer.buffer[j + 3], mRenderPaint);
            }
        }
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:68,代码来源:BarChartRenderer.java

示例8: drawDataSet

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
@Override
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {

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

    mShadowPaint.setColor(dataSet.getBarShadowColor());

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

    // initialize the buffer
    BarBuffer buffer = mBarBuffers[index];
    buffer.setPhases(phaseX, phaseY);
    buffer.setBarSpace(dataSet.getBarSpace());
    buffer.setDataSet(index);
    buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));

    buffer.feed(dataSet);

    trans.pointValuesToPixel(buffer.buffer);

    for (int j = 0; j < buffer.size(); j += 4) {

        if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))
            break;

        if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))
            continue;

        if (mChart.isDrawBarShadowEnabled()) {
            c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1],
                    mViewPortHandler.contentRight(),
                    buffer.buffer[j + 3], mShadowPaint);
        }

        // Set the color for the currently drawn value. If the index
        // is
        // out of bounds, reuse colors.
        mRenderPaint.setColor(dataSet.getColor(j / 4));
        c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                buffer.buffer[j + 3], mRenderPaint);
    }
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:44,代码来源:HorizontalBarChartRenderer.java

示例9: drawDataSet

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
@Override
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {

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

    mShadowPaint.setColor(dataSet.getBarShadowColor());
    mBarBorderPaint.setColor(dataSet.getBarBorderColor());
    mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth()));

    final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f;

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

    // initialize the buffer
    BarBuffer buffer = mBarBuffers[index];
    buffer.setPhases(phaseX, phaseY);
    buffer.setBarSpace(dataSet.getBarSpace());
    buffer.setDataSet(index);
    buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));

    buffer.feed(dataSet);

    trans.pointValuesToPixel(buffer.buffer);

    for (int j = 0; j < buffer.size(); j += 4) {

        if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))
            break;

        if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))
            continue;

        if (mChart.isDrawBarShadowEnabled()) {
            c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1],
                    mViewPortHandler.contentRight(),
                    buffer.buffer[j + 3], mShadowPaint);
        }

        // Set the color for the currently drawn value. If the index
        // is out of bounds, reuse colors.
        mRenderPaint.setColor(dataSet.getColor(j / 4));
        c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                buffer.buffer[j + 3], mRenderPaint);

        if (drawBorder) {
            c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                    buffer.buffer[j + 3], mBarBorderPaint);
        }
    }
}
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:52,代码来源:HorizontalBarChartRenderer.java

示例10: drawCircles

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

        mRenderPaint.setStyle(Paint.Style.FILL);

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

        List<LineDataSet> dataSets = mChart.getLineData().getDataSets();

        for (int i = 0; i < dataSets.size(); i++) {

            LineDataSet dataSet = dataSets.get(i);

            if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled())
                continue;

            mCirclePaintInner.setColor(dataSet.getCircleHoleColor());

            Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());
            List<Entry> entries = dataSet.getYVals();

            Entry entryFrom = dataSet.getEntryForXIndex((mMinX < 0) ? 0 : mMinX);
            Entry entryTo = dataSet.getEntryForXIndex(mMaxX);

            int minx = Math.max(dataSet.getEntryPosition(entryFrom), 0);
            int maxx = Math.min(dataSet.getEntryPosition(entryTo) + 1, entries.size());

            CircleBuffer buffer = mCircleBuffers[i];
            buffer.setPhases(phaseX, phaseY);
            buffer.limitFrom(minx);
            buffer.limitTo(maxx);
            buffer.feed(entries);

            trans.pointValuesToPixel(buffer.buffer);

            float halfsize = dataSet.getCircleSize() / 2f;

            for (int j = 0, count = (int) Math.ceil((maxx - minx) * phaseX + minx) * 2; j < count; j += 2) {

                float x = buffer.buffer[j];
                float y = buffer.buffer[j + 1];

                if (!mViewPortHandler.isInBoundsRight(x))
                    break;

                // make sure the circles don't do shitty things outside
                // bounds
                if (!mViewPortHandler.isInBoundsLeft(x) || !mViewPortHandler.isInBoundsY(y))
                    continue;

                int circleColor = dataSet.getCircleColor(j / 2 + minx);

                mRenderPaint.setColor(circleColor);

                c.drawCircle(x, y, dataSet.getCircleSize(),
                        mRenderPaint);

                if (dataSet.isDrawCircleHoleEnabled()
                        && circleColor != mCirclePaintInner.getColor())
                    c.drawCircle(x, y,
                            halfsize,
                            mCirclePaintInner);
            }
        }
    }
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:66,代码来源:LineChartRenderer.java

示例11: drawDataSet

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

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

        mShadowPaint.setColor(dataSet.getBarShadowColor());

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

        List<BarEntry> entries = dataSet.getYVals();

        // initialize the buffer
        BarBuffer buffer = mBarBuffers[index];
        buffer.setPhases(phaseX, phaseY);
        buffer.setBarSpace(dataSet.getBarSpace());
        buffer.setDataSet(index);
        buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));

        buffer.feed(entries);

        trans.pointValuesToPixel(buffer.buffer);

        // if multiple colors
        if (dataSet.getColors().size() > 1) {

            for (int j = 0; j < buffer.size(); j += 4) {

                if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2]))
                    continue;

                if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j]))
                    break;

                if (mChart.isDrawBarShadowEnabled()) {
                    c.drawRect(buffer.buffer[j], mViewPortHandler.contentTop(),
                            buffer.buffer[j + 2],
                            mViewPortHandler.contentBottom(), mShadowPaint);
                }

                // Set the color for the currently drawn value. If the index
                // is
                // out of bounds, reuse colors.
                mRenderPaint.setColor(dataSet.getColor(j / 4));
                c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                        buffer.buffer[j + 3], mRenderPaint);
            }
        } else {

            mRenderPaint.setColor(dataSet.getColor());

            for (int j = 0; j < buffer.size(); j += 4) {

                if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2]))
                    continue;

                if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j]))
                    break;

                if (mChart.isDrawBarShadowEnabled()) {
                    c.drawRect(buffer.buffer[j], mViewPortHandler.contentTop(),
                            buffer.buffer[j + 2],
                            mViewPortHandler.contentBottom(), mShadowPaint);
                }

                c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                        buffer.buffer[j + 3], mRenderPaint);
            }
        }
    }
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:70,代码来源:BarChartRenderer.java

示例12: drawDataSet

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

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

        mShadowPaint.setColor(dataSet.getBarShadowColor());

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

        List<BarEntry> entries = dataSet.getYVals();

        // initialize the buffer
        BarBuffer buffer = mBarBuffers[index];
        buffer.setPhases(phaseX, phaseY);
        buffer.setBarSpace(dataSet.getBarSpace());
        buffer.setDataSet(index);
        buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));

        buffer.feed(entries);

        trans.pointValuesToPixel(buffer.buffer);

        for (int j = 0; j < buffer.size(); j += 4) {

            if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))
                break;

            if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))
                continue;

            if (mChart.isDrawBarShadowEnabled()) {
                c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1],
                        mViewPortHandler.contentRight(),
                        buffer.buffer[j + 3], mShadowPaint);
            }

            // Set the color for the currently drawn value. If the index
            // is
            // out of bounds, reuse colors.
            mRenderPaint.setColor(dataSet.getColor(j / 4));
            c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                    buffer.buffer[j + 3], mRenderPaint);
        }
    }
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:45,代码来源:HorizontalBarChartRenderer.java

示例13: drawDataSet

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
@Override
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {

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

    mShadowPaint.setColor(dataSet.getBarShadowColor());
    mBarBorderPaint.setColor(dataSet.getBarBorderColor());
    mBarBorderPaint.setStrokeWidth(dataSet.getBarBorderWidth());

    final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f;

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

    // initialize the buffer
    BarBuffer buffer = mBarBuffers[index];
    buffer.setPhases(phaseX, phaseY);
    buffer.setBarSpace(dataSet.getBarSpace());
    buffer.setDataSet(index);
    buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));

    buffer.feed(dataSet);

    trans.pointValuesToPixel(buffer.buffer);

    for (int j = 0; j < buffer.size(); j += 4) {

        if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))
            break;

        if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))
            continue;

        if (mChart.isDrawBarShadowEnabled()) {
            c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1],
                    mViewPortHandler.contentRight(),
                    buffer.buffer[j + 3], mShadowPaint);
        }

        // Set the color for the currently drawn value. If the index
        // is out of bounds, reuse colors.
        mRenderPaint.setColor(dataSet.getColor(j / 4));
        c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                buffer.buffer[j + 3], mRenderPaint);

        if (drawBorder) {
            c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                    buffer.buffer[j + 3], mBarBorderPaint);
        }
    }
}
 
开发者ID:muyoumumumu,项目名称:QuShuChe,代码行数:52,代码来源:HorizontalBarChartRenderer.java

示例14: drawCircles

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

        mRenderPaint.setStyle(Paint.Style.FILL);

        float phaseY = mAnimator.getPhaseY();

        mCirclesBuffer[0] = 0;
        mCirclesBuffer[1] = 0;

        List<ILineDataSet> dataSets = mChart.getLineData().getDataSets();

        for (int i = 0; i < dataSets.size(); i++) {

            ILineDataSet dataSet = dataSets.get(i);

            if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled() ||
                    dataSet.getEntryCount() == 0)
                continue;

            mCirclePaintInner.setColor(dataSet.getCircleHoleColor());

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

            mXBounds.set(mChart, dataSet);

            float circleRadius = dataSet.getCircleRadius();
            float circleHoleRadius = dataSet.getCircleHoleRadius();
            boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() &&
                    circleHoleRadius < circleRadius &&
                    circleHoleRadius > 0.f;
            boolean drawTransparentCircleHole = drawCircleHole &&
                    dataSet.getCircleHoleColor() == ColorTemplate.COLOR_NONE;

            DataSetImageCache imageCache;

            if (mImageCaches.containsKey(dataSet)) {
                imageCache = mImageCaches.get(dataSet);
            } else {
                imageCache = new DataSetImageCache();
                mImageCaches.put(dataSet, imageCache);
            }

            boolean changeRequired = imageCache.init(dataSet);

            // only fill the cache with new bitmaps if a change is required
            if (changeRequired) {
                imageCache.fill(dataSet, drawCircleHole, drawTransparentCircleHole);
            }

            int boundsRangeCount = mXBounds.range + mXBounds.min;

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

                Entry e = dataSet.getEntryForIndex(j);

                if (e == null) break;

                mCirclesBuffer[0] = e.getX();
                mCirclesBuffer[1] = e.getY() * phaseY;

                trans.pointValuesToPixel(mCirclesBuffer);

                if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0]))
                    break;

                if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) ||
                        !mViewPortHandler.isInBoundsY(mCirclesBuffer[1]))
                    continue;

                Bitmap circleBitmap = imageCache.getBitmap(j);

                if (circleBitmap != null) {
                    c.drawBitmap(circleBitmap, mCirclesBuffer[0] - circleRadius, mCirclesBuffer[1] - circleRadius, mRenderPaint);
                }
            }
        }
    }
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:78,代码来源:LineChartRenderer.java

示例15: drawDataSet

import com.github.mikephil.charting.utils.Transformer; //导入方法依赖的package包/类
@Override
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {

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

    mShadowPaint.setColor(dataSet.getBarShadowColor());
    mBarBorderPaint.setColor(dataSet.getBarBorderColor());
    mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth()));

    final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f;

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

    // initialize the buffer
    BarBuffer buffer = mBarBuffers[index];
    buffer.setPhases(phaseX, phaseY);
    buffer.setDataSet(index);
    buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency()));
    buffer.setBarWidth(mChart.getBarData().getBarWidth());

    buffer.feed(dataSet);

    trans.pointValuesToPixel(buffer.buffer);

    for (int j = 0; j < buffer.size(); j += 4) {

        if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3]))
            break;

        if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))
            continue;

        if (mChart.isDrawBarShadowEnabled()) {
            c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1],
                    mViewPortHandler.contentRight(),
                    buffer.buffer[j + 3], mShadowPaint);
        }

        // Set the color for the currently drawn value. If the index
        // is out of bounds, reuse colors.
        mRenderPaint.setColor(dataSet.getColor(j / 4));
        c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                buffer.buffer[j + 3], mRenderPaint);

        if (drawBorder) {
            c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2],
                    buffer.buffer[j + 3], mBarBorderPaint);
        }
    }
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:52,代码来源:HorizontalBarChartRenderer.java


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