本文整理汇总了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);
}
}
示例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);
}
}