com.github.mikephil.charting.utils.Utils.getPosition()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中com.github.mikephil.charting.utils.Utils.getPosition()方法的一些代码示例,展示了Utils.getPosition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getPosition()方法的具体详情如下:
包路径:com.github.mikephil.charting.utils.Utils
类名称:Utils
方法名:getPosition

Utils.getPosition介绍

[英]Returns a recyclable MPPointF instance. Calculates the position around a center point, depending on the distance from the center, and the angle of the position around the center.
[中]返回可回收的MPPointF实例。计算围绕中心点的位置,具体取决于距中心的距离和位置围绕中心的角度。

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Returns a recyclable MPPointF instance.
 * Calculates the position around a center point, depending on the distance
 * from the center, and the angle of the position around the center.
 *
 * @param center
 * @param dist
 * @param angle  in degrees, converted to radians internally
 * @return
 */
public static MPPointF getPosition(MPPointF center, float dist, float angle) {
  MPPointF p = MPPointF.getInstance(0,0);
  getPosition(center, dist, angle, p);
  return p;
}

代码示例来源:origin: PhilJay/MPAndroidChart

Utils.getPosition(center, r, sliceangle * j + mChart.getRotationAngle(), pOut);

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public void renderAxisLabels(Canvas c) {
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
    return;
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  MPPointF center = mChart.getCenterOffsets();
  MPPointF pOut = MPPointF.getInstance(0,0);
  float factor = mChart.getFactor();
  final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
  final int to = mYAxis.isDrawTopYLabelEntryEnabled()
      ? mYAxis.mEntryCount
      : (mYAxis.mEntryCount - 1);
  for (int j = from; j < to; j++) {
    float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
    Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
    String label = mYAxis.getFormattedLabel(j);
    c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
}

代码示例来源:origin: PhilJay/MPAndroidChart

for (int i = 0; i < maxEntryCount; i += xIncrements) {
  Utils.getPosition(
      center,
      mChart.getYRange() * factor,
    Utils.getPosition(center, r, sliceangle * i + rotationangle, p1out);
    Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle, p2out);

代码示例来源:origin: PhilJay/MPAndroidChart

Utils.getPosition(
    center,
    (e.getY() - mChart.getYChartMin()) * factor * phaseY,

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
public void renderAxisLabels(Canvas c) {
  if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
    return;
  final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
  final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);
  mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
  mAxisLabelPaint.setColor(mXAxis.getTextColor());
  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);
  for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {
    String label = mXAxis.getValueFormatter().getAxisLabel(i, mXAxis);
    float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;
    Utils.getPosition(center, mChart.getYRange() * factor
        + mXAxis.mLabelRotatedWidth / 2f, angle, pOut);
    drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
        drawLabelAnchor, labelRotationAngleDegrees);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
  MPPointF.recycleInstance(drawLabelAnchor);
}

代码示例来源:origin: PhilJay/MPAndroidChart

Utils.getPosition(
    mChart.getCenterOffsets(), y * factor * phaseY,
    sliceangle * index * phaseX + mChart.getRotationAngle(), pOut);

代码示例来源:origin: PhilJay/MPAndroidChart

Utils.getPosition(
    center,
    (entry.getY() - mChart.getYChartMin()) * factor * phaseY,
 Utils.getPosition(
     center,
     (entry.getY()) * factor * phaseY + iconsOffset.y,

代码示例来源:origin: PhilJay/MPAndroidChart

Utils.getPosition(center,
    y * factor * mAnimator.getPhaseY(),
    sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),

代码示例来源:origin: WenWangAndroid/ChartManager

/**
 * Returns a recyclable MPPointF instance.
 * Calculates the position around a center point, depending on the distance
 * from the center, and the angle of the position around the center.
 *
 * @param center
 * @param dist
 * @param angle  in degrees, converted to radians internally
 * @return
 */
public static MPPointF getPosition(MPPointF center, float dist, float angle) {
  MPPointF p = MPPointF.getInstance(0,0);
  getPosition(center, dist, angle, p);
  return p;
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

/**
 * Returns a recyclable MPPointF instance.
 * Calculates the position around a center point, depending on the distance
 * from the center, and the angle of the position around the center.
 *
 * @param center
 * @param dist
 * @param angle  in degrees, converted to radians internally
 * @return
 */
public static MPPointF getPosition(MPPointF center, float dist, float angle) {
  MPPointF p = MPPointF.getInstance(0,0);
  getPosition(center, dist, angle, p);
  return p;
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

/**
 * Returns a recyclable MPPointF instance.
 * Calculates the position around a center point, depending on the distance
 * from the center, and the angle of the position around the center.
 *
 * @param center
 * @param dist
 * @param angle  in degrees, converted to radians internally
 * @return
 */
public static MPPointF getPosition(MPPointF center, float dist, float angle) {
  MPPointF p = MPPointF.getInstance(0, 0);
  getPosition(center, dist, angle, p);
  return p;
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

/**
 * Returns a recyclable MPPointF instance.
 * Calculates the position around a center point, depending on the distance
 * from the center, and the angle of the position around the center.
 *
 * @param center
 * @param dist
 * @param angle  in degrees, converted to radians internally
 * @return
 */
public static MPPointF getPosition(MPPointF center, float dist, float angle) {
  MPPointF p = MPPointF.getInstance(0,0);
  getPosition(center, dist, angle, p);
  return p;
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

@Override
public void renderAxisLabels(Canvas c) {
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
    return;
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  MPPointF center = mChart.getCenterOffsets();
  MPPointF pOut = MPPointF.getInstance(0,0);
  float factor = mChart.getFactor();
  final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
  final int to = mYAxis.isDrawTopYLabelEntryEnabled()
      ? mYAxis.mEntryCount
      : (mYAxis.mEntryCount - 1);
  for (int j = from; j < to; j++) {
    float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
    Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
    String label = mYAxis.getFormattedLabel(j);
    c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

@Override
public void renderAxisLabels(Canvas c) {
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled()) {
    return;
  }
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  MPPointF center = mChart.getCenterOffsets();
  MPPointF pOut = MPPointF.getInstance(0, 0);
  float factor = mChart.getFactor();
  final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
  final int to = mYAxis.isDrawTopYLabelEntryEnabled()
      ? mYAxis.mEntryCount
      : (mYAxis.mEntryCount - 1);
  for (int j = from; j < to; j++) {
    float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
    Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
    String label = mYAxis.getFormattedLabel(j);
    c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

@Override
public void renderAxisLabels(Canvas c) {
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
    return;
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  MPPointF center = mChart.getCenterOffsets();
  MPPointF pOut = MPPointF.getInstance(0,0);
  float factor = mChart.getFactor();
  final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
  final int to = mYAxis.isDrawTopYLabelEntryEnabled()
      ? mYAxis.mEntryCount
      : (mYAxis.mEntryCount - 1);
  for (int j = from; j < to; j++) {
    float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
    Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
    String label = mYAxis.getFormattedLabel(j);
    c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
}

代码示例来源:origin: WenWangAndroid/ChartManager

@Override
public void renderAxisLabels(Canvas c) {
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
    return;
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  MPPointF center = mChart.getCenterOffsets();
  MPPointF pOut = MPPointF.getInstance(0,0);
  float factor = mChart.getFactor();
  final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
  final int to = mYAxis.isDrawTopYLabelEntryEnabled()
      ? mYAxis.mEntryCount
      : (mYAxis.mEntryCount - 1);
  for (int j = from; j < to; j++) {
    float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
    Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
    String label = mYAxis.getFormattedLabel(j);
    c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

@Override
public void renderAxisLabels(Canvas c) {
  if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) {
    return;
  }
  final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
  final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);
  mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
  mAxisLabelPaint.setColor(mXAxis.getTextColor());
  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);
  for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {
    String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis);
    float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;
    Utils.getPosition(center, mChart.getYRange() * factor
        + mXAxis.mLabelRotatedWidth / 2f, angle, pOut);
    drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
        drawLabelAnchor, labelRotationAngleDegrees);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
  MPPointF.recycleInstance(drawLabelAnchor);
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

@Override
public void renderAxisLabels(Canvas c) {
  if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
    return;
  final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
  final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);
  mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
  mAxisLabelPaint.setColor(mXAxis.getTextColor());
  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);
  for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {
    String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis);
    float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;
    Utils.getPosition(center, mChart.getYRange() * factor
        + mXAxis.mLabelRotatedWidth / 2f, angle, pOut);
    drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
        drawLabelAnchor, labelRotationAngleDegrees);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
  MPPointF.recycleInstance(drawLabelAnchor);
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

@Override
public void renderAxisLabels(Canvas c) {
  if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
    return;
  final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
  final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);
  mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
  mAxisLabelPaint.setColor(mXAxis.getTextColor());
  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);
  for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {
    String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis);
    float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;
    Utils.getPosition(center, mChart.getYRange() * factor
        + mXAxis.mLabelRotatedWidth / 2f, angle, pOut);
    drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
        drawLabelAnchor, labelRotationAngleDegrees);
  }
  MPPointF.recycleInstance(center);
  MPPointF.recycleInstance(pOut);
  MPPointF.recycleInstance(drawLabelAnchor);
}

相关文章