zoukankan      html  css  js  c++  java
  • Android柱状图柱子分组

    import java.lang.reflect.Array;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    
    public class MyTestMap {
    	static int barGroupNum;//柱子数分为奇数和偶数
    	static int total ;//共有的组数
    	static List<double[]>list;
    	static int align = 2;//每组柱子间隔
    	static int[]xPoing;
    	
    	public static void main(String[] args) {
    		list = new ArrayList<double[]>();
    		barGroupNum = 3;
    		total = 4;
    		xPoing = new int[total];
    		totalData();
    		int length = list.size();
    		for (int i = 0; i < length; i++) {
    			double[] d = list.get(i);
    			System.out.println(Arrays.toString(d));
    		}
    		System.out.println("===============");
    		System.out.println(Arrays.toString(xPoing));
    	}
    
    	private static void totalData() {
    		int count = 0;
    		if(barGroupNum%2 != 0){
    			for(int i = 1; i <= total; i++){
    				double[] d = new double[barGroupNum];
    				for(int j = 1; j <= barGroupNum; j++ ){
    					int x = (total+1)*(j-1)+i;
    					d[j-1] = x;
    					if(j == (barGroupNum/2+1)){
    						xPoing[count++] = x;
    					}
    				}
    				list.add(d);
    			}
    		}else{
    			for(int i = 1; i <= total; i++){
    				double[] d = new double[barGroupNum];
    				int j = 1;
    				for(; j <= barGroupNum/2; j++ ){
    					d[j-1] = (barGroupNum+2)*(i-1)+j;
    				}
    				xPoing[count++] = (barGroupNum+2)*(i-1)+j;
    				int a = j-1;
    				for(j = barGroupNum/2+2; j <= barGroupNum+1; j++ ){
    					d[a++] = (barGroupNum+2)*(i-1)+j;
    				}
    				list.add(d);
    			}
    		}
    	}
    	
    }
    
  • 相关阅读:
    tomcat安装
    卸载重安firefox
    Metasploit笔记之信息收集命令
    postgresql-9.0.18-1-linux.run启动
    ubuntu 安装自启动管理
    MySQL数据库”mysql SQL Error:1146,SQLState:42S02 “解决方法
    PE笔记之节表
    标准类型String(学习中)
    链表实现(打印元素的实现)
    C++中new和delete来创建和释放动态数组
  • 原文地址:https://www.cnblogs.com/FCWORLD/p/2761904.html
Copyright © 2011-2022 走看看