本文整理匯總了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);
}
}
}