• android 数据报表


    引用:http://www.oschina.net/code/snippet_12_1257

    [图片] android_xy.gif

    [文件] xy_plot_4_Android_src.zip ~ 57KB    下载(127)

    [代码] 绘制网格线的方法

    01 public static void  draw_the_grid(Canvas this_g,  Vector these_labels)
    02      {        
    03         double rounded_max = 0.0;
    04         double rounded_min = 0.0;
    05         double rounded_max_temp;
    06         Object curElt; 
    07         String[] cur_elt_array;
    08         int left_margin_d, right_margin_d;     
    09  
    10         if( draw_only_this_idx == -1)     
    11            curElt = these_labels.elementAt(0);  // default  it to 1st one if non set
    12         else
    13            curElt = these_labels.elementAt(draw_only_this_idx);  // now just the 1st elt
    14             
    15         cur_elt_array = (String[])curElt;
    16  
    17         rounded_max = get_ceiling_or_floor (Double.parseDouble(cur_elt_array[2]) , true);
    18         rounded_min = get_ceiling_or_floor (Double.parseDouble(cur_elt_array[3]) ,false);
    19  
    20        // ok so now we have the max value of the set just get a cool ceiling and we go on
    21         final Paint paint = new Paint(); 
    22         paint.setTextSize(15);
    23          
    24        left_margin_d =  getCurTextLengthInPixels(paint, Double.toString(rounded_max));
    25        //keep the position for later drawing -- leave space for the legend
    26        int p_height = 170;
    27        int p_width = 220;
    28        int[] tmp_draw_sizes = {2 + left_margin_d, 25,p_width - 2 -
    29         left_margin_d ,p_height - 25 -5};
    30        drawSizes = tmp_draw_sizes; //keep it for later processing
    31          
    32         //with the mzrgins worked out draw the plotting grid
    33        paint.setStyle(Paint.Style.FILL);
    34        paint.setColor(Color.WHITE ); 
    35         
    36        // Android does by coords
    37        this_g.drawRect(drawSizes[0], drawSizes[1],drawSizes[0]+
    38         drawSizes[2], drawSizes[1]+ drawSizes[3] , paint);
    39         
    40        paint.setColor(Color.GRAY );      
    41         
    42         // finally draw the grid     
    43         
    44        paint.setStyle(Paint.Style.STROKE);
    45        this_g.drawRect(drawSizes[0], drawSizes[1],drawSizes[0]+
    46         drawSizes[2], drawSizes[1]+ drawSizes[3] , paint);
    47  
    48            for(int i=1; i < 5 ; i++)
    49            {
    50                this_g.drawLine(drawSizes[0], drawSizes[1] +
    51         (i * drawSizes[3] / 5), drawSizes[0] + drawSizes[2],
    52         drawSizes[1] + (i * drawSizes[3] / 5), paint);
    53                this_g.drawLine(drawSizes[0]+ (i * drawSizes[2] / 5),
    54         drawSizes[1], drawSizes[0] + (i * drawSizes[2] / 5),
    55         drawSizes[1] + drawSizes[3], paint);
    56            }
    57  
    58           // good for one value
    59            print_axis_values_4_grid(this_g, cur_elt_array[1] ,
    60         Double.toString(rounded_max) , Double.toString(rounded_min),
    61         cur_elt_array[0] , 2 ,0 );
    62           
    63      }  // --- end of draw_grid ---
  • 相关阅读:
    Orleans的深入
    Orleans的入门教程
    .net core 微服务通讯组件Orleans的使用与配置
    AddTransient、AddSingleton、AddScoped的区别
    近期做架构师的总结
    大数据分析的深度与假象
    SQL反模式-1
    学习总结---INNODB 事务并发
    Tomcat的error-page掩盖action实例化的exception
    A SQL to insert continuous values
  • 原文地址:https://www.cnblogs.com/sode/p/2186378.html
Copyright © 2020-2023  润新知