/* $Id: Sheet.java 743 2013-09-18 05:21:41Z shayashi $ */
package smart_gs.logical;

import java.util.List;
import java.util.ArrayList;

public class Sheet {
	
	private Spread parent;

	private String sheetName = "defaultSheet";

	public static final int SHOW_ALL_REGIONS = 0;
	public static final int SHOW_PROTECTED_REGIONS = 1;
	public static final int SHOW_NO_REGIONS = 2;

	private int showRegion = SHOW_ALL_REGIONS;

	// kazuhiro kobayashi 10/5
	private List<Region> regions;

	/*
	 * コンストラクタ（名前の指定なし、あり）
	 */
	// kazuhiroo kobayashi 10/5
	public Sheet(List<Region> regions, Spread parent) {
		this.regions = regions;
		this.parent = parent;
	}
	public Sheet(List<Region> regions, Spread parent, String sheetName) {
		this(regions, parent);
		this.sheetName = sheetName;
	}

	public List<Region> getAllRegions() {
		// kazuhiro kobayashi10/5
		return this.regions;
	}
	/*
	 * ShowRegionsを実行するときに、表示中のregionを保存したり取り出したりするのに使う
	 */
	public List<Region> getProtectedRegions() {
		// kazuhiro kobayashi 10/5
		List<Region> regions = new ArrayList<Region>();
		for (int i = 0; i < this.regions.size(); i++) {
			//kazuhiro kobayashi 10/7
			if (this.regions.get(i).isProtected().equals(Region.PROTECTED)) {
				regions.add(this.regions.get(i));
			}
		}
		return regions;
	}
	public List<Region> getNormalRegions() {
		// kazuhiro kobayashi 10/5
		List<Region> regions = new ArrayList<Region>();
		for (int i = 0; i < this.regions.size(); i++) {
			//kazuhiro kobayashi 10/7
			if (this.regions.get(i).isProtected().equals(Region.NORMAL)) {
				regions.add(this.regions.get(i));
			}
		}
		return regions;
	}

	public void addRegion(Region region) {
		this.regions.add(region);
	}
	/*
	 * showRegionの設定
	 */
	public int getShowRegion() {
		return showRegion;
	}
	public void setShowRegion(int showRegion) {
		this.showRegion = showRegion;
	}
	/*
	 * sheetの属性を取得
	 */
	public String getSheetName() {
		return sheetName;
	}

	public void setSheetName(String sheetName) {
		this.sheetName = sheetName;
	}

	public Spread getParent() {
		return parent;
	}
}