//<script type="text/javascript">

//=============================================================================
// The Doodle.Doc class stores information about the elements that the user is
// manipulating
Doodle.Doc = JSX.Class.create({
	name: 'Doc',
	constructor: function() {
		this.shapes = new Array();
		this.nextID = 0;
	},

	members: {
		addShape: function(shape) {
			this.shapes[shape.getID()] = shape;
		},
		delShape: function(shape) {
			delete this.shapes[shape.getID()];
		},
		delShapeByID: function(id) {
			delete this.shapes[id];
		},

		init: function() {
		},

		createPoint: function(pos) {
			var point = new Doodle.Doc.Point();
			point.setID(this.nextID++);
			point.setPos(pos);
			this.addShape(point);
			return point;
		},

		createLine: function(p1, p2) {
			var line = new Doodle.Doc.Line();
			line.setID(this.nextID++);
			line.setP1(p1);
			line.setP2(p2);
			this.addShape(line);
			return line;
		},

		createEllipse: function(p1, p2) {
			var ellipse = new Doodle.Doc.Ellipse();
			ellipse.setID(this.nextID++);
			ellipse.setP1(p1);
			ellipse.setP2(p2);
			this.addShape(ellipse);
			return ellipse;
		},

		createBezierCurve: function(points) {
			var curve = new Doodle.Doc.BezierCurve();
			curve.setID(this.nextID++);
			curve.setPoints(points);
			this.addShape(curve);
			return curve;
		}
	}
});


//=============================================================================
// The DoodleShape class is base class to all shape objects

Doodle.Doc.Shape = JSX.Class.create({
	name: 'Shape',
	constructor: function() {
	},
	statics: {
		// enumeration of Shape Types
		Types: {
			POINT: 0,
			LINE: 1,
			ELLIPSE: 2,
			BEZIER_CURVE: 3
		}
	},
	members: {
		init: function(id) {
			this.id = id
		},

		setID: function(val) {
			this.id = val;
		},
		getID: function() {
			return this.id;
		}
	}
});

//=============================================================================
// Doodle.Doc.Point

Doodle.Doc.Point = JSX.Class.create({
	name: 'Point',
	base: Doodle.Doc.Shape,
	constructor: function() {
		this.Shape.call(this);
	},

	members: {
		getType: function() {
		   return Doodle.Doc.Shape.Types.POINT;
		},
		setPos: function(p) { this.pos = p; },
		getPos: function() { return this.pos; }
	}
});

//=============================================================================
// Doodle.Doc.Line

Doodle.Doc.Line = JSX.Class.create({
	name: 'Line',
	base: Doodle.Doc.Shape,
	constructor: function() {
		this.Shape.call(this);
	},

	members: {
		getType: function() {
		   return Doodle.Doc.Shape.Types.LINE;
		},
		setP1: function(p) { this.p1 = p; },
		getP1: function() { return this.p1; },
		setP2: function(p) { this.p2 = p; },
		getP2: function() { return this.p2; }
	}
});

//=============================================================================
// Doodle.Doc.Ellipse

Doodle.Doc.Ellipse = JSX.Class.create({
	name: 'Ellipse',
	base: Doodle.Doc.Shape,
	constructor: function() {
		this.Shape.call(this);
	},

	members: {
		getType: function() {
		   return Doodle.Doc.Shape.Types.ELLIPSE;
		},
		setP1: function(p) { this.p1 = p; },
		getP1: function() { return this.p1; },
		setP2: function(p) { this.p2 = p; },
		getP2: function() { return this.p2; }
	}
});

//=============================================================================
// Doodle.Doc.BezierCurve

Doodle.Doc.BezierCurve = JSX.Class.create({
	name: 'BezierCurve',
	base: Doodle.Doc.Shape,
	constructor: function() {
		this.Shape.call(this);
	},

	members: {
		getType: function() {
		   return Doodle.Doc.Shape.Types.BEZIER_CURVE;
		},
		setPoints: function(p) { this.points = p; },
		getPoints: function() { return this.points; }
	}
});

//</script>