當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorTemplate.COLOR_NONE屬性代碼示例

本文整理匯總了Java中com.github.mikephil.charting.utils.ColorTemplate.COLOR_NONE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ColorTemplate.COLOR_NONE屬性的具體用法?Java ColorTemplate.COLOR_NONE怎麽用?Java ColorTemplate.COLOR_NONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.github.mikephil.charting.utils.ColorTemplate的用法示例。


在下文中一共展示了ColorTemplate.COLOR_NONE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setExtra

/**
 * Entries that will be appended to the end of the auto calculated
 *   entries after calculating the legend.
 * (if the legend has already been calculated, you will need to call notifyDataSetChanged()
 *   to let the changes take effect)
 */
public void setExtra(int[] colors, String[] labels) {

    List<LegendEntry> entries = new ArrayList<>();

    for (int i = 0; i < Math.min(colors.length, labels.length); i++) {
        final LegendEntry entry = new LegendEntry();
        entry.formColor = colors[i];
        entry.label = labels[i];

        if (entry.formColor == ColorTemplate.COLOR_SKIP ||
                entry.formColor == 0)
            entry.form = LegendForm.NONE;
        else if (entry.formColor == ColorTemplate.COLOR_NONE)
            entry.form = LegendForm.EMPTY;

        entries.add(entry);
    }

    mExtraEntries = entries.toArray(new LegendEntry[entries.size()]);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:Legend.java

示例2: drawHighlightCircle

public void drawHighlightCircle(Canvas c,
                                MPPointF point,
                                float innerRadius,
                                float outerRadius,
                                int fillColor,
                                int strokeColor,
                                float strokeWidth) {
    c.save();

    outerRadius = Utils.convertDpToPixel(outerRadius);
    innerRadius = Utils.convertDpToPixel(innerRadius);

    if (fillColor != ColorTemplate.COLOR_NONE) {
        Path p = mDrawHighlightCirclePathBuffer;
        p.reset();
        p.addCircle(point.x, point.y, outerRadius, Path.Direction.CW);
        if (innerRadius > 0.f) {
            p.addCircle(point.x, point.y, innerRadius, Path.Direction.CCW);
        }
        mHighlightCirclePaint.setColor(fillColor);
        mHighlightCirclePaint.setStyle(Paint.Style.FILL);
        c.drawPath(p, mHighlightCirclePaint);
    }

    if (strokeColor != ColorTemplate.COLOR_NONE) {
        mHighlightCirclePaint.setColor(strokeColor);
        mHighlightCirclePaint.setStyle(Paint.Style.STROKE);
        mHighlightCirclePaint.setStrokeWidth(Utils.convertDpToPixel(strokeWidth));
        c.drawCircle(point.x, point.y, outerRadius, mHighlightCirclePaint);
    }

    c.restore();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:33,代碼來源:RadarChartRenderer.java

示例3: Legend

@Deprecated
public Legend(int[] colors, String[] labels) {
    this();

    if (colors == null || labels == null) {
        throw new IllegalArgumentException("colors array or labels array is NULL");
    }

    if (colors.length != labels.length) {
        throw new IllegalArgumentException(
                "colors array and labels array need to be of same size");
    }

    List<LegendEntry> entries = new ArrayList<>();

    for (int i = 0; i < Math.min(colors.length, labels.length); i++) {
        final LegendEntry entry = new LegendEntry();
        entry.formColor = colors[i];
        entry.label = labels[i];

        if (entry.formColor == ColorTemplate.COLOR_SKIP)
            entry.form = LegendForm.NONE;
        else if (entry.formColor == ColorTemplate.COLOR_NONE ||
                entry.formColor == 0)
            entry.form = LegendForm.EMPTY;

        entries.add(entry);
    }

    mEntries = entries.toArray(new LegendEntry[entries.size()]);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:Legend.java

示例4: getColors

@Deprecated
public int[] getColors() {

    int[] old = new int[mEntries.length];
    for (int i = 0; i < mEntries.length; i++) {
        old[i] = mEntries[i].form == LegendForm.NONE ? ColorTemplate.COLOR_SKIP :
                (mEntries[i].form == LegendForm.EMPTY ? ColorTemplate.COLOR_NONE :
                        mEntries[i].formColor);
    }
    return old;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:Legend.java

示例5: getExtraColors

@Deprecated
public int[] getExtraColors() {

    int[] old = new int[mExtraEntries.length];
    for (int i = 0; i < mExtraEntries.length; i++) {
        old[i] = mExtraEntries[i].form == LegendForm.NONE ? ColorTemplate.COLOR_SKIP :
                (mExtraEntries[i].form == LegendForm.EMPTY ? ColorTemplate.COLOR_NONE :
                        mExtraEntries[i].formColor);
    }
    return old;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:Legend.java

示例6: drawHighlightCircle

public void drawHighlightCircle(Canvas c,
                            PointF point,
                            float innerRadius,
                            float outerRadius,
                            int fillColor,
                            int strokeColor,
                            float strokeWidth) {
    c.save();

    outerRadius = Utils.convertDpToPixel(outerRadius);
    innerRadius = Utils.convertDpToPixel(innerRadius);

    if (fillColor != ColorTemplate.COLOR_NONE) {
        Path p = new Path();
        p.addCircle(point.x, point.y, outerRadius, Path.Direction.CW);
        if (innerRadius > 0.f) {
            p.addCircle(point.x, point.y, innerRadius, Path.Direction.CCW);
        }
        mHighlightCirclePaint.setColor(fillColor);
        mHighlightCirclePaint.setStyle(Paint.Style.FILL);
        c.drawPath(p, mHighlightCirclePaint);
    }

    if (strokeColor != ColorTemplate.COLOR_NONE) {
        mHighlightCirclePaint.setColor(strokeColor);
        mHighlightCirclePaint.setStyle(Paint.Style.STROKE);
        mHighlightCirclePaint.setStrokeWidth(Utils.convertDpToPixel(strokeWidth));
        c.drawCircle(point.x, point.y, outerRadius, mHighlightCirclePaint);
    }

    c.restore();
}
 
開發者ID:pencil-box,項目名稱:NetKnight,代碼行數:32,代碼來源:RadarChartRenderer.java

示例7: renderShape

@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                        float posX, float posY, Paint renderPaint) {

    final float shapeSize = dataSet.getScatterShapeSize();
    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
    final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

    if (shapeSize > 0.0) {
        renderPaint.setStyle(Paint.Style.STROKE);
        renderPaint.setStrokeWidth(shapeStrokeSize);

        c.drawCircle(
                posX,
                posY,
                shapeHoleSizeHalf + shapeStrokeSizeHalf,
                renderPaint);

        if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
            renderPaint.setStyle(Paint.Style.FILL);

            renderPaint.setColor(shapeHoleColor);
            c.drawCircle(
                    posX,
                    posY,
                    shapeHoleSizeHalf,
                    renderPaint);
        }
    } else {
        renderPaint.setStyle(Paint.Style.FILL);

        c.drawCircle(
                posX,
                posY,
                shapeHalf,
                renderPaint);
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:44,代碼來源:CircleShapeRenderer.java

示例8: renderShape

@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                        float posX, float posY, Paint renderPaint) {

    final float shapeSize = dataSet.getScatterShapeSize();
    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

    renderPaint.setStyle(Paint.Style.FILL);

    // create a triangle path
    Path tri = mTrianglePathBuffer;
    tri.reset();

    tri.moveTo(posX, posY - shapeHalf);
    tri.lineTo(posX + shapeHalf, posY + shapeHalf);
    tri.lineTo(posX - shapeHalf, posY + shapeHalf);

    if (shapeSize > 0.0) {
        tri.lineTo(posX, posY - shapeHalf);

        tri.moveTo(posX - shapeHalf + shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.lineTo(posX + shapeHalf - shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.lineTo(posX,
                posY - shapeHalf + shapeStrokeSize);
        tri.lineTo(posX - shapeHalf + shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
    }

    tri.close();

    c.drawPath(tri, renderPaint);
    tri.reset();

    if (shapeSize > 0.0 &&
            shapeHoleColor != ColorTemplate.COLOR_NONE) {

        renderPaint.setColor(shapeHoleColor);

        tri.moveTo(posX,
                posY - shapeHalf + shapeStrokeSize);
        tri.lineTo(posX + shapeHalf - shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.lineTo(posX - shapeHalf + shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.close();

        c.drawPath(tri, renderPaint);
        tri.reset();
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:58,代碼來源:TriangleShapeRenderer.java

示例9: renderShape

@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                        float posX, float posY, Paint renderPaint) {

    final float shapeSize = dataSet.getScatterShapeSize();
    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
    final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

    if (shapeSize > 0.0) {
        renderPaint.setStyle(Paint.Style.STROKE);
        renderPaint.setStrokeWidth(shapeStrokeSize);

        c.drawRect(posX - shapeHoleSizeHalf - shapeStrokeSizeHalf,
                posY - shapeHoleSizeHalf - shapeStrokeSizeHalf,
                posX + shapeHoleSizeHalf + shapeStrokeSizeHalf,
                posY + shapeHoleSizeHalf + shapeStrokeSizeHalf,
                renderPaint);

        if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
            renderPaint.setStyle(Paint.Style.FILL);

            renderPaint.setColor(shapeHoleColor);
            c.drawRect(posX - shapeHoleSizeHalf,
                    posY - shapeHoleSizeHalf,
                    posX + shapeHoleSizeHalf,
                    posY + shapeHoleSizeHalf,
                    renderPaint);
        }

    } else {
        renderPaint.setStyle(Paint.Style.FILL);

        c.drawRect(posX - shapeHalf,
                posY - shapeHalf,
                posX + shapeHalf,
                posY + shapeHalf,
                renderPaint);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:44,代碼來源:SquareShapeRenderer.java

示例10: drawHighlighted

@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,代碼行數:65,代碼來源:RadarChartRenderer.java

示例11: drawForm

/**
 * Draws the Legend-form at the given position with the color at the given
 * index.
 *
 * @param c      canvas to draw with
 * @param x      position
 * @param y      position
 * @param entry  the entry to render
 * @param legend the legend context
 */
protected void drawForm(
        Canvas c,
        float x, float y,
        LegendEntry entry,
        Legend legend) {

    if (entry.formColor == ColorTemplate.COLOR_SKIP ||
            entry.formColor == ColorTemplate.COLOR_NONE ||
            entry.formColor == 0)
        return;

    int restoreCount = c.save();

    Legend.LegendForm form = entry.form;
    if (form == Legend.LegendForm.DEFAULT)
        form = legend.getForm();

    mLegendFormPaint.setColor(entry.formColor);

    final float formSize = Utils.convertDpToPixel(
            Float.isNaN(entry.formSize)
                    ? legend.getFormSize()
                    : entry.formSize);
    final float half = formSize / 2f;

    switch (form) {
        case NONE:
            // Do nothing
            break;

        case EMPTY:
            // Do not draw, but keep space for the form
            break;

        case DEFAULT:
        case CIRCLE:
            mLegendFormPaint.setStyle(Paint.Style.FILL);
            c.drawCircle(x + half, y, half, mLegendFormPaint);
            break;

        case SQUARE:
            mLegendFormPaint.setStyle(Paint.Style.FILL);
            c.drawRect(x, y - half, x + formSize, y + half, mLegendFormPaint);
            break;

        case LINE:
        {
            final float formLineWidth = Utils.convertDpToPixel(
                    Float.isNaN(entry.formLineWidth)
                            ? legend.getFormLineWidth()
                            : entry.formLineWidth);
            final DashPathEffect formLineDashEffect = entry.formLineDashEffect == null
                    ? legend.getFormLineDashEffect()
                    : entry.formLineDashEffect;
            mLegendFormPaint.setStyle(Paint.Style.STROKE);
            mLegendFormPaint.setStrokeWidth(formLineWidth);
            mLegendFormPaint.setPathEffect(formLineDashEffect);

            mLineFormPath.reset();
            mLineFormPath.moveTo(x, y);
            mLineFormPath.lineTo(x + formSize, y);
            c.drawPath(mLineFormPath, mLegendFormPaint);
        }
            break;
    }

    c.restoreToCount(restoreCount);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:78,代碼來源:LegendRenderer.java

示例12: drawCircles

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,代碼行數:77,代碼來源:LineChartRenderer.java

示例13: renderShape

@Override
public void renderShape(
        Canvas c, IScatterDataSet dataSet,
        ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {

    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
    final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

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

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

        if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
                || !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
            continue;

        mRenderPaint.setColor(dataSet.getColor(i / 2));

        if (shapeSize > 0.0) {
            mRenderPaint.setStyle(Paint.Style.STROKE);
            mRenderPaint.setStrokeWidth(shapeStrokeSize);

            c.drawCircle(
                    buffer.buffer[i],
                    buffer.buffer[i + 1],
                    shapeHoleSizeHalf + shapeStrokeSizeHalf,
                    mRenderPaint);

            if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
                mRenderPaint.setStyle(Paint.Style.FILL);

                mRenderPaint.setColor(shapeHoleColor);
                c.drawCircle(
                        buffer.buffer[i],
                        buffer.buffer[i + 1],
                        shapeHoleSizeHalf,
                        mRenderPaint);
            }
        } else {
            mRenderPaint.setStyle(Paint.Style.FILL);

            c.drawCircle(
                    buffer.buffer[i],
                    buffer.buffer[i + 1],
                    shapeHalf,
                    mRenderPaint);
        }
    }

}
 
開發者ID:pencil-box,項目名稱:NetKnight,代碼行數:56,代碼來源:CircleShapeRenderer.java

示例14: renderShape

@Override
public void renderShape(
        Canvas c, IScatterDataSet dataSet,
        ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {


    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

    mRenderPaint.setStyle(Paint.Style.FILL);

    // create a triangle path
    Path tri = new Path();

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

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

        if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
                || !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
            continue;

        mRenderPaint.setColor(dataSet.getColor(i / 2));

        tri.moveTo(buffer.buffer[i], buffer.buffer[i + 1] - shapeHalf);
        tri.lineTo(buffer.buffer[i] + shapeHalf, buffer.buffer[i + 1] + shapeHalf);
        tri.lineTo(buffer.buffer[i] - shapeHalf, buffer.buffer[i + 1] + shapeHalf);

        if (shapeSize > 0.0) {
            tri.lineTo(buffer.buffer[i], buffer.buffer[i + 1] - shapeHalf);

            tri.moveTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
                    buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
            tri.lineTo(buffer.buffer[i] + shapeHalf - shapeStrokeSize,
                    buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
            tri.lineTo(buffer.buffer[i],
                    buffer.buffer[i + 1] - shapeHalf + shapeStrokeSize);
            tri.lineTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
                    buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
        }

        tri.close();

        c.drawPath(tri, mRenderPaint);
        tri.reset();

        if (shapeSize > 0.0 &&
                shapeHoleColor != ColorTemplate.COLOR_NONE) {

            mRenderPaint.setColor(shapeHoleColor);

            tri.moveTo(buffer.buffer[i],
                    buffer.buffer[i + 1] - shapeHalf + shapeStrokeSize);
            tri.lineTo(buffer.buffer[i] + shapeHalf - shapeStrokeSize,
                    buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
            tri.lineTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
                    buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
            tri.close();

            c.drawPath(tri, mRenderPaint);
            tri.reset();
        }
    }

}
 
開發者ID:pencil-box,項目名稱:NetKnight,代碼行數:70,代碼來源:TriangleShapeRenderer.java

示例15: renderShape

@Override
public void renderShape(
        Canvas c, IScatterDataSet dataSet,
        ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {

    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
    final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

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

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

        if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
                || !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
            continue;

        mRenderPaint.setColor(dataSet.getColor(i / 2));

        if (shapeSize > 0.0) {
            mRenderPaint.setStyle(Paint.Style.STROKE);
            mRenderPaint.setStrokeWidth(shapeStrokeSize);

            c.drawRect(buffer.buffer[i] - shapeHoleSizeHalf - shapeStrokeSizeHalf,
                    buffer.buffer[i + 1] - shapeHoleSizeHalf - shapeStrokeSizeHalf,
                    buffer.buffer[i] + shapeHoleSizeHalf + shapeStrokeSizeHalf,
                    buffer.buffer[i + 1] + shapeHoleSizeHalf + shapeStrokeSizeHalf,
                    mRenderPaint);

            if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
                mRenderPaint.setStyle(Paint.Style.FILL);

                mRenderPaint.setColor(shapeHoleColor);
                c.drawRect(buffer.buffer[i] - shapeHoleSizeHalf,
                        buffer.buffer[i + 1] - shapeHoleSizeHalf,
                        buffer.buffer[i] + shapeHoleSizeHalf,
                        buffer.buffer[i + 1] + shapeHoleSizeHalf,
                        mRenderPaint);
            }

        } else {
            mRenderPaint.setStyle(Paint.Style.FILL);

            c.drawRect(buffer.buffer[i] - shapeHalf,
                    buffer.buffer[i + 1] - shapeHalf,
                    buffer.buffer[i] + shapeHalf,
                    buffer.buffer[i + 1] + shapeHalf,
                    mRenderPaint);
        }
    }
}
 
開發者ID:pencil-box,項目名稱:NetKnight,代碼行數:56,代碼來源:SquareShapeRenderer.java


注:本文中的com.github.mikephil.charting.utils.ColorTemplate.COLOR_NONE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。