张海江
2018-03-26 b4f0e07335e97d66d5a40c396f15a772619066b0
app/src/main/java/com/moral/yunfushao/ui/PanelView.java
@@ -55,7 +55,7 @@
    private Paint drawTextPaint;
    private int textColor = Color.GRAY;
    private int textSize = 36;
    private String[] level = {"安全","低辐射","中低辐射","中高辐射","高辐射"};
    private String[] level = {"安全","低辐射","中辐射","高辐射"};
    //内进度圆
    private Paint mCirclePaint;
@@ -246,55 +246,80 @@
    private void drawTextKedu(Canvas canvas){
        for(int i=0;i<level.length;i++){
            float textWidth = drawTextPaint.measureText(level[i]);
            if(percent<0.25){
            if(percent<0.125){
                if(i==0){
                    drawTextPaint.setColor(line3Color);
                }else{
                    drawTextPaint.setColor(Color.GRAY);
                }
                canvas.save();
                canvas.rotate(-120+i*60,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==2){
                    canvas.rotate(0,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.25&&percent>=0.44){
            }else if(percent>=0.125&&percent<0.4){
                if(i==1){
                    drawTextPaint.setColor(line3Color);
                }else{
                    drawTextPaint.setColor(Color.GRAY);
                }
                canvas.save();
                canvas.rotate(-120+i*60,mWidth/2,mWidth/2);
//                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==2){
                    canvas.rotate(0,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.44&&percent<0.7){
            }else if(percent>=0.4&&percent<1.0){
                if(i==2){
                    drawTextPaint.setColor(line3Color);
                }else{
                    drawTextPaint.setColor(Color.GRAY);
                }
                canvas.save();
                canvas.rotate(-120+i*60,mWidth/2,mWidth/2);
//                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==2){
                    canvas.rotate(0,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.7&&percent<0.9){
            }else if(percent>=1.0){
                if(i==3){
                    drawTextPaint.setColor(line3Color);
                }else{
                    drawTextPaint.setColor(Color.GRAY);
                }
                canvas.save();
                canvas.rotate(-120+i*60,mWidth/2,mWidth/2);
                canvas.drawText(level[i],mWidth / 2-textWidth/2, paddingKedu+line2Length+textSize,drawTextPaint);
                canvas.restore();
            }else {
                if (i == 4) {
                    drawTextPaint.setColor(line3Color);
                } else {
                    drawTextPaint.setColor(Color.GRAY);
//                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==2){
                    canvas.rotate(0,mWidth/2,mWidth/2);
                }else if(i==3){
                    canvas.rotate(120,mWidth/2,mWidth/2);
                }
                canvas.save();
                canvas.rotate(-120 + i * 60, mWidth / 2, mWidth / 2);
                canvas.drawText(level[i], mWidth / 2 - textWidth / 2, paddingKedu + line2Length + textSize, drawTextPaint);
                canvas.drawText(level[i],mWidth / 2-textWidth/2, paddingKedu+line2Length+textSize,drawTextPaint);
                canvas.restore();
            }
        }
@@ -311,19 +336,15 @@
        canvas.drawArc(new RectF(mShaderWidth + widthInner, mShaderWidth + widthInner, mWidth - mShaderWidth - widthInner, mWidth - mShaderWidth - widthInner), 120, 300, false, mShaderPaint);
        //画圆环分隔
        canvas.save();
        canvas.rotate(30, mWidth / 2, mWidth / 2);
        canvas.rotate(120, 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.rotate(90, mWidth / 2, mWidth / 2);
        canvas.rotate(0, 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.rotate(-30, 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.rotate(-90, mWidth / 2, mWidth / 2);
        canvas.rotate(-120, mWidth / 2, mWidth / 2);
        canvas.drawLine(mWidth / 2, line2Length + paddingKedu*3, mWidth / 2, (float) (line2Length + paddingKedu*0.65+mShaderWidth*2), paintGapLine);
        canvas.restore();
    }