/**
 * Bar-Class
 * 
 */
var Bar = Class.create(OFCData, {
	/* supported subtypes */
	/*public static*/ supported: [
		null,
		'filled',
		'fade',
		'glass',
		'sketch',
		'3d'
	],
	
	/**
	 * @constructor
	 * @class Bar
	 * @extends OFCData
	 * @param {String} sub subtype
	 */
	initialize: function($super, sub) {
		if (typeof sub == 'undefined') sub = null;
		$super('bar', sub);
		
		// bar style specific properties
		// alpha-value
		this.alpha = null;
		
		this.colors.update({
			inner: OFC.defaultColors[0],
			border: OFC.defaultColors[1]
		});
		
		// 3d-x-axis-size
		this.xAxis3D = 15;
		// sketch-disturbness
		this.sketchDist = 7;
	},
	
	/**
	 * @see OFCData#toData
	 */
	toData: function() {
		var values = [];
		if (this.alpha != null) values[0] = this.alpha;
		if (typeof values[0] == 'undefined') values[0] = 60;
		var c = 0;
		if (this.subType == 'sketch') {
			if (this.sketchDist != null) values[1] = this.sketchDist;
			if (typeof values[1] == 'undefined') values[1] = 7;
			c++;
		}
		if (this.colors.get('inner') != null) values[1+c] = this.colors.get('inner');
		if (typeof values[1+c] == 'undefined') values[1+c] = OFC.defaultColors[0];
		switch (this.subType) {
			case 'filled':
			case 'glass':
			case 'sketch':
				if (this.colors.get('border') != null) values[2+c] = this.colors.get('border');
				if (typeof values[2+c] == 'undefined') values[2+c] = OFC.defaultColors[1];
				c++;
			break;
		}
		if (this.key != null) values[2+c] = this.key;
		if (typeof values[2+c] == 'undefined') values[2+c] = 'Unnamed Bar';
		if (this.keySize != null) values[3+c] = this.keySize;
		if (typeof values[3+c] == 'undefined') values[3+c] = 10;
		
		return values;
	},
	
	/**
	 * @see OFCData#fromData
	 */
	fromData: function(info) {
		this.alpha = info[0];
		if (info.length > 1) {
			this.colors.set('inner', '#'+info[1].substr(-6));
		}
		c = 0;
		if (this.subType == 'filled' || this.subType == 'glass' && info.length > 4) {
			this.colors.set('border', info[2])
			c = 1;
		}
		this.setKey(info[2+c], info[3+c]);
	},
	
	/**
	 * @see OFCData#getRequiredColors
	 */
	getRequiredColors: function() {
		var cols = {
			inner: "Inner"
		};
		switch (this.subType) {
			case 'filled':
			case 'glass':
			case 'sketch':
				cols.border = "Border";
			break;
		}
		return new Hash(cols);
	},
	
	/**
	 * @see OFCData#getFullName
	 */
	getFullName: function() {
		
		var name = 'bar';
		
		if (this.subType == 'filled') {
			// solve inconsistency
			name = 'filled_bar';
		} else if (this.subType != null) {
			name += '_'+this.subType;
		}
		
		if (this.number != 0) {
			name += '_'+this.number;
		}
		
		return name;
	},
	
	/**
	 * @see OFCData#addToOFC
	 */
	addToOFC: function($super, /*OFC*/ ofc) {
		$super(ofc);
		
		if (this.subType == '3d') {
			ofc.set('x_axis_3d', this.xAxis3D);
		}
	},
	
	/**
	 * @see OFCData#addToOFC
	 */
	removeFromOFC: function($super, /*OFC*/ ofc) {
		$super(ofc);
		
		if (this.subType == '3d') {
			ofc.set('x_axis_3d', null);
		}
	}
});