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


Java XYSeriesRenderer.getDisplayChartValuesDistance方法代码示例

本文整理汇总了Java中org.achartengine.renderer.XYSeriesRenderer.getDisplayChartValuesDistance方法的典型用法代码示例。如果您正苦于以下问题:Java XYSeriesRenderer.getDisplayChartValuesDistance方法的具体用法?Java XYSeriesRenderer.getDisplayChartValuesDistance怎么用?Java XYSeriesRenderer.getDisplayChartValuesDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.achartengine.renderer.XYSeriesRenderer的用法示例。


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

示例1: drawChartValuesText

import org.achartengine.renderer.XYSeriesRenderer; //导入方法依赖的package包/类
/**
 * The graphical representation of the series values as text.
 * 
 * @param canvas the canvas to paint to
 * @param series the series to be painted
 * @param renderer the series renderer
 * @param paint the paint to be used for drawing
 * @param points the array of points to be used for drawing the series
 * @param seriesIndex the index of the series currently being drawn
 * @param startIndex the start index of the rendering points
 */
protected void drawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer,
    Paint paint, List<Float> points, int seriesIndex, int startIndex) {
  if (points.size() > 1) { // there are more than one point
    // record the first point's position
    float previousPointX = points.get(0);
    float previousPointY = points.get(1);
    for (int k = 0; k < points.size(); k += 2) {
      if (k == 2) { // decide whether to display first two points' values or
                    // not
        if (Math.abs(points.get(2) - points.get(0)) > renderer.getDisplayChartValuesDistance()
            || Math.abs(points.get(3) - points.get(1)) > renderer.getDisplayChartValuesDistance()) {
          // first point
          drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(startIndex)),
              points.get(0), points.get(1) - renderer.getChartValuesSpacing(), paint, 0);
          // second point
          drawText(canvas,
              getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + 1)),
              points.get(2), points.get(3) - renderer.getChartValuesSpacing(), paint, 0);

          previousPointX = points.get(2);
          previousPointY = points.get(3);
        }
      } else if (k > 2) {
        // compare current point's position with the previous point's, if they
        // are not too close, display
        if (Math.abs(points.get(k) - previousPointX) > renderer.getDisplayChartValuesDistance()
            || Math.abs(points.get(k + 1) - previousPointY) > renderer
                .getDisplayChartValuesDistance()) {
          drawText(canvas,
              getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + k / 2)),
              points.get(k), points.get(k + 1) - renderer.getChartValuesSpacing(), paint, 0);
          previousPointX = points.get(k);
          previousPointY = points.get(k + 1);
        }
      }
    }
  } else { // if only one point, display it
    for (int k = 0; k < points.size(); k += 2) {
      drawText(canvas,
          getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + k / 2)),
          points.get(k), points.get(k + 1) - renderer.getChartValuesSpacing(), paint, 0);
    }
  }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:56,代码来源:XYChart.java

示例2: drawChartValuesText

import org.achartengine.renderer.XYSeriesRenderer; //导入方法依赖的package包/类
/**
 * The graphical representation of the series values as text.
 * 
 * @param canvas the canvas to paint to
 * @param series the series to be painted
 * @param renderer the series renderer
 * @param paint the paint to be used for drawing
 * @param points the array of points to be used for drawing the series
 * @param seriesIndex the index of the series currently being drawn
 * @param startIndex the start index of the rendering points
 */
protected void drawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer,
    Paint paint, List<Float> points, int seriesIndex, int startIndex) {
  if (points.size() > 2) { // there are more than one point
    // record the first point's position
    float previousPointX = points.get(0);
    float previousPointY = points.get(1);
    for (int k = 0; k < points.size(); k += 2) {
      if (k == 2) { // decide whether to display first two points' values or
                    // not
        if (Math.abs(points.get(2) - points.get(0)) > renderer.getDisplayChartValuesDistance()
            || Math.abs(points.get(3) - points.get(1)) > renderer.getDisplayChartValuesDistance()) {
          // first point
          drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(startIndex)),
              points.get(0), points.get(1) - renderer.getChartValuesSpacing(), paint, 0);
          // second point
          drawText(canvas,
              getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + 1)),
              points.get(2), points.get(3) - renderer.getChartValuesSpacing(), paint, 0);

          previousPointX = points.get(2);
          previousPointY = points.get(3);
        }
      } else if (k > 2) {
        // compare current point's position with the previous point's, if they
        // are not too close, display
        if (Math.abs(points.get(k) - previousPointX) > renderer.getDisplayChartValuesDistance()
            || Math.abs(points.get(k + 1) - previousPointY) > renderer
                .getDisplayChartValuesDistance()) {
          drawText(canvas,
              getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + k / 2)),
              points.get(k), points.get(k + 1) - renderer.getChartValuesSpacing(), paint, 0);
          previousPointX = points.get(k);
          previousPointY = points.get(k + 1);
        }
      }
    }
  } else { // if only one point, display it
    for (int k = 0; k < points.size(); k += 2) {
      drawText(canvas,
          getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + k / 2)),
          points.get(k), points.get(k + 1) - renderer.getChartValuesSpacing(), paint, 0);
    }
  }
}
 
开发者ID:ddanny,项目名称:achartengine,代码行数:56,代码来源:XYChart.java


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