//Constructor
var JLine=function()
{
	// Field
	this.points=new Array();
	
	// Method
	this.setLength=JLine_setLength;
	this.setAt=JLine_setAt;
	this.addPoint=JLine_addPoint;
	this.removeAll=JLine_removeAll;
	this.calcRange=JLine_calcRange;
}

function JLine_setLength(length)
{
	this.points[length-1]=null;
}

function JLine_setAt(index,point)
{
	this.points[index]=point;
}

function JLine_addPoint(point)
{
	this.points[this.points.length]=point;
}

function JLine_removeAll()
{
	this.points=new Array();
}

function JLine_calcRange()
{
	var llx,lly;
	var urx,ury;
	var maxValue=10e100;
	
	llx = maxValue;
	lly = maxValue;
	urx = ury = -maxValue;

	for (var i = 0; i < this.points.length; i++)
	{    
		llx = Math.min(llx, this.points[i].x);
		lly = Math.min(lly, this.points[i].y);
		urx = Math.max(urx, this.points[i].x);
		ury = Math.max(ury, this.points[i].y);
	}
	
	return new JRectangle(llx,lly,urx-llx,ury-lly);
}

