Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1372 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.gfx.common");
13
dojo.provide("dojo.gfx.common");
12
dojo.require("dojo.gfx.color");
14
dojo.require("dojo.gfx.color");
13
dojo.require("dojo.lang.declare");
15
dojo.require("dojo.lang.declare");
14
dojo.require("dojo.lang.extras");
16
dojo.require("dojo.lang.extras");
15
dojo.require("dojo.dom");
17
dojo.require("dojo.dom");
16
dojo.lang.mixin(dojo.gfx, {defaultPath:{type:"path", path:""}, defaultPolyline:{type:"polyline", points:[]}, defaultRect:{type:"rect", x:0, y:0, width:100, height:100, r:0}, defaultEllipse:{type:"ellipse", cx:0, cy:0, rx:200, ry:100}, defaultCircle:{type:"circle", cx:0, cy:0, r:100}, defaultLine:{type:"line", x1:0, y1:0, x2:100, y2:100}, defaultImage:{type:"image", width:0, height:0, src:""}, defaultStroke:{color:"black", width:1, cap:"butt", join:4}, defaultLinearGradient:{type:"linear", x1:0, y1:0, x2:100, y2:100, colors:[{offset:0, color:"black"}, {offset:1, color:"white"}]}, defaultRadialGradient:{type:"radial", cx:0, cy:0, r:100, colors:[{offset:0, color:"black"}, {offset:1, color:"white"}]}, defaultPattern:{type:"pattern", x:0, y:0, width:0, height:0, src:""}, normalizeColor:function (color) {
18
dojo.lang.mixin(dojo.gfx, {defaultPath:{type:"path", path:""}, defaultPolyline:{type:"polyline", points:[]}, defaultRect:{type:"rect", x:0, y:0, width:100, height:100, r:0}, defaultEllipse:{type:"ellipse", cx:0, cy:0, rx:200, ry:100}, defaultCircle:{type:"circle", cx:0, cy:0, r:100}, defaultLine:{type:"line", x1:0, y1:0, x2:100, y2:100}, defaultImage:{type:"image", width:0, height:0, src:""}, defaultStroke:{color:"black", width:1, cap:"butt", join:4}, defaultLinearGradient:{type:"linear", x1:0, y1:0, x2:100, y2:100, colors:[{offset:0, color:"black"}, {offset:1, color:"white"}]}, defaultRadialGradient:{type:"radial", cx:0, cy:0, r:100, colors:[{offset:0, color:"black"}, {offset:1, color:"white"}]}, defaultPattern:{type:"pattern", x:0, y:0, width:0, height:0, src:""}, normalizeColor:function (color) {
17
	return (color instanceof dojo.gfx.color.Color) ? color : new dojo.gfx.color.Color(color);
19
	return (color instanceof dojo.gfx.color.Color) ? color : new dojo.gfx.color.Color(color);
18
}, normalizeParameters:function (existed, update) {
20
}, normalizeParameters:function (existed, update) {
19
	if (update) {
21
	if (update) {
20
		var empty = {};
22
		var empty = {};
21
		for (var x in existed) {
23
		for (var x in existed) {
22
			if (x in update && !(x in empty)) {
24
			if (x in update && !(x in empty)) {
23
				existed[x] = update[x];
25
				existed[x] = update[x];
24
			}
26
			}
25
		}
27
		}
26
	}
28
	}
27
	return existed;
29
	return existed;
28
}, makeParameters:function (defaults, update) {
30
}, makeParameters:function (defaults, update) {
29
	if (!update) {
31
	if (!update) {
30
		return dojo.lang.shallowCopy(defaults, true);
32
		return dojo.lang.shallowCopy(defaults, true);
31
	}
33
	}
32
	var result = {};
34
	var result = {};
33
	for (var i in defaults) {
35
	for (var i in defaults) {
34
		if (!(i in result)) {
36
		if (!(i in result)) {
35
			result[i] = dojo.lang.shallowCopy((i in update) ? update[i] : defaults[i], true);
37
			result[i] = dojo.lang.shallowCopy((i in update) ? update[i] : defaults[i], true);
36
		}
38
		}
37
	}
39
	}
38
	return result;
40
	return result;
39
}, formatNumber:function (x, addSpace) {
41
}, formatNumber:function (x, addSpace) {
40
	var val = x.toString();
42
	var val = x.toString();
41
	if (val.indexOf("e") >= 0) {
43
	if (val.indexOf("e") >= 0) {
42
		val = x.toFixed(4);
44
		val = x.toFixed(4);
43
	} else {
45
	} else {
44
		var point = val.indexOf(".");
46
		var point = val.indexOf(".");
45
		if (point >= 0 && val.length - point > 5) {
47
		if (point >= 0 && val.length - point > 5) {
46
			val = x.toFixed(4);
48
			val = x.toFixed(4);
47
		}
49
		}
48
	}
50
	}
49
	if (x < 0) {
51
	if (x < 0) {
50
		return val;
52
		return val;
51
	}
53
	}
52
	return addSpace ? " " + val : val;
54
	return addSpace ? " " + val : val;
53
}, pathRegExp:/([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g});
55
}, pathRegExp:/([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g});
54
dojo.declare("dojo.gfx.Surface", null, {initializer:function () {
56
dojo.declare("dojo.gfx.Surface", null, {initializer:function () {
55
	this.rawNode = null;
57
	this.rawNode = null;
56
}, getEventSource:function () {
58
}, getEventSource:function () {
57
	return this.rawNode;
59
	return this.rawNode;
58
}});
60
}});
59
dojo.declare("dojo.gfx.Point", null, {});
61
dojo.declare("dojo.gfx.Point", null, {});
60
dojo.declare("dojo.gfx.Rectangle", null, {});
62
dojo.declare("dojo.gfx.Rectangle", null, {});
61
 
63