package dataTable;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;

public class DataTable {
	
	private static final String [] mNames={"Jan","Feb","Mar","Apr","May", "Jun", "Jul"};
	private static final String [] mDay={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
	private static final String [] mTtown = {"Adrian", "Ailey", "Alamo", "Alapaha", "Albany", "Allenhurst", "Alma"}; 
	private List mounths = new ArrayList(); 
	private List numbers = new ArrayList();
	private String align; 
	private String bgcolor;
	private String border;
	private String width;
	private String columnsWidth;
	private boolean r2rendered;
	private boolean rendered;
	
	public DataTable() {
		align = "center";
		bgcolor = "aqua";
		border = "1";
		width = "400px";
		columnsWidth = "200px";
		rendered = true;
		r2rendered = true;
		
		Properties properties = System.getProperties();
		Enumeration keys = properties.keys();
		for(int i=0;i<7;i++){
			Data bean = new Data();
			int l = (int)(Math.random()*8)+1;
			bean.setTotal(0);
			bean.setMounth(DataTable.mNames[i]);
			bean.setDay(DataTable.mDay[i]);
			bean.setTown(DataTable.mTtown[i]);
			mounths.add(bean);
			for(int j=0;j<l;j++){
				ChildBean child = new ChildBean();
				child.setName((String) keys.nextElement());
				int qty = (int)(Math.random()*10);
				bean.setTotal(bean.getTotal()+qty);
				child.setQty(qty);
				bean.getDetail().add(child);
			}
		}
		for(int i=0;i<16;i++){
			numbers.add(new Integer(i));
		}
	}

	public boolean isC1rendered() {
		return r2rendered;
	}
	
	public void setC1rendered(boolean c1rendered) {
		this.r2rendered = c1rendered;
	}
	
	public String toggleColumn() {
		this.r2rendered = !this.r2rendered;
		return null;
	}
	/**
	 * @return the numbers
	 */
	public List getNumbers() {
		return this.numbers;
	}

	public boolean isRendered() {
		return rendered;
	}

	public void setRendered(boolean rendered) {
		this.rendered = rendered;
	}

	/**
	 * @param numbers the numbers to set
	 */
	public void setNumbers(List numbers) {
		this.numbers = numbers;
	}

	/**
	 * @return the mounths
	 */
	public List getMounths() {
		return this.mounths;
	}

	/**
	 * @param mounths the mounths to set
	 */
	public void setMounths(List mounths) {
		this.mounths = mounths;
	}

	public String getAlign() {
		return align;
	}

	public void setAlign(String align) {
		this.align = align;
	}

	public String getBgcolor() {
		return bgcolor;
	}

	public void setBgcolor(String bgcolor) {
		this.bgcolor = bgcolor;
	}

	public String getBorder() {
		return border;
	}

	public void setBorder(String border) {
		this.border = border;
	}

	public String getWidth() {
		return width;
	}

	public void setWidth(String width) {
		this.width = width;
	}

	public String getColumnsWidth() {
		return columnsWidth;
	}

	public void setColumnsWidth(String columnsWidth) {
		this.columnsWidth = columnsWidth;
	}

	public boolean isR2rendered() {
		return r2rendered;
	}

	public void setR2rendered(boolean r2rendered) {
		this.r2rendered = r2rendered;
	}
}
