|  | @@ -30,8 +30,6 @@ public class DashBoardView extends View {
 | 
	
		
			
				|  |  |      private int width;
 | 
	
		
			
				|  |  |      private int height;
 | 
	
		
			
				|  |  |      private int mRadius;
 | 
	
		
			
				|  |  | -    private int mCenterX;
 | 
	
		
			
				|  |  | -    private int mCenterY;
 | 
	
		
			
				|  |  |      private int paddingBottom = SizeUtils.dp2px(9);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private int mSection = 10; // 值域(mMax-mMin)等分份数
 | 
	
	
		
			
				|  | @@ -49,6 +47,8 @@ public class DashBoardView extends View {
 | 
	
		
			
				|  |  |      private Paint mTextValuePaint;
 | 
	
		
			
				|  |  |      private RectF mGradientLineRectF;
 | 
	
		
			
				|  |  |      private Paint mPointerPaint;
 | 
	
		
			
				|  |  | +    private float pointerHeight = 0;//指针高度
 | 
	
		
			
				|  |  | +    private double innerGradientRadiusPercent = 0.75;//渐变线的圆半径比例
 | 
	
		
			
				|  |  |      private int pointerAngle = 0;
 | 
	
		
			
				|  |  |      private int currentProgress = 0;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -102,17 +102,15 @@ public class DashBoardView extends View {
 | 
	
		
			
				|  |  |          cx = width / 2;
 | 
	
		
			
				|  |  |          cy = height - paddingBottom;
 | 
	
		
			
				|  |  |          mRadius = (int) ((width / 2) * 0.8);
 | 
	
		
			
				|  |  | -        mCenterX = cx;
 | 
	
		
			
				|  |  | -        mCenterY = cy;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        pointerHeight = (float) (mRadius * innerGradientRadiusPercent + SizeUtils.dp2px(9));//加上渐变环线笔的宽度的一半
 | 
	
		
			
				|  |  |          initGradientPaint();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          mGradientLineRectF = new RectF();
 | 
	
		
			
				|  |  |          mGradientLineRectF.set(
 | 
	
		
			
				|  |  | -                (float) (cx - mRadius * 0.75),
 | 
	
		
			
				|  |  | -                (float) (cy - (mRadius * 0.75)),
 | 
	
		
			
				|  |  | -                (float) (cx + mRadius * 0.75),
 | 
	
		
			
				|  |  | -                (float) (cy + (mRadius * 0.75))
 | 
	
		
			
				|  |  | +                (float) (cx - mRadius * innerGradientRadiusPercent),
 | 
	
		
			
				|  |  | +                (float) (cy - (mRadius * innerGradientRadiusPercent)),
 | 
	
		
			
				|  |  | +                (float) (cx + mRadius * innerGradientRadiusPercent),
 | 
	
		
			
				|  |  | +                (float) (cy + (mRadius * innerGradientRadiusPercent))
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -137,11 +135,15 @@ public class DashBoardView extends View {
 | 
	
		
			
				|  |  |          super.onDraw(canvas);
 | 
	
		
			
				|  |  |  //        canvas.drawLine(cx, cy, cx, 0, mCenterPointPaint);
 | 
	
		
			
				|  |  |          canvas.drawArc(mGradientLineRectF, -180, 180, false, mOuterGradientPaint);
 | 
	
		
			
				|  |  | -        canvas.drawLine(cx, cy, cx, (float) (cy - mRadius * 0.75 - SizeUtils.dp2px(9)), mPointerPaint);
 | 
	
		
			
				|  |  | +        float[] floats = countPointerPosition(currentProgress);
 | 
	
		
			
				|  |  | +        canvas.drawLine(cx, cy, floats[0], floats[1], mPointerPaint);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        float x0 = mCenterX;
 | 
	
		
			
				|  |  | +        //绘制长刻度
 | 
	
		
			
				|  |  | +        mLinePaint.setAlpha(255);
 | 
	
		
			
				|  |  | +        float x0 = cx;
 | 
	
		
			
				|  |  |          float y0 = height - mRadius;
 | 
	
		
			
				|  |  | -        float x1 = mCenterX;
 | 
	
		
			
				|  |  | +        float x1 = cx;
 | 
	
		
			
				|  |  |          float y1 = y0 + longScaleLineHeight;
 | 
	
		
			
				|  |  |          // 逆时针到开始处
 | 
	
		
			
				|  |  |          canvas.save();
 | 
	
	
		
			
				|  | @@ -168,7 +170,7 @@ public class DashBoardView extends View {
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          mLinePaint.setAlpha(90);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        float x2 = mCenterX;
 | 
	
		
			
				|  |  | +        float x2 = cx;
 | 
	
		
			
				|  |  |          float y2 = y0 + shortScaleLineHeight;
 | 
	
		
			
				|  |  |          // 逆时针到开始处
 | 
	
		
			
				|  |  |          canvas.save();
 | 
	
	
		
			
				|  | @@ -229,8 +231,43 @@ public class DashBoardView extends View {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private int maxMusicHzOffset = 50;
 | 
	
		
			
				|  |  | +    private int minMusicHzOffset = -50;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private float[] countPointerPosition(float diff) {
 | 
	
		
			
				|  |  | +        float[] points = new float[2];
 | 
	
		
			
				|  |  | +        if (diff > maxMusicHzOffset) {
 | 
	
		
			
				|  |  | +            diff = maxMusicHzOffset;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (diff < minMusicHzOffset) {
 | 
	
		
			
				|  |  | +            diff = minMusicHzOffset;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void countPointerPosition() {
 | 
	
		
			
				|  |  | +        if (diff > 0) {
 | 
	
		
			
				|  |  | +            double angle = (diff / maxMusicHzOffset) * mSweepAngle / 2;
 | 
	
		
			
				|  |  | +            Log.i("zxc","angle:"+angle);
 | 
	
		
			
				|  |  | +            float radian = (float) Math.toRadians(angle);
 | 
	
		
			
				|  |  | +            points[0] = (float) (cx + Math.sin(radian) * pointerHeight);
 | 
	
		
			
				|  |  | +            points[1] = (float) (cy - Math.cos(radian) * pointerHeight);
 | 
	
		
			
				|  |  | +        } else if (diff == 0) {
 | 
	
		
			
				|  |  | +            points[0] = cx;
 | 
	
		
			
				|  |  | +            points[1] = (float) (cy - pointerHeight);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            double angle = Math.abs((diff / minMusicHzOffset) * mSweepAngle / 2);
 | 
	
		
			
				|  |  | +            Log.i("zxc","angle:"+angle);
 | 
	
		
			
				|  |  | +            float radian = (float) Math.toRadians(angle);
 | 
	
		
			
				|  |  | +            points[0] = (float) (cx - Math.sin(radian) * pointerHeight);
 | 
	
		
			
				|  |  | +            points[1] = (float) (cy - Math.cos(radian) * pointerHeight);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Log.i("zxc","points[0]:"+points[0]);
 | 
	
		
			
				|  |  | +        Log.i("zxc","points[1]:"+points[1]);
 | 
	
		
			
				|  |  | +        return points;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public void setProgress(int progress) {
 | 
	
		
			
				|  |  | +        if (progress != -1) {
 | 
	
		
			
				|  |  | +            this.currentProgress = progress;
 | 
	
		
			
				|  |  | +            invalidate();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |