//<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 = null;
		this.nextID = 0;
	},
	members: {
		addShape: function(shape) {
			this.shapes[shape.getID()] = shape;
		},
		getShape: function(id) {
			return this.shapes[id];
		},
		delShape: function(shape) {
			delete this.shapes[shape.getID()];
		},
		delShapeByID: function(id) {
			delete this.shapes[id];
		},

		init: function() {
			this.shapes = new Array();
			this.nextID = 0;
		},

		createLine: function(p1, p2, properties) {
			var line = new Doodle.Doc.Line();
			line.setID(this.nextID++);
			line.init(p1, p2, properties);
			this.addShape(line);
			return line;
		}
	}
});

//=============================================================================
// The DoodleShape class is base class to all shape objects
Doodle.Doc.Shape = JSX.Class.create({
	name: 'Shape',
	constructor: function() {
		this.id = -1;
	},
	statics: {
		// enumeration of Shape Types
		Types: {
			LINE: 1
		}
	},
	members: {
		init: function(id) {
			this.id = id
		},

		setID: function(val) {
			this.id = val;
		},
		getID: function() {
			return this.id;
		}
	}
});

//=============================================================================
// Doodle.Doc.Line

Doodle.Doc.Line = JSX.Class.create({
	name: 'Line',
	base: Doodle.Doc.Shape,
	constructor: function() {
		this.Shape.call(this);
	},
	members: {
		init: function(p1, p2) {
			this.p1 = p1;
			this.p2 = p2;
		},
		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; }
	}
});

//</script>