/*
* 边距
* author: 吴安国
* version: 1.0
*/
* 边距
* author: 吴安国
* version: 1.0
*/
function Margin() {
switch(arguments.length) {
case 0:
throw new Error("Margin参数错误");
break;
case 1:
this.left = this.right = this.top = this.bottom = arguments[0];
break;
case 2:
this.top = this.bottom = arguments[0];
this.left = this.right = arguments[1];
break;
case 3:
this.top = arguments[0];
this.left = this.right = arguments[1];
this.bottom = arguments[2];
break;
case 4:
default:
this.top = arguments[0];
this.right = arguments[1];
this.bottom = arguments[2];
this.left = arguments[3];
break;
}
}
/**
* 左边边距
* @return left
*/
Margin.prototype.getLeft = function() {
return "'" + this.left + "'";
};
/**
* 右边边距
* @return right
*/
Margin.prototype.getRight = function() {
return "'" + this.right + "'";
};
/**
* 上边边距
* @return top
*/
Margin.prototype.getTop = function() {
return "'" + this.top + "'";
};
/**
* 下边边距
* @return bottom
*/
Margin.prototype.getBottom = function() {
return "'" + this.bottom + "'";
};
Margin.prototype.toString = function() {
var sb = new StringBuffer("'");
sb.append(this.top).append(" ");
sb.append(this.right).append(" ");
sb.append(this.bottom).append(" ");
sb.append(this.left).append("'");
return sb.toString();
};