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


Java Highlight.setDraw方法代碼示例

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


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

示例1: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的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

示例2: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的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

示例3: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    LineData lineData = mChart.getLineData();

    for (Highlight high : indices) {

        ILineDataSet set = lineData.getDataSetByIndex(high.getDataSetIndex());

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

        Entry e = set.getEntryForXValue(high.getX(), high.getY());

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

        MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
                .getPhaseY());

        high.setDraw((float) pix.x, (float) pix.y);

        // draw the lines
        drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:LineChartRenderer.java

示例4: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    ScatterData scatterData = mChart.getScatterData();

    for (Highlight high : indices) {

        IScatterDataSet set = scatterData.getDataSetByIndex(high.getDataSetIndex());

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

        final Entry e = set.getEntryForXValue(high.getX(), high.getY());

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

        MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
                .getPhaseY());

        high.setDraw((float) pix.x, (float) pix.y);

        // draw the lines
        drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:ScatterChartRenderer.java

示例5: setHighlightDrawPos

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
protected void setHighlightDrawPos(Highlight high, RectF bar) {
    high.setDraw(bar.centerY(), bar.right);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:HorizontalBarChartRenderer.java

示例6: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的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.getEntryForXPos(high.getX());

        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:letolab,項目名稱:LETO-Toggl_Android,代碼行數:68,代碼來源:BubbleChartRenderer.java

示例7: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的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

示例8: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    LineData lineData = mChart.getLineData();

    for (Highlight high : indices) {

        ILineDataSet set = lineData.getDataSetByIndex(high.getDataSetIndex());

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

        Entry e = set.getEntryForXPos(high.getX());

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

        MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY() * mAnimator
                .getPhaseY());

        high.setDraw((float) pix.x, (float) pix.y);

        // draw the lines
        drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
    }
}
 
開發者ID:letolab,項目名稱:LETO-Toggl_Android,代碼行數:27,代碼來源:LineChartRenderer.java

示例9: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    ScatterData scatterData = mChart.getScatterData();

    for (Highlight high : indices) {

        IScatterDataSet set = scatterData.getDataSetByIndex(high.getDataSetIndex());

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

        Entry e = set.getEntryForXPos(high.getX());

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

        MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), e.getY() * mAnimator
                .getPhaseY());

        high.setDraw((float) pix.x, (float) pix.y);

        // draw the lines
        drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
    }
}
 
開發者ID:letolab,項目名稱:LETO-Toggl_Android,代碼行數:27,代碼來源:ScatterChartRenderer.java

示例10: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    CandleData candleData = mChart.getCandleData();

    for (Highlight high : indices) {

        ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex());

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

        CandleEntry e = set.getEntryForXValue(high.getX(), high.getY());

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

        float lowValue = e.getLow() * mAnimator.getPhaseY();
        float highValue = e.getHigh() * mAnimator.getPhaseY();
        float y = (lowValue + highValue) / 2f;

        MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y);

        high.setDraw((float) pix.x, (float) pix.y);

        // draw the lines
        drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:CandleStickChartRenderer.java

示例11: drawHighlighted

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    CandleData candleData = mChart.getCandleData();

    for (Highlight high : indices) {

        ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex());

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

        CandleEntry e = set.getEntryForXPos(high.getX());

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

        float lowValue = e.getLow() * mAnimator.getPhaseY();
        float highValue = e.getHigh() * mAnimator.getPhaseY();
        float y = (lowValue + highValue) / 2f;

        MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelsForValues(e.getX(), y);

        high.setDraw((float) pix.x, (float) pix.y);

        // draw the lines
        drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
    }
}
 
開發者ID:letolab,項目名稱:LETO-Toggl_Android,代碼行數:30,代碼來源:CandleStickChartRenderer.java

示例12: setHighlightDrawPos

import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
 * Sets the drawing position of the highlight object based on the riven bar-rect.
 * @param high
 */
protected void setHighlightDrawPos(Highlight high, RectF bar) {
    high.setDraw(bar.centerX(), bar.top);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:BarChartRenderer.java


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