/**
* Draws the chart tick lines.
*
* @param canvas the canvas
* @param min the minimum chart value
* @param max the maximum chart value
* @param minAngle the minimum chart angle value
* @param maxAngle the maximum chart angle value
* @param centerX the center x value
* @param centerY the center y value
* @param longRadius the long radius
* @param shortRadius the short radius
* @param ticks the tick spacing
* @param paint the paint settings
* @param labels paint the labels
* @return the angle
*/
private void drawTicks(Canvas canvas, double min, double max, double minAngle, double maxAngle,
int centerX, int centerY, double longRadius, double shortRadius, double ticks, Paint paint,
boolean labels) {
for (double i = min; i <= max; i += ticks) {
double angle = getAngleForValue(i, minAngle, maxAngle, min, max);
double sinValue = Math.sin(angle);
double cosValue = Math.cos(angle);
int x1 = Math.round(centerX + (float) (shortRadius * sinValue));
int y1 = Math.round(centerY + (float) (shortRadius * cosValue));
int x2 = Math.round(centerX + (float) (longRadius * sinValue));
int y2 = Math.round(centerY + (float) (longRadius * cosValue));
canvas.drawLine(x1, y1, x2, y2, paint);
if (labels) {
paint.setTextAlign(Align.LEFT);
if (x1 <= x2) {
paint.setTextAlign(Align.RIGHT);
}
String text = i + "";
if (Math.round(i) == (long) i) {
text = (long) i + "";
}
canvas.drawText(text, x1, y1, paint);
}
}
}
DialChart.java 文件源码
java
阅读 45
收藏 0
点赞 0
评论 0
项目:buildAPKsApps
作者:
评论列表
文章目录