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