| | |
| | | private int mmHeight; |
| | | //绘制渐变圆弧的画笔 |
| | | private Paint mShaderPaint; |
| | | private int[] mshaderColor = new int[]{Color.RED, Color.RED, Color.GREEN, Color.GREEN, Color.YELLOW, Color.YELLOW, Color.RED}; |
| | | private int[] mshaderColor = new int[]{0xfff70e17,0xfff70e17,0xfff70e17,0xffff5c92,0xff00c44a,0xff00d062,0xff00f5af,0xff00f6cb,0xff00ccff,0xff179fff,0xffa054ff,0xffa53aff,0xffd74bff,0xfff64da5,0xfff70e17}; |
| | | private int[] mshaderRedColor = new int[]{0xfff70e17,0xffff5c92}; |
| | | private int[] mshaderZiseColor = new int[]{0xffa53aff,0xffd74bff,0xfff64da5}; |
| | | private int[] mshaderBlueColor = new int[]{0xff00f6cb,0xff00ccff,0xff179fff,0xffa054ff}; |
| | | private int[] mshaderGreenColor = new int[]{0xff00c44a,0xff00d062,0xff00f5af}; |
| | | //环形渐变色值渲染 |
| | | private SweepGradient mSweepGradient; |
| | | private int mShaderWidth = 70; |
| | |
| | | private Paint paintGapLine; |
| | | |
| | | //小格子线颜色3°画一次 |
| | | private int line1Color = 0xFFFAEAEB; |
| | | private int line1Color = 0xffb8e8f4; |
| | | //小格子线颜色15°画一次 |
| | | private int line2Color = 0xFFFEB7B9; |
| | | private int line2Color = 0xff7ed3ff; |
| | | //小格子线颜色60°画一次 |
| | | private int line3Color = 0xFFFF6C7E; |
| | | private int line3Color = 0xff009cff; |
| | | //短线长度 |
| | | private int line1Length = 50; |
| | | //长线长度 |
| | |
| | | private Paint drawTextPaint; |
| | | private int textColor = Color.GRAY; |
| | | private int textSize = 36; |
| | | private String[] level = {"安全","低辐射","中辐射","高辐射"}; |
| | | private String[] level = {"绝对安全","建议回避","紧急撤离","及时逃遁"}; |
| | | |
| | | //内进度圆 |
| | | private Paint mCirclePaint; |
| | | private int innerCircleColor = 0xFFF6DFE1; |
| | | private int innerCircleColor = 0xffb8e8f4; |
| | | private int mCircleWidth = 70; |
| | | private int innerPadding = 20; |
| | | //画进度 |
| | | private Paint mProgressPaint; |
| | | private int progressCircleColor = 0xFFFEB7B9; |
| | | private int progressCircleColor = 0xff53c9ff; |
| | | |
| | | //画指针 |
| | | private Paint mBitPaint; |
| | |
| | | private void drawTextKedu(Canvas canvas){ |
| | | for(int i=0;i<level.length;i++){ |
| | | float textWidth = drawTextPaint.measureText(level[i]); |
| | | if(percent<0.125){ |
| | | if(percent<0.25){ |
| | | if(i==0){ |
| | | drawTextPaint.setColor(line3Color); |
| | | }else{ |
| | |
| | | } |
| | | canvas.save(); |
| | | if(i==0){ |
| | | canvas.rotate(-150,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-120,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-45,mWidth/2,mWidth/2); |
| | | }else if(i==2){ |
| | | canvas.rotate(0,mWidth/2,mWidth/2); |
| | | canvas.rotate(45,mWidth/2,mWidth/2); |
| | | }else if(i==3){ |
| | | canvas.rotate(120,mWidth/2,mWidth/2); |
| | | } |
| | | canvas.drawText(level[i],mWidth / 2-textWidth/2, paddingKedu+line2Length+textSize,drawTextPaint); |
| | | canvas.restore(); |
| | | }else if(percent>=0.125&&percent<0.4){ |
| | | }else if(percent>=0.25&&percent<0.5){ |
| | | if(i==1){ |
| | | drawTextPaint.setColor(line3Color); |
| | | }else{ |
| | |
| | | canvas.save(); |
| | | // canvas.rotate(-120+i*75,mWidth/2,mWidth/2); |
| | | if(i==0){ |
| | | canvas.rotate(-150,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-120,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-45,mWidth/2,mWidth/2); |
| | | }else if(i==2){ |
| | | canvas.rotate(0,mWidth/2,mWidth/2); |
| | | canvas.rotate(45,mWidth/2,mWidth/2); |
| | | }else if(i==3){ |
| | | canvas.rotate(120,mWidth/2,mWidth/2); |
| | | } |
| | | canvas.drawText(level[i],mWidth / 2-textWidth/2, paddingKedu+line2Length+textSize,drawTextPaint); |
| | | canvas.restore(); |
| | | }else if(percent>=0.4&&percent<1.0){ |
| | | }else if(percent>=0.5&&percent<0.75){ |
| | | if(i==2){ |
| | | drawTextPaint.setColor(line3Color); |
| | | }else{ |
| | |
| | | canvas.save(); |
| | | // canvas.rotate(-120+i*75,mWidth/2,mWidth/2); |
| | | if(i==0){ |
| | | canvas.rotate(-150,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-120,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-45,mWidth/2,mWidth/2); |
| | | }else if(i==2){ |
| | | canvas.rotate(0,mWidth/2,mWidth/2); |
| | | canvas.rotate(45,mWidth/2,mWidth/2); |
| | | }else if(i==3){ |
| | | canvas.rotate(120,mWidth/2,mWidth/2); |
| | | } |
| | | canvas.drawText(level[i],mWidth / 2-textWidth/2, paddingKedu+line2Length+textSize,drawTextPaint); |
| | | canvas.restore(); |
| | | }else if(percent>=1.0){ |
| | | }else if(percent>=0.75){ |
| | | if(i==3){ |
| | | drawTextPaint.setColor(line3Color); |
| | | }else{ |
| | |
| | | canvas.save(); |
| | | // canvas.rotate(-105+i*75,mWidth/2,mWidth/2); |
| | | if(i==0){ |
| | | canvas.rotate(-150,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-120,mWidth/2,mWidth/2); |
| | | }else if(i==1){ |
| | | canvas.rotate(-45,mWidth/2,mWidth/2); |
| | | }else if(i==2){ |
| | | canvas.rotate(0,mWidth/2,mWidth/2); |
| | | canvas.rotate(45,mWidth/2,mWidth/2); |
| | | }else if(i==3){ |
| | | canvas.rotate(120,mWidth/2,mWidth/2); |
| | | } |
| | |
| | | private void drawJianbianCircle(Canvas canvas){ |
| | | mSweepGradient = new SweepGradient(mWidth / 2, mWidth / 2, mshaderColor, null); |
| | | mShaderPaint.setShader(mSweepGradient); |
| | | //145, 250 |
| | | canvas.drawArc(new RectF(mShaderWidth + widthInner, mShaderWidth + widthInner, mWidth - mShaderWidth - widthInner, mWidth - mShaderWidth - widthInner), 120, 300, false, mShaderPaint); |
| | | //画圆环分隔 |
| | | canvas.save(); |
| | | canvas.rotate(120, mWidth / 2, mWidth / 2); |
| | | canvas.rotate(75, mWidth / 2, mWidth / 2); |
| | | canvas.drawLine(mWidth / 2, line2Length + paddingKedu*3, mWidth / 2, (float) (line2Length + paddingKedu*0.65+mShaderWidth*2), paintGapLine); |
| | | canvas.restore(); |
| | | canvas.save(); |
| | |
| | | canvas.drawLine(mWidth / 2, line2Length + paddingKedu*3, mWidth / 2, (float) (line2Length + paddingKedu*0.65+mShaderWidth*2), paintGapLine); |
| | | canvas.restore(); |
| | | canvas.save(); |
| | | canvas.rotate(-120, mWidth / 2, mWidth / 2); |
| | | canvas.rotate(-75, mWidth / 2, mWidth / 2); |
| | | canvas.drawLine(mWidth / 2, line2Length + paddingKedu*3, mWidth / 2, (float) (line2Length + paddingKedu*0.65+mShaderWidth*2), paintGapLine); |
| | | canvas.restore(); |
| | | } |