Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
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:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.gfx.common");
14
dojo.require("dojo.gfx.color");
15
dojo.require("dojo.lang.declare");
16
dojo.require("dojo.lang.extras");
17
dojo.require("dojo.dom");
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) {
19
	return (color instanceof dojo.gfx.color.Color) ? color : new dojo.gfx.color.Color(color);
20
}, normalizeParameters:function (existed, update) {
21
	if (update) {
22
		var empty = {};
23
		for (var x in existed) {
24
			if (x in update && !(x in empty)) {
25
				existed[x] = update[x];
26
			}
27
		}
28
	}
29
	return existed;
30
}, makeParameters:function (defaults, update) {
31
	if (!update) {
32
		return dojo.lang.shallowCopy(defaults, true);
33
	}
34
	var result = {};
35
	for (var i in defaults) {
36
		if (!(i in result)) {
37
			result[i] = dojo.lang.shallowCopy((i in update) ? update[i] : defaults[i], true);
38
		}
39
	}
40
	return result;
41
}, formatNumber:function (x, addSpace) {
42
	var val = x.toString();
43
	if (val.indexOf("e") >= 0) {
44
		val = x.toFixed(4);
45
	} else {
46
		var point = val.indexOf(".");
47
		if (point >= 0 && val.length - point > 5) {
48
			val = x.toFixed(4);
49
		}
50
	}
51
	if (x < 0) {
52
		return val;
53
	}
54
	return addSpace ? " " + val : val;
55
}, pathRegExp:/([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g});
56
dojo.declare("dojo.gfx.Surface", null, {initializer:function () {
57
	this.rawNode = null;
58
}, getEventSource:function () {
59
	return this.rawNode;
60
}});
61
dojo.declare("dojo.gfx.Point", null, {});
62
dojo.declare("dojo.gfx.Rectangle", null, {});
63