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


Java YLabelPosition类代码示例

本文整理汇总了Java中com.github.mikephil.charting.utils.YLabels.YLabelPosition的典型用法代码示例。如果您正苦于以下问题:Java YLabelPosition类的具体用法?Java YLabelPosition怎么用?Java YLabelPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


YLabelPosition类属于com.github.mikephil.charting.utils.YLabels包,在下文中一共展示了YLabelPosition类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawYLabels

import com.github.mikephil.charting.utils.YLabels.YLabelPosition; //导入依赖的package包/类
/**
 * draws the y-axis labels to the screen
 */
private void drawYLabels() {

    if (!mDrawYLabels)
        return;

    float[] positions = new float[mYLabels.mEntryCount * 2];

    for (int i = 0; i < positions.length; i += 2) {
        // only fill y values, x values are not needed since the y-labels
        // are
        // static on the x-axis
        positions[i + 1] = mYLabels.mEntries[i / 2];
    }

    mTrans.pointValuesToPixel(positions);

    mYLabelPaint.setTypeface(mYLabels.getTypeface());
    mYLabelPaint.setTextSize(mYLabels.getTextSize());
    mYLabelPaint.setColor(mYLabels.getTextColor());

    float xoffset = Utils.convertDpToPixel(5f);
    float yoffset = Utils.calcTextHeight(mYLabelPaint, "A") / 2.5f;

    // determine position and draw adequately
    if (mYLabels.getPosition() == YLabelPosition.LEFT) {

        mYLabelPaint.setTextAlign(Align.RIGHT);
        drawYLabels(mOffsetLeft - xoffset, positions, yoffset);

    } else if (mYLabels.getPosition() == YLabelPosition.RIGHT) {

        mYLabelPaint.setTextAlign(Align.LEFT);
        drawYLabels(getWidth() - mOffsetRight + xoffset, positions, yoffset);

    } else if (mYLabels.getPosition() == YLabelPosition.RIGHT_INSIDE) {

        mYLabelPaint.setTextAlign(Align.RIGHT);
        drawYLabels(getWidth() - mOffsetRight - xoffset, positions, yoffset);

    } else if (mYLabels.getPosition() == YLabelPosition.LEFT_INSIDE) {

        mYLabelPaint.setTextAlign(Align.LEFT);
        drawYLabels(mOffsetLeft + xoffset, positions, yoffset);

    } else { // BOTH SIDED Y-AXIS LABELS

        // draw left legend
        mYLabelPaint.setTextAlign(Align.RIGHT);
        drawYLabels(mOffsetLeft - xoffset, positions, yoffset);

        // draw right legend
        mYLabelPaint.setTextAlign(Align.LEFT);
        drawYLabels(getWidth() - mOffsetRight + xoffset, positions, yoffset);
    }
}
 
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:59,代码来源:BarLineChartBase.java

示例2: drawYLabels

import com.github.mikephil.charting.utils.YLabels.YLabelPosition; //导入依赖的package包/类
/**
 * draws the y-axis labels to the screen
 */
private void drawYLabels() {

    if (!mDrawYLabels)
        return;

    float[] positions = new float[mYLabels.mEntryCount * 2];

    for (int i = 0; i < positions.length; i += 2) {
        // only fill y values, x values are not needed since the y-labels
        // are
        // static on the x-axis
        positions[i + 1] = mYLabels.mEntries[i / 2];
    }

    transformPointArray(positions);

    mYLabelPaint.setTypeface(mYLabels.getTypeface());
    mYLabelPaint.setTextSize(mYLabels.getTextSize());
    mYLabelPaint.setColor(mYLabels.getTextColor());

    float xoffset = Utils.convertDpToPixel(5f);
    float yoffset = Utils.calcTextHeight(mYLabelPaint, "A") / 2.5f;

    // determine position and draw adequately
    if (mYLabels.getPosition() == YLabelPosition.LEFT) {

        mYLabelPaint.setTextAlign(Align.RIGHT);
        drawYLabels(mOffsetLeft - xoffset, positions, yoffset);

    } else if (mYLabels.getPosition() == YLabelPosition.RIGHT) {

        mYLabelPaint.setTextAlign(Align.LEFT);
        drawYLabels(getWidth() - mOffsetRight + xoffset, positions, yoffset);

    } else if (mYLabels.getPosition() == YLabelPosition.RIGHT_INSIDE) {

        mYLabelPaint.setTextAlign(Align.RIGHT);
        drawYLabels(getWidth() - mOffsetRight - xoffset, positions, yoffset);

    } else if (mYLabels.getPosition() == YLabelPosition.LEFT_INSIDE) {

        mYLabelPaint.setTextAlign(Align.LEFT);
        drawYLabels(mOffsetLeft + xoffset, positions, yoffset);

    } else { // BOTH SIDED Y-AXIS LABELS

        // draw left legend
        mYLabelPaint.setTextAlign(Align.RIGHT);
        drawYLabels(mOffsetLeft - xoffset, positions, yoffset);

        // draw right legend
        mYLabelPaint.setTextAlign(Align.LEFT);
        drawYLabels(getWidth() - mOffsetRight + xoffset, positions, yoffset);
    }
}
 
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:59,代码来源:BarLineChartBase.java


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