Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.gfx.common");
12
dojo.require("dojo.gfx.color");
13
dojo.require("dojo.lang.declare");
14
dojo.require("dojo.lang.extras");
15
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) {
17
	return (color instanceof dojo.gfx.color.Color) ? color : new dojo.gfx.color.Color(color);
18
}, normalizeParameters:function (existed, update) {
19
	if (update) {
20
		var empty = {};
21
		for (var x in existed) {
22
			if (x in update && !(x in empty)) {
23
				existed[x] = update[x];
24
			}
25
		}
26
	}
27
	return existed;
28
}, makeParameters:function (defaults, update) {
29
	if (!update) {
30
		return dojo.lang.shallowCopy(defaults, true);
31
	}
32
	var result = {};
33
	for (var i in defaults) {
34
		if (!(i in result)) {
35
			result[i] = dojo.lang.shallowCopy((i in update) ? update[i] : defaults[i], true);
36
		}
37
	}
38
	return result;
39
}, formatNumber:function (x, addSpace) {
40
	var val = x.toString();
41
	if (val.indexOf("e") >= 0) {
42
		val = x.toFixed(4);
43
	} else {
44
		var point = val.indexOf(".");
45
		if (point >= 0 && val.length - point > 5) {
46
			val = x.toFixed(4);
47
		}
48
	}
49
	if (x < 0) {
50
		return val;
51
	}
52
	return addSpace ? " " + val : val;
53
}, pathRegExp:/([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g});
54
dojo.declare("dojo.gfx.Surface", null, {initializer:function () {
55
	this.rawNode = null;
56
}, getEventSource:function () {
57
	return this.rawNode;
58
}});
59
dojo.declare("dojo.gfx.Point", null, {});
60
dojo.declare("dojo.gfx.Rectangle", null, {});
61