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


Java Legend.getForm方法代碼示例

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


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

示例1: drawForm

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
 * 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 index the index of the color to use (in the colors array)
 */
protected void drawForm(Canvas c, float x, float y, int index, Legend legend) {

    if (legend.getColors()[index] == ColorTemplate.COLOR_SKIP)
        return;

    mLegendFormPaint.setColor(legend.getColors()[index]);

    float formsize = legend.getFormSize();
    float half = formsize / 2f;

    switch (legend.getForm()) {
        case CIRCLE:
            c.drawCircle(x + half, y, half, mLegendFormPaint);
            break;
        case SQUARE:
            c.drawRect(x, y - half, x + formsize, y + half, mLegendFormPaint);
            break;
        case LINE:
            c.drawLine(x, y, x + formsize, y, mLegendFormPaint);
            break;
    }
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:32,代碼來源:LegendRenderer.java

示例2: drawForm

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
 * 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,代碼行數:79,代碼來源:LegendRenderer.java


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