zoukankan      html  css  js  c++  java
  • 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 ---
  • 相关阅读:
    利用别名切换索引流程Elasticsearch 7.7
    关于误删除elasticSearch 索引,怎么能快速找回?
    总结traefik 在k8s 环境中的配置文件
    ES ElasticSearch 7.x 下动态扩大索引的shard数量
    Java框架Spring Boot & 服务治理框架Dubbo & 应用容器引擎Docker 实现微服务发布
    谈一下Docker与Kubernetes集群的日志和日志管理-转载
    Elasticsearch优化 & filebeat配置文件优化 & logstash格式配置 & grok实践
    Nginx错误日志(error_log)配置及信息详解
    赵总的运维体系专栏学习的总结
    APP或者前端通过识别用户代理详细信息和浏览器数据进行安全防御
  • 原文地址:https://www.cnblogs.com/sode/p/2186378.html
Copyright © 2011-2022 走看看